Пример #1
0
 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]);
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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(['id' => $this->id, 'phone_number' => $this->phone_number, 'dob' => $this->dob, 'gender' => $this->gender, 'language_id' => $this->language_id, 'is_active' => $this->is_active, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'total_purchase_orders' => $this->total_purchase_orders, 'total_purchase_products' => $this->total_purchase_products, 'total_purchase_value' => $this->total_purchase_value]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_path', $this->image_path])->andFilterWhere(['like', 'zip_postal_code', $this->zip_postal_code]);
     return $dataProvider;
 }
Пример #3
0
 public function actionGet()
 {
     $modelList = Customer::find()->where(['level' => Variable::$customer_type_w])->all();
     $jsonList = [];
     foreach ($modelList as $k => $v) {
         if ($v->level != Variable::$customer_type_w) {
             continue;
         }
         if (empty($v->parentId)) {
             continue;
         }
         if (!isset($v->parent) || empty($v->parent)) {
             continue;
         }
         $id = '1_' . $v->parent->id;
         $item = [];
         $tmp = [];
         $pic = [];
         if ($v->img1) {
             array_push($pic, FVariable::$domainUrl . $v->img1);
         }
         if ($v->img2) {
             array_push($pic, FVariable::$domainUrl . $v->img2);
         }
         if ($v->img3) {
             array_push($pic, FVariable::$domainUrl . $v->img3);
         }
         if ($v->img4) {
             array_push($pic, FVariable::$domainUrl . $v->img4);
         }
         if ($v->img5) {
             array_push($pic, FVariable::$domainUrl . $v->img5);
         }
         $tmp = ['name' => $v->name, 'pic' => $pic];
         $jsonList[$id]['item'][] = $tmp;
     }
     echo json_encode($jsonList);
 }
Пример #4
0
 public function actionCreatejsonkota()
 {
     $mcustomer = new Customer();
     $mkota = new Kota();
     $kota = $mkota->find()->all();
     $total = $mcustomer->find()->count();
     $labels = $mcustomer->attributeLabels();
     $array = array();
     $file = "uploads/json/customer/attributekota.json";
     fopen($file, "w");
     foreach ($kota as $row) {
         $namekota = $row->FIELD2;
         foreach ($labels as $key => $rows) {
             $label = strtoupper($rows);
             $filled = $mcustomer->find()->where($key . ' IS NOT NULL')->count();
             $notfilled = $mcustomer->find()->where($key . ' IS NULL')->count();
             array_push($array, array('kota' => $namekota, 'attribute' => array('labels' => $label, 'count' => $total, 'filled' => $filled, 'notfilled' => $notfilled)));
         }
     }
     $data = json_encode($array, JSON_PRETTY_PRINT);
     file_put_contents($file, $data);
 }