Example #1
0
 public function edit_post()
 {
     $data = $this->data;
     //取得公用數據
     $this->form_validation->set_rules('name_Str', '運輸名稱', 'required');
     $this->form_validation->set_rules('company_Str', '運輸公司', 'required');
     $this->form_validation->set_rules('url_Str', '輸查貨網址', 'required');
     $transportid_Num = $this->input->post('transportid_Num', TRUE);
     if ($this->form_validation->run() !== FALSE) {
         //基本post欄位
         $name_Str = $this->input->post('name_Str', TRUE);
         $company_Str = $this->input->post('company_Str', TRUE);
         $url_Str = $this->input->post('url_Str', TRUE);
         $base_price_Num = $this->input->post('base_price_Num', TRUE);
         $additional_price_Num = $this->input->post('additional_price_Num', TRUE);
         $prioritynum_Num = $this->input->post('prioritynum_Num', TRUE);
         //檢測不能重複上傳
         $transport = new Transport();
         $transport->construct_db(array('db_where_Arr' => array('transportid_Num !=' => $transportid_Num, 'name_Str' => $name_Str)));
         if (!empty($transport->transportid_Num)) {
             $this->load->model('Message');
             $this->Message->show(array('message' => '不可重複上傳相同名字的運輸方式', 'url' => 'admin/shop/transport/transport/tablelist'));
             return FALSE;
         }
         //建構Transport物件,並且更新
         $transport = new Transport();
         $transport->construct(array('transportid_Num' => $transportid_Num, 'name_Str' => $name_Str, 'company_Str' => $company_Str, 'url_Str' => $url_Str, 'base_price_Num' => $base_price_Num, 'additional_price_Num' => $additional_price_Num, 'prioritynum_Num' => $prioritynum_Num));
         $transport->update();
         //送出成功訊息
         $this->load->model('Message');
         $this->Message->show(array('message' => '設定成功', 'url' => 'admin/shop/transport/transport/tablelist'));
     } else {
         $validation_errors_Str = validation_errors();
         $validation_errors_Str = !empty($validation_errors_Str) ? $validation_errors_Str : '設定錯誤';
         $this->load->model('Message');
         $this->Message->show(array('message' => $validation_errors_Str, 'url' => 'admin/shop/transport/transport/edit/?transportid=' . $transportid_Num));
     }
 }