[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/SalesOrder/ -> EditView.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: /cvsroot/vtigercrm/vtiger_crm/modules/SalesOrder/EditView.php,v 1.5 2006/01/27 18:18:09 jerrydgeorge Exp $
  17   * Description:  TODO To be written.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   ********************************************************************************/
  22  
  23  require_once ('Smarty_setup.php');
  24  require_once ('data/Tracker.php');
  25  require_once ('modules/SalesOrder/SalesOrder.php');
  26  require_once ('modules/Quotes/Quotes.php');
  27  require_once ('include/CustomFieldUtil.php');
  28  require_once ('include/ComboUtil.php');
  29  require_once ('include/utils/utils.php');
  30  require_once ('include/FormValidationUtil.php');
  31  
  32  global $app_strings,$mod_strings,$log,$theme,$currentModule,$current_user;
  33  
  34  $log->debug("Inside Sales Order EditView");
  35  
  36  
  37  $focus = new SalesOrder();
  38  $smarty = new vtigerCRM_Smarty();
  39  $currencyid=fetchCurrency($current_user->id);
  40  $rate_symbol = getCurrencySymbolandCRate($currencyid);
  41  $rate = $rate_symbol['rate'];
  42  if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') 
  43  {
  44      if(isset($_REQUEST['convertmode']) &&  $_REQUEST['convertmode'] == 'quotetoso')
  45      {
  46      $quoteid = $_REQUEST['record'];
  47      $quote_focus = new Quotes();
  48      $quote_focus->id = $quoteid;
  49      $quote_focus->retrieve_entity_info($quoteid,"Quotes");
  50      $focus = getConvertQuoteToSoObject($focus,$quote_focus,$quoteid);
  51      $focus->id = $quoteid;
  52  
  53      //Added to display the Quotes's associated vtiger_products -- when we create SO from Quotes DetailView 
  54      $associated_prod = getAssociatedProducts("Quotes",$quote_focus);
  55      $smarty->assign("QUOTE_ID", $quoteid);
  56      $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
  57      $smarty->assign("MODE", $quote_focus->mode);
  58      $smarty->assign("AVAILABLE_PRODUCTS", 'true');
  59  
  60      }
  61      elseif(isset($_REQUEST['convertmode']) &&  $_REQUEST['convertmode'] == 'update_quote_val')
  62      {
  63      //Updating the Selected Quote Value in Edit Mode
  64      foreach($focus->column_fields as $fieldname => $val)
  65      {
  66              if(isset($_REQUEST[$fieldname]))
  67              {
  68                      $value = $_REQUEST[$fieldname];
  69                      $focus->column_fields[$fieldname] = $value;
  70              
  71              }
  72  
  73      }
  74      //Handling for dateformat in due_date vtiger_field
  75      if($focus->column_fields['duedate'] != '')
  76      {
  77          $curr_due_date = $focus->column_fields['duedate'];
  78          $focus->column_fields['duedate'] = getDBInsertDateValue($curr_due_date);
  79      }
  80          
  81      $quoteid = $focus->column_fields['quote_id'];
  82      $smarty->assign("QUOTE_ID", $focus->column_fields['quote_id']);
  83      $quote_focus = new Quotes();
  84      $quote_focus->id = $quoteid;
  85      $quote_focus->retrieve_entity_info($quoteid,"Quotes");
  86      $focus = getConvertQuoteToSoObject($focus,$quote_focus,$quoteid);
  87      $focus->id = $_REQUEST['record'];
  88      $focus->mode = 'edit';     
  89          $focus->name=$focus->column_fields['subject'];
  90              
  91      }    
  92      else
  93      {                
  94          $focus->id = $_REQUEST['record'];
  95      $focus->mode = 'edit';     
  96          $focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");        
  97          $focus->name=$focus->column_fields['subject'];
  98      }     
  99  }
 100  else
 101  {
 102      if(isset($_REQUEST['convertmode']) &&  $_REQUEST['convertmode'] == 'update_quote_val')
 103      {
 104          //Updating the Select Quote Value in Create Mode
 105          foreach($focus->column_fields as $fieldname => $val)
 106          {
 107                  if(isset($_REQUEST[$fieldname]))
 108                  {
 109                          $value = $_REQUEST[$fieldname];
 110                          $focus->column_fields[$fieldname] = $value;
 111                  }
 112  
 113          }
 114          //Handling for dateformat in due_date vtiger_field
 115          if($focus->column_fields['duedate'] != '')
 116          {
 117              $curr_due_date = $focus->column_fields['duedate'];
 118              $focus->column_fields['duedate'] = getDBInsertDateValue($curr_due_date);
 119          }        
 120          $quoteid = $focus->column_fields['quote_id'];
 121          $quote_focus = new Quotes();
 122          $quote_focus->id = $quoteid;
 123          $quote_focus->retrieve_entity_info($quoteid,"Quotes");
 124          $focus = getConvertQuoteToSoObject($focus,$quote_focus,$quoteid);
 125  
 126          //Added to display the Quotes's associated vtiger_products -- when we select Quote in New SO page
 127          if(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] !='')
 128          {
 129              $associated_prod = getAssociatedProducts("Quotes",$quote_focus,$focus->column_fields['quote_id']);
 130          }
 131  
 132          $smarty->assign("QUOTE_ID", $focus->column_fields['quote_id']);
 133          $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 134          $smarty->assign("MODE", $quote_focus->mode);
 135          $smarty->assign("AVAILABLE_PRODUCTS", 'true');
 136      }
 137  }
 138  
 139  if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
 140      $SO_associated_prod = getAssociatedProducts("SalesOrder",$focus);
 141      $focus->id = "";
 142          $focus->mode = '';     
 143  } 
 144  
 145  if(isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] !='')
 146  {
 147          $focus->column_fields['potential_id'] = $_REQUEST['potential_id'];
 148      $_REQUEST['account_id'] = get_account_info($_REQUEST['potential_id']);
 149      $log->debug("Sales Order EditView: Potential Id from the request is ".$_REQUEST['potential_id']);
 150          $associated_prod = getAssociatedProducts("Potentials",$focus,$focus->column_fields['potential_id']);
 151  
 152  }
 153  
 154  if(isset($_REQUEST['product_id']) && $_REQUEST['product_id'] !='')
 155  {
 156          $focus->column_fields['product_id'] = $_REQUEST['product_id'];
 157          $associated_prod = getAssociatedProducts("Products",$focus,$focus->column_fields['product_id']);
 158      $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 159      $smarty->assign("AVAILABLE_PRODUCTS", 'true');
 160  }
 161  
 162  // Get Account address if vtiger_account is given
 163  if(isset($_REQUEST['account_id']) && $_REQUEST['record']=='' && $_REQUEST['account_id'] != ''){
 164      require_once ('modules/Accounts/Accounts.php');
 165      $acct_focus = new Accounts();
 166      $acct_focus->retrieve_entity_info($_REQUEST['account_id'],"Accounts");
 167      $focus->column_fields['bill_city']=$acct_focus->column_fields['bill_city'];
 168      $focus->column_fields['ship_city']=$acct_focus->column_fields['ship_city'];
 169      $focus->column_fields['bill_street']=$acct_focus->column_fields['bill_street'];
 170      $focus->column_fields['ship_street']=$acct_focus->column_fields['ship_street'];
 171      $focus->column_fields['bill_state']=$acct_focus->column_fields['bill_state'];
 172      $focus->column_fields['ship_state']=$acct_focus->column_fields['ship_state'];
 173      $focus->column_fields['bill_code']=$acct_focus->column_fields['bill_code'];
 174      $focus->column_fields['ship_code']=$acct_focus->column_fields['ship_code'];
 175      $focus->column_fields['bill_country']=$acct_focus->column_fields['bill_country'];
 176      $focus->column_fields['ship_country']=$acct_focus->column_fields['ship_country'];
 177  
 178  }
 179  
 180  $theme_path="themes/".$theme."/";
 181  $image_path=$theme_path."images/";
 182  //retreiving the combo values array
 183  $comboFieldNames = Array('accounttype'=>'account_type_dom'
 184                        ,'industry'=>'industry_dom');
 185  $comboFieldArray = getComboArray($comboFieldNames);
 186  
 187  $disp_view = getView($focus->mode);
 188  $mode = $focus->mode;
 189  if($disp_view == 'edit_view')
 190      $smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
 191  else    
 192  {
 193      $bas_block = getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS');
 194      $adv_block = getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'ADV');
 195      
 196      $blocks['basicTab'] = $bas_block;
 197      if(is_array($adv_block ))
 198          $blocks['moreTab'] = $adv_block;
 199  
 200      $smarty->assign("BLOCKS",$blocks);
 201      $smarty->assign("BLOCKS_COUNT",count($blocks));
 202  }
 203  $smarty->assign("OP_MODE",$disp_view);
 204  
 205  $smarty->assign("MODULE",$currentModule);
 206  $smarty->assign("SINGLE_MOD",'SalesOrder');
 207  
 208  
 209  $smarty->assign("MOD", $mod_strings);
 210  $smarty->assign("APP", $app_strings);
 211  $category = getParentTab();
 212  $smarty->assign("CATEGORY",$category);
 213  
 214  
 215  require_once ($theme_path.'layout_utils.php');
 216  
 217  $log->info("Order view");
 218  
 219  if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
 220  else $smarty->assign("NAME", "");
 221  
 222  
 223  if(isset($_REQUEST['convertmode']) &&  ($_REQUEST['convertmode'] == 'quotetoso' || $_REQUEST['convertmode'] == 'update_quote_val'))
 224  {
 225      $txtTax = (($quote_focus->column_fields['txtTax'] != '')?$quote_focus->column_fields['txtTax']:'0.000');
 226      $txtAdj = (($quote_focus->column_fields['txtAdjustment'] != '')?$quote_focus->column_fields['txtAdjustment']:'0.000');
 227          
 228      $associated_prod = getAssociatedProducts("Quotes",$quote_focus);
 229      $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 230      $smarty->assign("MODE", $focus->mode);
 231  }
 232  elseif($focus->mode == 'edit')
 233  {
 234      $smarty->assign("UPDATEINFO",updateInfo($focus->id));
 235      $associated_prod = getAssociatedProducts("SalesOrder",$focus);
 236      $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 237      $smarty->assign("MODE", $focus->mode);
 238  }
 239  elseif(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true')
 240  {
 241      $smarty->assign("ASSOCIATEDPRODUCTS", $SO_associated_prod);
 242      $smarty->assign("AVAILABLE_PRODUCTS", 'true');
 243      $smarty->assign("MODE", $focus->mode);
 244  }
 245  elseif((isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') || (isset($_REQUEST['product_id']) && $_REQUEST['product_id'] != '')) {
 246          $smarty->assign("ASSOCIATEDPRODUCTS", $associated_prod);
 247      $InvTotal = getInventoryTotal($_REQUEST['return_module'],$_REQUEST['return_id']);
 248      $InvTotal = convertFromDollar($InvTotal,$rate);
 249          $smarty->assign("MODE", $focus->mode);
 250  
 251      //this is to display the Product Details in first row when we create new PO from Product relatedlist
 252      if($_REQUEST['return_module'] == 'Products')
 253      {
 254          $smarty->assign("PRODUCT_ID",$_REQUEST['product_id']);
 255          $smarty->assign("PRODUCT_NAME",getProductName($_REQUEST['product_id']));
 256          $smarty->assign("UNIT_PRICE",getUnitPrice($_REQUEST['product_id']));
 257          $smarty->assign("QTY_IN_STOCK",getPrdQtyInStck($_REQUEST['product_id']));
 258          $smarty->assign("VAT_TAX",getProductTaxPercentage("VAT",$_REQUEST['product_id']));
 259          $smarty->assign("SALES_TAX",getProductTaxPercentage("Sales",$_REQUEST['product_id']));
 260          $smarty->assign("SERVICE_TAX",getProductTaxPercentage("Service",$_REQUEST['product_id']));
 261      }
 262  }
 263  
 264  
 265  if(isset($cust_fld))
 266  {
 267          $smarty->assign("CUSTOMFIELD", $cust_fld);
 268  }
 269  
 270          
 271  
 272  if(isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
 273  else $smarty->assign("RETURN_MODULE","SalesOrder");
 274  if(isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
 275  else $smarty->assign("RETURN_ACTION","index");
 276  if(isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", $_REQUEST['return_id']);
 277  if (isset($_REQUEST['return_viewname'])) $smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
 278  $smarty->assign("THEME", $theme);
 279  $smarty->assign("IMAGE_PATH", $image_path);
 280  $smarty->assign("MODULE","SalesOrder");
 281  $smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
 282  $smarty->assign("ID", $focus->id);
 283  
 284  
 285  $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
 286  $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 287  
 288  //if create SO, get all available product taxes and shipping & Handling taxes
 289  if($focus->mode != 'edit')
 290  {
 291      $tax_details = getAllTaxes('available');
 292      $sh_tax_details = getAllTaxes('available','sh');
 293  
 294      $smarty->assign("GROUP_TAXES",$tax_details);
 295      $smarty->assign("SH_TAXES",$sh_tax_details);
 296  }
 297  
 298  
 299  
 300   $tabid = getTabid("SalesOrder");
 301   $validationData = getDBValidationData($focus->tab_name,$tabid);
 302   $data = split_validationdataArray($validationData);
 303  
 304   $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
 305   $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
 306   $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
 307  
 308  $check_button = Button_Check($module);
 309  $smarty->assign("CHECK", $check_button);
 310  if($focus->mode == 'edit')
 311      $smarty->display("Inventory/InventoryEditView.tpl");
 312  else
 313      $smarty->display('Inventory/InventoryCreateView.tpl');
 314  
 315  ?>


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