[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Settings/ -> PickList.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  require_once ('Smarty_setup.php');
  12  require_once ('include/database/PearDatabase.php');
  13  require_once ('database/DatabaseConnection.php');
  14  require_once('themes/'.$theme.'/layout_utils.php');
  15  global $mod_strings;
  16  global $app_strings;
  17  global $app_list_strings;
  18  global $current_language, $currentModule;
  19  
  20  if(isset($_REQUEST['fld_module']) && $_REQUEST['fld_module'] != '')
  21      $fld_module = $_REQUEST['fld_module'];
  22  else    
  23      $fld_module = 'Potentials';
  24  
  25  if(isset($_REQUEST['uitype']) && $_REQUEST['uitype'] != '')
  26      $uitype = $_REQUEST['uitype'];
  27  
  28  $smarty = new vtigerCRM_Smarty;
  29  $smarty->assign("MODULE_LISTS",getPickListModules());
  30  
  31  $picklists_entries = getUserFldArray($fld_module);
  32  if((sizeof($picklists_entries) %3) != 0)
  33      $value = (sizeof($picklists_entries) + 3 - (sizeof($picklists_entries))%3); 
  34  else
  35      $value = sizeof($picklists_entries);
  36  
  37  if($fld_module == 'Events')
  38  
  39      $temp_module_strings = return_module_language($current_language, 'Calendar');
  40  else
  41      $temp_module_strings = return_module_language($current_language, $fld_module);
  42  
  43  $smarty->assign("TEMP_MOD", $temp_module_strings);
  44  $picklist_fields = array_chunk(array_pad($picklists_entries,$value,''),3);
  45  $smarty->assign("MODULE",$fld_module);
  46  $smarty->assign("PICKLIST_VALUES",$picklist_fields);
  47  $smarty->assign("MOD", return_module_language($current_language,'Settings'));
  48  $smarty->assign("IMAGE_PATH",$image_path);
  49  $smarty->assign("APP", $app_strings);
  50  $smarty->assign("CMOD", $mod_strings);
  51  $smarty->assign("UITYPE", $uitype);
  52  
  53  if($_REQUEST['directmode'] != 'ajax')
  54      $smarty->display("Settings/PickList.tpl");
  55  else
  56      $smarty->display("Settings/PickListContents.tpl");
  57      
  58      /** Function to get picklist fields for the given module 
  59       *  @ param $fld_module
  60       *  It gets the picklist details array for the given module in the given format
  61       *              $fieldlist = Array(Array('fieldlabel'=>$fieldlabel,'generatedtype'=>$generatedtype,'columnname'=>$columnname,'fieldname'=>$fieldname,'value'=>picklistvalues))    
  62       */
  63  
  64  function getUserFldArray($fld_module)
  65  {
  66      global $adb;
  67      $user_fld = Array();
  68      $tabid = getTabid($fldmodule);
  69      $query = "select fieldlabel,generatedtype,columnname,fieldname,uitype from vtiger_field where displaytype = 1 and (tabid = ".getTabid($fld_module)." AND uitype IN (15,16, 111,33)) OR (tabid = ".getTabid($fld_module)." AND fieldname='salutationtype')";
  70      $result = $adb->query($query);
  71      $noofrows = $adb->num_rows($result);
  72      if($noofrows > 0)
  73      {
  74          $fieldlist = Array();
  75          for($i=0; $i<$noofrows; $i++)
  76          {
  77              $user_fld = Array();
  78              $fld_name = $adb->query_result($result,$i,"fieldname");
  79              if($fld_module == 'Events')    
  80              {
  81                  if($adb->query_result($result,$i,"fieldname") != 'recurringtype' && $adb->query_result($result,$i,"fieldname") != 'activitytype' && $adb->query_result($result,$i,"fieldname") != 'visibility')    
  82                  {    
  83                      $user_fld['fieldlabel'] = $adb->query_result($result,$i,"fieldlabel");    
  84                      $user_fld['generatedtype'] = $adb->query_result($result,$i,"generatedtype");    
  85                      $user_fld['columnname'] = $adb->query_result($result,$i,"columnname");    
  86                      $user_fld['fieldname'] = $adb->query_result($result,$i,"fieldname");    
  87                      $user_fld['uitype'] = $adb->query_result($result,$i,"uitype");    
  88                      $user_fld['value'] = getPickListValues($user_fld['fieldname']); 
  89                      $fieldlist[] = $user_fld;
  90                  }
  91              }
  92              else
  93              {
  94                      $user_fld['fieldlabel'] = $adb->query_result($result,$i,"fieldlabel");    
  95                      $user_fld['generatedtype'] = $adb->query_result($result,$i,"generatedtype");    
  96                      $user_fld['columnname'] = $adb->query_result($result,$i,"columnname");    
  97                      $user_fld['fieldname'] = $adb->query_result($result,$i,"fieldname");    
  98                      $user_fld['uitype'] = $adb->query_result($result,$i,"uitype");    
  99                      $user_fld['value'] = getPickListValues($user_fld['fieldname']); 
 100                      $fieldlist[] = $user_fld;
 101              }
 102          }
 103      }
 104      return $fieldlist;
 105  }
 106  
 107      /** Function to get picklist values for the given field  
 108       *  @ param $tablename
 109       *  It gets the picklist values for the given fieldname
 110       *              $fldVal = Array(0=>value,1=>value1,-------------,n=>valuen)    
 111       */
 112  
 113  function getPickListValues($tablename)
 114  {
 115      global $adb;    
 116      $query = "select * from vtiger_".$tablename." order by sortorderid";
 117      $result = $adb->query($query);
 118      $fldVal = Array();
 119      while($row = $adb->fetch_array($result))
 120      {
 121          $fldVal []= $row[$tablename];
 122      }
 123      return $fldVal;
 124  }
 125      /** Function to get modules which has picklist values  
 126       *  It gets the picklist modules and return in an array in the following format 
 127       *              $modules = Array($tabid=>$tablabel,$tabid1=>$tablabel1,$tabid2=>$tablabel2,-------------,$tabidn=>$tablabeln)    
 128       */
 129  function getPickListModules()
 130  {
 131      global $adb;
 132      $query = 'select distinct vtiger_field.fieldname,vtiger_field.tabid,tablabel,uitype from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where uitype IN (15,16, 111,33) and vtiger_field.tabid != 29';
 133      $result = $adb->query($query);
 134      while($row = $adb->fetch_array($result))
 135      {
 136          $modules[$row['tabid']] = $row['tablabel']; 
 137      }
 138      return $modules;
 139  }
 140  ?>


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