[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Import/ -> Forms.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the 
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header$
  17   * Description:  Contains a variety of utility functions used to display UI 
  18   * components such as form vtiger_headers and footers.  Intended to be modified on a per 
  19   * theme basis.
  20   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  21   * All Rights Reserved.
  22   * Contributor(s): ______________________________________..
  23   ********************************************************************************/
  24  
  25  function get_validate_import_fields_js (&$req_fields,&$all_fields)
  26  {
  27      global $mod_strings;
  28  
  29      $err_multiple = $mod_strings['ERR_MULTIPLE'];
  30      $err_required = $mod_strings['ERR_MISSING_REQUIRED_FIELDS']; 
  31      $err_select_full_name = $mod_strings['ERR_SELECT_FULL_NAME']; 
  32      $print_required_array = "";
  33  
  34      foreach ($req_fields as $required=>$unused)
  35      {
  36          $print_required_array .= "required['$required'] = '". $all_fields[$required] . "';\n";
  37          
  38      }
  39  
  40      $the_script  = <<<EOQ
  41  
  42  <script type="text/javascript" language="Javascript">
  43  <!--  to hide script contents from old browsers
  44  
  45  function verify_data(form) 
  46  {
  47      var isError = false;
  48      var errorMessage = "";
  49  
  50          var hash = new Object();
  51  
  52      var required = new Object();
  53  
  54      $print_required_array
  55  
  56      for(i=0;i < form.length;i++)
  57      {
  58          if ( form.elements[i].name.indexOf("colnum",0) == 0)
  59          {
  60          
  61              if ( form.elements[i].value == "-1")
  62              {
  63                  continue;
  64              }
  65              if ( hash[ form.elements[i].value ] == 1)
  66              {
  67                  // got same vtiger_field more than once
  68                  isError = true;
  69              }
  70              hash[form.elements[i].value] = 1;
  71          }
  72          }
  73  
  74      if (isError == true) 
  75      {
  76          alert( "$err_multiple" );
  77          return false;
  78      }
  79  
  80      if (hash['full_name'] == 1 && (hash['last_name'] == 1 || hash['first_name'] == 1) )
  81      {
  82          alert( "$err_select_full_name" );
  83          return false;
  84      }
  85  
  86      for(var vtiger_field_name in required)
  87      {
  88          // contacts hack to bypass errors if full_name is set
  89          if (field_name == 'last_name' && 
  90                  hash['full_name'] == 1)
  91          {
  92              continue;
  93          }
  94          if ( hash[ vtiger_field_name ] != 1 )
  95          {
  96                  isError = true;
  97                  errorMessage += "$err_required " + required[field_name];
  98          }
  99      }
 100  
 101      if (isError == true) 
 102      {
 103          alert( errorMessage);
 104          return false;
 105      }
 106  
 107  
 108      return true;
 109  }
 110  
 111  // end hiding contents from old browsers  -->
 112  </script>
 113  
 114  EOQ;
 115  
 116      return $the_script;
 117  }
 118  
 119  
 120  
 121  
 122  function get_validate_upload_js () 
 123  {
 124      global $mod_strings;
 125  
 126      $err_missing_required_fields = $mod_strings['ERR_MISSING_REQUIRED_FIELDS'];
 127      $lbl_select_file = $mod_strings['ERR_SELECT_FILE'];
 128      $lbl_custom = $mod_strings['LBL_CUSTOM'];
 129  
 130      $the_script  = <<<EOQ
 131  
 132  <script type="text/javascript" language="Javascript">
 133  <!--  to hide script contents from old browsers
 134  
 135  function verify_data(form) 
 136  {
 137      var isError = false;
 138      var errorMessage = "";
 139      if (form.userfile.value == "") 
 140      {
 141          isError = true;
 142          errorMessage += "\\n$lbl_select_file";
 143          } 
 144      else 
 145      {
 146          for(i=0;i < form.delimiter.length;i++)
 147          {
 148              if ( form.delimiter[i].value == "custom"
 149                  && form.delimiter[i].checked == true
 150                  && form.custom_delim.value == "")
 151              {
 152                  isError = true;
 153                  errorMessage += "\\n$lbl_custom";
 154                  break;
 155              }
 156          }
 157          }
 158  
 159      if (isError == true) 
 160      {
 161          alert("$err_missing_required_fields" + errorMessage);
 162          return false;
 163      }
 164  
 165  
 166      return true;
 167  }
 168  
 169  // end hiding contents from old browsers  -->
 170  </script>
 171  
 172  EOQ;
 173  
 174      return $the_script;
 175  }
 176  
 177  /**    function used to form the combo values with the available importable fields
 178   *    @param array reference &$column_fields - reference of the column fields which will be like lastname=>1, etc where as the key is the field name based on the import module and value is 1
 179   *    @param int $colnum - column number
 180   *    @param array reference &$required_fields - required fields of the import module
 181   *    @param string $suggest_field - field to show as selected in the combo box
 182   *    @param array  $translated_fields - list of fields which are available to map
 183   *    @param string $module - tablename for the import module
 184   *    @return picklist $output - return the combo box ie., picklist with the fields which are available to map
 185   */
 186  function getFieldSelect(&$column_fields,$colnum,&$required_fields,$suggest_field,$translated_fields,$module)
 187  {
 188  /*
 189  echo '<br> column vtiger_fields : ';print_r($column_fields);
 190  echo '<br> column  : '.$colnum;
 191  echo '<br> required vtiger_fields : ';print_r($required_fields);
 192  echo '<br> suggest vtiger_fields : '.$suggest_field;
 193  echo '<br> translated vtiger_fields : ';print_r($translated_fields);
 194  */    global $mod_strings;
 195      global $app_strings;
 196      global $outlook_contacts_field_map;
 197      require_once ('include/database/PearDatabase.php');
 198      global $adb;
 199  
 200      $output = "<select id=\"colnum" . $colnum ."\" name=\"colnum" . $colnum ."\">\n";
 201      $output .= "<option value=\"-1\">". $mod_strings['LBL_DONT_MAP'] . "</option>";
 202  
 203      $count = 0;
 204      $req_mark = ""; 
 205  
 206      require_once ("include/database/PearDatabase.php");
 207  
 208      $adb->println("Field select");
 209      $adb->println($translated_fields);
 210  
 211      asort($translated_fields);
 212  
 213  
 214      foreach ($translated_fields as $field=>$name)
 215      {
 216  
 217           if (! isset($column_fields[$field]))
 218          {
 219              continue;
 220          }
 221  //echo '<br> : '.$field;
 222          $output .= "<option value=\"".$field;
 223  
 224          if ( isset( $suggest_field) && 
 225              $field == $suggest_field)
 226          {
 227              $output .= "\" SELECTED>";
 228          }
 229          else 
 230          {
 231              $output .= "\">";
 232          }
 233          if ( isset( $required_fields[$field]))
 234          {
 235              $req_mark = " ". $app_strings['LBL_REQUIRED_SYMBOL'];
 236          } 
 237          else
 238          {
 239              $req_mark = "";
 240          }
 241  
 242          $output .=  $name . $req_mark."</option>\n";
 243  
 244          $count ++;
 245      }
 246      /*if($module == 'Contacts')
 247      {
 248      $module ='contactdetails';
 249      }    
 250      $custquery = "select * from vtiger_field where vtiger_tablename='".$module."'";
 251      $cust_result = $adb->query($custquery);
 252      while($row = $adb->fetch_array($cust_result))
 253      {
 254              $output .= "<option value='".$row['columnname']."'>". $row['fieldlabel'] . "</option>\n";
 255      }*/
 256  
 257      $output .= "</select>\n";
 258  
 259      return $output;
 260  
 261  }
 262  
 263  
 264  function get_readonly_js () 
 265  {
 266  ?>
 267  <script type="text/javascript" language="Javascript">
 268  <!--  to hide script contents from old browsers
 269  
 270  function set_readonly(form) 
 271  {
 272      
 273      if (form.save_map.checked) 
 274      { 
 275          form.save_map.value='on'; 
 276          form.save_map_as.readOnly=false;
 277          form.save_map_as.focus();
 278      }
 279      else 
 280      {
 281          form.save_map.value='off'; 
 282          form.save_map_as.value=""; 
 283          form.save_map_as.readOnly=true; 
 284      }
 285  }
 286  
 287  // end hiding contents from old browsers  -->
 288  </script>
 289  
 290  <?php
 291  }
 292  
 293  
 294  ?>


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