Esempio n. 1
0
 /**
  * checkPromoValidation : Individual & Korporasi
  * @return disc :: Total
  */
 function checkPromoValidation($whatPromo, $package, $promotionId = '', $payment = 0)
 {
     $tblPackage = new App_Model_Db_Table_Package();
     $rowPackage = $tblPackage->fetchRow("packageId={$package}");
     $periode = $rowPackage->charge * $payment;
     $tblPromosi = new App_Model_Db_Table_Promotion();
     $rowPromo = $tblPromosi->find($promotionId)->current();
     // check promotionID if exist then dischard query
     if (isset($rowPromo)) {
         if ($payment == 6) {
             $disc = $rowPromo->discount + 5;
         } elseif ($payment == 12) {
             $disc = $rowPromo->discount + 10;
         } else {
             $disc = $rowPromo->discount;
         }
         $total = ($periode - $disc / 100 * $periode) * 1.1;
     } else {
         $getPromo = $tblPromosi->fetchRow("periodeStart <= '" . date("Y-m-d") . "' AND periodEnd >= '" . date("Y-m-d") . "' AND monthlySubscriber=" . $payment . "");
         if (!empty($getPromo)) {
             if ($payment == 6) {
                 $disc = $getPromo->discount + 5;
             } elseif ($payment == 12) {
                 $disc = $getPromo->discount + 10;
             } else {
                 $disc = $getPromo->discount;
             }
             $total = ($periode - $disc / 100 * $periode) * 1.1;
         } else {
             if ($payment == 6) {
                 $disc = 5;
             } elseif ($payment == 12) {
                 $disc = 10;
             } else {
                 $disc = 0;
             }
             $total = ($periode - $disc / 100 * $periode) * 1.1;
         }
     }
     switch ($whatPromo) {
         case 'Disc':
             return $disc;
             break;
         case 'Total':
             return $total;
             break;
     }
 }
Esempio 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;
     }
 }
Esempio n. 3
0
 /**
  * Who's Online
  *
  */
 function wholAction()
 {
     if (!Pandamp_Controller_Action_Helper_IsAllowed::isAllowed('membership', 'all')) {
         $this->_redirect(ROOT_URL . '/' . $this->_zl->getLanguage() . '/error/restricted');
     }
     $this->_helper->layout->setLayout('layout-customer-credential');
     $modelPackage = new App_Model_Db_Table_Package();
     $rowPackage = $modelPackage->fetchAll();
     foreach ($rowPackage as $rp) {
         $p[] = $rp->packageId;
     }
     $pk = join(",", $p);
     $rowset = App_Model_Show_User::show()->countUser("ku.packageId IN ({$pk}) AND ku.ses!='*'");
     $a['totalCount'] = $rowset;
     $limit = 25;
     $a['limit'] = $limit;
     $this->view->aData = $a;
     $this->view->identity = $this->_user;
 }
Esempio n. 4
0
 /**
  * _writeConfirmCorporateEmail
  * @return JSON
  */
 function _writeConfirmCorporateEmail($mailcontent, $package, $fullname, $company, $payment, $disc, $total, $username, $guid, $email)
 {
     $obj = new Pandamp_Crypt_Password();
     $mailcontent = str_replace('$fullname', $fullname, $mailcontent);
     $mailcontent = str_replace('$company', $company, $mailcontent);
     $pn = App_Model_Show_AroGroup::show()->getUserGroup($package);
     $mailcontent = str_replace('$packagename', $pn['name'], $mailcontent);
     $mailcontent = str_replace('$timeline', $payment, $mailcontent);
     $mailcontent = str_replace('$disc', $disc, $mailcontent);
     $tblPackage = new App_Model_Db_Table_Package();
     $rowPackage = $tblPackage->fetchRow("packageId={$package}");
     $mailcontent = str_replace('$packageprice', number_format($rowPackage->charge), $mailcontent);
     $mailcontent = str_replace('$price', number_format($total), $mailcontent);
     $mailcontent = str_replace('$username1', $username, $mailcontent);
     $mailcontent = str_replace('$guid', $guid, $mailcontent);
     // table User
     $tblUser = new App_Model_Db_Table_User();
     $where = $tblUser->getAdapter()->quoteInto('company=?', $company);
     $rowUser = $tblUser->fetchAll($where, 'username ASC');
     $tag = '<table>';
     $tag .= '<tr><td><b>Username</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><b>Password</b></td></tr>';
     foreach ($rowUser as $rowsetUser) {
         $tag .= '<tr><td>' . $rowsetUser->username . '</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>' . $obj->decryptPassword($rowsetUser->password) . '</td></tr>';
     }
     $tag .= '</table>';
     $mailcontent = str_replace('$tag', $tag, $mailcontent);
     $mail_body = $mailcontent;
     // parse ini_file
     $config = new Zend_Config_Ini(CONFIG_PATH . '/mail.ini', 'mail');
     $mailAttempt = $this->add_mail($config->mail->sender->support->email, $email, $username, $config->mail->sender->support->name, $mail_body);
     // try to save mail before send
     if ($mailAttempt) {
         $sendAttempt = $this->send_mail();
         if ($sendAttempt) {
             $message = "Please check your email at {$email}!";
             // update user
             $rowUser = $tblUser->find($obj->decryptPassword($guid))->current();
             if ($rowUser) {
                 $rowUser->isEmailSent = 'Y';
                 $rowUser->save();
             }
         } else {
             $message = "Error send mail but register user successfully!<br>Please contact our customer service for more information";
         }
     } else {
         $message = "Error saving mail!";
     }
     return $message;
 }
Esempio n. 5
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);
 }