/** * Finds the Questionnaire model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Questionnaire the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Questionnaire::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIndex() { if (array_key_exists('lang', $_GET)) { Yii::$app->language = $_GET['lang']; } else { Yii::$app->language = 'en'; } $model = new Questionnaire(); if ($model->load(Yii::$app->request->post())) { // get multiple clothing options if (is_array($model->clothing)) { $model->clothing = join(",", $model->clothing); } // save to database if ($model->save()) { return $this->render('success'); } } return $this->render('index', ['model' => $model]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Questionnaire::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'occupation' => $this->occupation, 'office' => $this->office, 'choice_content' => $this->choice_content, 'choice_contest' => $this->choice_contest, 'choice_seminar' => $this->choice_seminar, 'choice_ict' => $this->choice_ict, 'choice_food' => $this->choice_food, 'choice_news' => $this->choice_news, 'choice_register' => $this->choice_register, 'choice_environment' => $this->choice_environment, 'choice_audiovisual' => $this->choice_audiovisual, 'choice_location' => $this->choice_location, 'choice_overall' => $this->choice_overall, 'adjust' => $this->adjust, 'batter' => $this->batter, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = QuestionnaireModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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_ank' => $this->id_ank]); $query->andFilterWhere(['like', 'name_ua', $this->name_ua])->andFilterWhere(['like', 'name_ru', $this->name_ru]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Questionnaire::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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; } $username = Yii::$app->user->identity->username; $query->andWhere('altered = 1')->andWhere("creation_name = '{$username}'"); $query->andFilterWhere(['id' => $this->id, 'fk_person' => $this->fk_person, 'date_interview' => $this->date_interview, 'time_interview' => $this->time_interview, 'mal_episodes' => $this->mal_episodes, 'dates_mal_occured' => $this->dates_mal_occured, 'left_date' => $this->left_date, 'return_date' => $this->return_date, 'mother_edu_level' => $this->mother_edu_level, 'child_5yrs_late' => $this->child_5yrs_late, 'toilet_type' => $this->toilet_type, 'floor_type' => $this->floor_type, 'fuel_type' => $this->fuel_type, 'household_own' => $this->household_own]); $query->andFilterWhere(['like', 'pregnant', $this->pregnant])->andFilterWhere(['like', 'menstruating', $this->menstruating])->andFilterWhere(['like', 'lmp', $this->lmp])->andFilterWhere(['like', 'ever_diagnosed_hbp', $this->ever_diagnosed_hbp])->andFilterWhere(['like', 'under_med_hbp', $this->under_med_hbp])->andFilterWhere(['like', 'hbp_med_list', $this->hbp_med_list])->andFilterWhere(['like', 'suffered_malaria', $this->suffered_malaria])->andFilterWhere(['like', 'mal_hospitalised', $this->mal_hospitalised])->andFilterWhere(['like', 'other_med_condition', $this->other_med_condition])->andFilterWhere(['like', 'med_condition_list', $this->med_condition_list])->andFilterWhere(['like', 'place_of_birth', $this->place_of_birth])->andFilterWhere(['like', 'date_of_relocation', $this->date_of_relocation])->andFilterWhere(['like', 'places_before_relocation', $this->places_before_relocation])->andFilterWhere(['like', 'Longest_time_away', $this->Longest_time_away])->andFilterWhere(['like', 'place_away', $this->place_away])->andFilterWhere(['like', 'household_school_greater_5', $this->household_school_greater_5])->andFilterWhere(['like', 'household_not_attend_primary', $this->household_not_attend_primary])->andFilterWhere(['like', 'household_malnourished', $this->household_malnourished])->andFilterWhere(['like', 'electricity', $this->electricity])->andFilterWhere(['like', 'share_toilet', $this->share_toilet])->andFilterWhere(['like', 'safe_drinking_water', $this->safe_drinking_water])->andFilterWhere(['like', 'time_safe_water_access', $this->time_safe_water_access])->andFilterWhere(['like', 'creation_name', $this->creation_name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getQuestionnaires() { return $this->hasMany(Questionnaire::className(), ['fk_person' => 'pk_person']); }
public function import_excel(Request $request) { $file = $request->file('file_excel'); $destinationPath = storage_path() . '/file_excel'; if ($request->hasFile('file_excel')) { $filename = $file->getClientOriginalName(); $ext = $file->getClientOriginalExtension(); if ($ext == "xls" || $ext == "xlsx") { if ($file->isValid()) { $file->move($destinationPath, $filename); $dataTest = Excel::load(storage_path('file_excel') . '/' . $filename, function ($reader) { })->get(); //dd($dataTest[0]); foreach ($dataTest[0] as $data) { /**ข้อมูลส่วนตัว**/ $input_profile = new Alumni(); $input_profile->year_of_graduation = $data->year_of_graduation; $input_profile->national_id = $data->national_id; $input_profile->student_id = $data->student_id; $input_profile->title = $data->title; $input_profile->firstname = $data->firstname; $input_profile->lastname = $data->lastname; $input_profile->birthdate = $data->birthdate; $input_profile->gpa = $data->gpa; $input_profile->house_no = $data->house_no; $input_profile->moo = $data->moo; $input_profile->soi = $data->soi; $input_profile->road = $data->road; $input_profile->district = $data->district; $input_profile->amphur = $data->amphur; $input_profile->province = $data->province; $input_profile->phone = $data->phone; $input_profile->zipcode = $data->zipcode; $input_profile->email = $data->email; $input_profile->education = $data->education; $input_profile->faculty = $data->faculty; $input_profile->branch = $data->branch; $input_profile->firstname = $data->firstname; $input_profile->course = $data->course; $input_profile->save(); ///////////////// /**ข้อมูลสถานที่ทำงาน**/ $input_workplace = new Workplace(); $input_workplace->office = $data->office; $input_workplace->number_office = $data->number_office; $input_workplace->moo_office = $data->moo_office; $input_workplace->building_office = $data->building_office; $input_workplace->class_office = $data->class_office; $input_workplace->soi_office = $data->soi_office; $input_workplace->road_office = $data->road_office; $input_workplace->amphur_office = $data->amphur_office; $input_workplace->district_office = $data->district_office; $input_workplace->province_office = $data->province_office; $input_workplace->zipcode_office = $data->zipcode_office; $input_workplace->phone_office = $data->phone_office; $input_workplace->fax_office = $data->fax_office; $input_workplace->email_office = $data->email_office; $input_workplace->salary = $data->salary; if ($input_profile != null) { $input_workplace->alumni()->associate($input_profile); $input_workplace->save(); } /**ข้อมูลแบบสอบถาม**/ $input_questionnaire = new Questionnaire(); $input_questionnaire->the_knowledge_that_students_applied_to_work_done = $data->the_knowledge_that_students_applied_to_work_done; $input_questionnaire->reasons_to_study = $data->reasons_to_study; $input_questionnaire->the_reason_is_that_no_jobs = $data->the_reason_is_that_no_jobs; $input_questionnaire->work_directly_with_the_subject_matter = $data->work_directly_with_the_subject_matter; $input_questionnaire->issues_in_education = $data->issues_in_education; $input_questionnaire->field_of_study = $data->field_of_study; $input_questionnaire->to_study_or_not = $data->to_study_or_not; $input_questionnaire->talent_helps_to_work = $data->talent_helps_to_work; $input_questionnaire->time_to_get_the_job_done = $data->time_to_get_the_job_done; $input_questionnaire->difficulties_in_finding_jobs = $data->difficulties_in_finding_jobs; $input_questionnaire->agencies = $data->agencies; $input_questionnaire->satisfaction_with_the_work_done = $data->satisfaction_with_the_work_done; $input_questionnaire->functional_status = $data->functional_status; $input_questionnaire->position = $data->position; $input_questionnaire->category = $data->category; $input_questionnaire->types_of_work = $data->types_of_work; if ($input_profile != null) { $input_questionnaire->alumni()->associate($input_profile); $input_questionnaire->save(); } } return redirect('admin/import')->with('status', 'Import Success!!'); } else { return redirect()->back()->with('status', 'file is valid'); } } else { return redirect()->back()->with('status', 'no file xls or xlsx!!'); } } else { return redirect()->back()->with('no file failed'); } }