Ejemplo n.º 1
0
 public static function ddlStatemst()
 {
     $statemsts = Statemst::find()->all();
     $data = array();
     foreach ($statemsts as $statemst) {
         $data[$statemst->stte_no] = trim(Utf8ToHtml::decrypt($statemst->stte_name1, 'UTF-8'));
     }
     return $data;
 }
Ejemplo n.º 2
0
 public static function ddlMajormst()
 {
     $majormsts = ResrveMajormst::find()->all();
     $data = array();
     foreach ($majormsts as $majormst) {
         $data[$majormst->rm_no] = trim(Utf8ToHtml::decrypt($majormst->rm_name1, 'UTF-8'));
     }
     return $data;
 }
 /**
  * Updates an existing ResrveCustomer model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $data['model'] = $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $model->customer_last_name = Utf8ToHtml::encrypt($model->customer_last_name, '');
         $model->customer_first_name = Utf8ToHtml::encrypt($model->customer_first_name, '');
         $model->customer_nickname = Utf8ToHtml::encrypt($model->customer_nickname, '');
         $model->customer_parent_name = Utf8ToHtml::encrypt($model->customer_parent_name, '');
         $model->customer_parent_last_name = Utf8ToHtml::encrypt($model->customer_parent_last_name, '');
         $model->customer_address1 = Utf8ToHtml::encrypt($model->customer_address1, '');
         $model->customer_birthdate = $_POST['birthdate_y'] . '-' . $_POST['birthdate_m'] . '-' . $_POST['birthdate_d'];
         if ($model->save()) {
             Yii::$app->session->setFlash('success', 'แก้ไขข้อมสมัครเรียบร้อยแล้ว');
         } else {
             echo '<pre>';
             print_r($model->getErrors());
             echo '</pre>';
         }
     }
     //Decode UTF-8
     $model->customer_last_name = Utf8ToHtml::decrypt($model->customer_last_name, 'UTF-8');
     $model->customer_first_name = Utf8ToHtml::decrypt($model->customer_first_name, 'UTF-8');
     $model->customer_nickname = Utf8ToHtml::decrypt($model->customer_nickname, 'UTF-8');
     $model->customer_parent_name = Utf8ToHtml::decrypt($model->customer_parent_name, 'UTF-8');
     $model->customer_parent_last_name = Utf8ToHtml::decrypt($model->customer_parent_last_name, 'UTF-8');
     $model->customer_address1 = Utf8ToHtml::decrypt($model->customer_address1, 'UTF-8');
     $data['birthdate_cur_d'] = date("d", strtotime($model->customer_birthdate));
     $data['birthdate_cur_m'] = date("n", strtotime($model->customer_birthdate));
     $data['birthdate_cur_y'] = date("Y", strtotime($model->customer_birthdate));
     $data['model'] = $model;
     $data['birthdate_d'] = array();
     for ($d = 1; $d <= 31; $d++) {
         $data['birthdate_d'][$d] = $d;
     }
     $data['birthdate_y'] = array();
     for ($y = date('Y'); $y >= date('Y') - 60; $y--) {
         $data['birthdate_y'][$y] = $y;
     }
     $data['birthdate_m'] = array(1 => 'มกราคม', 2 => 'กุมภาพันธ์', 3 => 'มีนาคม', 4 => 'เมษายน', 5 => 'พฤษภาคม', 6 => 'มิถุนายน', 7 => 'กรกฎาคม', 8 => 'สิงหาคม', 9 => 'กันยายน', 10 => 'ตุลาคม', 11 => 'พฤศจิกายน', 12 => 'ธันวาคม');
     $data['classLevels'] = ResrveClasslevel::ddlClassLevel();
     $data['majormsts'] = ResrveMajormst::ddlMajormst();
     $data['schools'] = ResrveSchool::ddlSchool();
     $data['statemsts'] = Statemst::ddlStatemst();
     return $this->render('update', $data);
 }