diff --git a/application/modules/Asset/controllers/Asset.php b/application/modules/Asset/controllers/Asset.php index ffb3226..cbafdb0 100644 --- a/application/modules/Asset/controllers/Asset.php +++ b/application/modules/Asset/controllers/Asset.php @@ -306,6 +306,14 @@ public function add_or_edit_asset_value() redirect('asset/view_asset_details/'.md5($this->input->post('asset_id'))); }else{ + $get_latest_asset_value = $this->Asset_model->get_latest_asset_value($this->input->post('asset_id_for_add'),user()->business_id); + $pre_current_value = $get_latest_asset_value->current_value; + if($this->input->post('type') == 'Upgrade') + { + $data['current_value'] = $pre_current_value + $this->input->post('value'); + }else if($this->input->post('type') == 'Depreciation') { + $data['current_value'] = $pre_current_value - $this->input->post('value'); + } $data['asset_id'] = $this->input->post('asset_id_for_add'); $data['business_id'] = user()->business_id; $data['type'] = $this->input->post('type'); @@ -626,9 +634,31 @@ public function deleteAssetInsurance($id) redirect('asset/view_asset_details/'.md5($asset_id)); } - public function get_history() + public function depreciation_report() { - echo $this->input->post(); + $Data = $this->Asset_model->depreciation_report(user()->business_id); + //print_r($Data);die(); + $this->layout->set('tableData', $Data); + $this->layout->buffer('main_content', 'Asset/depreciation_list'); + $this->layout->render('default_layout'); + + } + + public function amc_report() + { + $Data = $this->Asset_model->amc_insurance_report(3,user()->business_id); + $this->layout->set('tableData', $Data); + $this->layout->buffer('main_content', 'Asset/amc_reports_list'); + $this->layout->render('default_layout'); + + } + + public function insurance_report() + { + $Data = $this->Asset_model->amc_insurance_report(4,user()->business_id); + $this->layout->set('tableData', $Data); + $this->layout->buffer('main_content', 'Asset/insurance_reports_list'); + $this->layout->render('default_layout'); } diff --git a/application/modules/Asset/models/Asset_model.php b/application/modules/Asset/models/Asset_model.php index 1dec8e6..a5b4134 100644 --- a/application/modules/Asset/models/Asset_model.php +++ b/application/modules/Asset/models/Asset_model.php @@ -55,7 +55,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.is_active', 1); $this->db->where('A.type', 3); $query = $this->db->get(); $query = $query->result(); @@ -67,7 +67,7 @@ public function get_amc_by_id_with_join($id) $this->db->from('amc A'); $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.is_active', 1); $this->db->where('A.type', 3); $query = $this->db->get(); $query = $query->row(); @@ -81,7 +81,7 @@ public function get_insurance_with_join($id,$business_id) $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.is_active', 1); $this->db->where('A.type', 4); $query = $this->db->get(); $query = $query->result(); @@ -93,7 +93,7 @@ public function get_insurance_by_id_with_join($id) $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.is_active', 1); $this->db->where('A.type', 4); $query = $this->db->get(); $query = $query->row(); @@ -120,6 +120,55 @@ public function get_asset_id($id,$table,$business_id) return $query; } +public function get_latest_asset_value($asset_id,$business_id) + { + $this->db->select(); + $this->db->from('asset_value'); + $this->db->where('asset_id', $asset_id); + $this->db->where('business_id', $business_id); + $this->db->where('is_active', 1); + $this->db->order_by('id', 'DESC'); + $this->db->limit(1); + $query = $this->db->get(); + $query = $query->row(); + return $query; + } + + public function amc_insurance_report($type,$business_id) + { + $query = $this->db->query("SELECT amc.*,service_provider.name as service_provider_name,insurance_company.name as insurance_company_name, + asset.id,asset.name as asset_name,asset.tag,asset.serial,asset.model,asset.purchase_date,asset.cost as purchase_cost,status.name as status , categories.name as category,locations.location as location,manufacturer.name as manufacturer, Supplier.name as Supplier + FROM asset + LEFT JOIN amc ON asset.id = amc.asset_id AND amc.created_at = (SELECT MAX(amc.created_at) FROM amc + WHERE asset.id = amc.asset_id and amc.is_active=1 and amc.type=".$type.") + + LEFT JOIN third_parties as service_provider ON amc.service_provider = service_provider.id + LEFT JOIN third_parties as insurance_company ON amc.insurance_company = insurance_company.id + LEFT JOIN status ON asset.status = status.id + LEFT JOIN categories ON asset.category = categories.id + LEFT JOIN locations ON asset.location = locations.id + LEFT JOIN third_parties as manufacturer ON asset.manufacturer = manufacturer.id + LEFT JOIN third_parties as Supplier ON asset.Supplier = Supplier.id + where asset.business_id =".$business_id." and asset.is_active=1"); + $result =$query->result_array(); + return $result; + } + + public function depreciation_report($business_id) + { + $query = $this->db->query("SELECT asset_value.*, + asset.id,asset.name as asset_name,asset.tag,asset.serial,asset.model,asset.purchase_date,asset.cost as purchase_cost,status.name as status , categories.name as category,locations.location as location,manufacturer.name as manufacturer, Supplier.name as Supplier + FROM asset + LEFT JOIN asset_value ON asset.id = asset_value.asset_id AND asset_value.created_at = (SELECT MAX(asset_value.created_at) FROM asset_value WHERE asset.id = asset_value.asset_id and asset_value.is_active=1) + LEFT JOIN status ON asset.status = status.id + LEFT JOIN categories ON asset.category = categories.id + LEFT JOIN locations ON asset.location = locations.id + LEFT JOIN third_parties as manufacturer ON asset.manufacturer = manufacturer.id + LEFT JOIN third_parties as Supplier ON asset.Supplier = Supplier.id + where asset.business_id =".$business_id." and asset.is_active=1"); + $result =$query->result_array(); + return $result; + } } \ No newline at end of file diff --git a/application/modules/Asset/views/amc_reports_list.php b/application/modules/Asset/views/amc_reports_list.php new file mode 100644 index 0000000..2c510ee --- /dev/null +++ b/application/modules/Asset/views/amc_reports_list.php @@ -0,0 +1,69 @@ + +
+
+
+

AMC Reports Details

+ + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/application/modules/Asset/views/asset_sub_value_list.php b/application/modules/Asset/views/asset_sub_value_list.php index ab4d692..e2f962f 100644 --- a/application/modules/Asset/views/asset_sub_value_list.php +++ b/application/modules/Asset/views/asset_sub_value_list.php @@ -44,11 +44,12 @@ - - - - - + + + + + + @@ -59,6 +60,7 @@ +
Type Name Value Percentage Description Type Name Value Current Value Percentage Description Action
type; ?> name; ?> value; ?>current_value; ?> percentage; ?> description; ?> diff --git a/application/modules/Asset/views/depreciation_list.php b/application/modules/Asset/views/depreciation_list.php new file mode 100644 index 0000000..8a4db50 --- /dev/null +++ b/application/modules/Asset/views/depreciation_list.php @@ -0,0 +1,63 @@ + +
+
+
+

Depreciation Details

+ + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/application/modules/Asset/views/insurance_reports_list.php b/application/modules/Asset/views/insurance_reports_list.php new file mode 100644 index 0000000..20b3977 --- /dev/null +++ b/application/modules/Asset/views/insurance_reports_list.php @@ -0,0 +1,67 @@ + +
+
+
+

Insurance Reports Details

+ + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/application/modules/Dashboard/controllers/Dashboard.php b/application/modules/Dashboard/controllers/Dashboard.php index c705200..10aae67 100644 --- a/application/modules/Dashboard/controllers/Dashboard.php +++ b/application/modules/Dashboard/controllers/Dashboard.php @@ -38,7 +38,7 @@ public function __construct() public function index() { - if(is_admin()) + if(is_admin() || is_user()) { $asset_count = $this->Dashboard_model->get_assets_count(user()->business_id); $this->layout->set('asset_count', $asset_count); diff --git a/application/modules/Dashboard/views/dashboard.php b/application/modules/Dashboard/views/dashboard.php index 01cab39..25a19b2 100644 --- a/application/modules/Dashboard/views/dashboard.php +++ b/application/modules/Dashboard/views/dashboard.php @@ -21,7 +21,7 @@ - +
Total Users @@ -71,7 +71,7 @@
- +
diff --git a/application/modules/Layout/views/includes/default_menu.php b/application/modules/Layout/views/includes/default_menu.php index 5a7d917..0af7f38 100644 --- a/application/modules/Layout/views/includes/default_menu.php +++ b/application/modules/Layout/views/includes/default_menu.php @@ -73,6 +73,15 @@
  • Add Users
  • + + +
  • Reports + +
  • diff --git a/assets/uploads/logo/gk.jpg b/assets/uploads/logo/gk.jpg new file mode 100644 index 0000000..160bdea Binary files /dev/null and b/assets/uploads/logo/gk.jpg differ diff --git a/assets/uploads/profile_picture/istockphoto-1322913815-612x612.jpg b/assets/uploads/profile_picture/istockphoto-1322913815-612x612.jpg new file mode 100644 index 0000000..b305021 Binary files /dev/null and b/assets/uploads/profile_picture/istockphoto-1322913815-612x612.jpg differ diff --git a/assets/uploads/profile_picture/photo.jpg b/assets/uploads/profile_picture/photo.jpg new file mode 100644 index 0000000..0bebdd8 Binary files /dev/null and b/assets/uploads/profile_picture/photo.jpg differ