[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Inventory/actions/ -> GetTaxes.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  class Inventory_GetTaxes_Action extends Vtiger_Action_Controller {
  12  
  13  	function process(Vtiger_Request $request) {
  14          $recordId = $request->get('record');
  15          $idList = $request->get('idlist');
  16          $currencyId = $request->get('currency_id');
  17  
  18          $currencies = Inventory_Module_Model::getAllCurrencies();
  19          $conversionRate = 1;
  20  
  21          $response = new Vtiger_Response();
  22  
  23          if(empty($idList)) {
  24              $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
  25              $taxes = $recordModel->getTaxes();
  26              $listPriceValues = $recordModel->getListPriceValues($recordModel->getId());
  27  
  28              $priceDetails = $recordModel->getPriceDetails();
  29              foreach ($priceDetails as $currencyDetails) {
  30                  if ($currencyId == $currencyDetails['curid']) {
  31                      $conversionRate = $currencyDetails['conversionrate'];
  32                  }
  33              }
  34              $listPrice = (float)$recordModel->get('unit_price') * (float)$conversionRate;
  35  
  36              $response->setResult(array(
  37                                      $recordId => array(
  38                                          'id'=>$recordId, 'name'=>decode_html($recordModel->getName()),
  39                                          'taxes'=>$taxes, 'listprice'=>$listPrice, 'listpricevalues'=>$listPriceValues,
  40                                          'description' => decode_html($recordModel->get('description')),
  41                                          'quantityInStock' => $recordModel->get('qtyinstock')
  42                                      )));
  43          } else {
  44              foreach($idList as $id) {
  45                  $recordModel = Vtiger_Record_Model::getInstanceById($id);
  46                  $taxes = $recordModel->getTaxes();
  47                  $listPriceValues = $recordModel->getListPriceValues($recordModel->getId());
  48  
  49                  $priceDetails = $recordModel->getPriceDetails();
  50                  foreach ($priceDetails as $currencyDetails) {
  51                      if ($currencyId == $currencyDetails['curid']) {
  52                          $conversionRate = $currencyDetails['conversionrate'];
  53                      }
  54                  }
  55  
  56                  $listPrice = (float)$recordModel->get('unit_price') * (float)$conversionRate;
  57                  $info[] = array(
  58                              $id => array(
  59                                  'id'=>$id, 'name'=>decode_html($recordModel->getName()),
  60                                  'taxes'=>$taxes, 'listprice'=>$listPrice, 'listpricevalues'=>$listPriceValues,
  61                                  'description' => decode_html($recordModel->get('description')),
  62                                  'quantityInStock' => $recordModel->get('qtyinstock')
  63                              ));
  64              }
  65              $response->setResult($info);
  66          }
  67          $response->emit();
  68      }
  69  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1