184 lines
6.2 KiB
PHP
184 lines
6.2 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
/**
|
|
* AMS
|
|
*
|
|
* @package HMVC
|
|
* @author Venba
|
|
* @copyright 2022 Venba
|
|
* @license https://venbainfotech.com/licenses/MIT MIT License
|
|
* @link <URI> (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);
|
|
}
|
|
|
|
}
|