コード例 #1
0
ファイル: ClientController.php プロジェクト: tudorfis/urfx
 public function obMultipleAction()
 {
     $identity = (array) Zend_Auth::getInstance()->getIdentity();
     $params = $this->getRequest()->getParams();
     $this->view->assign('type', $params['type']);
     $center = $this->getCenters()->getById($identity['center_id']);
     $center = !is_null($center) ? $center->toArray() : array();
     $company = $this->getCompanies()->getById($identity['company_id']);
     $company = !is_null($company) ? $company->toArray() : array();
     $toEmailCenter = $center['email'];
     $toEmailCompany = $company['email'];
     // Submited request
     if (isset($params['process_ob'])) {
         $uid = mt_rand(100000, 999999);
         $date_created = date('Y-m-d H:i:s');
         $date_delivery = isset($params['date_delivery']) ? $params['date_delivery'] : date('d/m/Y');
         $date_delivery = convertUKtoUSdate($date_delivery);
         $company_id = $identity['company_id'];
         $center_id = $identity['center_id'];
         $customer_id = $identity['customer_id'];
         $amount = null;
         $uk_amount = $params['total'];
         $created_user_id = $identity['id'];
         $payment_type = $params['payment_type'];
         $traveller_name = $params['traveller_name'];
         $comment = $params['comment'];
         $type = $params['type'];
         $is_multiple = 1;
         $status = $company['with_check'] ? Table_Abstract::STATUS_PENDING : Table_Abstract::STATUS_UNPROCESSED;
         $ob = $this->getOrders()->createRow();
         $ob_id = $ob->setUid($uid)->setDateCreated($date_created)->setDateDelivery($date_delivery)->setCompanyId($company_id)->setCenterId($center_id)->setCustomerId($customer_id)->setAmount($amount)->setUkAmount($uk_amount)->setCreatedUserId($created_user_id)->setPaymentType($payment_type)->setTravellerName($traveller_name)->setComment($comment)->setType($type)->setIsMultiple($is_multiple)->setStatus($status)->save();
         // add to ob multiple
         foreach ($params['rate_id'] as $k => $rate_id) {
             $rate = $params['rate'][$k];
             $amount = $params['amount'][$k];
             $uk_amount = $params['uk_amount'][$k];
             $ob_multiple = $this->getObMultiple()->createRow();
             $ob_multiple->setObId($ob_id)->setRateId($rate_id)->setRate($rate)->setPaymentType($payment_type)->setAmount($amount)->setUkAmount($uk_amount)->save();
         }
         /**
          * Get order by uid
          * @var mixed
          */
         $ob = $this->getOrders()->getByUid($uid);
         $join_in = array(array('customers', 'customer_id'), array('companies', 'company_id'), array('centers', 'center_id'), array('rates', 'rate_id'), array('users', 'created_user_id'), array('users', 'response_user_id'));
         $ob = $this->_buildJoinTbl(array($ob), $join_in);
         $ob = $ob[0];
         $ob['company'] = $company;
         // Ob multiple
         $ob_multiple = array();
         $_ob_multiple = $this->getObMultiple()->geByOrderId($ob['id'])->toArray();
         foreach ($_ob_multiple as $obm) {
             $ob_multiple[$obm['id']] = $obm;
             $ob_multiple[$obm['id']]['rate_detail'] = $this->getRates()->getById($obm['rate_id'])->toArray();
         }
         $ob['multiple'] = $ob_multiple;
         /**
          * Send mail to processing center with order
          * @var NL_HtmlMailer
          */
         $is_error = false;
         $email = new NL_HtmlMailer();
         $email->sendOb($ob, $toEmailCenter);
         /** @var Send mail to approvers $approversTable */
         $approversTable = new Table_Approvers();
         $approvers = $approversTable->getByCompanyId($company['id']);
         foreach ($approvers->toArray() as $approver) {
             if (!is_null($approver['email']) && !empty($approver['email'])) {
                 $email->sendOb($ob, $approver['email']);
             }
         }
         /** send to company if with approve */
         if ($company['with_check']) {
             $email->sendOb($ob, $toEmailCompany);
         }
         // MESSAGE
         if (!$is_error) {
             // Success promotional message
             include APPLICATION_PATH . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'AjaxObController.php';
             $out = AjaxObController::renderSuccessMessage($type, $uid, $payment_type, $is_multiple = true);
         } else {
             // error message
             $out = NL_Render::renderErrorMessage();
         }
         echo $out;
         $this->view->assign('show_view', false);
     } else {
         $this->view->assign('show_view', true);
     }
 }
コード例 #2
0
ファイル: AjaxObController.php プロジェクト: tudorfis/urfx
 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));
 }