Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $mode = false)
 {
     if ($this->getScenario() === 'forSalon') {
         $query = UsersData::find()->forSalon();
     } elseif ($this->getScenario() === 'inBlack' or $this->getScenario() === 'inBlack-moderate') {
         $query = UsersData::find()->inBlack();
     } elseif ($this->getScenario() === 'inBlack-notmoderate') {
         $query = UsersData::find()->inBlackNotModerated();
     } else {
         $query = UsersData::find();
     }
     if ($this->getScenario() === 'inBlack-notmoderate') {
     }
     $dataProviderParam = ['query' => $query];
     if ($this->getScenario() === 'inBlack') {
         $dataProviderParam['sort'] = false;
     }
     $dataProvider = new ActiveDataProvider($dataProviderParam);
     $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');
         if ($this->getScenario() === 'inBlack' or $this->getScenario() === 'inBlack-notmoderate') {
             $query->where('0=1');
         }
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'account_id' => $this->account_id, 'salon_account_id' => $this->salon_account_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'document_num' => $this->document_num, 'is_black' => $this->is_black, 'city_id' => $this->city_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'full_name', $this->full_name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'is_organization', $this->is_organization])->andFilterWhere(['like', 'passport_number', $this->passport_number])->andFilterWhere(['like', 'passport_serion', $this->passport_serion])->andFilterWhere(['like', 'birth_date', $this->birth_date])->andFilterWhere(['like', 'address_reg', $this->address_reg])->andFilterWhere(['like', 'address_fact', $this->address_fact])->andFilterWhere(['like', 'license_number', $this->license_number])->andFilterWhere(['like', 'license_date', $this->license_date])->andFilterWhere(['like', 'image_passport_photo', $this->image_passport_photo])->andFilterWhere(['like', 'image_passport_reg', $this->image_passport_reg])->andFilterWhere(['like', 'image_drive_licence', $this->image_drive_licence])->andFilterWhere(['like', 'inn', $this->inn])->andFilterWhere(['like', 'kpp', $this->kpp])->andFilterWhere(['like', 'ogrn', $this->ogrn])->andFilterWhere(['like', 'okpo', $this->okpo])->andFilterWhere(['like', 'r_sch', $this->r_sch])->andFilterWhere(['like', 'bank', $this->bank])->andFilterWhere(['like', 'k_sch', $this->k_sch])->andFilterWhere(['like', 'bik', $this->bik])->andFilterWhere(['like', 'director', $this->director])->andFilterWhere(['like', 'is_confirmed', $this->is_confirmed])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'passport_give', $this->passport_give]);
     return $dataProvider;
 }
Example #2
0
 protected function findModel($id)
 {
     if (($model = UsersData::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function actionReserveACarStepLogin($id)
 {
     $loginModel = new \frontend\modules\account\models\LoginForm();
     if (!Yii::$app->user->isGuest) {
         //after login get default userdata
         $rentModel = $this->findRentModel($id);
         $currentUserdata = $rentModel->userData;
         $userData = UsersData::getUserDataForReserve(Yii::$app->user->id, $rentModel->system->account_id);
         $currentUserdata->setAttributes($userData->getAttributes());
         $currentUserdata->save();
         return $this->redirect(['/cars/reserve-a-car-step2', 'id' => $id]);
     } else {
         $rentModel = $this->findRentModelNotAuth($id);
         $systemModel = $rentModel->system;
         $loginModel->phone = $rentModel->phone;
     }
     return $this->render('reserveCar', ['systemModel' => $systemModel, 'rentModel' => $rentModel, 'stepForm' => 'auth', 'loginModel' => $loginModel]);
 }
Example #4
0
 public function actionGetProtectedImage($userdataid, $file, $w = '1200', $h = '1200')
 {
     $resImage = false;
     if (!Yii::$app->user->isGuest) {
         $userData = UsersData::findOne($userdataid);
         if ($userData) {
             $resImage = $userData->getThumbSecretPhoto($userdataid, $file, $w, $h);
         }
         if ($resImage) {
             $resImage->show('jpg', ['quality' => 80]);
         }
     }
     Yii::$app->end();
 }
Example #5
0
 public static function getCountInBlack()
 {
     return UsersData::find()->inBlack()->count();
 }
Example #6
0
 public function getUserData()
 {
     //return $this->hasOne(UsersData::className(), ['account_id' => 'id', 'salon_account_id' => 'id']);
     return UsersData::findOne(['account_id' => $this->id, 'salon_account_id' => null]);
 }