예제 #1
0
파일: User.php 프로젝트: hukumonline/admin
 /**
  * _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;
 }
예제 #2
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');
 }
예제 #3
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);
 }