Example #1
0
 public function screen_modify_project()
 {
     $btn1 = "";
     $btn2 = "";
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
         $_SESSION['id'] = $id;
         $CustomerModel = new CustomerModel();
         $project_data = $CustomerModel->get_project_raw($id);
         $default_t_start = array('Y' => substr($project_data['t_start'], 0, 4), 'm' => substr($project_data['t_start'], 4, 2), 'd' => substr($project_data['t_start'], 6, 2));
         $default_t_end = array('Y' => substr($project_data['t_end'], 0, 4), 'm' => substr($project_data['t_end'], 4, 2), 'd' => substr($project_data['t_end'], 6, 2));
         $default_shift_start = array('H' => substr($project_data['shift_start'], 0, 2), 'i' => substr($project_data['shift_start'], 2, 2));
         $default_shift_end = array('H' => substr($project_data['shift_end'], 0, 2), 'i' => substr($project_data['shift_end'], 2, 2));
         $setDefaults = array('valid' => $project_data['valid'], 'project_type' => $project_data['project_type'], 't_start' => $default_t_start, 't_end' => $default_t_end, 'shift_start' => $default_shift_start, 'shift_end' => $default_shift_end, 'title' => $project_data['title'], 'project_content' => $project_data['project_content'], 'area_type1' => $project_data['area_type'], 'salary_per_hour' => $project_data['salary_per_hour'], 'transportation' => $project_data['transportation'], 'valid' => array('valid' => $project_data['valid']));
         $this->form->setDefaults($setDefaults);
     }
     $this->make_customer_regist_project();
     $this->make_form_project_area();
     $this->make_select_form_project_type();
     if (isset($_POST['re'])) {
         $data = $this->form->getSubmitValues();
         $this->check_screen_regist_project($data);
     }
     if ($this->action == "form") {
         $this->title = "更新ページ";
         $this->next_type = "modify_project";
         $this->next_action = "confirm";
         $this->file = "customer_regist_project.tpl";
         $btn1 = "確認";
     } else {
         if ($this->action == "confirm" && isset($_POST['submit1']) && $_POST['submit1'] == "確認") {
             $this->form->freeze();
             $this->title = "更新ページ";
             $this->message = "下記で宜しいでしょうか?";
             $this->next_type = "modify_project";
             $this->next_action = "complete";
             $this->file = "customer_regist_project.tpl";
             $btn1 = "更新";
             $btn2 = "戻る";
         } else {
             if ($this->action == "complete" && isset($_POST['submit2']) && $_POST['submit2'] == "戻る") {
                 $this->title = "更新ページ";
                 $this->next_type = "modify_project";
                 $this->next_action = "confirm";
                 $this->file = "customer_regist_project.tpl";
                 $btn1 = "確認";
             } else {
                 if ($this->action == "complete" && isset($_POST['submit1']) && $_POST['submit1'] == "更新") {
                     $data['t_start'] = sprintf("%04d%02d%02d", $data['t_start']['Y'], $data['t_start']['m'], $data['t_start']['d']);
                     $data['t_end'] = sprintf("%04d%02d%02d", $data['t_end']['Y'], $data['t_end']['m'], $data['t_end']['d']);
                     $data['shift_start'] = sprintf("%02d%02d", $data['shift_start']['H'], $data['shift_start']['i']);
                     $data['shift_end'] = sprintf("%02d%02d", $data['shift_end']['H'], $data['shift_end']['i']);
                     $data['valid'] = $data['valid']['valid'];
                     $id = $_SESSION['id'];
                     unset($_SESSION['id']);
                     $CustomerModel = new CustomerModel();
                     $CustomerModel->modify_project($data, $id);
                     if ($this->is_system) {
                         header("Location:http://localhost/system.php?type=list_project&flag=modify");
                         exit;
                     } else {
                         header("Location:http://localhost/customer.php?type=list_project&flag=modify");
                         exit;
                     }
                 }
             }
         }
     }
     $this->form->addElement('submit', 'submit1', $btn1);
     $this->form->addElement('submit', 'submit2', $btn2);
     $this->form->addElement('reset', 'reset', "");
     $this->view_display();
 }