Ejemplo n.º 1
0
 public function actionDay()
 {
     $magazins = CMagazin::find()->all();
     $succes = 0;
     $fail = 0;
     $limit_mail = FConfigParam::find()->where(['name' => 'NUMBER_MAIL_MAGAZIN'])->one();
     if ($limit_mail) {
         $limit_mai = $limit_mail->value;
     } else {
         $limit_mai = 7;
     }
     foreach ($magazins as $magazin) {
         if ($magazin->Day >= -1 && $magazin->Day < $limit_mai) {
             $contentmagazin = FContentMagazin::findOne(['Day' => $magazin->Day + 1, 'Level' => $magazin->level]);
             if ($contentmagazin) {
                 $message = Yii::$app->mailer->compose('@common/mail/send_day_magazin', ['contentmagazin' => $contentmagazin, 'magazin' => $magazin]);
                 //$message->attach(dirname(dirname(__DIR__)).'/frontend/web/files/'.$magazin->level.'-'.$magazin->getDaytoNow().'.docx');
                 $message->setTo($magazin->email)->setFrom([Yii::$app->params['salesEmail'] => 'Magin Gam LTD'])->setSubject('Bài tập dành cho buổi ' . $magazin->getDaytoNow() . ' sau đăng ký');
                 if ($message->send()) {
                     $magazin->Day++;
                     $magazin->save();
                     $succes++;
                 } else {
                     $fail++;
                 }
             }
         }
     }
     return 'Thành công: ' . $succes . '- Thất bại: ' . $fail;
 }
 /**
  * Lists all FLanguecenter models.
  * @return mixed
  */
 public function actionIndex()
 {
     $limit_Lang_home = FConfigParam::find()->where(['name' => 'NUMBER_LANGUE_IN_HOME'])->one();
     $query = FLanguecenter::find()->where(['is_show' => 1])->orderBy('ordinal_view ASC');
     $count = $query->count();
     $pagination = new Pagination(['defaultPageSize' => $limit_Lang_home->value, 'totalCount' => $count]);
     $models = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['models' => $models, 'pagination' => $pagination]);
 }
Ejemplo n.º 3
0
 public function run()
 {
     parent::run();
     $limit_ad = FConfigParam::find()->where(['name' => 'NUMBER_AD_IN_BODY'])->one();
     if ($limit_ad) {
         $limit = $limit_ad->value;
     } else {
         $limit = 3;
     }
     $query = FAdvertise::find()->where(['is_show' => 1, 'position' => 'body', 'show_in' => $this->lan_center])->andwhere(['<=', 'start_at', new Expression('NOW()')])->andwhere(['>=', 'end_at', new Expression('NOW()')]);
     $advertise = $query->limit($limit)->all();
     return $this->render('@frontend/views/widgets/banner', ['advertises' => $advertise]);
 }
Ejemplo n.º 4
0
 public function run()
 {
     parent::run();
     $limit_Lang_most = FConfigParam::find()->where(['name' => 'NUMBER_LANGUE_IN_MOST'])->one();
     if ($limit_Lang_most) {
         $limit = $limit_Lang_most->value;
     } else {
         $limit = 10;
     }
     $query = FLanguecenter::find()->where(['is_show' => 1])->orderBy('number DESC');
     $mostViewlangs = $query->limit($limit)->all();
     return $this->render('@frontend/views/widgets/mostView', ['mostViewlangs' => $mostViewlangs]);
 }
Ejemplo n.º 5
0
 public function run()
 {
     parent::run();
     $limit_ad = FConfigParam::find()->where(['name' => 'NUMBER_IMAGE_TOP'])->one();
     if ($limit_ad) {
         $limit = $limit_ad->value;
     } else {
         $limit = 3;
     }
     $query = FAdvertise::find()->where(['is_show' => 1, 'position' => 'top', 'type' => 'image', 'show_in' => $this->lan_center]);
     $advertise = $query->limit($limit)->all();
     $banner = null;
     if (!$advertise) {
         $query1 = FAdvertise::find()->where(['is_show' => 1, 'position' => 'top', 'type' => 'image', 'show_in' => null]);
         $banner = $query1->one();
         //print_r($banner);
         //die('hello');
     }
     return $this->render('@frontend/views/widgets/bannertop', ['advertises' => $advertise, 'banner' => $banner]);
 }