Пример #1
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);
         }
     }
 }
Пример #2
0
 /**
  * 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";
     }
 }