Example #1
0
 public function invoiceAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->getHelper('viewRenderer')->setNoRender(TRUE);
     $tblUser = new App_Model_Db_Table_User();
     $rowUser = $tblUser->fetchRow("kopel='00015'");
     $temptime = strtotime($rowUser->createdDate);
     //$temptime = time();
     $temptime = Pandamp_Lib_Formater::DateAdd('d', 5, $temptime);
     $rowInvoice = strftime('%Y-%m-%d', $temptime);
     Pandamp_Debug::manager($rowInvoice);
 }
Example #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;
     }
 }
Example #3
0
 public function payconfirmyesAction()
 {
     $this->_helper->viewRenderer->setNoRender(TRUE);
     //print_r($this->_request->getParams());
     $id = $this->_request->getParam('orderId');
     $tblOrder = new App_Model_Db_Table_Order();
     $tblHistory = new App_Model_Db_Table_OrderHistory();
     $tblConfirm = new App_Model_Db_Table_PaymentConfirmation();
     $rowOrder = $tblOrder->find($id)->current();
     if ($rowOrder->paymentMethodNote == 'membership') {
         $oldUser = App_Model_Show_User::show()->getUserById($rowOrder->userId);
         $oldpackage = App_Model_Show_AroGroup::show()->getUserGroup($oldUser['packageId']);
         $newGroup = App_Model_Show_AroGroup::show()->getUserGroup($rowOrder->note);
         $notes = date("Y-m-d h:i:s") . " - Changed package " . $oldpackage['name'] . " TO " . $newGroup['name'];
         $notes = $oldUser['notes'] ? $oldUser['notes'] . "\n" . $notes : $notes;
         $dataUser = array('packageId' => $rowOrder->note, 'notes' => $notes, 'modifiedDate' => date("Y-m-d h:i:s"), 'modifiedBy' => Zend_Auth::getInstance()->getIdentity()->username);
         $modelUser = new App_Model_Db_Table_User();
         $dataUserDetail = array('userId' => $oldUser['kopel'], 'packageId' => $oldUser['packageId'], 'promotionId' => $oldUser['promotionId'], 'educationId' => $oldUser['educationId'], 'expenseId' => $oldUser['expenseId'], 'paymentId' => $oldUser['paymentId'], 'businessTypeId' => $oldUser['businessTypeId'], 'periodeId' => $oldUser['periodeId'], 'activationDate' => $oldUser['activationDate'], 'createdDate' => $oldUser['createdDate'], 'createdBy' => $oldUser['createdBy'], 'modifiedDate' => $oldUser['modifiedDate'], 'modifiedBy' => $oldUser['modifiedBy'], 'isActive' => $oldUser['isActive'], 'isContact' => $oldUser['isContact']);
         $modelUserDetail = new App_Model_Db_Table_UserDetail();
         $modelUserDetail->insert($dataUserDetail);
         $acl = Pandamp_Acl::manager();
         $acl->deleteUser($oldUser['username']);
         $acl->addUser($oldUser['username'], $newGroup['name']);
         $tblInvoice = new App_Model_Db_Table_Invoice();
         $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $rowOrder->userId);
         $rowInvoice = $tblInvoice->fetchRow($where);
         if ($rowInvoice) {
             $rowInvoice->invoiceConfirmDate = date("Y-m-d");
             $rowInvoice->isPaid = 'Y';
             // get expiration date
             $temptime = time();
             $temptime = Pandamp_Lib_Formater::DateAdd('m', $oldUser['paymentId'], $temptime);
             $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime);
             $rowInvoice->save();
             $dataUser['periodeId'] = 3;
         }
         $modelUser->update($dataUser, "kopel='" . $rowOrder->userId . "'");
     }
     //select payment date from paymentconfirmation
     $date = $tblConfirm->fetchAll("orderId = " . $id . " AND confirmed = 0");
     $data['paymentDate'] = $date[0]->paymentDate;
     //update order
     $data['orderStatus'] = 3;
     $tblOrder->update($data, "orderId = " . $id);
     //update paymentconfirmation
     $dataConfirm['confirmed'] = 1;
     $tblConfirm->update($dataConfirm, "orderId = " . $id);
     //add history
     $dataHistory = $tblHistory->fetchNew();
     //history data
     $dataHistory['orderId'] = $id;
     $dataHistory['orderStatusId'] = 3;
     $dataHistory['dateCreated'] = date('Y-m-d');
     $dataHistory['userNotified'] = 1;
     $dataHistory['note'] = 'confirmed';
     $dataHistory->save();
     //mailer
     //$this->Mailer($id, 'user-confirm', 'user');
     $mod = new App_Model_Store_Mailer();
     $mod->sendReceiptToUser($id, ucwords($date[0]->paymentMethod));
     //redirect to confirmation page
     $this->_redirect($this->view->serverUrl() . '/' . $this->view->getLanguage() . '/store/confirm');
 }
Example #4
0
 /**
  * _writeInvoice : Individual & Korporasi
  * @return 
  */
 function _writeInvoice($memberId, $totalPromo, $discPromo, $payment, $access = '')
 {
     $aclMan = Pandamp_Acl::manager();
     $tblInvoice = new Pandamp_Modules_Payment_Invoice_Model_Invoice();
     $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $memberId);
     $rowInvoice = $tblInvoice->fetchAll($where);
     if (count($rowInvoice) <= 0) {
         $rowInvoice = $tblInvoice->fetchNew();
         $rowInvoice->uid = $memberId;
         $rowInvoice->price = $totalPromo;
         $rowInvoice->discount = $discPromo;
         $rowInvoice->invoiceOutDate = date("Y-m-d");
         $rowInvoice->invoiceConfirmDate = "0000-00-00";
         $temptime = time();
         $temptime = Pandamp_Lib_Formater::DateAdd('d', 5, $temptime);
         $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime);
         $tblUser = new Pandamp_Modules_Identity_User_Model_User();
         $rowUser = $tblUser->fetchRow("kopel=" . $memberId);
         // add user to gacl
         //			$aclMan->addUser($rowUser->username,'member_gratis');
         if (empty($access)) {
             $rowInvoice->save();
         } else {
             $result = $rowInvoice->save();
             if ($result) {
                 $response['success'] = true;
                 $response['message'] = "set invoice:{$memberId} successfully";
             } else {
                 $response['failure'] = true;
             }
             echo Zend_Json::encode($response);
         }
     } else {
         if (!empty($access)) {
             $response['success'] = true;
             $response['message'] = "invoice:{$memberId} sudah dibuat!";
             echo Zend_Json::encode($response);
         }
     }
 }
Example #5
0
 /**
  * _writeInvoice : Individual & Korporasi
  * @modifiedDate : 2012-11-20 12:53N
  * @todo Changed invoiceOutDate with createdDate from User Table
  * @return 
  */
 function _writeInvoice($memberId, $totalPromo, $discPromo, $payment, $access = '')
 {
     //$aclMan	= Pandamp_Acl::manager();
     $tblInvoice = new App_Model_Db_Table_Invoice();
     $where = $tblInvoice->getAdapter()->quoteInto("uid=?", "{$memberId}");
     $rowInvoice = $tblInvoice->fetchAll($where);
     if (count($rowInvoice) <= 0) {
         $tblUser = new App_Model_Db_Table_User();
         $rowUser = $tblUser->fetchRow("kopel='" . $memberId . "'");
         $rowInvoice = $tblInvoice->fetchNew();
         $rowInvoice->uid = $memberId;
         $rowInvoice->price = $totalPromo;
         $rowInvoice->discount = $discPromo;
         //$rowInvoice->invoiceOutDate = date("Y-m-d");
         $rowInvoice->invoiceOutDate = date("Y-m-d", strtotime($rowUser->createdDate));
         $rowInvoice->invoiceConfirmDate = "0000-00-00";
         //$temptime = time();
         $temptime = strtotime($rowUser->createdDate);
         if ($rowUser->trialInDays == 0) {
             $trial = 5;
         } else {
             $trial = $rowUser->trialInDays;
         }
         $temptime = Pandamp_Lib_Formater::DateAdd('d', $trial, $temptime);
         $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime);
         if (empty($access)) {
             $rowInvoice->save();
         } else {
             $result = $rowInvoice->save();
             if ($result) {
                 $r = $memberId . " OK";
             } else {
                 $r = 'failure';
             }
         }
     } else {
         if (!empty($access)) {
             $r = "invoice:{$memberId} sudah pernah dibuat!";
         }
     }
     return $r;
 }
Example #6
0
 function confirmAction()
 {
     $this->_helper->getHelper('layout')->disableLayout();
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     $request = $this->getRequest();
     $result = 'RESULT_ERROR';
     if (Pandamp_Controller_Action_Helper_IsAllowed::isAllowed('membership', 'all')) {
         if ($request->isPost()) {
             $id = $request->getPost('id');
             //        		$ids = array();
             //        		$ids = Zend_Json::decode($id);
             $aclMan = Pandamp_Acl::manager();
             $modelUser = new App_Model_Db_Table_User();
             //   		        foreach ($ids as $id) {
             $sql = $modelUser->select()->setIntegrityCheck(false);
             $sql->from(array('ku' => 'KutuUser'))->join(array('gag' => 'gacl_aro_groups'), 'ku.packageId = gag.id')->where('ku.kopel=?', $id);
             $rowUser = $modelUser->fetchRow($sql);
             $modelPackage = new App_Model_Db_Table_Package();
             $rowPackage = $modelPackage->fetchRow("packageId=" . $rowUser->packageId);
             //if (in_array($rowUser->packageId,array(14,15,16,17,18))) {
             if ($rowPackage) {
                 $tblInvoice = new App_Model_Db_Table_Invoice();
                 $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $id);
                 $rowInvoice = $tblInvoice->fetchRow($where);
                 if ($rowInvoice) {
                     $rowInvoice->invoiceConfirmDate = date("Y-m-d");
                     $rowInvoice->isPaid = 'Y';
                     // get expiration date
                     $temptime = time();
                     $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser->paymentId, $temptime);
                     $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime);
                     $rowInvoice->save();
                     // delete user group = trial from gacl
                     $aclMan->deleteUser($rowUser->username);
                     // add user to gacl
                     $aReturn = $aclMan->getGroupData($rowUser->packageId);
                     $aclMan->addUser($rowUser->username, $aReturn[2]);
                     $rowUser->periodeId = 3;
                     $rowUser->isActive = 1;
                     $rowUser->modifiedDate = date("Y-m-d h:i:s");
                     $rowUser->modifiedBy = "{$rowUser->username}";
                     $rowUser->save();
                     $result = 'RESULT_OK';
                 } else {
                     $result = 'Create Invoice First';
                 }
             } else {
                 $result = 'Wrong Package';
             }
             //   		        }
         }
     }
     $this->getResponse()->setBody($result);
 }
 /**
  * confirm is for administrator directly from GridPanel	
  * confirm is for user packed Individual or Corporate
  * If this function is execute then 
  * User status changed isActive = 1 and period = active and
  * Also check, if invoice exist then update it
  * @param uid
  */
 function confirmAction()
 {
     $uid = $this->_getParam('uid') ? $this->_getParam('uid') : '';
     //$formater = new Kutu_Lib_Formater();
     $aclMan = Pandamp_Acl::manager();
     $tblUser = new Pandamp_Modules_Identity_User_Model_User();
     $sql = $tblUser->select()->setIntegrityCheck(false);
     $sql->from(array('ku' => 'KutuUser'))->join(array('gag' => 'gacl_aro_groups'), 'ku.packageId = gag.id')->where('ku.kopel=?', $uid);
     $rowUser = $tblUser->fetchRow($sql);
     if ($rowUser->packageId == 26 || $rowUser->packageId == 27) {
         $tblInvoice = new Pandamp_Modules_Payment_Invoice_Model_Invoice();
         $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $uid);
         $rowInvoice = $tblInvoice->fetchRow($where);
         if ($rowInvoice) {
             $rowInvoice->invoiceConfirmDate = date("Y-m-d");
             $rowInvoice->isPaid = 'Y';
             // get expiration date
             $temptime = time();
             $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser->paymentId, $temptime);
             $rowInvoice->expirationDate = strftime('%Y-%m-%d', $temptime);
             $rowInvoice->save();
             // delete user group = trial from gacl
             $aclMan->deleteUser($rowUser->username);
             // add user to gacl
             $aReturn = $aclMan->getGroupData($rowUser->packageId);
             $aclMan->addUser($rowUser->username, $aReturn[2]);
             $rowUser->periodeId = 3;
             $rowUser->isActive = 1;
             $rowUser->updatedDate = date("Y-m-d h:i:s");
             $rowUser->updatedBy = "{$rowUser->username}";
             $result = $rowUser->save();
             if ($result) {
                 $this->view->success = true;
                 $this->view->message = $rowUser->username . ", confirm saved";
             } else {
                 $this->view->success = false;
                 $this->view->message = "Error user confirmation!";
             }
         } else {
             $this->view->success = false;
             $this->view->message = "Please, create invoice first!";
         }
     } else {
         $this->view->success = false;
         $this->view->message = $rowUser->username . ", wrong packed";
     }
 }
Example #8
0
 /**
  * @modifiedDate: 2012-11-20 15:25
  * @todo Changed $temptime = strtotime($rowset->expirationDate)
  *
  */
 function renewAction()
 {
     if (!Pandamp_Controller_Action_Helper_IsAllowed::isAllowed('membership', 'all')) {
         $this->_redirect(ROOT_URL . '/' . $this->_zl->getLanguage() . '/error/restricted');
     }
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $aResult = array();
     $id = $this->_request->getParam('id') ? $this->_request->getParam('id') : '';
     $tblInvoice = new App_Model_Db_Table_Invoice();
     $rowset = $tblInvoice->fetchRow("invoiceId=" . $id . " AND isPaid='Y'");
     if ($rowset) {
         $rowInvoice = $tblInvoice->fetchNew();
         $rowInvoice->uid = $rowset->uid;
         $rowUser = App_Model_Show_User::show()->getUserById($rowset->uid);
         if (isset($rowUser['paymentId']) && $rowUser['paymentId'] != 0) {
             $todays_date = date("Y-m-d");
             $tblPackage = new App_Model_Db_Table_Package();
             $rowPackage = $tblPackage->fetchRow("packageId=" . $rowUser['packageId'] . "");
             if ($rowUser['paymentId'] == 12) {
                 $price = $rowPackage->charge * 11;
                 $price = $price + 0.1 * $price;
             } else {
                 $price = $rowPackage->charge * $rowUser['paymentId'];
                 $price = $price + 0.1 * $price;
             }
             //$rowInvoice->price				= $rowset->price;
             $rowInvoice->price = $price;
             $rowInvoice->discount = $rowset->discount;
             $rowInvoice->invoiceOutDate = $rowset->expirationDate;
             $rowInvoice->invoiceConfirmDate = $todays_date;
             $rowInvoice->clientBankAccount = $rowset->clientBankAccount;
             $rowInvoice->isPaid = 'Y';
             // get expiration date
             //$temptime = time();
             $temptime = strtotime($rowset->expirationDate);
             //$temptime = strtotime($todays_date); // Expire dihitung setelah pelanggan membayarar
             $temptime = Pandamp_Lib_Formater::DateAdd('m', $rowUser['paymentId'], $temptime);
             $expiredDate = strftime('%Y-%m-%d', $temptime);
             $today = strtotime($todays_date);
             $expiration_date = strtotime($expiredDate);
             if ($expiration_date < $today) {
                 $rowset->isPaid = 'E';
                 // status expire
                 $rowset->save();
                 $notes = date("Y-m-d h:i:s") . " - Invoice expired:" . $id;
                 $data = array('notes' => new Zend_Db_Expr("CONCAT(ifnull(notes,''),' \n{$notes}')"));
                 $modelUser = new App_Model_Db_Table_User();
                 $modelUser->update($data, "kopel='" . $rowset->uid . "'");
                 $aResult['isError'] = true;
                 $aResult['msg'] = 'Invoice sudah tidak bisa di renew karena tanggal expire < dari tanggal sekarang, <br>silahkan anda buat baru';
             } else {
                 $rowInvoice->expirationDate = $expiredDate;
                 $rowInvoice->save();
                 $rowset->isPaid = 'R';
                 // status renew
                 $rowset->save();
                 $notes = date("Y-m-d h:i:s") . " - Renew invoice:" . $id;
                 $data = array('notes' => new Zend_Db_Expr("CONCAT(ifnull(notes,''),' \n{$notes}')"));
                 $modelUser = new App_Model_Db_Table_User();
                 $modelUser->update($data, "kopel='" . $rowset->uid . "'");
                 $aResult['isError'] = true;
                 $aResult['msg'] = 'Invoice has been updated';
             }
         } else {
             $aResult['isError'] = true;
             $aResult['msg'] = 'Lamanya berlangganan kosong';
         }
     } else {
         $aResult['isError'] = true;
         $aResult['msg'] = 'Invalid Invoice ID';
     }
     echo Zend_Json::encode($aResult);
 }