diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php
index 31df90c..7bd2c55 100644
--- a/application/core/MY_Model.php
+++ b/application/core/MY_Model.php
@@ -88,6 +88,8 @@ function select_by_user($table)
$query = $query->result();
return $query;
}
+
+
// select by function
@@ -111,6 +113,31 @@ function select($table)
$query = $query->result();
return $query;
}
+
+ // select by business_id
+ function select_by_business_id($table,$business_id)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $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)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $this->db->where('type', $type);
+ $this->db->order_by('id','ASC');
+ $query = $this->db->get();
+ $query = $query->result();
+ return $query;
+ }
// asc select function
function select_asc($table)
diff --git a/assets/frontend/.gitkeep b/application/modules/Asset/.gitkeep
similarity index 100%
rename from assets/frontend/.gitkeep
rename to application/modules/Asset/.gitkeep
diff --git a/application/modules/Asset/controllers/Asset.php b/application/modules/Asset/controllers/Asset.php
new file mode 100644
index 0000000..cf557d6
--- /dev/null
+++ b/application/modules/Asset/controllers/Asset.php
@@ -0,0 +1,183 @@
+ (description)
+ * @version GIT: $Id$
+ * @since Version 0.0.1
+ * @filesource
+ *
+ */
+
+class Asset extends Admin_Controller
+{
+ /**
+ * [__construct description]
+ *
+ * @method __construct
+ */
+ 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->helper(array('form', 'url'));
+ }
+
+ public function index()
+ {
+
+ $this->layout->set('users', "gowtham");
+ $this->layout->buffer('main_content', 'Asset/index');
+ $this->layout->render('default_layout');
+
+
+ }
+
+ public function addAsset($id='empty')
+ {
+ if($id != 'empty')
+ {
+ $assetData = $this->Asset_model->get_asset_by_md5_id($id,user()->business_id);
+ $this->layout->set('assetData', $assetData);
+ }
+ $this->layout->set('manufacturerData', $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,1));
+ $this->layout->set('suppliorData', $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,2));
+ $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->buffer('main_content', 'Asset/add_asset');
+ $this->layout->render('default_layout');
+
+ }
+
+ public function assetList()
+ {
+
+ $assets_list = $this->Asset_model->get_assets(user()->business_id);
+ $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;
+ echo $this->input->post('asset_img');
+ //file upload confic
+ $asset_image['upload_path'] = APPPATH. '../assets/uploads/';
+ $asset_image['allowed_types'] = 'gif|jpg|png';
+ $asset_image['max_size'] = 80000;
+ //upload
+ $this->load->library('upload', $asset_image);
+ $this->upload->initialize($asset_image);
+ if ( ! $this->upload->do_upload('asset_img'))
+ {
+ $error = array('error' => $this->upload->display_errors());
+ } else{
+ $upload_asset_image = $this->upload->data();
+ $data['asset_img'] = $upload_asset_image['file_name'];
+ }
+ //print_r($data);die();
+ $table="asset";
+ $create_assets = $this->MY_Model->insert($data,$table);
+ redirect('asset/assetList');
+
+ }
+
+
+ public function editAsset($id)
+ {
+ //select dropdown values
+ $this->layout->set('manufacturerData', $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,1));
+ $this->layout->set('suppliorData', $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,2));
+ $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));
+ // select asset value by id
+ $table="asset";
+ $assetData = $this->Asset_model->get_asset_by_md5_id($id,user()->business_id);
+ // select asset sub values by id
+ $asset_value = $this->Asset_model->get_by_asset_id($id,'asset_value',user()->business_id);
+ $asset_usage = $this->Asset_model->get_by_asset_id($id,'asset_usage',user()->business_id);
+ $asset_amc = $this->Asset_model->get_by_asset_id($id,'amc',user()->business_id);
+ $data = array('asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc);
+ $sub_asset_value_htmlPage = $this->load->view('asset_sub_value_list.php',$data,true);
+ $this->layout->set('sub_asset_value_htmlPage', $sub_asset_value_htmlPage);
+ $this->layout->set('editData', $assetData);
+ $this->layout->buffer('main_content', 'Asset/edit_asset');
+ $this->layout->render('default_layout');
+
+ }
+
+ public function editAssets()
+ {
+
+ $table="asset";
+ $action = $this->input->post();
+
+ $id = $this->input->post('id');
+ //file upload confic
+ $asset_image['upload_path'] = APPPATH. '../assets/uploads/';
+ $asset_image['allowed_types'] = 'gif|jpg|png';
+ $asset_image['max_size'] = 80000;
+ //upload
+ $this->load->library('upload', $asset_image);
+ $this->upload->initialize($asset_image);
+ if ( ! $this->upload->do_upload('asset_img'))
+ {
+ $error = array('error' => $this->upload->display_errors());
+
+ unset($action['asset_img']);
+ } else{
+ $upload_asset_image = $this->upload->data();
+ $action['asset_img'] = $upload_asset_image['file_name'];
+
+ }
+
+
+
+ $assetData = $this->MY_Model->edit_option($action, $id, $table);
+ redirect('asset/assetList');
+
+ }
+
+ public function deleteAsset($id)
+ {
+ $Data = $this->Asset_model->delete_asset_by_md5_id($id,user()->business_id);
+ redirect('asset/assetList');
+ }
+
+ public function getAssetDetails($id)
+ {
+ $asset_value = $this->Asset_model->get_by_asset_id($id,'asset_value',user()->business_id);
+ $asset_usage = $this->Asset_model->get_by_asset_id($id,'asset_usage',user()->business_id);
+ $asset_amc = $this->Asset_model->get_by_asset_id($id,'amc',user()->business_id);
+ $data = array('asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc);
+
+ $htmlPage = $this->load->view('asset_sub_value_list.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+
+
+public function getAssetUsageDetails($id)
+ {
+ $data = array();
+ $htmlPage = $this->load->view('asset_usage_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+public function getAssetValueDetails($id)
+ {
+ $data = array();
+ $htmlPage = $this->load->view('asset_value_form.php',$data,true);
+ echo json_encode($htmlPage);
+ }
+
+}
diff --git a/assets/frontend/css/.gitkeep b/application/modules/Asset/models/.gitkeep
similarity index 100%
rename from assets/frontend/css/.gitkeep
rename to application/modules/Asset/models/.gitkeep
diff --git a/application/modules/Asset/models/Asset_model.php b/application/modules/Asset/models/Asset_model.php
new file mode 100644
index 0000000..9694f9f
--- /dev/null
+++ b/application/modules/Asset/models/Asset_model.php
@@ -0,0 +1,56 @@
+db->select('A.* , categories.name as category_name , third_parties.name as manufacturer_name ,tp.name as supplier_name , locations.location as location_name');
+ $this->db->from('asset A');
+ $this->db->join('categories', 'categories.id = A.category', 'left');
+ $this->db->join('third_parties', 'third_parties.id = A.manufacturer', 'left');
+ $this->db->join('third_parties as tp', 'tp.id = A.supplier', 'left');
+ $this->db->join('locations', 'locations.id = A.location', '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_asset_by_md5_id($id,$business_id)
+ {
+ $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');
+ $this->db->from('asset A');
+ $this->db->join('categories', 'categories.id = A.category', 'left');
+ $this->db->join('third_parties', 'third_parties.id = A.manufacturer', 'left');
+ $this->db->join('third_parties as tp', 'tp.id = A.supplier', 'left');
+ $this->db->join('locations', 'locations.id = A.location', 'left');
+ $this->db->where('A.business_id', $business_id);
+ $this->db->where('md5(A.id)', $id);
+ $query = $this->db->get();
+ $query = $query->row();
+ return $query;
+ }
+
+ public function delete_asset_by_md5_id($id,$business_id)
+ {
+ $this->db->where('md5(id)', $id);
+ $this->db->where('business_id', $business_id);
+ $this->db->set('is_active',0);
+ $this->db->update('asset');
+ return;
+ }
+
+ public function get_by_asset_id($id,$table,$business_id)
+ {
+ $this->db->select();
+ $this->db->from($table);
+ $this->db->where('business_id', $business_id);
+ $this->db->where('md5(asset_id)', $id);
+ $query = $this->db->get();
+ $query = $query->result();
+ return $query;
+ }
+
+
+}
\ No newline at end of file
diff --git a/assets/frontend/images/.gitkeep b/application/modules/Asset/views/.gitkeep
similarity index 100%
rename from assets/frontend/images/.gitkeep
rename to application/modules/Asset/views/.gitkeep
diff --git a/application/modules/Asset/views/add_asset.php b/application/modules/Asset/views/add_asset.php
new file mode 100644
index 0000000..8ee679b
--- /dev/null
+++ b/application/modules/Asset/views/add_asset.php
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
General Information
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/Asset/views/asset_list.php b/application/modules/Asset/views/asset_list.php
new file mode 100644
index 0000000..e0c894b
--- /dev/null
+++ b/application/modules/Asset/views/asset_list.php
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..4b624f2
--- /dev/null
+++ b/application/modules/Asset/views/asset_sub_value_list.php
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | Type |
+ Name |
+ Value |
+ Percentage |
+ Action |
+
+
+
+
+ $value) { ?>
+
+ | type; ?> |
+ name; ?> |
+ value; ?> |
+ percentage; ?> |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | From |
+ To |
+ Quater |
+ Shift |
+ Action |
+
+
+
+
+ $value) { ?>
+
+
+ | date_from; ?> |
+ date_to; ?> |
+ quater; ?> |
+ shift; ?> |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+ | Service Provider |
+ Cost |
+ Type |
+ Description |
+ Valid From |
+ Valid To |
+ Action |
+
+
+
+
+ $value) { ?>
+
+
+ | service_provider; ?> |
+ cost; ?> |
+ type; ?> |
+ description; ?> |
+ valid_from; ?> |
+ valid_to; ?> |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
; ?>assets/uploads/hand_points.jpg)
+
+
+
+
+
+
+
+
; ?>assets/uploads/hand_points.jpg)
+
+
+
+
+
+
+
+
+
+
+
+
+ xxFood truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo
+ booth letterpress, commodo enim craft beer mlkshk
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/modules/Asset/views/asset_usage_form.php b/application/modules/Asset/views/asset_usage_form.php
new file mode 100644
index 0000000..34b2e76
--- /dev/null
+++ b/application/modules/Asset/views/asset_usage_form.php
@@ -0,0 +1,48 @@
+
+
+
\ No newline at end of file
diff --git a/application/modules/Asset/views/asset_value_form.php b/application/modules/Asset/views/asset_value_form.php
new file mode 100644
index 0000000..078a0da
--- /dev/null
+++ b/application/modules/Asset/views/asset_value_form.php
@@ -0,0 +1,48 @@
+
+
+
\ No newline at end of file
diff --git a/application/modules/Asset/views/edit_asset.php b/application/modules/Asset/views/edit_asset.php
new file mode 100644
index 0000000..9a2fe5a
--- /dev/null
+++ b/application/modules/Asset/views/edit_asset.php
@@ -0,0 +1,194 @@
+
+
+
+
+
+
+
+
+
+
Edit Assets
+
+
+
+
+
+
+
+
+
+
+
General Information
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/Asset/views/includes/footer.php b/application/modules/Asset/views/includes/footer.php
new file mode 100644
index 0000000..d6f0738
--- /dev/null
+++ b/application/modules/Asset/views/includes/footer.php
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+