Пример #1
0
 private function saveOrder($cart, $method)
 {
     $defaultCurrency = 'Rp';
     $tblPaymentSetting = new Pandamp_Modules_Payment_Setting_Model_PaymentSetting();
     $usdIdrEx = $tblPaymentSetting->fetchRow(" settingKey= 'USDIDR'");
     $currencyValue = $usdIdrEx->settingValue;
     $rowTaxRate = $tblPaymentSetting->fetchRow("settingKey='taxRate'");
     $taxRate = $rowTaxRate->settingValue;
     $auth = Zend_Auth::getInstance();
     $userId = $auth->getIdentity()->guid;
     $tblOrder = new Pandamp_Modules_Payment_Order_Model_Order();
     $row = $tblOrder->fetchNew();
     $row->userId = $userId;
     //get value from post var (store/checkout.phtml)
     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');
     //        if ($method == "nsiapay") {
     //        	$row->orderStatus=8;
     //        }
     //        else {
     //        $row->orderStatus=1; //pending
     //        }
     $row->orderStatus = 1;
     //pending
     $row->currency = $defaultCurrency;
     $row->currencyValue = $currencyValue;
     $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 Pandamp_Modules_Misc_Number_Model_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));
     $rowJustInserted->invoiceNumber = $noinvoice;
     $rowJustInserted->save();
     $this->view->invoiceNumber = $rowJustInserted->invoiceNumber;
     $this->view->datePurchased = $rowJustInserted->datePurchased;
     $tblOrderDetail = new Pandamp_Modules_Payment_OrderDetail_Model_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->qty = $cart['items'][$iCart]['qty'];
         $rowDetail->finalPrice = $cart['items'][$iCart]['itemTotal'];
         $rowDetail->save();
     }
     //[TODO] MUST ALSO INSERT/UPDATE KutuUserFinance
     return $orderId;
 }
Пример #2
0
 function signupAction()
 {
     $this->_helper->layout->setLayout('layout-hukumonlineid-daftar');
     $r = $this->getRequest();
     if ($r->isPost()) {
         $id = $r->getParam('id') ? $r->getParam('id') : '';
         $promotionCode = $r->getParam('promotionCode') ? $r->getParam('promotionCode') : '';
         $package = $r->getParam('paket') ? $r->getParam('paket') : '';
         $fullName = $r->getParam('fullName') ? $r->getParam('fullName') : '';
         $gender = $r->getParam('chkGender') ? $r->getParam('chkGender') : '';
         $month = $r->getParam('month') ? $r->getParam('month') : '';
         $day = $r->getParam('day') ? $r->getParam('day') : '';
         $year = $r->getParam('year') ? $r->getParam('year') : '';
         $education = $r->getParam('education') ? $r->getParam('education') : '';
         $expense = $r->getParam('expense') ? $r->getParam('expense') : '';
         $company = $r->getParam('company') ? $r->getParam('company') : '';
         $businessType = $r->getParam('businessType') ? $r->getParam('businessType') : '';
         $phone = $r->getParam('phone') ? $r->getParam('phone') : '';
         $fax = $r->getParam('fax') ? $r->getParam('fax') : '';
         $payment = $r->getParam('payment') ? $r->getParam('payment') : '';
         $email = $r->getParam('email') ? $r->getParam('email') : '';
         $newArtikel = $r->getParam('newArtikel') ? $r->getParam('newArtikel') : '';
         $newRegulation = $r->getParam('newRegulation') ? $r->getParam('newRegulation') : '';
         $newWRegulation = $r->getParam('newWeeklyRegulation') ? $r->getParam('newWeeklyRegulation') : '';
         $iscontact = $r->getParam('iscontact') ? $r->getParam('iscontact') : '';
         $obj = new Pandamp_Crypt_Password();
         $formater = new Pandamp_Core_Hol_User();
         $aclMan = Pandamp_Acl::manager();
         try {
             for ($x = 1; $x <= $id; $x++) {
                 $username = $r->getParam('username' . $x) ? $r->getParam('username' . $x) : '';
                 $password = $r->getParam('password' . $x) ? $r->getParam('password' . $x) : '';
                 $tblUser = new Pandamp_Modules_Identity_User_Model_User();
                 Zend_Db_Table::getDefaultAdapter()->beginTransaction();
                 $rowUser = $tblUser->fetchNew();
                 $rowUser->username = $username;
                 $rowUser->password = $obj->encryptPassword($password);
                 $rowUser->fullName = $fullName;
                 $rowUser->gender = $gender == 1 ? 'L' : 'P';
                 $rowUser->birthday = $year . '-' . $month . '-' . $day;
                 $rowUser->indexCol = $x;
                 $rowUser->phone = $phone;
                 $rowUser->fax = $fax;
                 $rowUser->email = $email;
                 $rowUser->company = $company;
                 $rowUser->newArticle = $newArtikel == 1 ? 'Y' : 'N';
                 $rowUser->weeklyList = $newWRegulation == "1" ? 'Y' : 'N';
                 $rowUser->monthlyList = $newRegulation == 1 ? 'Y' : 'N';
                 $rowUser->isContact = $iscontact == $x ? 'Y' : 'N';
                 $rowUser->packageId = $package;
                 $rowUser->promotionId = $promotionCode;
                 $rowUser->educationId = $education;
                 $rowUser->expenseId = $expense;
                 $rowUser->paymentId = $payment;
                 $rowUser->businessTypeId = $businessType;
                 $tblNumber = new Pandamp_Modules_Misc_Number_Model_GenerateNumber();
                 $rowset = $tblNumber->fetchRow();
                 $num = $rowset->user;
                 $totdigit = 5;
                 $num = strval($num);
                 $jumdigit = strlen($num);
                 $noinvoice = str_repeat("0", $totdigit - $jumdigit) . $num;
                 $rowset->user = $rowset->user += 1;
                 $tblNumber->update(array('user' => $rowset->user));
                 $rowUser->kopel = $noinvoice;
                 $rowUser->save();
                 Zend_Db_Table::getDefaultAdapter()->commit();
                 $aclMan->addUser($username, 'member_gratis');
             }
             switch ($package) {
                 case 25:
                     $mailcontent = $formater->getMailContent('konfirmasi email gratis');
                     $m = $formater->_writeConfirmFreeEmail($mailcontent, $fullName, $r->getParam('username1'), $r->getParam('password1'), base64_encode(Pandamp_Lib_Formater::get_user_id($r->getParam('username1'))), $email, 'gratis');
                     break;
                 case 26:
                     $disc = $formater->checkPromoValidation('Disc', $aclMan->getGroupIds('member_individual'), $promotionCode, $payment);
                     $total = $formater->checkPromoValidation('Total', $aclMan->getGroupIds('member_individual'), $promotionCode, $payment);
                     $mailcontent = $formater->getMailContent('konfirmasi-email-individual');
                     $m = $formater->_writeConfirmIndividualEmail($mailcontent, $fullName, $r->getParam('username1'), $r->getParam('password1'), $payment, $disc, $total, base64_encode(Pandamp_Lib_Formater::get_user_id($r->getParam('username1'))), $email);
                     break;
                 case 27:
                     $disc = $formater->checkPromoValidation('Disc', $aclMan->getGroupIds('member_corporate'), $promotionCode, $payment);
                     $total = $formater->checkPromoValidation('Total', $aclMan->getGroupIds('member_corporate'), $promotionCode, $payment);
                     $mailcontent = $formater->getMailContent('konfirmasi-email-korporasi');
                     $m = $formater->_writeConfirmCorporateEmail($mailcontent, $fullName, $company, $payment, $disc, $total, $r->getParam('username1'), base64_encode(Pandamp_Lib_Formater::get_user_id($r->getParam('username1'))), $email);
                     break;
             }
             $this->view->message = $m;
         } catch (Zend_Exception $e) {
             Zend_Db_Table::getDefaultAdapter()->rollBack();
             $this->view->message = $e->getMessage();
         }
     }
 }