예제 #1
0
 public function actionOfficecustomstat()
 {
     $offices = MOffice::findAll(['gh_id' => 'gh_03a74ac96138']);
     $rows = [];
     $custom_count = [];
     foreach ($offices as $office) {
         //$row = [];
         $row['office_id'] = $office->office_id;
         $row['office_title'] = $office->title;
         $custom = Custom::findOne(['office_id' => $office->office_id]);
         if ($custom !== null) {
             $custom_counts = Custom::find()->select('*, count(*) as c')->where('office_id=:office_id', [':office_id' => $office->office_id])->groupBy(['office_id'])->orderBy('office_id')->asArray()->all();
             foreach ($custom_counts as $custom_count) {
                 $row['custom_count'] = $custom_count['c'];
             }
         } else {
             continue;
         }
         $rows[] = $row;
     }
     //print_r($custom_count);
     //U::W("####################################");
     //U::W($rows);
     //U::W($custom_count);
     $filter = new \app\models\FiltersForm();
     $filter->unsetAttributes();
     if (isset($_GET['FiltersForm'])) {
         $filter->setAttributes($_GET['FiltersForm'], false);
     }
     $rows = $filter->filterArrayData($rows);
     $dataProvider = new ArrayDataProvider(['allModels' => $rows, 'sort' => ['attributes' => ['office_id', 'office_title', 'custom_count'], 'defaultOrder' => ['custom_count' => SORT_DESC]], 'pagination' => ['pageSize' => 50]]);
     return $this->render('officecustomstat', ['dataProvider' => $dataProvider, 'filter' => $filter]);
 }
예제 #2
0
 /**
  * Finds the Custom model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Custom the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Custom::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
 public function actionClientCustomer($gh_id, $openid, $customer_id, $backwards = true, $pop = false)
 {
     if (!$backwards) {
         \app\models\utils\BrowserHistory::delete($gh_id, $openid);
         \app\models\utils\BrowserHistory::push($gh_id, $openid);
     } else {
         if ($pop) {
             \app\models\utils\BrowserHistory::pop($gh_id, $openid);
         } else {
             \app\models\utils\BrowserHistory::push($gh_id, $openid);
         }
     }
     $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     $customer = \app\models\Custom::findOne(['custom_id' => $customer_id]);
     $this->layout = false;
     return $this->render('client-customer', ['wx_user' => $wx_user, 'backwards' => $backwards, 'customer' => $customer]);
 }
예제 #4
0
 public function actionImportcustom()
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'custom.txt';
     $fh = fopen($file, "r");
     $i = 0;
     while (!feof($fh)) {
         $line = fgets($fh);
         if (empty($line)) {
             continue;
         }
         $arr = explode("\t", $line);
         $arr[1] = iconv('GBK', 'UTF-8//IGNORE', $arr[1]);
         $arr[2] = iconv('GBK', 'UTF-8//IGNORE', $arr[2]);
         $mobile = trim($arr[0]);
         $name = trim($arr[1]);
         $office_title = trim($arr[2]);
         $office = MOffice::findOne(['gh_id' => 'gh_03a74ac96138', 'title' => $office_title]);
         if (empty($office)) {
             U::W(['office_title is invalid', $arr]);
             exit;
         }
         $custom = Custom::findOne(['mobile' => $mobile]);
         if (!empty($custom)) {
             //U::W("mobile=$mobile already exists");
             //U::W($arr);
         } else {
             $custom = new Custom();
         }
         $custom->mobile = $mobile;
         $custom->name = $name;
         $custom->office_id = $office->office_id;
         $custom->save(false);
         $i++;
         if ($i % 1000 == 1) {
             U::W($i);
         }
     }
     fclose($fh);
 }