Beispiel #1
0
 public function latestRatesAction()
 {
     // AjaxOb calculate
     include APPLICATION_PATH . '/controllers/AjaxObController.php';
     // Company
     $user = (array) Zend_Auth::getInstance()->getIdentity();
     $company = $this->getCompanies()->getById($user['company_id']);
     $company = !is_null($company) ? $company->toArray() : array();
     // Rates
     $filter = array('status' => Table_Abstract::STATUS_ACTIVE, 'order' => 'country asc');
     $array = array();
     $_array = $this->getRates()->getAll($filter)->toArray();
     foreach ($_array as $rate) {
         // Margins
         $array[$rate['id']] = $rate;
         $margins = $this->getMargins()->getFeeByRateCode($rate['c_code']);
         $margins = $margins != false ? $margins : array();
         // Cash / Buying total
         $array[$rate['id']]['cash_s_total'] = AjaxObController::calculateRate('order', $rate, $margins, $company, 'cash', false, true);
         $array[$rate['id']]['tc_s_total'] = AjaxObController::calculateRate('order', $rate, $margins, $company, 'tc', false, true);
         $array[$rate['id']]['cash_b_total'] = AjaxObController::calculateRate('buyback', $rate, $margins, $company, 'cash', false, true);
         $array[$rate['id']]['tc_b_total'] = AjaxObController::calculateRate('buyback', $rate, $margins, $company, 'tc', false, true);
     }
     $this->view->assign('array', $array);
 }
Beispiel #2
0
 public function calculateRateAjaxAction()
 {
     $params = $this->getRequest()->getParams();
     $type = $params['type'];
     $payment_type = $params['payment_type'];
     $rate_id = $params['rate_id'];
     $rate = $this->getRates()->getById($rate_id)->toArray();
     $margins = $this->getMargins()->getFeeByRateCode($rate['c_code']);
     $company = array();
     echo round2Nr(AjaxObController::calculateRate($type, $rate, $margins, $company, $payment_type, false, true));
 }