[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Settings/ -> 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  /**
  26   * Create javascript to validate the data entered into a record.
  27   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  28   * All Rights Reserved.
  29   * Contributor(s): ______________________________________..
  30   */
  31  
  32   require_once ('include/utils/utils.php'); //new
  33  
  34  function get_validate_record_js () {
  35  global $mod_strings;
  36  global $app_strings;
  37  
  38  $lbl_last_name = $mod_strings['LBL_LIST_LAST_NAME'];
  39  $lbl_email_id = $mod_strings['LBL_EMAIL_ADDRESS'];
  40  $lbl_user_name = $app_strings['LBL_LIST_USER_NAME'];
  41  $lbl_password = $mod_strings['LBL_LIST_PASSWORD'];
  42  $lbl_servername = $mod_strings['LBL_MAIL_SERVER_NAME'];
  43  $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
  44  $err_invalid_email_address = $app_strings['ERR_INVALID_EMAIL_ADDRESS'];
  45  
  46  $the_script  = <<<EOQ
  47  
  48  <script type="text/javascript" language="Javascript">
  49  <!--  to hide script contents from old browsers
  50  
  51  function verify_data(form) {
  52      var isError = false;
  53      var errorMessage = "";
  54      if (trim(form.email.value) == "") {
  55          isError = true;
  56          errorMessage += "\\n$lbl_email_id";
  57      }
  58      if (trim(form.server_username.value) == "") {
  59          isError = true;
  60          errorMessage += "\\n$lbl_user_name";
  61      }
  62      if (trim(form.server_password.value) == "") {
  63          isError = true;
  64          errorMessage += "\\n$lbl_password";
  65      }
  66      if (trim(form.mail_servername.value) == "") {
  67          isError = true;
  68          errorMessage += "\\n$lbl_servername";
  69      }
  70  
  71      if (isError == true) {
  72          alert("$err_missing_required_fields" + errorMessage);
  73          return false;
  74      }
  75      if (trim(form.email.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value)) {
  76          alert('"' + form.email.value + '" $err_invalid_email_address');
  77          return false;
  78      }
  79      return true;
  80  }
  81  
  82  // end hiding contents from old browsers  -->
  83  </script>
  84  
  85  EOQ;
  86  
  87  return $the_script;
  88  }
  89  
  90  /**
  91   * Create HTML form to enter a new record with the minimum necessary vtiger_fields.
  92   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  93   * All Rights Reserved.
  94   * Contributor(s): ______________________________________..
  95   */
  96  
  97  function get_new_record_form () {
  98  global $mod_strings;
  99  global $app_strings;
 100  global $current_user;
 101  global $adb;//for dynamic quickcreateform construction
 102  
 103  
 104  $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
 105  $lbl_first_name = $mod_strings['LBL_FIRST_NAME'];
 106  $lbl_last_name = $mod_strings['LBL_LAST_NAME'];
 107  $lbl_account_name = $mod_strings['LBL_ACCOUNT_NAME'];
 108  $lbl_phone = $mod_strings['LBL_PHONE'];
 109  $lbl_email_address = $mod_strings['LBL_EMAIL_ADDRESS'];
 110  $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
 111  $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
 112  $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
 113  $user_id = $current_user->id;
 114  
 115  $qcreate_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 116  
 117  
 118  $qcreate_get_field="select * from vtiger_field where tabid=4 and quickcreate=0 order by quickcreatesequence";
 119  $qcreate_get_result=$adb->query($qcreate_get_field);
 120  $qcreate_get_noofrows=$adb->num_rows($qcreate_get_result);
 121  
 122  $fieldName_array = Array();//for validation
 123  
 124  $qcreate_form.='<form name="EditView" onSubmit="return formValidate()" method="POST" action="index.php">';
 125  $qcreate_form.='<input type="hidden" name="module" value="Contacts">';
 126  $qcreate_form.='<input type="hidden" name="record" value="">';
 127  $qcreate_form.='<input type="hidden" name="assigned_user_id" value="'.$user_id.'">';
 128  $qcreate_form.='<input type="hidden" name="email2" value="">';
 129  $qcreate_form.='<input type="hidden" name="action" value="Save">';
 130  //$qcreate_form.='<input type="hidden" name="return_action" value="index">';
 131  //$qcreate_form.='<input type="hidden" name="return_module" value="Contacts">';
 132  
 133  $qcreate_form.='<table>';
 134  
 135  for($j=0;$j<$qcreate_get_noofrows;$j++)
 136  {
 137          $qcreate_form.='<tr>';
 138          $fieldlabel=$adb->query_result($qcreate_get_result,$j,'fieldlabel');
 139          $uitype=$adb->query_result($qcreate_get_result,$j,'uitype');
 140          $tabid=$adb->query_result($qcreate_get_result,$j,'tabid');
 141  
 142          $fieldname=$adb->query_result($qcreate_get_result,$j,'fieldname');//for validation
 143          $typeofdata=$adb->query_result($qcreate_get_result,$j,'typeofdata');//for validation
 144          $qcreate_form .= get_quickcreate_form($fieldlabel,$uitype,$fieldname,$tabid);
 145  
 146  
 147          //to get validationdata
 148          //start
 149          $fldLabel_array = Array();
 150          $fldLabel_array[$fieldlabel] = $typeofdata;
 151          $fieldName_array['QCK_'.$fieldname] = $fldLabel_array;
 152  
 153          //end
 154  
 155          $qcreate_form.='</tr>';
 156  
 157  }
 158  
 159  
 160  //for validation
 161  $validationData = $fieldName_array;
 162  $fieldName = '';
 163  $fieldLabel = '';
 164  $fldDataType = '';
 165  
 166  $rows = count($validationData);
 167  foreach($validationData as $fldName => $fldLabel_array)
 168  {
 169     if($fieldName == '')
 170     {
 171       $fieldName="'".$fldName."'";
 172     }
 173     else
 174     {
 175       $fieldName .= ",'".$fldName ."'";
 176     }
 177     foreach($fldLabel_array as $fldLabel => $datatype)
 178     {
 179          if($fieldLabel == '')
 180          {
 181  
 182                  $fieldLabel = "'".$fldLabel ."'";
 183          }
 184          else
 185          {
 186                  $fieldLabel .= ",'".$fldLabel ."'";
 187          }
 188          if($fldDataType == '')
 189          {
 190                  $fldDataType = "'".$datatype ."'";
 191          }
 192          else
 193          {
 194                  $fldDataType .= ",'".$datatype ."'";
 195          }
 196     }
 197  }
 198  
 199  $qcreate_form.='</table>';
 200  
 201  
 202  $qcreate_form.='<input title="'.$lbl_save_button_title.'" accessKey="'.$lbl_save_button_key.'" class="button" type="submit" name="button" value="'.$lbl_save_button_label.'" >';
 203  $qcreate_form.='</form>';
 204  $qcreate_form.='<script type="text/javascript">
 205  
 206          var fieldname = new Array('.$fieldName.')
 207          var fieldlabel = new Array('.$fieldLabel.')
 208          var fielddatatype = new Array('.$fldDataType.')
 209  
 210                  </script>';
 211  
 212  $qcreate_form .= get_left_form_footer();
 213  return $qcreate_form;
 214  
 215  
 216  
 217  
 218  }
 219  
 220  /*function get_new_record_form () {
 221  global $mod_strings;
 222  global $app_strings;
 223  global $current_user;
 224  
 225  $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
 226  $lbl_first_name = $mod_strings['LBL_FIRST_NAME'];
 227  $lbl_last_name = $mod_strings['LBL_LAST_NAME'];
 228  $lbl_phone = $mod_strings['LBL_PHONE'];
 229  $lbl_email_address = $mod_strings['LBL_EMAIL_ADDRESS'];
 230  $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
 231  $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
 232  $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
 233  $user_id = $current_user->id;
 234  
 235  $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
 236  $the_form .= <<<EOQ
 237  
 238          <form name="ContactSave" onSubmit="return verify_data(ContactSave)" method="POST" action="index.php">
 239              <input type="hidden" name="module" value="Contacts">
 240              <input type="hidden" name="record" value="">
 241              <input type="hidden" name="assigned_user_id" value='${user_id}'>
 242              <input type="hidden" name="email2" value="">
 243              <input type="hidden" name="action" value="Save">
 244          $lbl_first_name<br>
 245          <input name='first_name' type="text" value=""><br>
 246          <FONT class="required">$lbl_required_symbol</FONT>$lbl_last_name<br>
 247          <input name='last_name' type="text" value=""><br>
 248          $lbl_phone<br>
 249          <input name='phone_work' type="text" value=""><br>
 250          $lbl_email_address<br>
 251          <input name='email1' type="text" value=""><br><br>
 252          <input title="$lbl_save_button_title" accessKey="$lbl_save_button_key" class="button" type="submit" name="button" value="  $lbl_save_button_label  " >
 253          </form>
 254  
 255  EOQ;
 256  $the_form .= get_left_form_footer();
 257  $the_form .= get_validate_record_js();
 258  
 259  return $the_form;
 260  }*/
 261  
 262  ?>


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