Exemple #1
0
 protected function findModel($id)
 {
     if (($model = Adult::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if ($this->date != null) {
         $this->date = date('U', strtotime($this->date));
     }
     $query = Adult::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 8]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'date' => $this->date, 'adult_gender' => $this->adult_gender, 'adult_dob' => $this->adult_dob, 'subscribe' => $this->subscribe, 'how_hear_id' => $this->how_hear_id]);
     $query->andFilterWhere(['like', 'user_full_name', $this->user_full_name])->andFilterWhere(['like', 'printed_name', $this->printed_name])->andFilterWhere(['like', 'signature_img', $this->signature_img])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'state', $this->state]);
     if ($this->date != null) {
         $this->date = date('d-m-Y', $this->date);
     }
     return $dataProvider;
 }
Exemple #3
0
 public function actionAdult()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new Adult();
     $userId = Yii::$app->request->post('user_id1');
     //  $signature = Yii::$app->request->post('signature');
     $model->user_full_name = Yii::$app->request->post('full_name');
     $model->adult_dob = Yii::$app->request->post('adult_dob');
     $model->printed_name = Yii::$app->request->post('printed_name');
     $dirPath = 'images/' . $userId;
     $filePath = $dirPath . '/' . uniqid() . '_' . $model->user_full_name . '.jpg';
     FileHelper::createDirectory($dirPath);
     $source = imagecreatefromstring(base64_decode($_POST['image']));
     imagejpeg($source, $filePath);
     imagedestroy($source);
     $model->signature_img = $filePath;
     $name = Adult::find()->where(['user_full_name' => $model->user_full_name])->one();
     if ($name) {
         return ['status' => 'error', 'error' => array('login' => 'Record ' . $name . ' has already been added.')];
     } elseif ($model->save()) {
         return ['status' => 'success', 'data' => $model];
     } else {
         return ['status' => 'error', 'data' => $model];
     }
 }