[Vtigercrm-commits] [vtiger-commits] r10763 - in /vtigercrm/branches/5.0.3: Smarty/templates/CustomView.tpl include/js/en_us.lang.js modules/CustomView/CustomView.js modules/CustomView/CustomView.php modules/CustomView/EditView.php modules/CustomView/Save.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Apr 23 10:56:14 EDT 2007


Author: richie
Date: Mon Apr 23 08:56:01 2007
New Revision: 10763

Log:
fix for customview-filter related issue. Fixes #3485 #3456 #3579 --minnie

Modified:
    vtigercrm/branches/5.0.3/Smarty/templates/CustomView.tpl
    vtigercrm/branches/5.0.3/include/js/en_us.lang.js
    vtigercrm/branches/5.0.3/modules/CustomView/CustomView.js
    vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php
    vtigercrm/branches/5.0.3/modules/CustomView/EditView.php
    vtigercrm/branches/5.0.3/modules/CustomView/Save.php

Modified: vtigercrm/branches/5.0.3/Smarty/templates/CustomView.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/CustomView.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/CustomView.tpl Mon Apr 23 08:56:01 2007
@@ -22,6 +22,7 @@
 <input type="hidden" name="return_module" value="{$RETURN_MODULE}">
 <input type="hidden" name="record" value="{$CUSTOMVIEWID}">
 <input type="hidden" name="return_action" value="{$RETURN_ACTION}">
+<input type="hidden" id="user_dateformat" name="user_dateformat" value="{$DATEFORMAT}">
 <script language="javascript" type="text/javascript">
 var typeofdata = new Array();
 typeofdata['V'] = ['e','n','s','c','k'];
@@ -82,7 +83,10 @@
                                 {rdelim}
                                 if(mandatorycheck == true)
                                 {ldelim}
-                                        return true;
+					if(($("stdDateFilter").options[$("stdDateFilter").selectedIndex].value == "custom") && ($("jscal_field_date_start").value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0) || ($("jscal_field_date_end").value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0))
+						return stdfilterdateValidate();
+					else
+						return true;
                                 {rdelim}else
                                 {ldelim}
                                         mandatorycheck = false;
@@ -372,7 +376,7 @@
 		     <b>{$MOD.LBL_STEP_4_TITLE}</b>
 		    </td>
 		    {else}
-                    <td class="dvtSelectedCell" style="width: 100px;" align="center" nowrap id="mi" onload="alert('hiiiiiiii')">
+                    <td class="dvtSelectedCell" style="width: 100px;" align="center" nowrap id="mi">
                      <b>{$MOD.LBL_STEP_4_TITLE}</b>
                     </td>
 
@@ -409,7 +413,7 @@
 			  <tr>
 			     <td align="right" class="dvtCellLabel">{$MOD.Select_Duration} :</td>
 			     <td class="dvtCellInfo">
-			        <select name="stdDateFilter" class="select" onchange='showDateRange(this.options[this.selectedIndex].value )'>
+			        <select name="stdDateFilter" id="stdDateFilter" class="select" onchange='showDateRange(this.options[this.selectedIndex].value )'>
 				{foreach item=duration from=$STDFILTERCRITERIA}
 					<option {$duration.selected} value={$duration.value}>{$duration.text}</option>
 				{/foreach}
@@ -419,22 +423,31 @@
 			  <tr>
 			     <td align="right" class="dvtCellLabel">{$MOD.Start_Date} :</td>
 			     <td width="25%" align=left class="dvtCellInfo">
