public function update($id = '')
 {
     $labour = $this->Model_labour->get_labour($id);
     $action = $this->post('action');
     if (!$id) {
         show_error('The labour id not defined.');
     }
     if ($action == 'update') {
         $labour = $this->post('labour');
         if (!$this->validation($this->validate_condition, $this->post('labour'))) {
             $this->errors_response();
             $this->setViewData('labour', $this->post('labour'));
         } elseif ($errors = $this->Model_common->check_with_specific_fields_with_errors($this->table, $this->existance_condition, $labour, db_condition_maker(db_field_concat($this->table, 'id'), $id, '!='))) {
             $this->setErrors($errors);
             $this->errors_response();
         } else {
             $this->Model_labour->update($id, $this->post('labour'));
             $this->redirectTO(admin_base_url('labour/update/' . $id), "The labour successfully updated.");
         }
     }
     $this->set_entry_data();
     $this->setViewData('labour', $labour);
     $this->setViewData('action', 'update');
     $this->setViewData('panel_heading', "Labour info");
     $this->render_view('register', 'labour');
 }
 public function update($id = '')
 {
     $this->setViewData('action', 'update');
     $discount = $this->Model_discount->get_discount($id);
     $action = $this->post('action');
     if (!$id) {
         show_error('The discount id not defined.');
     }
     if ($action == 'update') {
         $discount = $this->post('discount');
         $condition = array('coupon_code' => "Please provide coupon code.", 'validity' => "Please provide validity.");
         $field_check = array('coupon_code' => "The coupon code already exists.");
         if (!$this->validation($condition, $this->post('discount'))) {
             $this->errors_response();
             $this->setViewData('discount', $this->post('discount'));
         } elseif (!$this->request_array('discount_persent', $discount) && !$this->request_array('discount_amount', $discount)) {
             $this->errors_response("Give either discount persentage or discount amount of this coupon.");
         } elseif ($errors = $this->Model_common->check_with_specific_fields_with_errors(TBL_DISCOUNT, $field_check, $discount, db_condition_maker(db_field_concat(TBL_DISCOUNT, 'id'), $id, '!='))) {
             $this->setErrors($errors);
             $this->errors_response();
         } else {
             $this->Model_discount->update($id, $this->post('discount'));
             $this->redirectTO(admin_base_url('discount/update/' . $id), "The discount successfully updated.");
         }
     }
     $this->setViewData('discount', $discount);
     $this->setViewData('panel_heading', "Discount info");
     $this->render_view('register', 'discount');
 }
 public function update($id = '')
 {
     $this->setViewData('action', 'update');
     $agency = $this->Model_agency->get_agency($id);
     $action = $this->post('action');
     if (!$id) {
         show_error('The agency id not defined.');
     }
     if ($action == 'update') {
         $agency = $this->post('agency');
         $condition = array('registration_no' => "Please provide registration no.", 'owner_name' => "Please provide owner name.", 'owner_contact_no' => "Please provide contact no.", 'city' => "Please provide city.", 'pin_code' => "Please provide pin code.", 'agency_bank_name' => "Please provide bank name.", 'agency_bank_accont_no' => "Please provide bank A/C no.");
         $field_check = array('registration_no' => "The registration no already exists.", 'owner_contact_no' => "The owner contact no already exists.", 'agency_bank_accont_no' => "The bank account no already exists.");
         if (!$this->validation($condition, $this->post('agency'))) {
             $this->errors_response();
             $this->setViewData('agency', $this->post('agency'));
         } elseif ($errors = $this->Model_common->check_with_specific_fields_with_errors(TBL_AGENCIES, $field_check, $agency, db_condition_maker(db_field_concat(TBL_AGENCIES, 'id'), $id, '!='))) {
             $this->setErrors($errors);
             $this->errors_response();
         } else {
             $this->Model_agency->update($id, $this->post('agency'));
             $this->redirectTO(admin_base_url('agency/update/' . $id), "The agency successfully updated.");
         }
     }
     $this->setViewData('agency', $agency);
     $this->setViewData('panel_heading', "Agency info");
     $this->render_view('register', 'agency');
 }
 public function update($id = '')
 {
     $this->setViewData('action', 'update');
     $user = $this->Model_driver->get_driver($id);
     $action = $this->post('action');
     if (!$id) {
         show_error('The driver id not defined.');
     }
     if ($action == 'update') {
         $insert_data = $user = $this->post('user');
         $condition = $this->dataArrayUnsetter($this->validate_condition, array('password'));
         if (!$this->validation($condition, $insert_data)) {
             $this->errors_response();
         } elseif ($errors = $this->Model_common->check_with_specific_fields_with_errors($this->table, $this->existance_condition, $insert_data, db_condition_maker(db_field_concat($this->table, 'id'), $id, '!='))) {
             $this->setErrors($errors);
             $this->errors_response();
         } else {
             $this->Model_driver->update($this->post('user'), $id);
             $this->redirectTO(admin_base_url('driver/update/' . $id), "The driver successfully updated.");
         }
     }
     $this->setViewData('user', $user);
     $this->setViewData('panel_heading', "Driver info");
     $this->render_view('register', 'driver');
 }