diff --git a/application/modules/Asset/controllers/Asset.php b/application/modules/Asset/controllers/Asset.php index 9b0c57b..757f31c 100644 --- a/application/modules/Asset/controllers/Asset.php +++ b/application/modules/Asset/controllers/Asset.php @@ -338,6 +338,7 @@ public function add_or_edit_asset_amc() $data['valid_from'] = $this->input->post('valid_from'); $data['valid_to'] = $this->input->post('valid_to'); $data['created_by'] = user()->id; + $data['type'] = 3; //(amc service provider type = 3 * in third_parties table) $createAMCData = $this->MY_Model->insert($data, 'amc'); //$this->view_asset_details(md5($this->input->post('asset_id_for_add'))); redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add'))); @@ -371,16 +372,19 @@ public function add_or_edit_asset_insurance() { $value = $this->input->post(); unset($value['asset_id_for_add']); - $editInsuranceData = $this->MY_Model->edit_option($value, $this->input->post('id'), 'asset_insurance'); + $editInsuranceData = $this->MY_Model->edit_option($value, $this->input->post('id'), 'amc'); redirect('asset/view_asset_details/'.md5($this->input->post('asset_id'))); }else{ $data['asset_id'] = $this->input->post('asset_id_for_add'); $data['business_id'] = user()->business_id; $data['insurance_company'] = $this->input->post('insurance_company'); + $data['cost'] = $this->input->post('cost'); + $data['description'] = $this->input->post('description'); $data['valid_from'] = $this->input->post('valid_from'); $data['valid_to'] = $this->input->post('valid_to'); $data['created_by'] = user()->id; - $createInsuranceData = $this->MY_Model->insert($data, 'asset_insurance'); + $data['type'] = 4; //(insurance company type = 4 * in third_parties table) + $createInsuranceData = $this->MY_Model->insert($data, 'amc'); redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add'))); } } @@ -463,7 +467,7 @@ public function deleteAssetInsurance($id) $split = preg_split('/_/', $id); $key = $split[0]; $asset_id = $split[1]; - $Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'asset_insurance'); + $Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'amc'); redirect('asset/view_asset_details/'.md5($asset_id)); } diff --git a/application/modules/Asset/models/Asset_model.php b/application/modules/Asset/models/Asset_model.php index 4b0f440..a6c4ddd 100644 --- a/application/modules/Asset/models/Asset_model.php +++ b/application/modules/Asset/models/Asset_model.php @@ -56,6 +56,7 @@ public function get_amc_with_join($id,$business_id) $this->db->where('A.business_id', $business_id); $this->db->where('md5(A.asset_id)', $id); $this->db->where('is_active', 1); + $this->db->where('A.type', 3); $query = $this->db->get(); $query = $query->result(); return $query; @@ -67,6 +68,7 @@ public function get_amc_by_id_with_join($id) $this->db->join('third_parties', 'third_parties.id = A.service_provider', 'left'); $this->db->where('md5(A.id)', $id); $this->db->where('is_active', 1); + $this->db->where('A.type', 3); $query = $this->db->get(); $query = $query->row(); return $query; @@ -75,11 +77,12 @@ public function get_amc_by_id_with_join($id) public function get_insurance_with_join($id,$business_id) { $this->db->select('A.* , third_parties.name as insurance_company_name '); - $this->db->from('asset_insurance A'); + $this->db->from('amc A'); $this->db->join('third_parties', 'third_parties.id = A.insurance_company', 'left'); $this->db->where('A.business_id', $business_id); $this->db->where('md5(A.asset_id)', $id); $this->db->where('is_active', 1); + $this->db->where('A.type', 4); $query = $this->db->get(); $query = $query->result(); return $query; @@ -87,10 +90,11 @@ public function get_insurance_with_join($id,$business_id) public function get_insurance_by_id_with_join($id) { $this->db->select('A.* , third_parties.name as insurance_company_name '); - $this->db->from('asset_insurance A'); + $this->db->from('amc A'); $this->db->join('third_parties', 'third_parties.id = A.insurance_company', 'left'); $this->db->where('md5(A.id)', $id); $this->db->where('is_active', 1); + $this->db->where('A.type', 4); $query = $this->db->get(); $query = $query->row(); return $query; diff --git a/application/modules/Asset/views/asset_amc_form.php b/application/modules/Asset/views/asset_amc_form.php index 69c500a..8ed65fe 100644 --- a/application/modules/Asset/views/asset_amc_form.php +++ b/application/modules/Asset/views/asset_amc_form.php @@ -39,13 +39,6 @@ -