[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
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: /cvsroot/vtigercrm/vtiger_crm/modules/Products/Save.php,v 1.12 2006/02/07 07:27:23 jerrydgeorge Exp $ 17 * Description: Saves an Account record and then redirects the browser to the 18 * defined return URL. 19 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. 20 * All Rights Reserved. 21 * Contributor(s): ______________________________________.. 22 ********************************************************************************/ 23 24 require_once ('modules/Products/Products.php'); 25 require_once ('include/logging.php'); 26 require_once ('include/database/PearDatabase.php'); 27 global $log,$current_user; 28 $currencyid=fetchCurrency($current_user->id); 29 $rate_symbol = getCurrencySymbolandCRate($currencyid); 30 $rate = $rate_symbol['rate']; 31 $focus = new Products(); 32 if(isset($_REQUEST['record'])) 33 { 34 $focus->id = $_REQUEST['record']; 35 $record_id=$focus->id; 36 $log->info("Record Id is present during Saving the product :->".$record_id); 37 } 38 if(isset($_REQUEST['mode'])) 39 { 40 $focus->mode = $_REQUEST['mode']; 41 $mode=$focus->mode; 42 $log->info("Type of 'mode' during Product Save is ".$mode); 43 } 44 foreach($focus->column_fields as $fieldname => $val) 45 { 46 if(isset($_REQUEST[$fieldname])) 47 { 48 $value = $_REQUEST[$fieldname]; 49 $focus->column_fields[$fieldname] = $value; 50 } 51 if(isset($_REQUEST['unit_price'])) 52 { 53 $value = convertToDollar($_REQUEST['unit_price'],$rate); 54 $focus->column_fields['unit_price'] = $value; 55 } 56 } 57 58 if($_REQUEST['imagelist'] != '') 59 { 60 $del_images = array(); 61 $del_images = explode('###',$_REQUEST['imagelist']); 62 $del_image_array = array_slice($del_images,0,count($del_images)-1); 63 } 64 65 //Checking If image is given or not 66 $image_lists=array(); 67 $count=0; 68 69 $saveimage = "true"; 70 $image_error = "false"; 71 //end of code to retain the pictures from db 72 73 //code added for returning back to the current view after edit from list view 74 if($_REQUEST['return_viewname'] == '') $return_viewname='0'; 75 if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname']; 76 77 if($image_error=="true") //If there is any error in the file upload then moving all the data to EditView. 78 { 79 //re diverting the page and reassigning the same values as image error occurs 80 if($_REQUEST['activity_mode'] != '')$activity_mode=$_REQUEST['activity_mode']; 81 if($_REQUEST['return_module'] != '')$return_module=$_REQUEST['return_module']; 82 if($_REQUEST['return_action'] != '')$return_action=$_REQUEST['return_action']; 83 if($_REQUEST['return_id'] != '')$return_id=$_REQUEST['return_id']; 84 85 $log->debug("There is an error during the upload of product image."); 86 $field_values_passed.=""; 87 foreach($focus->column_fields as $fieldname => $val) 88 { 89 if(isset($_REQUEST[$fieldname])) 90 { 91 $log->debug("Assigning the previous values given for the product to respective vtiger_fields "); 92 $field_values_passed.="&"; 93 $value = $_REQUEST[$fieldname]; 94 $focus->column_fields[$fieldname] = $value; 95 $field_values_passed.=$fieldname."=".$value; 96 97 } 98 } 99 $values_pass=$field_values_passed; 100 $encode_field_values=base64_encode($values_pass); 101 102 $error_module = "Products"; 103 $error_action = "EditView"; 104 105 if(isset($_request['return_id']) && $_request['return_id'] != "") 106 $return_id = $_request['return_id']; 107 if(isset($_request['activity_mode'])) 108 $return_action .= '&activity_mode='.$_request['activity_mode']; 109 110 if($mode=="edit") 111 { 112 $return_id=$_REQUEST['record']; 113 } 114 header("location: index.php?action=$error_action&module=$error_module&record=$return_id&return_id=$return_id&return_action=$return_action&return_module=$return_module&activity_mode=$activity_mode&return_viewname=$return_viewname&saveimage=$saveimage&error_msg=$errormessage&image_error=$image_error&encode_val=$encode_field_values"); 115 116 } 117 if($saveimage=="true") 118 { 119 $image_lists_db=implode("###",$image_lists); 120 $focus->column_fields['imagename']=$image_lists_db; 121 $log->debug("Assign the Image name to the vtiger_field name "); 122 } 123 //Saving the product 124 if($image_error=="false") 125 { 126 $focus->save("Products"); 127 $return_id = $focus->id; 128 129 //Checking and Sending Mail from reorder level 130 global $current_user; 131 $productname = $focus->column_fields['productname']; 132 $qty_stk = $focus->column_fields['qtyinstock']; 133 $reord = $focus->column_fields['reorderlevel']; 134 $handler = $focus->column_fields['assigned_user_id']; 135 if($qty_stk != '' && $reord != '') 136 { 137 if($qty_stk < $reord) 138 { 139 $handler_name = getUserName($handler); 140 $sender_name = getUserName($current_user->id); 141 $to_address= getUserEmail($handler); 142 $subject = $productname.' Stock Level is Low'; 143 $body = 'Dear '.$handler_name.', 144 145 The current stock of '.$productname.' in our warehouse is '.$qty_stk.'. Kindly procure required number of units as the stock level is below reorder level '.$reord.'. 146 147 Severity: Major 148 Thanks, 149 '.$sender_name; 150 151 include ("modules/Emails/mail.php"); 152 $mail_status = send_mail("Products",$to_address,$current_user->user_name,$current_user->email1,$subject,$body); 153 } 154 } 155 156 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module']; 157 else $return_module = "Products"; 158 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action']; 159 else $return_action = "DetailView"; 160 if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id']; 161 if(isset($_REQUEST['activity_mode'])) $return_action .= '&activity_mode='.$_REQUEST['activity_mode']; 162 163 if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab']; 164 header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname"); 165 } 166 167 168 169 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |