Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/asm/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Assets extends BaseAdminController { protected $inst_id=''; protected $inst_parent_id=''; protected $inst_code=''; protected $inst_type=''; protected $asm_access=''; function __construct() { parent::__construct(); $institute_data=check_institute($this->data['userdata']); $this->inst_id=$institute_data['institute_id']; $this->inst_parent_id=$institute_data['inst_parent_id']; $this->inst_code=$institute_data['inst_code']; $this->inst_type=$institute_data['inst_type']; $this->asm_access=$institute_data['asm_access']; $this->load->model('asm/assets_model','asm'); } function index($category_id=null){ if(session_userdata('isAdminLoggedin')){ if($this->asm_access=='yes'){ $categories=array(); $suplliers=array(); $stores=array(); $category_id=decode_data($category_id); $_categories=$this->asm->get_assets_category(array('category_inst_id'=>$this->inst_id,'category_inst_type'=>$this->inst_type,'category_status'=>'active'),FALSE); if(!empty($_categories)){ foreach ($_categories as $key => $value) { $categories[]=array( 'category_id'=>$value->category_id, 'category_name'=>$value->category_name, 'selected'=>($value->category_id==$category_id)?'selected':'' ); } } $_suppliers=$this->asm->get_assets_suppliers(array('supplier_inst_type'=>$this->inst_type,'supplier_inst_id'=>$this->inst_id),FALSE); if(!empty($_suppliers)){ foreach ($_suppliers as $key => $value) { $suppliers[]=array( 'supplier_id'=>$value->supplier_id, 'supplier_name'=>$value->supplier_name ); } } $_stores=$this->asm->get_assets_stores(array('store_inst_type'=>$this->inst_type,'store_inst_id'=>$this->inst_id),FALSE); if(!empty($_stores)){ foreach ($_stores as $key => $value) { $stores[]=array( 'store_id'=>$value->store_id, 'store_name'=>$value->store_name ); } } $_brands=$this->asm->get_brands(array('brand_status'=>'active','brand_inst_type'=>$this->inst_type,' brand_inst_id'=>$this->inst_id),FALSE); if(!empty($_brands)){ foreach ($_brands as $key => $value) { $brands[]=array( 'brand_id'=>$value->brand_id, 'brand_name'=>$value->brand_name ); } } $this->data['categories']=$categories; $this->data['suppliers']=$suppliers; $this->data['stores']=$stores; $this->data['brands']=$brands; $this->data['page_title']='Assets'; $this->theme->title($this->data['page_title'])->load('asm/vw_assets', $this->data); }else{ $this->data['page_title']='Assets'; $this->theme->title($this->data['page_title'])->load('asm/vw_assets_permission_denied', $this->data); } }else{ redirect($this->data['base_url']); } } function indexAssetsCategories(){ if(session_userdata('isAdminLoggedin')){ if($this->asm_access=='yes'){ $this->data['page_title']='Assets Category'; $this->theme->title($this->data['page_title'])->load('asm/vw_assets_categories', $this->data); }else{ $this->data['page_title']='Assets'; $this->theme->title($this->data['page_title'])->load('asm/vw_assets_permission_denied', $this->data); } }else{ redirect($this->data['base_url']); } } public function onSearchAssetsList(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $institute_data=check_institute($this->data['userdata']); $inst_id=$institute_data['institute_id']; $inst_type=$institute_data['inst_type']; $param['column_order'] = array( null, 'asset_name' ); $param['asset_inst_id']=$this->inst_id; $param['column_search'] = array('asset_name','category_name'); $param['order'] = array('asset_category_id' => 'ASC'); $posts=$this->input->post(); // $asset_category_id=$posts['asset_category_id']; // $category_id=decode_data($asset_category_id); // $param['asset_category_id']=$category_id; $list = $this->asm->_get_assets($posts,$param,FALSE,FALSE); $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $asm){ $no++; $row = array(); $row[] = $no; $row[] = $asm->asset_name; $row[] = $asm->asset_code; if($asm->asset_status=='active'){ $status='<span class="badge badge-sm badge-success">Active</span>'; }else if($asm->asset_status=='inactive'){ $status='<span class="badge badge-sm badge-danger">Inactive</span>'; }else if($asm->asset_status=='maintanance'){ $status='<span class="badge badge-sm badge-warning">Maintanance</span>'; } $row[] = $status; $row[] = '<button type="button" class="btn btn-xs btn-info btn_asset_edit" data-asset_id="'.encode_data($asm->asset_id).'" data-asset_name="'.$asm->asset_name.'" data-asset_status="'.$asm->asset_status.'" data-asset_category="'.$asm->asset_category_id.'" data-asset_store_id="'.$asm->asset_store_id.'" data-supplier_id="'.$asm->asset_supplier_id.'" data-asset_type="'.$asm->asset_inst_type.'" data-asset_code="'.$asm->asset_code.'"><i class="fa fa-pencil"></i></button> <button type="button" class="btn btn-xs btn-danger btn_asset_del" data-asset_id="'.encode_data($asm->asset_id).'" data-asset_status="'.$asm->asset_status.'"><i class="fa fa-trash"></i></button>'; $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->asm->_get_assets($posts,$param,TRUE), "recordsFiltered" => $this->asm->_get_assets($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onAddEditAssets(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $asset_id=post_data('assets_id'); $assets_name=post_data('assets_name'); $assets_code=post_data('assets_code'); $asset_category=post_data('asset_category'); $assets_type=post_data('assets_type'); $assets_brand=post_data('assets_brand'); $assets_store=post_data('assets_store'); $assets_supplier=post_data('assets_supplier'); $assets_purchase_date=post_data('assets_purchase_date'); $assets_purchase_cost=post_data('assets_purchase_cost'); $assets_warranty_period=post_data('asset_warranty'); $assets_note=post_data('assets_note'); $assets_status=post_data('assets_status'); $institute_data=check_institute($this->data['userdata']); $inst_id=$institute_data['institute_id']; $inst_type=$institute_data['inst_type']; $user_id=$this->data['userdata']->user_id; if(empty($asset_id)){ $asset_found=$this->asm->get_assets(array('asset_code'=>$assets_code)); if(empty($asset_found)){ $data_to_add=array( 'asset_category_id'=>$asset_category, 'asset_store_id'=>$assets_store, 'asset_supplier_id'=>$assets_supplier, 'asset_inst_id'=>$this->inst_id, 'asset_inst_type'=>$this->inst_type, 'asset_type'=>$assets_type, 'asset_name'=>$assets_name, 'asset_code'=>$assets_code, 'asset_status'=>$assets_status, 'asset_purchase_date'=>date('Y-m-d',strtotime($assets_purchase_date)), 'asset_manufacturer'=>$assets_brand, 'asset_note'=>$assets_note, 'asset_created_by'=>$user_id ); $added=$this->asm->store_assets($data_to_add); if($added){ $return['success']='Asset added.'; }else{ $return['error']='Asset not added.'; } }else{ $return['error']='Asset already found in the system'; } }else{ $asset_id=decode_data($asset_id); $asset_found=$this->asm->get_assets(array('asset_id'=>$asset_id,'asset_inst_id'=>$this->inst_id)); if(!empty($asset_found)){ $data_to_add=array( 'asset_category_id'=>$asset_category, 'asset_store_id'=>$assets_store, 'asset_supplier_id'=>$assets_supplier, 'asset_inst_id'=>$this->inst_id, 'asset_inst_type'=>$this->inst_type, 'asset_type'=>$assets_type, 'asset_name'=>$assets_name, 'asset_code'=>$assets_code, 'asset_status'=>$assets_status, 'asset_purchase_date'=>date('Y-m-d',strtotime($assets_purchase_date)), 'asset_manufacturer'=>$assets_brand, 'asset_note'=>$assets_note, 'asset_updated_by'=>$user_id, 'asset_updated_at'=>date('Y-m-d H:i:s') ); $added=$this->asm->update_assets_category($data_to_add,array('asset_id'=>$asset_id,'asset_inst_id'=>$this->inst_id)); if($added){ $return['success']='Asset updated.'; }else{ $return['error']='Asset not updated.'; } }else{ $return['error']='Asset data not found in the system.'; } } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onDeleteAssetsCategory(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $_assets_category=post_data('_assets_category'); $category_inst_id=$this->data['userdata']->user_id; if(!empty($_assets_category)){ $category_id=decode_data($_assets_category); $category_found=$this->asm->get_assets_category(array('category_id'=>$category_id,'category_inst_id'=>$category_inst_id)); if(!empty($category_found)){ $deleted=$this->asm->delete_assets_category(array('category_id'=>$category_id,'category_inst_id'=>$category_inst_id)); if($deleted){ $return['success']='Assets Category deleted successfully.'; }else{ $return['error']='Assets Category not deleted.'; } $return['success']='Assets Category deleted successfully.'; }else{ $return['error']='Assets Category not found'; } }else{ $return['error']='Data manipulation not permitted'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } }