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; } }
public function getGroupName($id) { $modelGroup = new App_Model_Db_Table_Group(); $row = $modelGroup->fetchRow("id={$id}"); return $row ? $row->name : '-'; }