-			     <input name="startdate" id="jscal_field_date_start" type="text" size="10" class="textField" value="{$STARTDATE}">
-			     <img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_date_start">
+			     {if $STDFILTERCRITERIA.0.value eq "custom"}
+				{assign var=img_style value="visibility:visible"}
+				{assign var=msg_style value=""}
+			     {else}
+				{assign var=img_style value="visibility:hidden"}
+				{assign var=msg_style value="readonly"}
+			     {/if}	
+			     <input name="startdate" id="jscal_field_date_start" type="text" size="10" class="textField" value="{$STARTDATE}" {$msg_style}>
+			     <img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_date_start" style={$img_style}>
+			     <span id="jscal_trigger_start_format" style={$img_style}><font size=1><em old="(yyyy-mm-dd)">({$DATEFORMAT})</em></font></span>
 			     <script type="text/javascript">
 			  		Calendar.setup ({ldelim}
-			 		inputField : "jscal_field_date_start", ifFormat : "%Y-%m-%d", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
+			 		inputField : "jscal_field_date_start", ifFormat : "{$JS_DATEFORMAT}", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
 					{rdelim})
 			     </script></td>
 	            	  </tr>
 			  <tr>
 			     <td align="right" class="dvtCellLabel">{$MOD.End_Date} :</td> 
   			     <td width="25%" align=left class="dvtCellInfo">
-			     <input name="enddate" id="jscal_field_date_end" type="text" size="10" class="textField" value="{$ENDDATE}">
-			     <img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_date_end">
+			     <input name="enddate" {$msg_style} id="jscal_field_date_end" type="text" size="10" class="textField" value="{$ENDDATE}">
+			     <img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_date_end" style={$img_style}>
+			     <span id="jscal_trigger_end_format" style={$img_style}><font size=1><em old="(yyyy-mm-dd)">({$DATEFORMAT})</em></font></span>
 			     <script type="text/javascript">
 					Calendar.setup ({ldelim}
-					inputField : "jscal_field_date_end", ifFormat : "%Y-%m-%d", showsTime : false, button : "jscal_trigger_date_end", singleClick : true, step : 1
+					inputField : "jscal_field_date_end", ifFormat : "{$JS_DATEFORMAT}", showsTime : false, button : "jscal_trigger_date_end", singleClick : true, step : 1
 					{rdelim})
 			     </script></td>
 			  </tr>
@@ -456,7 +469,7 @@
 	  <tr><td colspan="3" class="detailedViewHeader"><b>{$MOD.LBL_RULE}</b></td></tr>
 	  
 	  <tr class="dvtCellLabel">
-          <td><select name="fcol1" id="fcol1" onchange="updatefOptions(this, 'fop1');">
+          <td><nobr><select name="fcol1" id="fcol1" onchange="updatefOptions(this, 'fop1');">
               <option value="">{$MOD.LBL_NONE}</option>
               {foreach item=filteroption key=label from=$BLOCK1}
                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
@@ -470,10 +483,11 @@
                 <option {$criteria.selected} value={$criteria.value}>{$criteria.text}</option>
               {/foreach}
               </select>&nbsp; <input name="fval1" id="fval1" type="text" size=30 maxlength=80 value="{$VALUE1}">
-            &nbsp;{$MOD.LBL_AND}</td>
+	      <span id="andfcol1">{$AND_TEXT1}</span></nobr>
+            </td>
         </tr>
 	<tr class="dvtCellInfo">
-          <td><select name="fcol2" id="fcol2" onchange="updatefOptions(this, 'fop2');">
+          <td><nobr><select name="fcol2" id="fcol2" onchange="updatefOptions(this, 'fop2');">
               <option value="">{$MOD.LBL_NONE}</option>
               {foreach item=filteroption key=label from=$BLOCK2}
                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
@@ -487,10 +501,11 @@
                 <option {$criteria.selected} value={$criteria.value}>{$criteria.text}</option>
               {/foreach}
               </select>&nbsp; <input name="fval2" id="fval2" type="text" size=30 maxlength=80 value="{$VALUE2}">
-            &nbsp;{$MOD.LBL_AND}</td>
+	      <span id="andfcol2">{$AND_TEXT2}</span></nobr>
+            </td>
         </tr>
 	<tr class="dvtCellLabel">
-          <td><select name="fcol3" id="fcol3" onchange="updatefOptions(this, 'fop3');">
+          <td><nobr><select name="fcol3" id="fcol3" onchange="updatefOptions(this, 'fop3');">
               <option value="">{$MOD.LBL_NONE}</option>
               {foreach item=filteroption key=label from=$BLOCK3}
                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
@@ -504,10 +519,11 @@
                 <option {$criteria.selected} value={$criteria.value}>{$criteria.text}</option>
               {/foreach}
               </select>&nbsp; <input name="fval3" id="fval3" type="text" size=30 maxlength=80 value="{$VALUE3}">
