コード例 #1
0
ファイル: User.php プロジェクト: hukumonline/quart80
 /**
  * _writeConfirmAkunHabis
  * @return JSON
  */
 function _writeConfirmAkunHabis($guid, $access = '')
 {
     $mailContent = $this->getMailContent('konfirmasi-akun-habis');
     $tblUser = new Pandamp_Modules_Identity_User_Model_User();
     $rowset = $tblUser->find($guid)->current();
     $mailContent = str_replace('$fullname', $rowset->fullName, $mailContent);
     $tblInvoice = new Pandamp_Modules_Payment_Invoice_Model_Invoice();
     $where = $tblInvoice->getAdapter()->quoteInto("uid=?", $guid);
     $rowInvoice = $tblInvoice->fetchRow($where, "invoiceId DESC");
     if ($rowInvoice) {
         $mailContent = str_replace('$bataswaktu', $rowInvoice->expirationDate, $mailContent);
         $mail_body = $mailContent;
         $today = date("Y-m-d");
         $getMDays = strftime('%Y-%m-%d', strtotime("-7 day", strtotime($rowInvoice->expirationDate)));
         if (empty($access)) {
             if ($getMDays == $today) {
                 // parse ini_file
                 $config = new Zend_Config_Ini(CONFIG_PATH . '/mail.ini', 'mail');
                 $mailAttempt = $this->add_mail($config->mail->sender->support->email, $rowset->email, $rowset->username, 'Pemberitahuan berlangganan habis', $mail_body);
                 // try to save mail before send
                 if ($mailAttempt) {
                     $sendAttempt = $this->send_mail();
                     if ($sendAttempt) {
                         $response['success'] = true;
                         $response['message'] = "Email verification sent successfully to {$rowset->email}!";
                         // update user
                         $rowset->isEmailSentOver = 'Y';
                         $rowset->save();
                     } else {
                         ob_clean();
                         $response['failure'] = false;
                         $response['message'] = "Error send mail";
                     }
                 } else {
                     $response['failure'] = true;
                     $response['message'] = "Error mail!";
                 }
             } else {
                 $response['failure'] = true;
                 $response['message'] = "Invalid time of limits";
             }
             echo Zend_Json::encode($response);
         } else {
             if ($getMDays == $today) {
                 // parse ini_file
                 $config = new Zend_Config_Ini(CONFIG_PATH . '/mail.ini', 'mail');
                 $mailAttempt = $this->add_mail($config->mail->sender->support->email, $rowset->email, $rowset->username, 'Pemberitahuan berlangganan habis', $mail_body);
                 // try to save mail before send
                 if ($mailAttempt) {
                     $sendAttempt = $this->send_mail();
                     if ($sendAttempt) {
                         // update user
                         $rowset->isEmailSentOver = 'Y';
                         $rowset->save();
                     }
                 }
             }
         }
     }
 }
コード例 #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";
     }
 }