示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TbEmail::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'email_to', $this->email_to])->andFilterWhere(['like', 'email_from', $this->email_from])->andFilterWhere(['like', 'email_subject', $this->email_subject])->andFilterWhere(['like', 'email_message', $this->email_message]);
     return $dataProvider;
 }
示例#2
0
 public function actionIndex()
 {
     Yii::$app->view->title = "Lifeguard";
     if (Yii::$app->user->can("admin")) {
         $this->layout = "admin";
         //$list= Yii::app()->db->createCommand('select * from post where category=:category')->bindValue('category',$category)->queryAll();
         $list_user = Yii::$app->db->createCommand("SELECT DATE_FORMAT(FROM_UNIXTIME(created_at), '%Y-%m') as 'created_at_date', COUNT('created_at_date') as 'count_date' FROM `user` GROUP BY `created_at_date` ORDER BY `created_at_date`")->queryAll();
         $list_user_status = Yii::$app->db->createCommand("SELECT status, COUNT(status) as count_user FROM `user` WHERE 1 GROUP BY status")->queryAll();
         $count_user = User::find()->count();
         $count_email = TbEmail::find()->count();
         $array_user_status = array();
         foreach ($list_user_status as $user) {
             $label = "";
             switch ($user['status']) {
                 case User::STATUS_LOCK:
                     $label = "Locked";
                     break;
                 case User::STATUS_ACTIVE:
                     $label = "Active";
                     break;
                 case User::STATUS_WAITING:
                     $label = "Inactive";
                     break;
                 case User::STATUS_DELETED:
                     $label = "Deleted";
                     break;
                 default:
                     $label = "Other";
             }
             $array_user_status[] = array("value" => $user["count_user"], "label" => $label);
         }
         return $this->render("admin-index", ['list_user' => $list_user, "array_user_status" => $array_user_status, "count_user" => $count_user, "count_email" => $count_email]);
     } else {
         if (!Yii::$app->user->isGuest) {
             $this->layout = "user";
         }
         return $this->render('index');
     }
 }
示例#3
0
 /**
  * Finds the TbEmail model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TbEmail the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TbEmail::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }