[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Settings/ -> CustomFieldList.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 ('include/CustomFieldUtil.php');
  14  
  15  global $mod_strings;
  16  global $app_strings;
  17  $smarty=new vtigerCRM_Smarty;
  18  $smarty->assign("MOD",$mod_strings);
  19  $smarty->assign("APP",$app_strings);
  20  global $theme;
  21  $theme_path="themes/".$theme."/";
  22  $image_path=$theme_path."images/";
  23  require_once ($theme_path.'layout_utils.php');
  24  $smarty->assign("IMAGE_PATH", $image_path);
  25  $module_array=getCustomFieldSupportedModules();
  26  
  27  $cfimagecombo = Array($image_path."text.gif",
  28  $image_path."number.gif",
  29  $image_path."percent.gif",
  30  $image_path."currency.gif",
  31  $image_path."date.gif",
  32  $image_path."email.gif",
  33  $image_path."phone.gif",
  34  $image_path."picklist.gif",
  35  $image_path."url.gif",
  36  $image_path."checkbox.gif",
  37  $image_path."text.gif",
  38  $image_path."picklist.gif");
  39  
  40  $cftextcombo = Array($mod_strings['Text'],
  41  $mod_strings['Number'],
  42  $mod_strings['Percent'],
  43  $mod_strings['Currency'],
  44  $mod_strings['Date'],
  45  $mod_strings['Email'],
  46  $mod_strings['Phone'],
  47  $mod_strings['PickList'],
  48  $mod_strings['LBL_URL'],
  49  $mod_strings['LBL_CHECK_BOX'],
  50  $mod_strings['LBL_TEXT_AREA'],
  51  $mod_strings['LBL_MULTISELECT_COMBO']
  52  );
  53  
  54  
  55  $smarty->assign("MODULES",$module_array);
  56  $smarty->assign("CFTEXTCOMBO",$cftextcombo);
  57  $smarty->assign("CFIMAGECOMBO",$cfimagecombo);
  58  if($_REQUEST['fld_module'] !='')
  59      $fld_module = $_REQUEST['fld_module'];
  60  else
  61      $fld_module = 'Leads';
  62  $smarty->assign("MODULE",$fld_module);
  63  $smarty->assign("CFENTRIES",getCFListEntries($fld_module));
  64  if(isset($_REQUEST["duplicate"]) && $_REQUEST["duplicate"] == "yes")
  65  {
  66      $error='Custom Field in the Name '.$_REQUEST["fldlabel"].' already exists. Please specify a different Label';
  67      $smarty->assign("DUPLICATE_ERROR", $error);
  68  }
  69  
  70  if($_REQUEST['mode'] !='')
  71      $mode = $_REQUEST['mode'];
  72  $smarty->assign("MODE", $mode);
  73  
  74  if($_REQUEST['ajax'] != 'true')
  75      $smarty->display('CustomFieldList.tpl');    
  76  else
  77      $smarty->display('CustomFieldEntries.tpl');
  78  
  79      /**
  80      * Function to get customfield entries
  81      * @param string $module - Module name
  82      * return array  $cflist - customfield entries
  83      */
  84  function getCFListEntries($module)
  85  {
  86      $tabid = getTabid($module);
  87      global $adb;
  88      global $theme;
  89      $theme_path="themes/".$theme."/";
  90      $image_path=$theme_path."images/";
  91      $dbQuery = "select fieldid,columnname,fieldlabel,uitype,displaytype,vtiger_convertleadmapping.cfmid from vtiger_field left join vtiger_convertleadmapping on  vtiger_convertleadmapping.leadfid = vtiger_field.fieldid where tabid=".$tabid." and generatedtype=2 order by sequence";
  92      $result = $adb->query($dbQuery);
  93      $row = $adb->fetch_array($result);
  94      $count=1;
  95      $cflist=Array();
  96      if($row!='')
  97      {
  98          do
  99          {
 100              $cf_element=Array();
 101              $cf_element['no']=$count;
 102              $cf_element['label']=$row["fieldlabel"];
 103              $fld_type_name = getCustomFieldTypeName($row["uitype"]);
 104              $cf_element['type']=$fld_type_name;
 105              if($module == 'Leads')
 106              {
 107                  $mapping_details = getListLeadMapping($row["cfmid"]);
 108                  $cf_element[]= $mapping_details['accountlabel'];
 109                  $cf_element[]= $mapping_details['contactlabel'];
 110                  $cf_element[]= $mapping_details['potentiallabel'];
 111              }
 112              $cf_element['tool']='<img src="'.$image_path.'editfield.gif" border="0" style="cursor:pointer;" onClick="fnvshobj(this,\'createcf\');getCreateCustomFieldForm(\''.$module.'\',\''.$row["fieldid"].'\',\''.$tabid.'\',\''.$row["uitype"].'\')" alt="Edit" title="Edit"/>&nbsp;|&nbsp;<img style="cursor:pointer;" onClick="deleteCustomField('.$row["fieldid"].',\''.$module.'\', \''.$row["columnname"].'\', \''.$row["uitype"].'\')" src="'.$image_path.'delete.gif" border="0"  alt="Delete" title="Delete"/></a>';
 113  
 114              $cflist[] = $cf_element;
 115              $count++;
 116          }while($row = $adb->fetch_array($result));
 117      }
 118      return $cflist;
 119  }
 120  
 121  /**
 122  * Function to Lead customfield Mapping entries
 123  * @param integer  $cfid   - Lead customfield id
 124  * return array    $label  - customfield mapping
 125  */
 126  function getListLeadMapping($cfid)
 127  {
 128      global $adb;
 129      $sql="select * from vtiger_convertleadmapping where cfmid =".$cfid;
 130      $result = $adb->query($sql);
 131      $noofrows = $adb->num_rows($result);
 132      for($i =0;$i <$noofrows;$i++)
 133      {
 134          $leadid = $adb->query_result($result,$i,'leadfid');
 135          $accountid = $adb->query_result($result,$i,'accountfid');
 136          $contactid = $adb->query_result($result,$i,'contactfid');
 137          $potentialid = $adb->query_result($result,$i,'potentialfid');
 138          $cfmid = $adb->query_result($result,$i,'cfmid');
 139  
 140          $sql2="select fieldlabel from vtiger_field where fieldid ='".$accountid."'";
 141          $result2 = $adb->query($sql2);
 142          $accountfield = $adb->query_result($result2,0,'fieldlabel');
 143          $label['accountlabel'] = $accountfield;
 144          
 145          $sql3="select fieldlabel from vtiger_field where fieldid ='".$contactid."'";
 146          $result3 = $adb->query($sql3);
 147          $contactfield = $adb->query_result($result3,0,'fieldlabel');
 148          $label['contactlabel'] = $contactfield;
 149          $sql4="select fieldlabel from vtiger_field where fieldid ='".$potentialid."'";
 150          $result4 = $adb->query($sql4);
 151          $potentialfield = $adb->query_result($result4,0,'fieldlabel');
 152          $label['potentiallabel'] = $potentialfield;
 153      }
 154      return $label;
 155  }
 156  
 157  /* function to get the modules supports Custom Fields
 158  */
 159  
 160  function getCustomFieldSupportedModules()
 161  {
 162      global $adb;
 163      $sql="select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_field.tabid=vtiger_tab.tabid where vtiger_field.tabid not in(9,10,16,15,8,29)";
 164      $result = $adb->query($sql);
 165      while($moduleinfo=$adb->fetch_array($result))
 166      {
 167          $modulelist[$moduleinfo['name']] = $moduleinfo['name'];
 168      }
 169      return $modulelist;
 170  }
 171  ?>


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