-            &nbsp;{$MOD.LBL_AND}</td>
+	      <span id="andfcol3">{$AND_TEXT3}</span></nobr>
+            </td>
         </tr>
 	<tr class="dvtCellInfo">
-          <td><select name="fcol4" id="fcol4" onchange="updatefOptions(this, 'fop4');">
+          <td><nobr><select name="fcol4" id="fcol4" onchange="updatefOptions(this, 'fop4');">
               <option value="">{$MOD.LBL_NONE}</option>
               {foreach item=filteroption key=label from=$BLOCK4}
                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
@@ -521,10 +537,11 @@
                 <option {$criteria.selected} value={$criteria.value}>{$criteria.text}</option>
               {/foreach}
               </select>&nbsp; <input name="fval4" id="fval4" type="text" size=30 maxlength=80 value="{$VALUE4}">
-            &nbsp;{$MOD.LBL_AND}</td>
+	      <span id="andfcol4">{$AND_TEXT4}</span></nobr>
+            </td>
         </tr>
 	<tr class="dvtCellLabel">
-          <td><select name="fcol5" id="fcol5" onchange="updatefOptions(this, 'fop5');">
+          <td><nobr><select name="fcol5" id="fcol5" onchange="updatefOptions(this, 'fop5');">
               <option value="">{$MOD.LBL_NONE}</option>
               {foreach item=filteroption key=label from=$BLOCK5}
                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
@@ -538,7 +555,8 @@
                 <option {$criteria.selected} value={$criteria.value}>{$criteria.text}</option>
               {/foreach}
               </select>&nbsp; <input name="fval5" id="fval5" type="text" size=30 maxlength=80 value="{$VALUE5}">
-            &nbsp;</td>
+	      <span id="andfcol5">{$AND_TEXT5}</span></nobr>
+            </td>
         </tr>
 
 	  {*section name=advancedFilter start=1 loop=6 step=1}
@@ -635,5 +653,25 @@
 		return true;
 }
 checkDuplicate();
+function stdfilterdateValidate()
+{
+	if(!dateValidate("startdate",alert_arr.STDFILTER+" - "+alert_arr.STARTDATE,"OTH"))
+	{
+		getObj("startdate").focus()
+		return false;
+	}
+	else if(!dateValidate("enddate",alert_arr.STDFILTER+" - "+alert_arr.ENDDATE,"OTH"))
+	{
+		getObj("enddate").focus()
+		return false;
+	}
+	else
+	{
+		if (!dateComparison("enddate",alert_arr.STDFILTER+" - "+alert_arr.ENDDATE,"startdate",alert_arr.STDFILTER+" - "+alert_arr.STARTDATE,"GE")) {
+                        getObj("enddate").focus()
+                        return false
+                } else return true;
+	}
+}
 {/literal}
 </script>

Modified: vtigercrm/branches/5.0.3/include/js/en_us.lang.js
==============================================================================
--- vtigercrm/branches/5.0.3/include/js/en_us.lang.js (original)
+++ vtigercrm/branches/5.0.3/include/js/en_us.lang.js Mon Apr 23 08:56:01 2007
@@ -120,6 +120,7 @@
                                 START_DATE_TIME : 'Start Date & Time',
                                 START_TIME : 'Start Time',
                                 DATE_SHOULDNOT_PAST :'Current date & time for Activities with status as Planned',
-                                TIME_SHOULDNOT_PAST :'Current Time for Activities with status as Planned'
+                                TIME_SHOULDNOT_PAST :'Current Time for Activities with status as Planned',
+				LBL_AND : 'And'
 
                        };

