Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Blog::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['blog_id' => $this->blog_id, 'user_id' => $this->user_id, 'category_id' => $this->category_id, 'date_create' => $this->date_create]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     $mregional = new Regional();
     $mcustomer = new Customer();
     $session = new Session();
     $company = $session->get('company');
     $facebook = Facebook::find()->asArray()->count();
     $twitter = Twitter::find()->asArray()->count();
     $blog = Blog::find()->asArray()->count();
     $instagram = Instagram::find()->asArray()->count();
     $customer = Customer::find()->asArray()->count();
     $customer_countall = $mcustomer->find()->limit(7)->count();
     $regional = $mregional->find()->limit(7)->all();
     $speedo = "";
     foreach ($regional as $key => $rows) {
         $customer_count = $mcustomer->find()->where(['FIELD7' => $rows->FIELD1])->andWhere(['FIELD9' => $company])->limit(7)->count();
         $no = $key + 1;
         $percentage = $customer_count / $customer_countall * 100;
         $agree = number_format($percentage, 0, '.', '.');
         $speedo .= "<div class='wrapp-spedo'>\n            <div id='speedo" . $no . "'>\n              " . $agree . "\n            </div>\n            <h4 align='center'>REGIONAL " . $no . "</h4>\n          </div>";
     }
     return $this->render('index', ['speedo' => $speedo, 'facebook' => $facebook, 'twitter' => $twitter, 'blog' => $blog, 'instagram' => $instagram, 'customer' => $customer]);
 }
 /**
  * Lists all Blog models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = Blog::find()->orderBy(['blog_id' => SORT_DESC])->all();
     return $this->render('index', ['models' => $model]);
 }