diff --git a/application/config/testing/database.php b/application/config/testing/database.php
index e6c4a9c..55ec504 100644
--- a/application/config/testing/database.php
+++ b/application/config/testing/database.php
@@ -78,7 +78,7 @@
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
- 'database' => 'ams',
+ 'database' => 'test',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
diff --git a/application/config/testing/routes.php b/application/config/testing/routes.php
index f17dbb6..f00df48 100644
--- a/application/config/testing/routes.php
+++ b/application/config/testing/routes.php
@@ -54,5 +54,5 @@
$route['translate_uri_dashes'] = FALSE;
//modules routes
-$route['logout'] = 'auth/logout';
-$route['login'] = 'auth';
+$route['logout'] = 'Auth/logout';
+$route['login'] = 'Auth';
diff --git a/application/core/Admin_Controller.php b/application/core/Admin_Controller.php
index e518d3a..240bc65 100644
--- a/application/core/Admin_Controller.php
+++ b/application/core/Admin_Controller.php
@@ -29,6 +29,7 @@ public function __construct()
}
$global_data['settings'] = $this->auth_model->get_settings();
$global_data['business'] = $this->auth_model->get_business(0);
+ // print_r($global_data['business']);
$this->load->vars($global_data);
$this->load->library('user_agent');
diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php
index f10541b..4ee740f 100644
--- a/application/core/MY_Controller.php
+++ b/application/core/MY_Controller.php
@@ -47,8 +47,9 @@ public function __construct()
// Copyright
// $this->global_data['copyright_from_mycontroller'] = $date;
// $this->load->vars($this->global_data);
- $this->load->module('layout');
- $this->load->module('audit');
+ ### Syntax : $this->load->module('module_name', $params, $object_name);
+ $this->load->module('Layout');
+ $this->load->module('Audit');
}
}
diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php
index b89a38a..52f739f 100644
--- a/application/core/MY_Model.php
+++ b/application/core/MY_Model.php
@@ -34,6 +34,8 @@ function edit_option_md5($action, $id, $table){
function update($action,$id,$table){
$this->db->where('id',$id);
$this->db->update($table,$action);
+
+
}
// update function
@@ -120,11 +122,38 @@ function select_by_business_id($table,$business_id)
$this->db->select();
$this->db->from($table);
$this->db->where('business_id', $business_id);
+ // $this->db->where('is_active ', 1);
$this->db->order_by('id','ASC');
$query = $this->db->get();
$query = $query->result();
return $query;
}
+
+ // select category data
+ function select_by_category_data($table,$business_id)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $this->db->where('is_active ', 1);
+ $this->db->order_by('id','ASC');
+ $query = $this->db->get();
+ $query = $query->result();
+ return $query;
+ }
+
+ // select department data
+ function select_by_department_data($table,$business_id)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $this->db->where('is_active ', 1);
+ $this->db->order_by('id','ASC');
+ $query = $this->db->get();
+ $query = $query->result();
+ return $query;
+ }
// select by business_id and type
function select_by_business_id_and_type($table,$business_id,$type)
diff --git a/application/helpers/custom_helper.php b/application/helpers/custom_helper.php
index 24952ac..e254012 100644
--- a/application/helpers/custom_helper.php
+++ b/application/helpers/custom_helper.php
@@ -78,6 +78,23 @@ function user()
}
}
+ if (!function_exists('employee'))
+ {
+ function employee()
+ {
+ // Get a reference to the controller object
+ $ci =& get_instance();
+ $emp = $ci->auth_model->get_logged_employee();
+ if (empty($emp))
+ {
+ $ci->auth_model->logout();
+ } else {
+ return $emp;
+ }
+
+ }
+ }
+
if (!function_exists('hash_password')) {
function hash_password($password)
{
@@ -151,6 +168,23 @@ function show_year($date){
}
}
+ if(!function_exists('dateFormat'))
+ {
+ function dateFormat($format='d-m-Y', $givenDate=null)
+ {
+ return date($format, strtotime($givenDate));
+ }
+ }
+
+
+ if(!function_exists('timeFormat'))
+ {
+ function timeFormat($format='h:i:s a', $givenTime=null)
+ {
+ return date($format, strtotime($givenTime));
+ }
+ }
+
//get days
if (!function_exists('get_days')) {
diff --git a/application/modules/Asset/controllers/Asset.php b/application/modules/Asset/controllers/Asset.php
index 2d40c81..de1beeb 100644
--- a/application/modules/Asset/controllers/Asset.php
+++ b/application/modules/Asset/controllers/Asset.php
@@ -29,22 +29,21 @@ public function __construct()
{
// To inherit directly the attributes of the parent class.
parent::__construct();
- $this->load->model('MY_Model');
- $this->load->model('Asset_model');
- $this->load->model('Audit_model');
+ ### Syntax : $this->load->model('Model Path' , 'Alias name');
+ ### The second parameter (optional) is used to call the method.
+ $this->load->model('MY_Model','MY_Model');
+ $this->load->model('Asset_model','Asset_model');
+ $this->load->model('Audit/audit_model','Audit_model');
$this->load->helper(array('form', 'url'));
+ // print_r($business);die();
-
}
public function index()
{
-
$this->layout->set('users', "gowtham");
$this->layout->buffer('main_content', 'Asset/index');
- $this->layout->render('default_layout');
-
-
+ $this->layout->render('default_layout');
}
public function addAsset($id='empty')
@@ -64,19 +63,133 @@ public function addAsset($id='empty')
$this->layout->render('default_layout');
}
-
- public function assetList()
+
+ public function assetLandingPage()
{
- $assets_list = $this->Asset_model->get_assets(user()->business_id);
+ $assets_list = $this->Asset_model->get_category_wise_assets(user()->business_id);
+ $this->layout->set('tableData', $assets_list);
+ $this->layout->buffer('main_content', 'Asset/asset_landing_page');
+ $this->layout->render('default_layout');
+
+ }
+
+ public function assetList($category , $purchase_date_from = null , $purchase_date_to = null)
+ {
+
+ $table = 'asset';
+ $assets_list = $this->Asset_model->get_assets(user()->business_id , $category );
+ foreach ($assets_list as $key => $value) {
+ // update yearly once
+ if($value->last_updated_year != date('Y'))
+ {
+ // update last_updated_year in db
+ $year['last_updated_year'] = date('Y');
+ // $editCurrentValue = $this->MY_Model->edit_option($year, $value->id, $table);
+ // find difference between two dates
+ $date1 = new DateTime(date('Y-m-d'));
+ $date2 = new DateTime($value->purchase_date);
+ $interval = $date1->diff($date2);
+ $nxt_year = date('Y-m-d', strtotime("+12 months $value->purchase_date"));
+ // echo $nxt_year;die();
+ // echo $interval->y; die();
+ // year intervel greater than 0
+ if($interval->y > 0)
+ {
+ $curr_month = date('n', strtotime($value->purchase_date));
+
+ // echo $curr_month;die();
+ $month_array_for_50_percentage = array(10 , 11 , 12 , 1 , 2 ,3);
+ if (in_array($curr_month, $month_array_for_50_percentage) && date('Y-m-d') > $nxt_year)
+ {
+ $cost = $value->cost;
+ // get depreciation value
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ // percentage formula calculation
+ $category_percentage = $category_percentage[0]['depreciation_percentage'] / 2;
+ $depreciate_value = $cost * $category_percentage / 100;
+ $cost = abs($depreciate_value - $cost);
+ // echo $cost;die();
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ for ($i=0 ; $i < $interval->y ; $i++)
+ {
+ // $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ $category_per = $category_percentage[0]['depreciation_percentage'];
+ $depreciate_value = $cost * $category_per / 100;
+ $data['current_cost'] = abs($depreciate_value - $cost);
+ $editCurrentValue = $this->MY_Model->edit_option($data, $value->id, $table);
+ $cost = abs($depreciate_value - $cost);
+ }
+ }
+ else
+ {
+ $cost = $value->cost;
+ // get depreciation value
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ // percentage formula calculation
+ $category_percentage = $category_percentage[0]['depreciation_percentage'];
+ $depreciate_value = $cost * $category_percentage / 100;
+ $cost = abs($depreciate_value - $cost);
+
+ // $cost = $value->cost;
+ // get depreciation value
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ for ($i=0 ; $i < $interval->y ; $i++)
+ {
+ $category_per = $category_percentage[0]['depreciation_percentage'];
+ $depreciate_value = $cost * $category_per / 100;
+ // echo $depreciate_value; die();
+ $data['current_cost'] = abs($depreciate_value- $cost);
+ $editCurrentValue = $this->MY_Model->edit_option($data, $value->id, $table);
+ $cost = abs($depreciate_value - $cost);
+ }
+ }
+ }
+ // year intervel less than 0
+ else
+ {
+ $curr_month = date('n', strtotime($value->purchase_date));
+ $month_array_for_50_percentage = array(10 , 11 , 12 , 1 , 2 , 3);
+ if (in_array($curr_month, $month_array_for_50_percentage))
+ {
+ $cost = $value->cost;
+ // get depreciation value
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ // percentage formula calculation
+ $category_percentage = $category_percentage[0]['depreciation_percentage'] / 2;
+ $depreciate_value = $cost * $category_percentage / 100;
+ $data['current_cost'] = abs($cost - $depreciate_value);
+ $editCurrentValue = $this->MY_Model->edit_option($data, $value->id, $table);
+ }
+ else if(date('Y-m-d') > $nxt_year)
+ {
+ echo $nxt_year;die();
+ $cost = $value->cost;
+ // get depreciation value
+ $category_percentage = $this->Asset_model->get_by_category_id($value->category);
+ // percentage formula calculation
+ $depreciate_value = $cost * $category_percentage[0]['depreciation_percentage'] / 100;
+ $data['current_cost'] = abs($cost - $depreciate_value);
+ $editCurrentValue = $this->MY_Model->edit_option($data, $value->id, $table);
+ }
+ else {
+ $data['current_cost'] = $value->cost;
+ $editCurrentValue = $this->MY_Model->edit_option($data, $value->id, $table);
+ }
+ }
+ }
+ }
+ $assets_list = $this->Asset_model->get_assets(user()->business_id , $category, $purchase_date_from , $purchase_date_to);
$this->layout->set('tableData', $assets_list);
$this->layout->buffer('main_content', 'Asset/asset_list');
$this->layout->render('default_layout');
}
+
public function createAssets()
{
+
$data=$this->input->post();
$data['business_id'] = user()->business_id;
$data['created_by'] = user()->name;
@@ -99,6 +212,7 @@ public function createAssets()
}
$table="asset";
+
//create asset
$create_assets = $this->MY_Model->insert($data,$table);
@@ -106,6 +220,7 @@ public function createAssets()
// Qr code
$qr_data['qrcode_img'] = (new QRCode)->render(base_url().'Asset/view_asset_details/'.md5($create_assets));
$editAssetData = $this->MY_Model->edit_option($qr_data, $create_assets, $table);
+ $editCurrentValue = $this->MY_Model->edit_option($qr_data, $create_assets, $table);
if($create_assets)
@@ -119,7 +234,7 @@ public function createAssets()
$test = $this->audit->create_history('insert');
}
- redirect('asset/assetList');
+ redirect('Asset/assetList/'.md5($this->input->post('category')));
}
@@ -194,14 +309,16 @@ public function editAssets()
//audit history generation for update
$test = $this->audit->create_history('update');
}
- redirect('asset/assetList');
+ redirect('Asset/assetList/'.md5($this->input->post('category')));
}
- public function deleteAsset($id)
+ public function deleteAsset()
{
+ $id = $this->input->post('id');
+ $assetdata = $this->Asset_model->get_asset__id($id,'asset',user()->business_id);
$Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,'asset');
- redirect('asset/assetList');
+ redirect('Asset/assetList/'.md5($assetdata->category));
}
@@ -232,18 +349,6 @@ public function view_qrcode()
}
-
-
-
-
-
-
-
-
-
-
-
-
public function view_asset_details($id)
{
$tab = $this->session->flashdata();
@@ -323,16 +428,17 @@ public function add_or_edit_asset_value()
}
$this->session->set_flashdata('msg', "asset_value");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id')));
+ 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');
- }
+ // 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['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');
@@ -342,6 +448,7 @@ public function add_or_edit_asset_value()
$data['description'] = $this->input->post('description');
$data['created_by'] = user()->id;
$createAssetValueData = $this->MY_Model->insert($data, 'asset_value');
+ // print_r($createAssetValueData);die();
if($createAssetValueData)
{
//set id $ table name for audit history
@@ -353,11 +460,11 @@ public function add_or_edit_asset_value()
$this->audit->create_history('insert');
}
$this->session->set_flashdata(1); $this->session->set_flashdata('msg', "asset_value");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
+ redirect('Asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
}
}
-
+
public function getAssetUsageForm($id)
@@ -423,7 +530,7 @@ public function add_or_edit_asset_usage()
$this->audit->create_history('update');
}
$this->session->set_flashdata('msg', "asset_usage");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id')));
+ 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;
@@ -444,7 +551,7 @@ public function add_or_edit_asset_usage()
$this->audit->create_history('insert');
}
$this->session->set_flashdata('msg', "asset_usage");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
+ redirect('Asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
}
}
@@ -495,7 +602,7 @@ public function add_or_edit_asset_amc()
$this->audit->create_history('update');
}
$this->session->set_flashdata('msg', "asset_amc");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id')));
+ 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;
@@ -521,7 +628,7 @@ public function add_or_edit_asset_amc()
$this->audit->create_history('insert');
}
$this->session->set_flashdata('msg', "asset_amc");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
+ redirect('Asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
}
}
@@ -572,7 +679,7 @@ public function add_or_edit_asset_insurance()
$this->audit->create_history('update');
}
$this->session->set_flashdata('msg', "asset_insurance");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id')));
+ 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;
@@ -597,7 +704,7 @@ public function add_or_edit_asset_insurance()
$this->audit->create_history('insert');
}
$this->session->set_flashdata('msg', "asset_insurance");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
+ redirect('Asset/view_asset_details/'.md5($this->input->post('asset_id_for_add')));
}
}
@@ -609,7 +716,7 @@ public function add_or_edit_asset_insurance()
public function getAssetImageForm($id)
{
- $data = array('asset_id'=> $id, 'heading'=>'Add Image' , 'submit_button_title'=>'Submit');
+ $data = array('asset_id'=> $id, 'heading'=>'Add File' , 'submit_button_title'=>'Submit');
$htmlPage = $this->load->view('asset_image_form.php',$data,true);
echo json_encode($htmlPage);
}
@@ -623,7 +730,7 @@ public function add_asset_image()
//file upload confic
$asset_image['upload_path'] = APPPATH. '../assets/uploads/';
- $asset_image['allowed_types'] = 'gif|jpg|png|jpeg';
+ $asset_image['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
$asset_image['max_size'] = 80000;
//upload
$this->load->library('upload', $asset_image);
@@ -639,7 +746,7 @@ public function add_asset_image()
$table="asset_images";
$create_assets = $this->MY_Model->insert($data,$table);
$this->session->set_flashdata('msg', "asset_image");
- redirect('asset/view_asset_details/'.md5($this->input->post('asset_id')));
+ redirect('Asset/view_asset_details/'.md5($this->input->post('asset_id')));
}
@@ -650,7 +757,7 @@ public function deleteAssetValue($id)
$asset_id = $split[1];
$Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'asset_value');
$this->session->set_flashdata('msg', "asset_value");
- redirect('asset/view_asset_details/'.md5($asset_id));
+ redirect('Asset/view_asset_details/'.md5($asset_id));
}
public function deleteAssetUsage($id)
{
@@ -659,34 +766,37 @@ public function deleteAssetUsage($id)
$asset_id = $split[1];
$Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'asset_usage');
$this->session->set_flashdata('msg', "asset_usage");
- redirect('asset/view_asset_details/'.md5($asset_id));
+ redirect('Asset/view_asset_details/'.md5($asset_id));
}
- public function deleteAssetAMC($id)
+ public function deleteAssetAMC()
{
+ $id = $this->input->post('id');
$split = preg_split('/_/', $id);
$key = $split[0];
$asset_id = $split[1];
$Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'amc');
$this->session->set_flashdata('msg', "asset_amc");
- redirect('asset/view_asset_details/'.md5($asset_id));
+ redirect('Asset/view_asset_details/'.md5($asset_id));
}
- public function deleteAssetImage($id)
+ public function deleteAssetImage()
{
+ $id = $this->input->post('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_images');
$this->session->set_flashdata('msg', "asset_image");
- redirect('asset/view_asset_details/'.md5($asset_id));
+ redirect('Asset/view_asset_details/'.md5($asset_id));
}
- public function deleteAssetInsurance($id)
+ public function deleteAssetInsurance()
{
+ $id = $this->input->post('id');
$split = preg_split('/_/', $id);
$key = $split[0];
$asset_id = $split[1];
$Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'amc');
$this->session->set_flashdata('msg', "asset_insurance");
- redirect('asset/view_asset_details/'.md5($asset_id));
+ redirect('Asset/view_asset_details/'.md5($asset_id));
}
public function depreciation_report()
@@ -727,8 +837,11 @@ public function masterDataList()
$this->layout->set('supplierData', $this->Asset_model->get_third_party_value_by_md5_id(user()->business_id,2));
$this->layout->set('service_privoder', $this->Asset_model->get_third_party_value_by_md5_id(user()->business_id,3));
$this->layout->set('insurence', $this->Asset_model->get_third_party_value_by_md5_id(user()->business_id,4));
- $this->layout->set('locationsData', $this->MY_Model->select_by_business_id('locations',user()->business_id));
- $this->layout->set('categoriesData', $this->MY_Model->select_by_business_id('categories',user()->business_id));
+ $this->layout->set('locationsData', $this->MY_Model->select_by_business_id('locations',user()->business_id,1));
+ $this->layout->set('categoriesData', $this->MY_Model->select_by_category_data('categories',user()->business_id));
+ $this->layout->set('departmentData', $this->MY_Model->select_by_department_data('department_master',user()->business_id));
+ $this->layout->set('leaveData', $this->MY_Model->select_by_department_data('leave_master',user()->business_id));
+ $this->layout->set('enum_value', $this->MY_Model->select_by_department_data('enum',user()->business_id));
$this->layout->buffer('main_content', 'Asset/master_list');
$this->layout->render('default_layout');
@@ -737,6 +850,7 @@ public function masterDataList()
public function getThirdPartyForm($id)
{
+
$state = $this->MY_Model->select('state');
if ($id == "manufacture") {
$data = array('heading'=> "Manufacturer Details", 'type' => 1 , 'states' => $state , 'submit_button_title'=>'Add' );
@@ -772,7 +886,6 @@ public function getThirdPartyForm($id)
public function add_or_edit_ThirdPartyForm()
{
-
$table = 'third_parties';
$action = $this->input->post();
$id = $this->input->post('id');
@@ -780,12 +893,12 @@ public function add_or_edit_ThirdPartyForm()
if ($id) {
$userData = $this->MY_Model->edit_option($action, $id, $table);
$this->session->set_flashdata('msg', $type);
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
} else {
$userData = $this->MY_Model->insert($action, $table);
if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
$this->session->set_flashdata('msg', $type);
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
}
}
@@ -816,12 +929,12 @@ public function add_or_edit_LocationForm()
if ($id) {
$userData = $this->MY_Model->edit_option($action, $id, $table);
$this->session->set_flashdata('msg', "location");
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
} else {
$userData = $this->MY_Model->insert($action, $table);
if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
$this->session->set_flashdata('msg', "location");
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
}
}
@@ -837,8 +950,8 @@ public function getCatogaryForm($id)
}
else {
$table = 'categories';
- $location_data = $this->MY_Model->get_by_md5_id($id, $table);
- $data = array('heading'=> "Catogary Details", 'catogary_data'=> $location_data , 'submit_button_title'=>'Add' );
+ $catogary_data = $this->MY_Model->get_by_md5_id($id, $table);
+ $data = array('heading'=> "Catogary Details", 'catogary_data'=> $catogary_data , 'submit_button_title'=>'Update' );
$htmlPage = $this->load->view('catogary_master_form.php',$data,true);
echo json_encode($htmlPage);
}
@@ -851,27 +964,206 @@ public function add_or_edit_CategoriesForm()
$table = 'categories';
$action = $this->input->post();
$id = $this->input->post('id');
+ // print_r($id);die();
if ($id) {
$userData = $this->MY_Model->edit_option($action, $id, $table);
$this->session->set_flashdata('msg', "categories");
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
} else {
$userData = $this->MY_Model->insert($action, $table);
if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
$this->session->set_flashdata('msg', "categories");
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
}
}
- public function deleteThirdPartyData($id)
+ public function getDepartmentForm($id)
{
+ if ($id == "department") {
+ $table = 'department_master';
+ $data = array('heading'=> "Department Details", 'submit_button_title'=>'Add' );
+ $htmlPage = $this->load->view('department_master_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ else {
+ $table = 'department_master';
+ $department_data = $this->MY_Model->get_by_md5_id($id, $table);
+ $data = array('heading'=> "Department Details", 'department_data'=> $department_data , 'submit_button_title'=>'Update' );
+ $htmlPage = $this->load->view('department_master_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ }
+
+
+ public function add_or_edit_DepartmentForm()
+ {
+
+ $table = 'department_master';
+ $action = $this->input->post();
+ $id = $this->input->post('id');
+ // print_r($id);die();
+ if ($id) {
+ $userData = $this->MY_Model->edit_option($action, $id, $table);
+ $this->session->set_flashdata('msg', "department");
+ redirect('Asset/masterDataList');
+ } else {
+ $userData = $this->MY_Model->insert($action, $table);
+ if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
+ $this->session->set_flashdata('msg', "department");
+ redirect('Asset/masterDataList');
+ }
+
+ }
+
+ public function deleteDepartmentFormData()
+ {
+ $id = $this->input->post('id');
+ $table = 'department_master';
+ $user = $this->Asset_model->get_by_id($id , $table);
+ $Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,$table);
+ $this->session->set_flashdata('msg', "department");
+ redirect('Asset/masterDataList');
+ }
+
+
+
+
+ public function getLeaveForm($id)
+ {
+ if ($id == "leave") {
+ $table = 'leave_master';
+ $data = array('heading'=> "Leave Details", 'submit_button_title'=>'Add' );
+ $htmlPage = $this->load->view('leave_master_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ else {
+ $table = 'leave_master';
+ $leave_data = $this->MY_Model->get_by_md5_id($id, $table);
+ $data = array('heading'=> "Leave Details", 'leave_data'=> $leave_data , 'submit_button_title'=>'Update' );
+ $htmlPage = $this->load->view('leave_master_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ }
+
+
+ public function add_or_edit_LeaveForm()
+ {
+
+ $table = 'leave_master';
+ $action = $this->input->post();
+ $id = $this->input->post('id');
+ if ($id) {
+ $userData = $this->MY_Model->edit_option($action, $id, $table);
+ $this->session->set_flashdata('msg', "leave");
+ redirect('Asset/masterDataList');
+ } else {
+ $userData = $this->MY_Model->insert($action, $table);
+ if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
+ $this->session->set_flashdata('msg', "leave");
+ redirect('Asset/masterDataList');
+ }
+
+ }
+
+ public function deleteLeaveFormData()
+ {
+ $id = $this->input->post('id');
+ $table = 'leave_master';
+ $Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,$table);
+ $this->session->set_flashdata('msg', "leave");
+ redirect('Asset/masterDataList');
+ }
+
+/// decline reason
+
+ public function getDeclineForm($id)
+ {
+ if ($id == "decline") {
+ $table = 'enum';
+ $data = array('heading'=> "Decline Reason", 'submit_button_title'=>'Add' );
+ $htmlPage = $this->load->view('Decline_Reason_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ else {
+ $table = 'enum';
+ $Decline_data = $this->MY_Model->get_by_md5_id($id, $table);
+ $data = array('heading'=> "Decline Reason", 'Decline_data'=> $Decline_data , 'submit_button_title'=>'Update' );
+ $htmlPage = $this->load->view('Decline_Reason_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+ }
+
+
+ public function add_or_edit_DeclineForm()
+ {
+
+ $table = 'enum';
+ $action = $this->input->post();
+ $action['is_active'] = 1;
+ $id = $this->input->post('id');
+ if ($id) {
+ $userData = $this->MY_Model->edit_option($action, $id, $table);
+ $this->session->set_flashdata('msg', "decline");
+ redirect('Asset/masterDataList');
+ } else {
+ $userData = $this->MY_Model->insert($action, $table);
+ if($business->is_master_data_entered == 0){ $this->MY_Model->editBusiness(); }
+ $this->session->set_flashdata('msg', "decline");
+ redirect('Asset/masterDataList');
+ }
+
+ }
+
+
+ public function deleteDeclineFormData()
+ {
+ $id = $this->input->post('id');
+ $table = 'enum';
+ $Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,$table);
+ $this->session->set_flashdata('msg', "decline");
+ redirect('Asset/masterDataList');
+ }
+
+
+
+
+ public function deleteThirdPartyData()
+ {
+ $id = $this->input->post('id');
$table = 'third_parties';
$user = $this->Asset_model->get_by_id($id , $table);
$Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,$table);
$this->session->set_flashdata('msg', $user->type);
- redirect('asset/masterDataList');
+ redirect('Asset/masterDataList');
}
+ public function deleteCategoriesFormData()
+ {
+ $id = $this->input->post('id');
+ $table = 'categories';
+ $user = $this->Asset_model->get_by_id($id , $table);
+ $Data = $this->Asset_model->delete_by_md5_id($id,user()->business_id,$table);
+ $this->session->set_flashdata('msg', "categories");
+ redirect('Asset/masterDataList');
+ }
+
+ public function getDeleteConfirmationPopup()
+ {
+ $data = array();
+ $htmlPage = $this->load->view('confirmation_popup.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+
+ public function filterAssets()
+ {
+ $split = preg_split('/-/', $this->input->post('reservation'));
+ $purchase_date_from = date_format(date_create($split[0]),"Y-m-d");
+ $purchase_date_to = date_format(date_create($split[1]),"Y-m-d");
+ redirect('Asset/assetList/'.md5($this->input->post('category')).'/'.$purchase_date_from.'/'.$purchase_date_to);
+ }
+
+
+
}
diff --git a/application/modules/Asset/models/Asset_model.php b/application/modules/Asset/models/Asset_model.php
index e1a7a2a..37d1185 100644
--- a/application/modules/Asset/models/Asset_model.php
+++ b/application/modules/Asset/models/Asset_model.php
@@ -1,8 +1,25 @@
db->select('A.* , A.category as category_value , SUM(A.cost) as total , SUM(A.current_cost) as total_current_cost , categories.name as category_name ');
+ $this->db->group_by('A.category');
+ $this->db->from('asset A');
+ $this->db->join('categories', 'categories.id = A.category', 'left');
+ $this->db->where('A.business_id', $business_id);
+ $this->db->order_by('A.id','ASC');
+ $this->db->where('A.is_active', 1);
+ $query = $this->db->get();
+ $query = $query->result();
+ return $query;
+ }
+
+
+ public function get_assets($business_id , $category , $purchase_date_from = null , $purchase_date_to = null)
+ {
+
$this->db->select('A.* , categories.name as category_name , third_parties.name as manufacturer_name ,tp.name as supplier_name , locations.location as location_name , status.display_name as status_display_name');
$this->db->from('asset A');
$this->db->join('categories', 'categories.id = A.category', 'left');
@@ -11,10 +28,17 @@ public function get_assets($business_id)
$this->db->join('locations', 'locations.id = A.location', 'left');
$this->db->join('status', 'status.id = A.status', 'left');
$this->db->where('A.business_id', $business_id);
+ $this->db->where('md5(A.category)', $category);
+ if($purchase_date_from != null && $purchase_date_to != null)
+ {
+ $this->db->where('A.purchase_date >=', $purchase_date_from);
+ $this->db->where('A.purchase_date <=', $purchase_date_to);
+ }
$this->db->order_by('A.id','ASC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
- $query = $query->result();
+ $query = $query->result();
+
return $query;
}
@@ -34,7 +58,16 @@ public function get_asset_by_md5_id($id,$business_id)
return $query;
}
-
+ public function get_by_category_id($id)
+ {
+ $this->db->select();
+ $this->db->from('categories');
+ $this->db->where('id', $id);
+ $this->db->where('is_active', 1);
+ $query = $this->db->get();
+ $query = $query->result_array();
+ return $query;
+ }
public function get_by_asset_id($id,$table,$business_id)
{
@@ -47,6 +80,19 @@ public function get_by_asset_id($id,$table,$business_id)
$query = $query->result();
return $query;
}
+
+ public function get_asset__id($id,$table,$business_id)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $this->db->where('md5(id)', $id);
+ $this->db->where('is_active', 1);
+ $query = $this->db->get();
+ $query = $query->row();
+ return $query;
+ }
+
public function get_amc_with_join($id,$business_id)
{
$this->db->select('A.* , third_parties.name as service_provider_name ');
@@ -137,7 +183,7 @@ public function get_latest_asset_value($asset_id,$business_id)
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
+ asset.id,asset.name as asset_name,asset.tag,asset.serial,asset.model,asset.purchase_date,asset.cost as purchase_cost,status.display_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.")
@@ -157,7 +203,7 @@ public function amc_insurance_report($type,$business_id)
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
+ asset.id,asset.name as asset_name,asset.tag,asset.serial,asset.current_cost,asset.model,asset.purchase_date,asset.cost as purchase_cost,status.display_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
diff --git a/application/modules/Asset/views/Decline_Reason_form.php b/application/modules/Asset/views/Decline_Reason_form.php
new file mode 100644
index 0000000..968bf0e
--- /dev/null
+++ b/application/modules/Asset/views/Decline_Reason_form.php
@@ -0,0 +1,39 @@
+
+
+
+
diff --git a/application/modules/Asset/views/amc_reports_list.php b/application/modules/Asset/views/amc_reports_list.php
index 963f110..ea09986 100644
--- a/application/modules/Asset/views/amc_reports_list.php
+++ b/application/modules/Asset/views/amc_reports_list.php
@@ -43,7 +43,7 @@
|
|
|
- |
+ |
|
|
|
diff --git a/application/modules/Asset/views/asset_landing_page.php b/application/modules/Asset/views/asset_landing_page.php
new file mode 100644
index 0000000..2e3c6c3
--- /dev/null
+++ b/application/modules/Asset/views/asset_landing_page.php
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/modules/Asset/views/asset_list.php b/application/modules/Asset/views/asset_list.php
index bd482c6..9b2c76b 100644
--- a/application/modules/Asset/views/asset_list.php
+++ b/application/modules/Asset/views/asset_list.php
@@ -1,18 +1,20 @@
+
+
Assets Details
@@ -21,18 +23,42 @@