[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Settings/ -> CreateCustomField.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/CustomFieldUtil.php');
  13  require_once ('Smarty_setup.php');
  14  
  15  
  16  global $mod_strings,$app_strings,$app_list_strings,$theme,$adb;
  17  
  18  $theme_path="themes/".$theme."/";
  19  $image_path=$theme_path."images/";
  20  
  21  require_once ($theme_path.'layout_utils.php');
  22  
  23  $tabid=$_REQUEST['tabid'];
  24  $fieldid=$_REQUEST['fieldid'];
  25  if(isset($_REQUEST['uitype']) && $_REQUEST['uitype'] != '')
  26      $uitype=$_REQUEST['uitype'];
  27  else
  28      $uitype=1;
  29  $readonly = '';
  30  $smarty = new vtigerCRM_Smarty;
  31  $cfimagecombo = Array($image_path."text.gif",
  32                          $image_path."number.gif",
  33                          $image_path."percent.gif",
  34                          $image_path."cfcurrency.gif",
  35                          $image_path."date.gif",
  36                          $image_path."email.gif",
  37                          $image_path."phone.gif",
  38                          $image_path."cfpicklist.gif",
  39                          $image_path."url.gif",
  40                          $image_path."checkbox.gif",
  41                          $image_path."text.gif",
  42                          $image_path."cfpicklist.gif",
  43              $image_path."skype.gif");
  44  
  45  $cftextcombo = Array($mod_strings['Text'],
  46                          $mod_strings['Number'],
  47                          $mod_strings['Percent'],
  48                          $mod_strings['Currency'],
  49                          $mod_strings['Date'],
  50                          $mod_strings['Email'],
  51                          $mod_strings['Phone'],
  52                          $mod_strings['PickList'],
  53                          $mod_strings['LBL_URL'],
  54                          $mod_strings['LBL_CHECK_BOX'],
  55                          $mod_strings['LBL_TEXT_AREA'],
  56                          $mod_strings['LBL_MULTISELECT_COMBO'],
  57              $mod_strings['Skype']
  58                  );    
  59  $typeVal = Array(
  60      '0'=>'Text',
  61      '1'=>'Number',
  62      '2'=>'Percent',
  63      '3'=>'Currency',
  64      '4'=>'Date',
  65      '5'=>'Email',
  66      '6'=>'Phone',
  67      '7'=>'Picklist',
  68      '8'=>'URL',
  69      '11'=>'MultiSelectCombo',
  70      '12'=>'Skype');
  71  if(isset($fieldid) && $fieldid!='')
  72  {
  73      $mode='edit';
  74      $customfield_columnname=getCustomFieldData($tabid,$fieldid,'columnname');
  75      $customfield_typeofdata=getCustomFieldData($tabid,$fieldid,'typeofdata');
  76      $customfield_fieldlabel=getCustomFieldData($tabid,$fieldid,'fieldlabel');
  77      $customfield_typename=getCustomFieldTypeName($uitype);
  78      $fieldtype_lengthvalue=getFldTypeandLengthValue($customfield_typename,$customfield_typeofdata);
  79      list($fieldtype,$fieldlength,$decimalvalue)= explode(";",$fieldtype_lengthvalue);
  80      $readonly = "readonly";
  81      if($fieldtype == '7' || $fieldtype == '11')
  82      {
  83          $query = "select * from vtiger_".$customfield_columnname;
  84          $result = $adb->query($query);
  85          $fldVal='';
  86          while($row = $adb->fetch_array($result))
  87          {
  88              $fldVal .= $row[$customfield_columnname];
  89              $fldVal .= "\n";
  90          }
  91          $smarty->assign("PICKLISTVALUE",$fldVal);
  92      }
  93      $selectedvalue = $typeVal[$fieldtype];
  94  }
  95  $smarty->assign("MOD", $mod_strings);
  96  $smarty->assign("APP", $app_strings);
  97  $smarty->assign("FLD_MODULE", $_REQUEST['fld_module']);
  98  if(isset($_REQUEST["duplicate"]) && $_REQUEST["duplicate"] == "yes")
  99  {
 100      $error='Custom Field in the Name '.$_REQUEST["fldlabel"].' already exists. Please specify a different Label';
 101      $smarty->assign("DUPLICATE_ERROR", $error);
 102      $customfield_fieldlabel=$_REQUEST["fldlabel"];
 103      $fieldlength=$_REQUEST["fldlength"];
 104      $decimalvalue=$_REQUEST["flddecimal"];
 105      $fldVal = $_REQUEST["fldPickList"];
 106      $selectedvalue = $typeVal[$_REQUEST["fldType"]];
 107  }
 108  elseif($fieldid == '')
 109  {
 110      $selectedvalue = "0";
 111  }
 112  
 113  if($mode == 'edit')
 114      $disable_str = 'disabled' ;
 115  else
 116      $disable_str = '' ;
 117  
 118  $output = '';
 119  
 120  $combo_output = '';
 121  for($i=0;$i<count($cftextcombo);$i++)
 122  {
 123          if($selectedvalue == $i && $fieldid != '')
 124                  $sel_val = 'selected';
 125          else
 126                  $sel_val = '';
 127      $combo_output.= '<a href="javascript:void(0);" onClick="makeFieldSelected(this,'.$i.');" id="field'.$i.'" style="text-decoration:none;background-image:url('.$cfimagecombo[$i].');" class="customMnu" '.$disable_str.'>'.$cftextcombo[$i].'</a>';
 128  
 129  }
 130  $output .= '<div id="orgLay" style="display:block;" class="layerPopup"><script language="JavaScript" type="text/javascript" src="include/js/customview.js"></script>
 131      <form action="index.php" method="post" name="addtodb" onSubmit="return validate()">
 132        <input type="hidden" name="module" value="Settings">
 133        <input type="hidden" name="fld_module" value="'.$_REQUEST['fld_module'].'">
 134        <input type="hidden" name="parenttab" value="Settings">
 135            <input type="hidden" name="action" value="AddCustomFieldToDB">
 136        <input type="hidden" name="fieldid" value="'.$fieldid.'">
 137        <input type="hidden" name="column" value="'.$customfield_columnname.'">
 138        <input type="hidden" name="mode" id="cfedit_mode" value="'.$mode.'">
 139        <input type="hidden" name="cfcombo" id="selectedfieldtype" value="">
 140  
 141        
 142          <table width="100%" border="0" cellpadding="5" cellspacing="0" class="layerHeadingULine">
 143              <tr>';
 144              if($mode == 'edit')
 145                  $output .= '<td width="60%" align="left" class="layerPopupHeading">'.$mod_strings['LBL_EDIT_FIELD_TYPE'].' - '.$mod_strings[$customfield_typename].'</td>';
 146              else
 147                  $output .= '<td width="60%" align="left" class="layerPopupHeading">'.$mod_strings['LBL_ADD_FIELD'].'</td>';
 148                  
 149              $output .= '<td width="40%" align="right"><a href="javascript:fninvsh(\'orgLay\');"><img src="'.$image_path.'close.gif" border="0"  align="absmiddle" /></a></td>
 150              </tr>';
 151              $output .='</table><table border=0 cellspacing=0 cellpadding=5 width=95% align=center> 
 152                              <tr>
 153                                  <td class=small >
 154                                      <table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
 155                                          <tr>';
 156              if($mode != 'edit')
 157              {    
 158                  $output .= '<td><table>
 159                          <tr><td>'.$mod_strings['LBL_SELECT_FIELD_TYPE'].'</td></tr>
 160                          <tr><td>
 161                              <div name="cfcombo" id="cfcombo" class=small  style="width:205px;height:150px;overflow-y:auto;overflow-x:hidden;overflow:auto;border:1px solid #CCCCCC;">'.$combo_output.'</div>
 162                          </td></tr>
 163                          </table></td>';
 164              }
 165              $output .='<td width="50%">
 166                      <table width="100%" border="0" cellpadding="5" cellspacing="0">
 167                          <tr>
 168                              <td class="dataLabel" nowrap="nowrap" align="right" width="30%"><b>'.$mod_strings['LBL_LABEL'].' </b></td>
 169                              <td align="left" width="70%"><input name="fldLabel" value="'.$customfield_fieldlabel.'" type="text" class="txtBox"></td>
 170                          </tr>';
 171                      if($mode == 'edit')
 172                      {
 173                          switch($uitype)
 174                          {
 175                              case 1:
 176                                  $output .= '<tr id="lengthdetails">
 177                                      <td class="dataLabel" nowrap="nowrap" align="right"><b>'.$mod_strings['LBL_LENGTH'].'</b></td>
 178                                      <td align="left"><input type="text" name="fldLength" value="'.$fieldlength.'" '.$readonly.' class="txtBox"></td>
 179                                  </tr>';
 180                                  break;
 181                              case 71:
 182                              case 9:
 183                              case 7:
 184                                  $output .= '<tr id="lengthdetails">
 185                                      <td class="dataLabel" nowrap="nowrap" align="right"><b>'.$mod_strings['LBL_LENGTH'].'</b></td>
 186                                      <td align="left"><input type="text" name="fldLength" value="'.$fieldlength.'" '.$readonly.' class="txtBox"></td>
 187                                  </tr>';
 188                                  $output .= '<tr id="decimaldetails">
 189                                      <td class="dataLabel" nowrap="nowrap" align="right"><b>'.$mod_strings['LBL_DECIMAL_PLACES'].'</b></td>
 190                                      <td align="left"><input type="text" name="fldDecimal" value="'.$decimalvalue.'" '.$readonly.' class="txtBox"></td>
 191                                  </tr>';
 192                                  break;
 193                              case 33:
 194                              case 15:
 195                                  $output .= '<tr id="picklist">
 196                                      <td class="dataLabel" nowrap="nowrap" align="right" valign="top"><b>'.$mod_strings['LBL_PICK_LIST_VALUES'].'</b></td>
 197                                      <td align="left" valign="top"><textarea name="fldPickList" rows="10" class="txtBox" >'.$fldVal.'</textarea></td>
 198                                      <!--td style="padding-left:10px"><img src="themes/Aqua/images/picklist_hint.gif"/></td-->
 199                                  </tr>';
 200                                  break;
 201                                  
 202                          }
 203                      }
 204                      else
 205                      {
 206                          $output .= '<tr id="lengthdetails">
 207                              <td class="dataLabel" nowrap="nowrap" align="right"><b>'.$mod_strings['LBL_LENGTH'].'</b></td>
 208                              <td align="left"><input type="text" name="fldLength" value="'.$fieldlength.'" '.$readonly.' class="txtBox"></td>
 209                          </tr>
 210                          <tr id="decimaldetails" style="visibility:hidden;">
 211                              <td class="dataLabel" nowrap="nowrap" align="right"><b>'.$mod_strings['LBL_DECIMAL_PLACES'].'</b></td>
 212                              <td align="left"><input type="text" name="fldDecimal" value="'.$decimalvalue.'" '.$readonly.' class="txtBox"></td>
 213                          </tr>
 214                          <tr id="picklist" style="visibility:hidden;">
 215                              <td class="dataLabel" nowrap="nowrap" align="right" valign="top"><b>'.$mod_strings['LBL_PICK_LIST_VALUES'].'</b></td>
 216                              <td align="left" valign="top"><textarea name="fldPickList" rows="10" class="txtBox" '.$readonly.'>'.$fldVal.'</textarea></td>
 217                              <!--td style="padding-left:10px"><img src="themes/Aqua/images/picklist_hint.gif"/></td-->
 218                          </tr>';
 219                      }
 220                  $output .= '    
 221                      </table>
 222                  </td>
 223              </tr>
 224              </table>
 225          </td>
 226      </tr>
 227      </table>
 228      <table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
 229              <tr>
 230                  <td align="center">
 231                      <input type="submit" name="save" value=" &nbsp; '.$app_strings['LBL_SAVE_BUTTON_LABEL'].' &nbsp; " class="crmButton small save" />&nbsp;
 232                      <input type="button" name="cancel" value=" '.$app_strings['LBL_CANCEL_BUTTON_LABEL'].' " class="crmButton small cancel" onclick="fninvsh(\'orgLay\');" />
 233                  </td>
 234              </tr>
 235      </table>
 236          <input type="hidden" name="fieldType" id="fieldType" value="'.$selectedvalue.'">
 237      </form></div>';
 238  echo $output;
 239  ?>


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