Пример #1
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;
     }
 }
Пример #2
0
 function completeAction()
 {
     $formater = new Pandamp_Core_Hol_User();
     $defaultCurrency = 'Rp';
     $guid = $this->_request->getParam('guid');
     $method = $this->_request->getParam('method');
     $tblPaymentSetting = new Pandamp_Modules_Payment_Setting_Model_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $tblUser = new Pandamp_Modules_Identity_User_Model_User();
     $rowUser = $tblUser->find($guid)->current();
     $this->view->rowUser = $rowUser;
     // discount
     $disc = $formater->checkPromoValidation('Disc', $rowUser->packageId, $rowUser->promotionId, $rowUser->paymentId);
     $total = $formater->checkPromoValidation('Total', $rowUser->packageId, $rowUser->promotionId, $rowUser->paymentId);
     $tblPackage = new Pandamp_Modules_Identity_Package_Model_Package();
     $rowPackage = $tblPackage->find($rowUser->packageId)->current();
     $this->view->rowPackage = $rowPackage;
     $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $guid;
     if ($this->getRequest()->getPost()) {
         $value = $this->getRequest()->getPost();
         $row->taxNumber = $value['taxNumber'];
         $row->taxCompany = $value['taxCompany'];
         $row->taxAddress = $value['taxAddress'];
         $row->taxCity = $value['taxCity'];
         $row->taxZip = $value['taxZip'];
         $row->taxProvince = $value['taxProvince'];
         $row->taxCountryId = $value['taxCountry'];
         $row->paymentMethod = $method;
     }
     $row->datePurchased = date('YmdHis');
     $row->paymentMethodNote = "membership";
     if ($method == "nsiapay") {
         $row->orderStatus = 8;
     } else {
         $row->orderStatus = 1;
         //pending
     }
     $row->currency = $defaultCurrency;
     $row->currencyValue = $currencyValue;
     $row->orderTotal = $total;
     $row->ipAddress = Pandamp_Lib_Formater::getRealIpAddr();
     $orderId = $row->save();
     $rowJustInserted = $tblOrder->find($orderId)->current();
     $rowJustInserted->invoiceNumber = date('Ymd') . '.' . $orderId;
     $temptime = time();
     $temptime = Pandamp_Lib_Formater::DateAdd('d', 5, $temptime);
     $rowJustInserted->discount = $disc;
     $rowJustInserted->invoiceExpirationDate = strftime('%Y-%m-%d', $temptime);
     $rowJustInserted->save();
     $this->view->invoiceNumber = $rowJustInserted->invoiceNumber;
     $this->view->datePurchased = $rowJustInserted->datePurchased;
     $tblOrderDetail = new Pandamp_Modules_Payment_OrderDetail_Model_OrderDetail();
     $rowDetail = $tblOrderDetail->fetchNew();
     $rowDetail->orderId = $orderId;
     $rowDetail->itemId = $rowPackage->packageId;
     if ($rowUser->packageId == 26) {
         $group = "Subsciption for Member Individual " . $rowUser->paymentId . " Months";
     } else {
         if ($rowUser->packageId == 27) {
             $group = "Subsciption for Member Corporate" . $rowUser->paymentId . " Months";
         }
     }
     $this->view->itemName = $group;
     $rowDetail->documentName = $group;
     $rowDetail->price = $total;
     $numOfUsers = $tblUser->getUserCount($rowUser->guid);
     $this->view->numOfUsers = $numOfUsers;
     $this->view->grandtotal = $grandTotal;
     $this->view->method = $method;
     $this->view->orderId = $orderId;
     $this->view->total = $total;
     $rowDetail->qty = $numOfUsers;
     $rowDetail->finalPrice = $total;
     $rowDetail->save();
     $data = $this->_request->getParams();
     $this->view->data = $data;
     $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 'nsiapay':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }