Exemplo n.º 1
0
 private function saveOrder($cart, $payment)
 {
     $defaultCurrency = 'Rp';
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $tblOrder = new App_Model_Db_Table_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $this->_user->kopel;
     //get value from post var (store/checkout.phtml)
     if ($this->getRequest()->getPost()) {
         $value = $this->getRequest()->getPost();
         $row->taxNumber = '';
         $row->taxCompany = $value['taxCompany'];
         $row->taxAddress = $value['taxAddress'];
         $row->taxCity = $value['taxCity'];
         $row->taxZip = $value['taxZip'];
         $row->taxProvince = $value['taxProvince'];
         $row->taxCountryId = '';
         $row->paymentMethod = $payment['method'];
         $row->bankName = $payment['bank_options'];
     }
     $row->datePurchased = date('YmdHis');
     $row->orderStatus = 1;
     //pending
     $row->currency = $defaultCurrency;
     $row->currencyValue = $currencyValue;
     $row->discount = $cart['disc'];
     $row->orderTotal = $cart['grandTotal'];
     $row->orderTax = $cart['taxAmount'];
     $row->ipAddress = Pandamp_Lib_Formater::getRealIpAddr();
     $orderId = $row->save();
     $rowJustInserted = $tblOrder->find($orderId)->current();
     //      $rowJustInserted->invoiceNumber = date('Ymd') . '.' . $orderId;
     $tblNumber = new App_Model_Db_Table_GenerateNumber();
     $rowset = $tblNumber->fetchRow();
     $num = $rowset->invoice;
     $totdigit = 5;
     $num = strval($num);
     $jumdigit = strlen($num);
     $noinvoice = str_repeat("0", $totdigit - $jumdigit) . $num;
     $rowset->invoice = $rowset->invoice += 1;
     $tblNumber->update(array('invoice' => $rowset->invoice), NULL);
     $rowJustInserted->invoiceNumber = $noinvoice;
     $rowJustInserted->save();
     $this->view->invoiceNumber = $rowJustInserted->invoiceNumber;
     $this->view->datePurchased = $rowJustInserted->datePurchased;
     $tblOrderDetail = new App_Model_Db_Table_OrderDetail();
     for ($iCart = 0; $iCart < count($cart['items']); $iCart++) {
         $rowDetail = $tblOrderDetail->fetchNew();
         $itemId = $cart['items'][$iCart]['itemId'];
         $rowDetail->orderId = $orderId;
         $rowDetail->itemId = $itemId;
         $rowDetail->documentName = $cart['items'][$iCart]['item_name'];
         $rowDetail->price = $cart['items'][$iCart]['itemPrice'];
         $itemPrice = $rowDetail->price;
         @($rowDetail->tax = ($cart['grandTotal'] - $cart['subTotal']) / $cart['subTotal'] * 100);
         $rowDetail->discount = $cart['disc'];
         $rowDetail->qty = $cart['items'][$iCart]['qty'];
         $rowDetail->finalPrice = $cart['items'][$iCart]['itemTotal'];
         $rowDetail->save();
     }
     //[TODO] MUST ALSO INSERT/UPDATE KutuUserFinance
     return $orderId;
 }
Exemplo n.º 2
0
 function completeAction()
 {
     $formater = new Pandamp_Core_Hol_User();
     $defaultCurrency = 'Rp';
     $kopel = $this->_request->getParam('kopel');
     $method = $this->_request->getParam('method');
     $packageId = $this->_request->getParam('packageId');
     $paymentSubscription = $this->_request->getParam('payment');
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $tblUser = new App_Model_Db_Table_User();
     $rowUser = $tblUser->find($kopel)->current();
     /*
         	$modelGroup = new Kutu_Core_Orm_Table_Group();
         	$row = $modelGroup->fetchRow("id=".$this->_user->packageId);
     if ($row->name == "free") {
     	$rowUser->periodeId = 2;
     	$rowUser->save();
     }
     */
     $this->view->rowUser = $rowUser;
     // discount
     $disc = $formater->checkPromoValidation('Disc', $packageId, $rowUser->promotionId, $paymentSubscription);
     $total = $formater->checkPromoValidation('Total', $packageId, $rowUser->promotionId, $paymentSubscription);
     $tblPackage = new App_Model_Db_Table_Package();
     $rowPackage = $tblPackage->fetchRow("packageId={$packageId}");
     $this->view->rowPackage = $rowPackage;
     $tblOrder = new App_Model_Db_Table_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $kopel;
     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 App_Model_Db_Table_OrderDetail();
     $rowDetail = $tblOrderDetail->fetchNew();
     $rowDetail->orderId = $orderId;
     $rowDetail->itemId = $rowPackage->packageId;
     $modelGroup = new App_Model_Db_Table_Group();
     $row = $modelGroup->fetchRow("id={$packageId}");
     $group = "Subsciption for Member " . ucwords(strtolower($row->name)) . " " . $paymentSubscription . " Months";
     $this->view->packageId = $packageId;
     $this->view->paymentSubscription = $paymentSubscription;
     $this->view->itemName = $group;
     $rowDetail->documentName = $group;
     $rowDetail->price = $total;
     $numOfUsers = $tblUser->getUserCount($rowUser->kopel);
     $this->view->numOfUsers = $numOfUsers;
     $this->view->grandtotal = $total;
     $this->view->method = $method;
     $this->view->orderId = $orderId;
     $this->view->total = $rowPackage->charge;
     $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 Membership_Model_Store_Mailer();
     switch (strtolower($method)) {
         case 'manual':
         case 'bank':
             $mod->sendBankInvoiceToUser($orderId);
             break;
         case 'nsiapay':
             $mod->sendInvoiceToUser($orderId);
             break;
     }
 }
Exemplo n.º 3
0
 public function confirmAction()
 {
     $this->_checkAuth();
     $userId = $this->_user->kopel;
     $rowset = App_Model_Show_Order::show()->getTransactionToConfirm($userId);
     $numCount = App_Model_Show_Order::show()->getTransactionToConfirmCount($userId);
     $modelPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $bankAccount = $modelPaymentSetting->fetchAll("settingKey = 'bankAccount'");
     if ($this->_request->get('sended') == 1) {
         $this->view->sended = 'Payment Confirmation Sent';
     }
     $this->view->numCount = $numCount;
     $this->view->rowset = $rowset;
     $this->view->bankAccount = $bankAccount;
 }
Exemplo n.º 4
0
 public function editpaymentsettingAction()
 {
     $idSetting = $this->_request->getParam('id');
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $rowset = $tblPaymentSetting->fetchAll("settingId = " . $idSetting);
     $this->view->id = $idSetting;
     $this->view->rows = $rowset;
     if ($this->_request->isPost($this->_request->getParam('save'))) {
         $id = $this->_request->getParam('id');
         $data['settingValue'] = $this->_request->getParam('value');
         $data['note'] = $this->_request->getParam('note');
         $update = $tblPaymentSetting->update($data, 'settingId = ' . $id);
         $zl = Zend_Registry::get('Zend_Locale');
         $this->_redirect(ROOT_URL . '/' . $zl->getLanguage() . '/store/paymentsetting');
     }
 }
Exemplo n.º 5
0
 function viewinvoiceAction()
 {
     $this->_checkAuth();
     $orderId = $this->_request->getParam('orderId');
     $items = App_Model_Show_Order::show()->getOrderDetail($orderId);
     $this->view->orderId = $orderId;
     $this->view->invoiceNumber = $items[0]['invoiceNumber'];
     $this->view->datePurchased = Pandamp_Lib_Formater::get_date($items[0]['datePurchased']);
     $tblPaymentSetting = new App_Model_Db_Table_PaymentSetting();
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     if ($this->_user->kopel != $items[0]['userId']) {
         $this->_redirect(ROOT_URL . '/shop/payment/cartempty');
     }
     $result = array();
     $result['subTotal'] = 0;
     for ($iCart = 0; $iCart < count($items); $iCart++) {
         $itemId = $items[$iCart]['itemId'];
         $qty = 1;
         $itemPrice = $items[$iCart]['price'];
         $result['items'][$iCart]['itemId'] = $itemId;
         $result['items'][$iCart]['item_name'] = $items[$iCart]['documentName'];
         $result['items'][$iCart]['itemPrice'] = $itemPrice;
         $result['items'][$iCart]['qty'] = $qty;
         $result['subTotal'] += $itemPrice * $qty;
     }
     $result['taxAmount'] = $result['subTotal'] * $rowTaxRate->settingValue / 100;
     $result['grandTotal'] = $result['subTotal'] + $result['taxAmount'];
     $this->view->cart = $result;
     $data = array();
     $data['taxNumber'] = $items[0]['taxNumber'];
     $data['taxCompany'] = $items[0]['taxCompany'];
     $data['taxAddress'] = $items[0]['taxAddress'];
     $data['taxCity'] = $items[0]['taxCity'];
     $data['taxZip'] = $items[0]['taxZip'];
     $data['taxProvince'] = $items[0]['taxProvince'];
     $data['taxCountry'] = $items[0]['taxCountryId'];
     $data['paymentMethod'] = $items[0]['paymentMethod'];
     $data['currencyValue'] = $items[0]['currencyValue'];
     $this->view->data = $data;
     $this->view->identity = "Lihat Faktur-" . $orderId;
 }