public function actionIndex() { $model = new Admission(); $location_list = array(); $location = AdmissionLocation::model()->findAll(); foreach ($location as $locate) { $location_list[$locate->location_id] = $locate->name; } $program_list = array(); $programs = AdmissionProgram::model()->findAll(); foreach ($programs as $pro) { $program_list[$pro->program_id] = $pro->name; } if (isset($_POST['Admission'])) { list($d, $m, $y) = explode("/", $_POST['Admission']['birthday']); $birthday = $y - 543 . "-" . $m . "-" . $d; $_POST['Admission']['birthday'] = $birthday; $model->attributes = $_POST['Admission']; if ($model->save()) { Yii::app()->user->setFlash('admission', 'ส่งใบสมัครเรียนออนไลน์เรียบร้อยแล้ว ทางเราจะติดต่อกลับไปในภายหลัง ขอบคุณค่ะ'); $this->refresh(); //$this->redirect(array('index')); } } $this->render('index', array('model' => $model, 'location_list' => $location_list, 'program_list' => $program_list)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { if ($this->menu_use[14]) { $model = new Admission(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Admission'])) { $model->attributes = $_POST['Admission']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->admission_id)); } } $this->render('create', array('model' => $model)); } else { $this->redirect(array('site/index')); } }
/** * Store a newly created admission in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Admission::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $admission = new Admission(); $admission->name = Input::get('name'); $admission->date = date('Y-m-d'); $admission->id_number = Input::get('id_number'); $admission->place_of_death = Input::get('place_of_death'); $admission->cause_of_death = Input::get('cause_of_death'); $admission->certificate_no = Input::get('certificate_no'); $admission->category = Input::get('category'); $admission->admission_no = Admission::getAdmissionNumber(); $admission->kin_name = Input::get('kin_name'); $admission->kin_phone = Input::get('kin_phone'); $admission->kin_id_number = Input::get('kin_id_number'); $admission->save(); return Redirect::route('admissions.index'); }
<?php require_once '../../inc/initialize.php'; $admission_status = $_POST["admission_status"]; foreach ($_POST as $key => $value) { if ($key != "admission_status") { $applicant_id = customDecrypt($value); $admissions = new Admission(); $admissions->db_fields = array('status'); $admissions->applicant_id = $applicant_id; $admissions->status = $admission_status; $sql_adm = "select admission_id from admission_status where applicant_id='" . $admissions->applicant_id . "'"; $res_adm = Admission::find_by_sql($sql_adm); $res_adm = array_shift($res_adm); $admissions->admission_id = $res_adm->admission_id; $admissions->save(); } } echo '<h4 class="alert alert-success"><i class="iconic-o-check" style="color: #51A351"></i> Success</h4>'; echo '<hr>'; echo 'Admission status successfully set.';
<?php require_once "../../inc/initialize.php"; if (isset($_POST["aid"])) { $admission = new Admission(); $admission->db_fields = array('applicant_id', 'status', 'reason'); $admission->applicant_id = customDecrypt($_POST["aid"]); $admission->status = $_POST["eligibility_status"]; $admission->reason = $_POST["reason"]; $sql_adm = "select admission_id from admission_status where applicant_id='" . $admission->applicant_id . "'"; $res_adm = Admission::find_by_sql($sql_adm); $res_adm = array_shift($res_adm); $admission->admission_id = $res_adm->admission_id; if ($admission->save()) { sleep(2); echo '<h4 class="alert alert-success"><i class="iconic-o-check" style="color: #51A351"></i> Success</h4>'; echo '<hr>'; echo "Eligibility status for this user has been successfully saved."; echo "<br>"; echo '<hr>'; } else { sleep(2); echo '<h4 class="alert alert-error">Error</h4>'; echo '<hr>'; echo "An error occured while saving eligibility status."; echo "<br>"; echo '<hr>'; } }