[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/include/ -> CustomFieldUtil.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9  *
  10   ********************************************************************************/
  11  
  12  require_once ('include/database/PearDatabase.php');
  13  require_once ('include/utils/utils.php');
  14  
  15  /**
  16   * Function to get vtiger_field typename
  17   * @param $uitype :: uitype -- Type integer
  18   * returns the vtiger_field type name -- Type string
  19   */
  20  function getCustomFieldTypeName($uitype)
  21  {
  22      global $log;
  23      $log->debug("Entering getCustomFieldTypeName(".$uitype.") method ...");
  24      global $log;
  25          $log->info("uitype is ".$uitype);
  26      $fldname = '';
  27      
  28      if($uitype == 1)
  29      {
  30          $fldname = 'Text';
  31      }
  32      elseif($uitype == 7)
  33      {
  34          $fldname = 'Number';
  35      }
  36      elseif($uitype == 9)
  37      {
  38          $fldname = 'Percent';
  39      }
  40      elseif($uitype == 5)
  41      {
  42          $fldname = 'Date';
  43      }
  44      elseif($uitype == 13)
  45      {
  46          $fldname = 'Email';
  47      }
  48      elseif($uitype == 11)
  49      {
  50          $fldname = 'Phone';
  51      }
  52      elseif($uitype == 15)
  53      {
  54          $fldname = 'PickList';
  55      }
  56      elseif($uitype == 17)
  57      {
  58          $fldname = 'Url';
  59      }
  60      elseif($uitype == 56)
  61      {
  62          $fldname = 'Checkbox';
  63      }
  64      elseif($uitype == 71)
  65      {
  66          $fldname = 'Currency';
  67      }
  68      elseif($uitype == 21)
  69      {
  70          $fldname = 'Text Area';
  71      }
  72      elseif($uitype == 33)
  73      {
  74          $fldname = 'Multi-Select Combo Box';
  75      }
  76      elseif($uitype == 85)
  77      {
  78          $fldname = 'Skype';
  79      }
  80  $log->debug("Exiting getCustomFieldTypeName method ...");
  81      return $fldname;
  82  }
  83  
  84  /**
  85   * Function to get custom vtiger_fields
  86   * @param $module :: vtiger_table name -- Type string
  87   * returns customfields in key-value pair array format
  88   */
  89  function getCustomFieldArray($module)
  90  {
  91      global $log;
  92      $log->debug("Entering getCustomFieldArray(".$module.") method ...");
  93      global $adb;
  94      $custquery = "select * from vtiger_field where tablename='".$module."'";
  95      $custresult = $adb->query($custquery);
  96      $custFldArray = Array();
  97      $noofrows = $adb->num_rows($custresult);
  98      for($i=0; $i<$noofrows; $i++)
  99      {
 100          $colName=$adb->query_result($custresult,$i,"column_name");
 101          $custFldArray[$colName] = $i;
 102      }
 103      $log->debug("Exiting getCustomFieldArray method ...");
 104      return $custFldArray;
 105      
 106  }
 107  
 108  /**
 109   * Function to get columnname and vtiger_fieldlabel from vtiger_field vtiger_table
 110   * @param $module :: module name -- Type string
 111   * @param $trans_array :: translated column vtiger_fields -- Type array
 112   * returns trans_array in key-value pair array format
 113   */
 114  function getCustomFieldTrans($module, $trans_array)
 115  {
 116      global $log;
 117      $log->debug("Entering getCustomFieldTrans(".$module.",". $trans_array.") method ...");
 118      global $adb;
 119      $tab_id = getTabid($module);    
 120      $custquery = "select columnname,fieldlabel from vtiger_field where generatedtype=2 and tabid=".$tab_id;
 121      $custresult = $adb->query($custquery);
 122      $custFldArray = Array();
 123      $noofrows = $adb->num_rows($custresult);
 124      for($i=0; $i<$noofrows; $i++)
 125      {
 126          $colName=$adb->query_result($custresult,$i,"columnname");
 127          $fldLbl = $adb->query_result($custresult,$i,"fieldlabel");
 128          $trans_array[$colName] = $fldLbl;
 129      }    
 130      $log->debug("Exiting getCustomFieldTrans method ...");
 131  }
 132  
 133  
 134  /**
 135   * Function to get customfield record from vtiger_field vtiger_table
 136   * @param $tab :: Tab ID -- Type integer
 137   * @param $datatype :: vtiger_field name -- Type string
 138   * @param $id :: vtiger_field Id -- Type integer
 139   * returns the data result in string format
 140   */
 141  function getCustomFieldData($tab,$id,$datatype)
 142  {
 143      global $log;
 144      $log->debug("Entering getCustomFieldData(".$tab.",".$id.",".$datatype.") method ...");
 145      global $adb;
 146      $query = "select * from vtiger_field where tabid=".$tab." and fieldid=".$id;
 147      $result = $adb->query($query);
 148      $return_data=$adb->fetch_array($result);
 149      $log->debug("Exiting getCustomFieldData method ...");
 150      return $return_data[$datatype];
 151  }
 152  
 153  
 154  /**
 155   * Function to get customfield type,length value,decimal value and picklist value
 156   * @param $label :: vtiger_field typename -- Type string
 157   * @param $typeofdata :: datatype -- Type string
 158   * returns the vtiger_field type,length,decimal
 159   * and picklist value in ';' separated array format
 160   */
 161  function getFldTypeandLengthValue($label,$typeofdata)
 162  {
 163      global $log;
 164      $log->debug("Entering getFldTypeandLengthValue(".$label.",".$typeofdata.") method ...");
 165      if($label == 'Text')
 166      {
 167          $types = explode("~",$typeofdata);
 168          $data_array=array('0',$types[3]);
 169          $fieldtype = implode(";",$data_array);
 170      }
 171      elseif($label == 'Number')
 172      {
 173          $types = explode("~",$typeofdata);
 174          $data_decimal = explode(",",$types[2]);
 175          $data_array=array('1',$data_decimal[0],$data_decimal[1]);
 176          $fieldtype = implode(";",$data_array);
 177      }
 178      elseif($label == 'Percent')
 179      {
 180          $types = explode("~",$typeofdata);
 181          $data_array=array('2','5',$types[3]);
 182          $fieldtype = implode(";",$data_array);
 183      }
 184      elseif($label == 'Currency')
 185      {
 186          $types = explode("~",$typeofdata);
 187          $data_decimal = explode(",",$types[2]);
 188          $data_array=array('71',$data_decimal[0],$data_decimal[1]);
 189          $fieldtype = implode(";",$data_array);
 190      }
 191      elseif($label == 'Date')
 192      {
 193          $fieldtype = '4';
 194      }
 195      elseif($label == 'Email')
 196      {
 197          $fieldtype = '5';
 198      }
 199      elseif($label == 'Phone')
 200      {
 201          $fieldtype = '6';
 202      }
 203      elseif($label == 'PickList')
 204      {
 205          $fieldtype = '7';
 206      }
 207      elseif($label == 'Url')
 208      {
 209          $fieldtype = '8';
 210      }
 211      elseif($label == 'Checkbox')
 212      {
 213          $fieldtype = '9';
 214      }
 215      elseif($label == 'Text Area')
 216      {
 217          $fieldtype = '10';
 218      }
 219      elseif($label == 'Multi-Select Combo Box')
 220          {
 221                  $fieldtype = '11';
 222          }
 223      elseif($label == 'Skype')
 224      {
 225          $fieldtype = '12';
 226      }
 227      $log->debug("Exiting getFldTypeandLengthValue method ...");
 228      return $fieldtype;
 229  }
 230  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7