Modified: vtigercrm/branches/5.0.3/modules/CustomView/CustomView.js
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/CustomView.js (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/CustomView.js Mon Apr 23 08:56:01 2007
@@ -20,6 +20,24 @@
 
     var currOption = selObj.options[selObj.selectedIndex];
     var currField = sel.options[sel.selectedIndex];
+    
+    var fld = currField.value.split(":");
+    var tod = fld[4];
+    if(fld[4] == 'D' || (fld[4] == 'T' && fld[1] != 'time_start' && fld[1] != 'time_end') || fld[4] == 'DT')
+    {
+	$("and"+sel.id).innerHTML =  "";
+	if(sel.id != "fcol5")
+		$("and"+sel.id).innerHTML =  "<em old='(yyyy-mm-dd)'>("+$("user_dateformat").value+")</em>&nbsp;"+alert_arr.LBL_AND;
+	else
+		$("and"+sel.id).innerHTML =  "<em old='(yyyy-mm-dd)'>("+$("user_dateformat").value+")</em>&nbsp;";
+    }
+    else {
+	$("and"+sel.id).innerHTML =  "";
+	if(sel.id != "fcol5")
+		$("and"+sel.id).innerHTML =  "&nbsp;"+alert_arr.LBL_AND;
+	else
+		$("and"+sel.id).innerHTML =  "&nbsp;";
+    } 	
 
     if(currField.value != null && currField.value.length != 0)
     {

Modified: vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php Mon Apr 23 08:56:01 2007
@@ -536,16 +536,20 @@
 				if (type!="custom")
 				{
 					document.CustomView.startdate.readOnly=true
-						document.CustomView.enddate.readOnly=true
-						getObj("jscal_trigger_date_start").style.visibility="hidden"
-						getObj("jscal_trigger_date_end").style.visibility="hidden"
+					document.CustomView.enddate.readOnly=true
+					getObj("jscal_trigger_date_start").style.visibility="hidden"
+					getObj("jscal_trigger_date_end").style.visibility="hidden"
+					getObj("jscal_trigger_start_format").style.visibility="hidden"
+					getObj("jscal_trigger_end_format").style.visibility="hidden"
 				}
 				else
 				{
 					document.CustomView.startdate.readOnly=false
-						document.CustomView.enddate.readOnly=false
-						getObj("jscal_trigger_date_start").style.visibility="visible"
-						getObj("jscal_trigger_date_end").style.visibility="visible"
+					document.CustomView.enddate.readOnly=false
+					getObj("jscal_trigger_date_start").style.visibility="visible"
+					getObj("jscal_trigger_date_end").style.visibility="visible"
+					getObj("jscal_trigger_start_format").style.visibility="visible"
+					getObj("jscal_trigger_end_format").style.visibility="visible"
 				}
 				if( type == "today" )
 				{
@@ -719,7 +723,6 @@
 			$stdfilterlist["startdate"] = $datefilter[0];
 			$stdfilterlist["enddate"] = $datefilter[1];
 		}
-
 		return $stdfilterlist;
 	}
 
@@ -747,7 +750,6 @@
 			$advft["value"] = $advfilterrow["value"];
 			$advfilterlist[] = $advft;
 		}
-
 		return $advfilterlist;
 	}
 

Modified: vtigercrm/branches/5.0.3/modules/CustomView/EditView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/EditView.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/EditView.php Mon Apr 23 08:56:01 2007
@@ -39,7 +39,8 @@
 $smarty->assign("MODULE",$cv_module);
 $smarty->assign("CVMODULE", $cv_module);
 $smarty->assign("CUSTOMVIEWID",$recordid);
