[Vtigercrm-commits] [vtiger-commits] r10237 - in /vtigercrm/branches/5.0.3: include/utils/CommonUtils.php modules/Import/ImportStep2.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri Feb 23 02:13:46 EST 2007


Author: saraj
Date: Fri Feb 23 00:13:38 2007
New Revision: 10237

Log:
* we are getting the import fields from DB instead of hard coded array ie., previously we haved used the hardcoded array for importable fields but now retrieved from DB

Modified:
    vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
    vtigercrm/branches/5.0.3/modules/Import/ImportStep2.php

Modified: vtigercrm/branches/5.0.3/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/CommonUtils.php Fri Feb 23 00:13:38 2007
@@ -2668,4 +2668,48 @@
 	return $str;
 }
 
+/**	function used to get the list of importable fields
+ *	@param string $module - module name
+ *	@return array $fieldslist - array with list of fieldnames and the corresponding translated fieldlabels. The return array will be in the format of [fieldname]=>[fieldlabel] where as the fieldlabel will be translated
+ */
+function getImportFieldsList($module)
+{
+	global $adb, $log;
+	$log->debug("Entering into function getImportFieldsList($module)");
+	
+	$tabid = getTabid($module);
+
+	//Here we can add special cases for module basis, ie., if we want the fields of display type 3, we can add
+	$displaytype = " displaytype=1 ";
+
+	$fieldnames = "";
+	//For module basis we can add the list of fields for Import mapping
+	if($module == "Leads")
+	{
+		$fieldnames = " fieldname='salutationtype' ";
+	}
+
+	//Form the where condition based on tabid , displaytype and extra fields
+	$where = " WHERE tabid=$tabid and ( $displaytype ";
+	if($fieldnames != "")
+	{
+		$where .= " or $fieldnames ";
+	}
+	$where .= ")";
+
+	//Get the list of fields and form as array with [fieldname] => [fieldlabel]
+	$query = "SELECT fieldname, fieldlabel FROM vtiger_field $where";
+	$result = $adb->query($query);
+	for($i=0;$i<$adb->num_rows($result);$i++)
+	{
+		$fieldname = $adb->query_result($result,$i,'fieldname');
+		$fieldlabel = $adb->query_result($result,$i,'fieldlabel');
+		$fieldslist[$fieldname] = $fieldlabel;
+	}
+
+	$log->debug("Exit from function getImportFieldsList($module)");
+
+	return $fieldslist;
+}
+
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Import/ImportStep2.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Import/ImportStep2.php (original)
+++ vtigercrm/branches/5.0.3/modules/Import/ImportStep2.php Fri Feb 23 00:13:38 2007
@@ -226,10 +226,11 @@
 $list_string_key = strtolower($_REQUEST['module']);
 $list_string_key .= "_import_fields";
 
-$translated_column_fields = $mod_list_strings[$list_string_key];
+//Now we are getting the import fields from DB instead of hard coded array $mod_list_strings
+$translated_column_fields = getImportFieldsList($_REQUEST['module']);//$mod_list_strings[$list_string_key];
 
 // adding custom vtiger_fields translations
-getCustomFieldTrans($_REQUEST['module'],&$translated_column_fields);
+//getCustomFieldTrans($_REQUEST['module'],&$translated_column_fields);
 
 $cnt=1;
 for($field_count = 0; $field_count < $ret_field_count; $field_count++)





More information about the vtigercrm-commits mailing list