Example #1
0
 public function run($args)
 {
     $user_info = Admin::model()->findAll();
     $count = Advice::model()->count('status=0');
     foreach ($user_info as $row) {
         if ($row->send_email == 0 || empty($row->email)) {
             continue;
         }
         $message = "您今天新增" . $count . "条后勤办反馈建议\n\t        \t\t'http://localhost/logistics/index.php?r=admin/index/index' 点击链接登录后台进行查看";
         $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
         $mailer->Host = 'smtp.qq.com';
         $mailer->IsSMTP();
         $mailer->SMTPAuth = true;
         $mailer->From = '*****@*****.**';
         $mailer->AddReplyTo("{$row->email}");
         $mailer->AddAddress("{$row->email}");
         $mailer->FromName = '你大爷';
         $mailer->Username = '******';
         //这里输入发件地址的用户名
         $mailer->Password = '******';
         //这里输入发件地址的密码
         $mailer->SMTPDebug = true;
         //设置SMTPDebug为true,就可以打开Debug功能,根据提示去修改配置
         $mailer->CharSet = 'UTF-8';
         $mailer->Subject = Yii::t('demo', 'Yii rulez!');
         $mailer->Body = $message;
         $x = $mailer->Send();
         $x = $mailer->Send();
     }
 }
Example #2
0
 /**
  *  发布一则反馈
  */
 public function actionUpdateStatus($aid = 0)
 {
     if ($aid != 0) {
         $model = Advice::model()->findByPk($aid);
         if (isset($model->aid)) {
             $model->attributes = array('status' => 1);
         }
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->redirect(array('index'));
 }
Example #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Advice the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Advice::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 /**
  * 选时间段画出统计图
  */
 private function analyse($time = -1, $all = 1)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'cid';
     if ($all == 0) {
         $criteria->addCondition('`status`=0');
     }
     if ($time > 0) {
         $start_time = date("Y-m-d H:i:s", strtotime("-{$time} week"));
         $end_time = date("Y-m-d H:i:s", time());
         $criteria->addCondition("create_time>'" . $start_time . "'");
         $criteria->addCondition("create_time<'" . $end_time . "'");
     } else {
         if ($time == 0) {
             $end_time = date("Y-m-d H:i:s", strtotime("{$time} week"));
             $start_time = date("Y-m-d 00:00:00", time());
             $criteria->addCondition("create_time>'" . $start_time . "'");
             $criteria->addCondition("create_time<'" . $end_time . "'");
         }
     }
     $model = Advice::model()->findAll($criteria);
     if (count($model) == 0) {
         return array();
     }
     $data = array();
     $cate_name = array();
     $cates = Category::model()->findAll();
     foreach ($cates as $row) {
         $cate_name[$row->cid] = $row->cname;
         $data[$cate_name[$row->cid]] = 0;
     }
     foreach ($model as $row) {
         $data[$cate_name[$row->cid]]++;
     }
     return $data;
 }
 /**
  *  查看近一个星期的反馈情况
  */
 private function analyse($id)
 {
     $criteria = new CDbCriteria();
     $criteria->select = array('create_time');
     $criteria->addCondition('cid=' . $id);
     $start_time = date("Y-m-d H:i:s", strtotime("-1 week"));
     $end_time = date("Y-m-d H:i:s", time());
     $criteria->addCondition("create_time>'" . $start_time . "'");
     $criteria->addCondition("create_time<'" . $end_time . "'");
     //$criteria -> order =  'create_time desc';
     $model = Advice::model()->findAll($criteria);
     if (count($model) == 0) {
         return array();
     }
     $data = array();
     for ($i = 0; $i < 7; $i++) {
         $data[date("Y-m-d ", strtotime("-{$i} day"))] = 0;
     }
     foreach ($model as $row) {
         $date = substr($row->create_time, 0, 10);
         $data[$date]++;
     }
     return $data;
 }