-$smarty->assign("DATAFORMAT",$current_user->date_format);
+$smarty->assign("DATEFORMAT",$current_user->date_format);
+$smarty->assign("JS_DATEFORMAT",parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 if($recordid == "")
 {
 	$oCustomView = new CustomView();
@@ -111,8 +112,14 @@
 
 	if(isset($stdfilterlist["startdate"]) && isset($stdfilterlist["enddate"]))
 	{
-		$smarty->assign("STARTDATE",$stdfilterlist["startdate"]);
-		$smarty->assign("ENDDATE",$stdfilterlist["enddate"]);
+		if($stdfilterhtml[0]['value'] == 'custom')
+		{
+			$smarty->assign("STARTDATE",getDisplayDate($stdfilterlist["startdate"]));
+			$smarty->assign("ENDDATE",getDisplayDate($stdfilterlist["enddate"]));
+		}else{
+			$smarty->assign("STARTDATE",$stdfilterlist["startdate"]);
+			$smarty->assign("ENDDATE",$stdfilterlist["enddate"]);
+		}	
 	}
 
 	$advfilterlist = $oCustomView->getAdvFilterByCvid($recordid);
@@ -123,7 +130,19 @@
 		$advcolumnhtml = getByModule_ColumnsHTML($cv_module,$modulecollist,$advfilterlist[$i-1]["columnname"]);
 		$smarty->assign("FOPTION".$i,$advfilterhtml);
 		$smarty->assign("BLOCK".$i,$advcolumnhtml);
+		$col = explode(":",$advfilterlist[$i-1]["columnname"]);
+		$temp_val = explode(",",$advfilterlist[$i-1]["value"]);
+		$and_text = "&nbsp;".$mod_strings['LBL_AND'];
+		if($col[4] == 'D' || ($col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end') || $col[4] == 'DT')
+		{
+			$val = Array();
+			for($x=0;$x<count($temp_val);$x++)
+				$val[$x] = getDisplayDate(trim($temp_val[$x]));
+			$advfilterlist[$i-1]["value"] = implode(", ",$val);
+			$and_text = "<em old='(yyyy-mm-dd)'>(".$current_user->date_format.")</em>&nbsp;".$mod_strings['LBL_AND'];
+		}
 		$smarty->assign("VALUE".$i,$advfilterlist[$i-1]["value"]);
+		$smarty->assign("AND_TEXT".$i,$and_text);
 	}
 
 	$smarty->assign("STDFILTERCOLUMNS",$stdfiltercolhtml);

Modified: vtigercrm/branches/5.0.3/modules/CustomView/Save.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/Save.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/Save.php Mon Apr 23 08:56:01 2007
@@ -55,8 +55,13 @@
 	$stdcriteria = $_REQUEST["stdDateFilter"];
 	$std_filter_list["stdfilter"] = $stdcriteria;
 	$startdate = $_REQUEST["startdate"];
+	$enddate = $_REQUEST["enddate"];
+	if($stdcriteria == "custom")
+	{
+		$startdate = getDBInsertDateValue($startdate);
+		$enddate = getDBInsertDateValue($enddate);
+	}
 	$std_filter_list["startdate"] = $startdate;
-	$enddate = $_REQUEST["enddate"];
 	$std_filter_list["enddate"]=$enddate;
 	//<<<<<<<standardfilters>>>>>>>>>
 
@@ -69,7 +74,6 @@
            	$adv_filter_col[] = $_REQUEST[$allKeys[$i]];
    	   }
 	}
-
 	for ($i=0;$i<count($allKeys);$i++)
 	{
 	   $string = substr($allKeys[$i], 0, 3);
@@ -140,6 +144,15 @@
 					}
 					for($i=0;$i<count($adv_filter_col);$i++)
 					{
+						$col = explode(":",$adv_filter_col[$i]);
+						$temp_val = explode(",",$adv_filter_value[$i]);
+						if($col[4] == 'D' || ($col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end') || $col[4] == 'DT')
+						{
+							$val = Array();
+							for($x=0;$x<count($temp_val);$x++)
+								$val[$x] = getDBInsertDateValue(trim($temp_val[$x]));
+							$adv_filter_value[$i] = implode(", ",$val);
+						}
 						$advfiltersql = "INSERT INTO vtiger_cvadvfilter
 								(cvid,
 								columnindex,
@@ -216,6 +229,16 @@
 				}
 				for($i=0;$i<count($adv_filter_col);$i++)
 				{
+					$col = explode(":",$adv_filter_col[$i]);
+					$temp_val = explode(",",$adv_filter_value[$i]);
+					if($col[4] == 'D' || ($col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end') || $col[4] == 'DT')
+					{
+						$val = Array();
+						for($x=0;$x<count($temp_val);$x++){
+							$val[$x] = getDBInsertDateValue(trim($temp_val[$x]));
+						}
+						$adv_filter_value[$i] = implode(", ",$val);	
+					}
 					$advfiltersql = "INSERT INTO vtiger_cvadvfilter
 								(cvid,
 								columnindex,





More information about the vtigercrm-commits mailing list