public function update($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $changes = "";
         $post = security::xss_clean($this->input->post('name'));
         $district = $this->district_model->find($id);
         $changes .= custom_helper::compare_variable("District Name", $district->name, $post);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         $district->name = $post;
         log_helper::add("1", $this->user_log, $this->user_id, "Updated a District. " . $changes);
         echo json_encode($this->district_model->getOne($district->save($id)));
     }
 }
示例#2
0
 public function update($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $post = security::xss_clean($this->input->post());
         $office = $this->office_model->with('district')->find($id);
         $district = $this->district_model->find($post['district_id']);
         $changes = "";
         $changes .= custom_helper::compare_variable("Office Name", $office->name, $post['name']);
         $changes .= custom_helper::compare_variable("District Name", $office->district->name, $district->name);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         $office->district_id = $post['district_id'];
         $office->name = $post['name'];
         log_helper::add("1", $this->user_log, $this->user_id, "Updated an Office. " . $changes);
         echo json_encode($office->save()->as_array());
     }
 }
 public function update($id)
 {
     if (request::is_ajax() && request::method() == 'post') {
         $this->auto_render = FALSE;
         $changes = "";
         $post = security::xss_clean($this->input->post());
         $category = $this->category_model->find($id);
         $changes .= custom_helper::compare_variable("Category Name", $category->name, $post['name']);
         $changes .= custom_helper::compare_variable("Category Description", $category->description, $post['description']);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         //print_r($changes);exit;
         $category->name = $post['name'];
         $category->description = $post['description'];
         log_helper::add("1", $this->user_log, $this->user_id, "Updated a Category. " . $changes);
         echo $category->save();
     }
 }
 public function update($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $post = security::xss_clean($this->input->post());
         $supplier = $this->supplier_model->find($id);
         $changes = "";
         $changes .= custom_helper::compare_variable("Supplier Name", $supplier->name, $post['name']);
         $changes .= custom_helper::compare_variable("Supplier Representative", $supplier->representative, $post['representative']);
         $changes .= custom_helper::compare_variable("Supplier Contact Number", $supplier->contact_number, $post['contact_number']);
         $changes .= custom_helper::compare_variable("Supplier Email", $supplier->email, $post['email']);
         $changes .= custom_helper::compare_variable("Supplier Address", $supplier->address, $post['address']);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         foreach ($post as $key => $value) {
             $supplier->{$key} = $value;
         }
         log_helper::add("1", $this->user_log, $this->user_id, "Updated a Supplier. " . $changes);
         echo $supplier->save();
     }
 }