Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ClientOutlet::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 24]]);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($params));
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($this));
     $this->load($params);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($this));
     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(['outlet_id' => $this->outlet_id, 'client_id' => $this->client_id, 'supervision_organization_id' => $this->supervision_organization_id, 'category' => $this->category, 'longitude' => $this->longitude, 'latitude' => $this->latitude, 'original_office_id' => $this->original_office_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'pics', $this->pics]);
     $query->andFilterWhere(['supervision_organization_id' => ClientOrganization::findOne(['organization_id' => $this->msc_id])->getMscIdArray()]);
     \Yii::warning(__METHOD__ . \yii\helpers\Json::encode($query));
     return $dataProvider;
 }
Esempio n. 2
0
 public function actionOutlets()
 {
     $outlets = \app\models\ClientOutlet::find()->all();
     foreach ($outlets as $outlet) {
         $office = \app\models\MOffice::find()->where(['title' => $outlet->title])->one();
         if (!empty($office)) {
             echo "found {$outlet->title}" . PHP_EOL;
             $details = \app\models\MOfficeCampaignDetail::findAll(['office_id' => $office->office_id]);
             $pics = [];
             foreach ($details as $detail) {
                 $pic_urls = explode(',', $detail->pic_url);
                 foreach ($pic_urls as $pic_url) {
                     $from = $detail->getPicFileByMedia($pic_url);
                     $media = str_replace('.jpg', '', $pic_url);
                     $to = $outlet->getPicPathname($media);
                     copy($from, $to);
                     $pics[] = $media;
                 }
             }
             $outlet->pics = implode(",", $pics);
             $outlet->original_office_id = $office->office_id;
             $outlet->latitude = $office->lat;
             $outlet->longitude = $office->lon;
             $outlet->save(false);
         }
     }
 }
Esempio n. 3
0
 public function actionNearestoutlets()
 {
     $this->layout = false;
     $gh_id = U::getSessionParam('gh_id');
     $openid = U::getSessionParam('openid');
     Yii::$app->wx->setGhId($gh_id);
     $gh = Yii::$app->wx->getGh();
     $jssdk = new JSSDK($gh['appid'], $gh['appsecret']);
     $clientWechat = \app\models\ClientWechat::findOne(['gh_id' => $gh_id]);
     $outlets = \app\models\ClientOutlet::find()->where(['client_id' => $clientWechat->client_id])->where(['<>', 'longitude', 0])->all();
     return $this->render('nearestoutlets', ['gh_id' => $gh_id, 'openid' => $openid, 'outlets' => $outlets, 'jssdk' => $jssdk]);
 }