[Vtigercrm-commits] [vtiger-commits] r10813 - in /vtigercrm/branches/5.0.3: include/PopulateComboValues.php modules/Migration/DBChanges/503rc2_to_503.php modules/Settings/EditComboField.php modules/Settings/UpdateComboValues.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Apr 30 03:12:52 EDT 2007


Author: richie
Date: Mon Apr 30 01:12:41 2007
New Revision: 10813

Log:
* Changed the presence in picklists and organised in a common way. Now we can use presence=0 for non editable and presence=1 for editable entries in all picklists, we don't worry about uitypes. In this change we have fixed ticket 3622 also, Fixed #3622

Modified:
    vtigercrm/branches/5.0.3/include/PopulateComboValues.php
    vtigercrm/branches/5.0.3/modules/Migration/DBChanges/503rc2_to_503.php
    vtigercrm/branches/5.0.3/modules/Settings/EditComboField.php
    vtigercrm/branches/5.0.3/modules/Settings/UpdateComboValues.php

Modified: vtigercrm/branches/5.0.3/include/PopulateComboValues.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/PopulateComboValues.php (original)
+++ vtigercrm/branches/5.0.3/include/PopulateComboValues.php Mon Apr 30 01:12:41 2007
@@ -68,6 +68,23 @@
 		{
 			$this->insertComboValues($combo_strings[$comTab."_dom"],$comTab);
 		}
+
+		//we have to decide what are all the picklist and picklist values are non editable
+		//presence = 0 means you cannot edit the picklist value
+		//presence = 1 means you can edit the picklist value
+		$noneditable_tables = Array("ticketstatus","taskstatus","eventstatus","eventstatus","faqstatus","quotestage","postatus","sostatus","invoicestatus");
+		$noneditable_values = Array(
+						"sales_stage"=>"Closed Won",
+					   );
+		foreach($noneditable_tables as $picklistname)
+		{
+			$adb->query("update vtiger_".$picklistname." set PRESENCE=0");
+		}
+		foreach($noneditable_values as $picklistname => $value)
+		{
+			$adb->query("update vtiger_".$picklistname." set PRESENCE=0 where $picklistname='".$value."'");
+		}
+
 		$log->debug("Exiting create_tables () method ...");
 	}
 }

Modified: vtigercrm/branches/5.0.3/modules/Migration/DBChanges/503rc2_to_503.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Migration/DBChanges/503rc2_to_503.php (original)
+++ vtigercrm/branches/5.0.3/modules/Migration/DBChanges/503rc2_to_503.php Mon Apr 30 01:12:41 2007
@@ -188,6 +188,26 @@
 }
 
 
+//change the picklist - presence value ie., if presence = 0 then you cannot edit, if presence = 1 then you can edit
+$noneditable_tables = Array("ticketstatus","taskstatus","eventstatus","eventstatus","faqstatus","quotestage","postatus","sostatus","invoicestatus");
+$noneditable_values = Array(
+				"sales_stage"=>"Closed Won",
+			   );
+foreach($noneditable_tables as $picklistname)
+{
+	//we have to interchange 0 and 1, so change 0->2, 1->0, 2->1
+	ExecuteQuery("UPDATE vtiger_".$picklistname." SET PRESENCE=2 WHERE PRESENCE=0");
+	ExecuteQuery("UPDATE vtiger_".$picklistname." SET PRESENCE=0 WHERE PRESENCE=1");
+	ExecuteQuery("UPDATE vtiger_".$picklistname." SET PRESENCE=1 WHERE PRESENCE=2");
+}
+foreach($noneditable_values as $picklistname => $value)
+{
+	ExecuteQuery("UPDATE vtiger_".$picklistname." SET PRESENCE=0 WHERE $picklistname='".$value."'");
+}
+
+
+
+
 
 $migrationlog->debug("\n\nDB Changes from 5.0.3RC2 to 5.0.3 -------- Ends \n\n");
 

Modified: vtigercrm/branches/5.0.3/modules/Settings/EditComboField.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Settings/EditComboField.php (original)
+++ vtigercrm/branches/5.0.3/modules/Settings/EditComboField.php Mon Apr 30 01:12:41 2007
@@ -32,67 +32,48 @@
 else
 	$temp_module_strings = return_module_language($current_language, $moduleName);
 
-//To get the Editable Picklist Values 
-if($uitype != 111)
+//Get the Editable Picklist Values 
+$query = "select * from vtiger_".$tableName." where presence=1";
+$result = $adb->query($query);
+$fldVal='';
+
+while($row = $adb->fetch_array($result))
 {
-	$query = "select * from vtiger_".$tableName ;
-	$result = $adb->query($query);
-	$fldVal='';
-
-	while($row = $adb->fetch_array($result))
-	{
-		if($temp_module_strings[$row[$tableName]] != '')
-			$fldVal .= $temp_module_strings[$row[$tableName]];
-		else
-			$fldVal .= $row[$tableName];
-		$fldVal .= "\n";	
-	}
-}
-else
-{
-	$query = "select * from vtiger_".$tableName." where presence=0"; 
-	$result = $adb->query($query);
-	$fldVal='';
-
-	while($row = $adb->fetch_array($result))
-	{
-		if($temp_module_strings[$row[$tableName]] != '')
-			$fldVal .= $temp_module_strings[$row[$tableName]];
-		else
-			$fldVal .= $row[$tableName];
-		$fldVal .= "\n";	
-	}
+	if($temp_module_strings[$row[$tableName]] != '')
+		$fldVal .= $temp_module_strings[$row[$tableName]];
+	else
+		$fldVal .= $row[$tableName];
+	$fldVal .= "\n";	
 }
 
-//To get the Non Editable Picklist Entries
-if($uitype == 111) 
+//Get the Non - Editable Picklist Values 
+$qry = "select * from vtiger_".$tableName." where presence=0"; 
+$res = $adb->query($qry);
+$nonedit_fldVal='';
+
+while($row = $adb->fetch_array($res))
 {
-	$qry = "select * from vtiger_".$tableName." where presence=1"; 
-	$res = $adb->query($qry);
-	$nonedit_fldVal='';
+	if($temp_module_strings[$row[$tableName]] != '')
+		$nonedit_fldVal .= $temp_module_strings[$row[$tableName]];
+	else
+		$nonedit_fldVal .= $row[$tableName];
+	$nonedit_fldVal .= "<br>";	
+}
 
-	while($row = $adb->fetch_array($res))
-	{
-		if($temp_module_strings[$row[$tableName]] != '')
-			$nonedit_fldVal .= $temp_module_strings[$row[$tableName]];
-		else
-			$nonedit_fldVal .= $row[$tableName];
-		$nonedit_fldVal .= "<br>";	
-	}
-}
+
 $query = 'select fieldlabel from vtiger_tab inner join vtiger_field on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.name="'.$moduleName.'" and fieldname="'.$tableName.'"';
 $fieldlabel = $adb->query_result($adb->query($query),0,'fieldlabel'); 
 
 if($nonedit_fldVal == '')
-		$smarty->assign("EDITABLE_MODE","edit");
-	else
-		$smarty->assign("EDITABLE_MODE","nonedit");
+	$smarty->assign("EDITABLE_MODE","edit");
+else
+	$smarty->assign("EDITABLE_MODE","nonedit");
 $smarty->assign("NON_EDITABLE_ENTRIES", $nonedit_fldVal);
 $smarty->assign("ENTRIES",$fldVal);
 $smarty->assign("MODULE",$moduleName);
 $smarty->assign("FIELDNAME",$tableName);
 //First look into app_strings and then mod_strings and if not available then original label will be displayed
-$temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel);
+$temp_label = getTranslatedString($fieldlabel);
 $smarty->assign("FIELDLABEL",$temp_label);
 $smarty->assign("UITYPE", $uitype);
 $smarty->assign("MOD", return_module_language($current_language,'Settings'));

Modified: vtigercrm/branches/5.0.3/modules/Settings/UpdateComboValues.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Settings/UpdateComboValues.php (original)
+++ vtigercrm/branches/5.0.3/modules/Settings/UpdateComboValues.php Mon Apr 30 01:12:41 2007
@@ -18,17 +18,9 @@
 
 global $adb;
 
-//Deleting the already existing values
-if($uitype == 111)
-{
-	$delquery="delete from vtiger_".$tableName." where presence=0";
-	$adb->query($delquery);
-}
-else
-{
-	$delquery="delete from vtiger_".$tableName;
-	$adb->query($delquery);
-}
+//Delete the already existing values which are editable (presence=0 means non editable, we will not touch that values)
+$delquery="delete from vtiger_".$tableName." where presence=1";
+$adb->query($delquery);
 
 $pickArray = explode("\n",$fldPickList);
 $count = count($pickArray);
@@ -38,29 +30,15 @@
 if($tabname[1]!='')
        	$custom=true;
 
-/*for($i = 0; $i < $count; $i++)
-{
-	$pickArray[$i] = trim($pickArray[$i]);
-	if($pickArray[$i] != '')
-	{
-		if($uitype == 111)
-			$query = "insert into vtiger_".$tableName." values('','".$pickArray[$i]."',".$i.",0)";
-		else
-			$query = "insert into vtiger_".$tableName." values('','".$pickArray[$i]."',".$i.",1)";
-
-	        $adb->query($query);
-	}
-}*/
 /* ticket2369 fixed */
 $columnName = $tableName;
-foreach ($pickArray as $index => $data) {
+foreach ($pickArray as $index => $data)
+{
         $data = trim($data);
-        if(!empty($data)){
+        if(!empty($data))
+	{
 		$data = $adb->formatString("vtiger_$tableName",$columnName,$data);
-		if($uitype == 111)
-			$query = "insert into vtiger_$tableName values('',$data,$index,0)";
-		else
-			$query = "insert into vtiger_$tableName values('',$data,$index,1)";
+		$query = "insert into vtiger_$tableName values('',$data,$index,1)";
 		$adb->query($query);
         }
 } 





More information about the vtigercrm-commits mailing list