Ejemplo n.º 1
0
 function completeorderAction()
 {
     $modelPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $rowTaxRate = $modelPaymentSetting->fetchRow("settingKey='taxRate'");
     $cart =& $_SESSION['jCart'];
     if (!is_object($cart)) {
         $cart = new jCart();
     }
     if (empty($cart) || count($cart->items) == 0) {
         $this->_redirect(ROOT_URL . '/checkout/cartempty');
     }
     $bpm = new Pandamp_Core_Hol_Catalog();
     $result = array('subTotal' => 0, 'disc' => 0, 'taxAmount' => 0, 'grandTotal' => 0, 'items' => array());
     for ($iCart = 0; $iCart < count($cart->items); $iCart++) {
         $itemId = $cart->items[$iCart];
         $qty = $cart->itemqtys[$itemId];
         $coupon = isset($cart->coupon) ? $cart->coupon : '';
         $itemPrice = $bpm->getPrice($itemId);
         $disc = $bpm->getDiscount($coupon);
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($itemId, 'fixedTitle');
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['itemTotal'] = $qty * $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['coupon'] = $coupon;
         $result['disc'] = $disc;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $grandTotal = $result['subTotal'] - $result['disc'] / 100 * $result['subTotal'];
     $result['grandTotal'] = $grandTotal + $result['taxAmount'];
     $payment = $this->_request->getParam('payment');
     $orderId = $this->saveOrder($result, $payment);
     //        $cart = null;
     $data = $this->_request->getParams();
     $this->view->cart = $result;
     $this->view->data = $data;
     $this->view->orderId = $orderId;
     $modDir = $this->getFrontController()->getModuleDirectory();
     require_once $modDir . '/models/Store/Mailer.php';
     $mod = new HolSite_Model_Store_Mailer();
     switch (strtolower($payment['method'])) {
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'nsiapay':
             //                $mod->sendInvoiceToUser($orderId);
             break;
         case 'postpaid':
             $tblUserFinance = new App_Model_Db_Table_UserFinance();
             $userFinanceInfo = $tblUserFinance->find($this->_user->kopel)->current();
             if (!$userFinanceInfo->isPostPaid) {
                 return $this->_helper->redirector('notpostpaid', 'store_payment', 'hol-site');
             }
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }
Ejemplo n.º 2
0
 function completeorderAction()
 {
     $tblPaymentSetting = new Pandamp_Modules_Payment_Setting_Model_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $cart =& $_SESSION['jCart'];
     if (!is_object($cart)) {
         $cart = new jCart();
     }
     //		echo "<pre>";
     //		print_r($cart);
     //		echo "</pre><br>";
     if (empty($cart) || count($cart->items) == 0) {
         $this->_redirect(ROOT_URL . '/store/cartempty');
     }
     $bpm = new Pandamp_Core_Hol_Catalog();
     $result = array('subTotal' => 0, 'taxAmount' => 0, 'grandTotal' => 0, 'items' => array());
     for ($iCart = 0; $iCart < count($cart->items); $iCart++) {
         $modelCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
         $itemId = $cart->items[$iCart];
         $qty = $cart->itemqtys[$itemId];
         $itemPrice = $bpm->getPrice($itemId);
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = $modelCatalogAttribute->getCatalogAttributeValue($itemId, 'fixedTitle');
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['itemTotal'] = $qty * $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     //		echo "Result : <br><br><pre>";
     //		print_r($result);
     //		echo "</pre><br>";
     //		die;
     $method = $this->_request->getParam('paymentMethod');
     $orderId = $this->saveOrder($result, $method);
     //		$cart = null;
     $data = $this->_request->getParams();
     $this->view->cart = $result;
     $this->view->data = $data;
     $this->view->orderId = $orderId;
     $modDir = $this->getFrontController()->getModuleDirectory();
     require_once $modDir . '/models/Store/Mailer.php';
     $mod = new Holsite_Model_Store_Mailer();
     switch (strtolower($method)) {
         case 'manual':
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'paypal':
             $mod->sendInvoiceToUser($orderId);
             break;
         case 'postpaid':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }