Results 1 to 4 of 4

Thread: custom field with condition

  1. #1
    muniek is offline Member
    Join Date
    Jun 2009
    Location
    Watford, Uk
    Posts
    9

    Default custom field with condition

    Hi.

    I'm using Sugar 5.2.0e on linux hosting.


    I need a field in detailview wich will turn on (picture will change from one to another) when case will be older than one week.
    something like this:

    PHP Code:
    $zmienna "2009-06-28"; - here will be date from database

    $dzien 
    date("Y-m-d",time() - 60*60*24*7);

    if (
    $zmienna $dzien) {
        echo 
    "<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><img src="/img/pusty.jpg" width="10" height="10" /></td>";
    }
    else {
        echo 
    "<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><img src="/img/pelny.jpg" width="10" height="10" /></td>";
    }
    ?> 
    I can't use code field from enhanced studio because I'm using demo.

    Please help.

  2. #2
    ishaan is offline Senior Member
    Join Date
    Apr 2009
    Location
    Mumbai,India
    Posts
    100

    Default Re: custom field with condition

    Quote Originally Posted by muniek View Post
    Hi.

    I'm using Sugar 5.2.0e on linux hosting.


    I need a field in detailview wich will turn on (picture will change from one to another) when case will be older than one week.
    something like this:

    PHP Code:
    $zmienna "2009-06-28"; - here will be date from database

    $dzien 
    date("Y-m-d",time() - 60*60*24*7);

    if (
    $zmienna $dzien) {
        echo 
    "<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><img src="/img/pusty.jpg" width="10" height="10" /></td>";
    }
    else {
        echo 
    "<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><img src="/img/pelny.jpg" width="10" height="10" /></td>";
    }
    ?> 
    I can't use code field from enhanced studio because I'm using demo.

    Please help.
    Hi,

    You can make the two fields in the module and then display one or hide one writing some javascript code in the onload() event of the page.

    Hope this helps

    Cheers,
    Ishaan

  3. #3
    muniek is offline Member
    Join Date
    Jun 2009
    Location
    Watford, Uk
    Posts
    9

    Default Re: custom field with condition

    no. it's not that.

    But I've try to do it in report template in javascript but I don't know how to get variable for "zmienna":

    var zmienna=ROW.CASES_DATE_RECEIVED_FEES_C;

    I don't know javascript - I've just copied and changed code from examples found on google.

    HTML Code:
    <!-- BEGIN: rows -->
    <table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView">
    	<tr height="20">
    		<td align="center" scope="col" class="listViewThS1" nowrap><slot>Case Number</a></slot></td>
    		<td align="center" scope="col" class="listViewThS1" nowrap><slot>Client Name</slot></td>
            <td align="center" scope="col" class="listViewThS1" nowrap><slot>MY DATE</slot></td>
            <td align="center" scope="col" class="listViewThS1" nowrap><slot>Graphic element</slot></td>
    	</tr>
    	<!-- BEGIN: row -->
    	<tr height="20"  onmouseover="setPointer(this, '{ROW.CASES_ID}', 'over', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');" onmouseout="setPointer(this, '{ROW.CASES_ID}', 'out', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');" onmousedown="setPointer(this, '{ROW.CASES_ID}', 'click', '{BG_COLOR}', '{BG_HILITE}', '{BG_CLICK}');">
    		<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><slot><a href="{SITE_URL}/index.php?action=DetailView&module=Cases&record={ROW.CASES_ID}" class="listViewTdLinkS1">{ROW.CASES_NAME}</a></slot></td>
      		<td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><slot>{ROW.CASES_ACCOUNT_NAME}</slot></td>
            <td width"10%" class="{ROW_COLOR}S1" bgcolor="{BG_COLOR}"><slot>{ROW.CASES_DATE_RECEIVED_FEES_C}</slot></td>
    <script type="text/javascript">
    
    var d=new Date();
    d.setDate (d.getDate() - 7);
    var day=d.getDate();
    var month=d.getMonth() + 1;
    var year=d.getFullYear();
    
    var dzien=(year + "-" + month + "-" + day);
    
    var zmienna=ROW.CASES_DATE_RECEIVED_FEES_C;
    
    if (zmienna > dzien) {
    document.write("<td width\"10%\" class=\"{ROW_COLOR}S1\" bgcolor=\"{BG_COLOR}\"><img src=\"/img/pusty.jpg\" width=\"10\" height=\"10\" /></td>");
    }
    else {
    document.write("<td width\"10%\" class=\"{ROW_COLOR}S1\" bgcolor=\"{BG_COLOR}\"><img src=\"/img/pusty.jpg\" width=\"10\" height=\"10\" /></td>");
    }
    
    
    </script>
    
    	</tr>
    	<tr>
    		<td colspan="20" class="listViewHRS1"></td>
    	</tr>
    <!-- END: row -->
    	</table>
    <!-- END: rows -->

  4. #4
    muniek is offline Member
    Join Date
    Jun 2009
    Location
    Watford, Uk
    Posts
    9

    Default Re: custom field with condition

    I found it:

    var zmienna=('{ROW.CASES_DATE_RECEIVED_FEES_C}');
    Last edited by muniek; 2009-07-14 at 01:22 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Condition for display relate field
    By mahmoud07 in forum Help
    Replies: 0
    Last Post: 2009-05-21, 11:52 AM
  2. Custom fields in Alert Template Condition?
    By prismusa in forum Help
    Replies: 2
    Last Post: 2007-01-18, 05:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •