protected function doJob($arg)
 {
     $tomorrow = strtotime("+ 12 day", strtotime(date('Y-m-d H:i:s')));
     $mAppointment = Appointment::model()->findAll(array('condition' => 't.date_appointment < "' . date('Y-m-d H:i:s', $tomorrow) . '" AND t.date_appointment > "' . date('Y-m-d H:i:s') . '"', 'order' => 't.date_appointment ASC'));
     if (count($mAppointment) > 0) {
         foreach ($mAppointment as $eApp) {
             foreach ($eApp->bookings as $booking) {
                 if ($booking->email_reminded == 0) {
                     //send email notification to doctor
                     $modelEmailTemplate = EmailTemplates::model()->findByPk(8);
                     $dataEmail = array($booking->appointment->users->first_name . ' ' . $booking->appointment->users->last_name, $booking->user->first_name . ' ' . $booking->user->last_name, $booking->user->email, $booking->user->phone, date('l, d M Y, g:i A', strtotime($booking->appointment->date_appointment)), $booking->id, $booking->user->first_name . ' ' . $booking->user->last_name);
                     $pattern = array('{DOCTOR_NAME}', '{PATIENT_NAME}', '{PATIENT_EMAIL}', '{PATIENT_PHONE}', '{DATE_APPOINTMENT}', '{BOOKING_ID}', '{BOOKING_NAME}');
                     $message = str_replace($pattern, $dataEmail, $modelEmailTemplate->email_body);
                     $subject = $modelEmailTemplate->email_subject;
                     $data = array('subject' => $subject, 'params' => array('message' => $message), 'view' => 'message', 'to' => $booking->appointment->users->email, 'from' => Yii::app()->params['autoEmail']);
                     CmsEmail::mail($data);
                     //send email notification to patient
                     $modelEmailTemplate = EmailTemplates::model()->findByPk(7);
                     $dataEmail = array($booking->appointment->users->first_name . ' ' . $booking->appointment->users->last_name, $booking->user->first_name . ' ' . $booking->user->last_name, $booking->appointment->users->doctors->main_specialty, date('l, d M Y, g:i A', strtotime($booking->appointment->date_appointment)), $booking->id, $booking->appointment->address->address);
                     $pattern = array('{DOCTOR_NAME}', '{PATIENT_NAME}', '{DOCTOR_SPECIALTY}', '{DATE_APPOINTMENT}', '{BOOKING_ID}', '{DOCTOR_ADDRESS}');
                     $message = str_replace($pattern, $dataEmail, $modelEmailTemplate->email_body);
                     $subject = $modelEmailTemplate->email_subject;
                     $data = array('subject' => $subject, 'params' => array('message' => $message), 'view' => 'message', 'to' => $booking->user->email, 'from' => Yii::app()->params['autoEmail']);
                     CmsEmail::mail($data);
                     $booking->email_reminded = 1;
                     $booking->update(array('email_reminded'));
                     $this->index++;
                     //count email is sent for current cron job
                     if ($this->index >= $this->max) {
                         break;
                     }
                 }
             }
         }
     } else {
         return;
     }
 }
Example #2
0
 public function run($arg)
 {
     /* ANH DUNG MAR 05, 2015 dùng chỗ này để chạy import update database cuar singpost www.singpost.com
        $from = time();
        if( Yii::app()->setting->getItem('rss') == 0 ){
            Yii::app()->setting->setDbItem('rss', 1);
            ApiPostcode::HandleUpdateLonLatTableBuilding();
            
            $to = time();
            $second = $to-$from;
            $res = ' done in: '.($second).'  Second  <=> '.($second/60).' Minutes';
            Yii::app()->setting->setDbItem('linkedin', $res);
        }
        Yii::app()->setting->setDbItem('facebook', time());
        die;
         * end ANH DUNG MAR 05, 2015 dùng chỗ này để chạy import update database cuar singpost www.singpost.com
         */
     //        if(Yii::app()->params['mailchimp_on'] == 'yes')
     //            return;
     //        $last_working = Yii::app()->setting->getItem('last_working');
     //        if(!empty($last_working))
     //        {
     //            $timestampNext = strtotime(ActiveRecord::timeCalMinutes(-10));
     //            if(strtotime($last_working) > $timestampNext)
     //            {
     ////                Yii::log(strtotime($last_working), 'error', 'NewsletterCommand.run');
     ////                Yii::log($timestampNext, 'error', 'NewsletterCommand.run');
     //                echo 'waiting because last working is nearly';
     //                return;
     //            }
     //        }
     $this->doJob($arg);
     CmsEmail::mailAll($this->data);
     echo "Sent {$this->index} emails";
     Yii::app()->setting->setDbItem('last_working', date('Y-m-d h:i:s'));
 }
Example #3
0
 public function actionResetPassword()
 {
     $id = Yii::app()->request->getParam('id');
     $key = Yii::app()->request->getParam('key');
     $model = Users::model()->findByPk((int) $id);
     if ($model !== null && $key == ForgotPasswordForm::generateKey($model)) {
         $pass = ActiveRecord::randString(6);
         $model->password_hash = md5($pass);
         $model->temp_password = $pass;
         $model->update();
         $name = $model->first_name . ' ' . $model->last_name;
         $login_link = '<a href="' . Yii::app()->createAbsoluteUrl("admin/site/login") . '">' . Yii::app()->createAbsoluteUrl("admin/site/login") . '</a>';
         $aBody = array('{NAME}' => $name, '{PASSWORD}' => $model->temp_password, '{LINK_LOGIN}' => $login_link);
         if (CmsEmail::sendmail(2, array(), $aBody, $model->email)) {
             Yii::app()->user->setFlash("success", "An email has sent to: {$model->email}. Please check email to get new password.");
         } else {
             $model->addError('email', 'Can not send email to: ' . $model->email);
         }
     } else {
         Yii::log('Invalid request. Please do not repeat this request again.');
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     $this->render('ResetPassword', array('model' => $model));
 }
Example #4
0
     try {
         $model = ProOpportunity::GetBySlug($slug);
         if (is_null($model)) {
             throw new Exception('Invalid Request');
         }
         $this->pageTitle = 'View Job - ' . Yii::app()->params['title'];
         $this->render('career/View_job', array('model' => $model));
     } catch (Exception $exc) {
         throw new CHttpException(404, $exc->getMessage());
     }
 }
 public function actionResume()
 {
     $model = new ProResume();
     $flag = false;
     $this->pageTitle = 'Submit Resume - ' . Yii::app()->params['title'];
     if (isset($_POST['ProResume'])) {
         $model->attributes = $_POST['ProResume'];
         $model->file_resume = CUploadedFile::getInstance($model, 'file_resume');
         $model->validate();
         if (!$model->hasErrors()) {
             if ($model->save()) {
                 //file_resule
                 if (!is_null($model->file_resume)) {
                     ProResume::save_upload_file_resume($model);
                 }
                 $flag = true;
                 Yii::app()->user->setFlash('success', "Your Resume has been uploaded!");
                 //gui mail
Example #5
0
 public function sendMailToAdmin($engage)
 {
     try {
         $mUser = Users::model()->findByPk(Yii::app()->user->id);
         $aBody = array('{PROPERTY_NAME}' => $this->getPropertyDetail($engage->transaction_id), '{NAME}' => $mUser->title . ' ' . $mUser->first_name . ' ' . $mUser->last_name, '{REMARK}' => $engage->remark, '{PRICE}' => $engage->price, '{NRIC}' => $mUser->nric_passportno_roc);
         CmsEmail::sendmail(MAIL_LANDLORD_SEND_ENGAGE_US, $aBody, $aBody, Yii::app()->params['adminEmail']);
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
     }
 }
Example #6
0
 /**
  * 
  * @param int $iEmailTemplateID
  * @param array $aSubject
  * @param array $aBody
  * @param string $sTo
  * @author bb  <*****@*****.**>
  * @copyright (c) 2013, bb 
  */
 public static function sendmailTranslate($iEmailTemplateID, $aSubject, $aBody, $sTo)
 {
     $modelEmailTemplate = new TranslateHelper('EmailTemplates', $iEmailTemplateID);
     $sSubject = $modelEmailTemplate->get('email_subject');
     if (is_array($aSubject)) {
         foreach ($aSubject as $key => $value) {
             $sSubject = str_replace($key, $value, $sSubject);
         }
     }
     $sBody = $modelEmailTemplate->get('email_body');
     if (is_array($aBody)) {
         foreach ($aBody as $key => $value) {
             $sBody = str_replace($key, $value, $sBody);
         }
     }
     $data = array('subject' => $sSubject, 'params' => array('message' => $sBody), 'view' => 'message', 'to' => $sTo, 'from' => Yii::app()->params['autoEmail']);
     return CmsEmail::mail($data);
 }
Example #7
0
</strong></p>
				<ul>
				<?php 
            foreach ($group['childs'] as $item) {
                ?>
Example #8
0
 /**
  * @param $model
  * @return bool
  * <Jason>
  * <*****@*****.**>
  */
 public static function sendMailAfterRegister($model)
 {
     $url_login = Yii::app()->createAbsoluteUrl('site/login', array('role' => ROLE_REGISTER_MEMBER, 'verify_code' => $model->verify_code));
     $url_login = "******";
     $aBody = array('{EMAIL}' => $model->email, '{FULL_NAME}' => $model->title . ' ' . $model->first_name . ' ' . $model->last_name, '{PASSWORD}' => $model->temp_password, '{LINK}' => $url_login);
     if (CmsEmail::sendmail(MAIL_AFTER_REGISTER, array(), $aBody, $model->email)) {
         // Send a email to admin
         return true;
     } else {
         $model->addError('email', 'Can not send email');
     }
 }