Exemplo n.º 1
0
 public function actionMinor()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $userId = Yii::$app->request->post('user_id1');
     $full_name = Yii::$app->request->post('full_name');
     $full_child_name = Yii::$app->request->post('full_child_name');
     $child_dob = Yii::$app->request->post('child_dob');
     $printed_name = Yii::$app->request->post('printed_name');
     $contact_info = Yii::$app->request->post('contact_info');
     $signature = Yii::$app->request->post('image');
     $dirPath = 'images/' . $userId;
     $filePath = $dirPath . '/' . uniqid() . '_' . $full_name . '.jpg';
     FileHelper::createDirectory($dirPath);
     $source = imagecreatefromstring(base64_decode($_POST['image']));
     imagejpeg($source, $filePath);
     imagedestroy($source);
     $model = new Minor();
     $model->full_name = $full_name;
     $model->full_child_name = $full_child_name;
     $model->child_dob = $child_dob;
     $model->printed_name = $printed_name;
     $model->contact_info = $contact_info;
     $model->signature = $filePath;
     //  $model->child_dob = date('U', strtotime($child_dob));
     $name = Minor::find()->where(['full_name' => $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];
     }
 }
Exemplo n.º 2
0
 protected function findModel($id)
 {
     if (($model = Minor::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Minor::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 8]]);
     $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, 'user_id' => $this->user_id, 'date' => $this->date, 'subscribe' => $this->subscribe, 'adult_gender' => $this->adult_gender, 'adult_dob' => $this->adult_dob, 'child_gender' => $this->child_gender, 'child_dob' => $this->child_dob, 'how_hear_id' => $this->how_hear_id]);
     $query->andFilterWhere(['like', 'full_name', $this->full_name])->andFilterWhere(['like', 'full_child_name', $this->full_child_name])->andFilterWhere(['like', 'printed_name', $this->printed_name])->andFilterWhere(['like', 'contact_info', $this->contact_info])->andFilterWhere(['like', 'signature', $this->signature])->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]);
     return $dataProvider;
 }