MMCT TEAM
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  ]

Current File : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/asm/AssetsIssues.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');


/**
 * 
 */
class AssetsIssues  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');
    }

    public function index(){
        if(session_userdata('isAdminLoggedin')){

            $institute_data=check_institute($this->data['userdata']);
            $inst_id=$this->inst_id;
            $inst_type=$this->inst_type;

            $asm_access=$institute_data['asm_access'];

            if($asm_access=='yes'){
                $this->data['page_title']='Assets Issue';
                $view='asm/vw_assets_issues';
            }else{
                $this->data['page_title']='Assets Issue';
                $view='asm/vw_assets_permission_denied';
            }

            $this->theme->title($this->data['page_title'])->load($view, $this->data);
        }else{
            redirect($this->data['base_url']);
        }
    }


    public function onAddEditBrand(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){
            if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){

                $inst_id=$this->inst_id;
                $inst_type=$this->inst_type;
                $user_id=$this->data['userdata']->user_id;

                $_assets_brand=post_data('_assets_brand');
                $assets_brand_name=post_data('assets_brand_name');
                $assets_brand_status=post_data('assets_brand_status');              

                $data_to_add=array(
                    'brand_inst_id'=>$inst_id,
                    'brand_inst_type'=>$inst_type,
                    'brand_name'=>$assets_brand_name,
                    'brand_created_by'=>$user_id,
                    'brand_status'=>$assets_brand_status
                );

                if(empty($_assets_brand)){
                    $added=$this->asm->store_brand_stores($data_to_add);

                    if($added){
                        $return['success']='Brand added successfully';
                    }else{
                        $return['error']='Brand not added';
                    }
                }else{
                    $brand_id=decode_data($_assets_brand);

                    $data_to_add=array(
                        'brand_inst_id'=>$inst_id,
                        'brand_inst_type'=>$inst_type,
                        'brand_name'=>$assets_brand_name,
                        'brand_updated_by'=>$user_id,
                        'brand_status'=>$assets_brand_status,
                        'brand_updated_at'=>date('Y-m-d H:i:s')
                    );

                    $updated=$this->asm->update_brand_stores($data_to_add,array('brand_id'=>$brand_id,'brand_inst_id'=>$inst_id,'brand_inst_type'=>$inst_type));

                    if($updated){
                        $return['success']='Brand updated successfully';
                    }else{
                        $return['error']='Brand not updated';
                    }
                }  

                json_headers($return);

            }else{
                redirect($this->data['base_url']);
            }
        }else{
            redirect($this->data['base_url']);
        }
    }


    public function onDeleteBrand(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){
            if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){

                $_brand_id=post_data('brand_id');

                $brand_id=decode_data($_brand_id);

                $brand_data=$this->asm->get_brands(array('brand_id'=>$brand_id));

                if(!empty($brand_data)){

                    $deleted=$this->asm->delete_brand(array('brand_id'=>$brand_id));

                    if($deleted){
                        $return['success']='Brand deleted.';
                    }else{
                        $return['error']='Brand not deleted';
                    }

                }else{
                    $return['error']='Brand data not found.';
                }

                json_headers($return);

            }else{
                redirect($this->data['base_url']);
            }
        }else{
            redirect($this->data['base_url']);
        }
    }


    public function onSearchAssetIssuesList(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){
            if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){

                $inst_id=$this->inst_id;
                $inst_type=$this->inst_type;

                $param['column_order'] = array(
                    null,
                    'category_name',
                    'asset_name'
                );

                $param['inst_id']=$inst_id;
                $param['inst_type']=$inst_type;

                $param['column_search'] = array('category_name','asset_name');
                $param['order'] = array('asset_issue_id ' => 'ASC');
                $posts=$this->input->post();

                $list = $this->asm->_get_assets_issues($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->category_name;
                    $row[]  =   $asm->asset_name;
                    $row[]  =   $asm->asset_issue_qty;
                    $row[]  =   '';
                    $row[]  =   '';
                    $row[]  =   date('d-m-Y',strtotime($asm->asset_issue_date));

                    //$row[]  =   $status;
                    
                    $row[]  =   '<button type="button" class="btn btn-xs btn-dark btn_edit_brand"><i class="fa fa-pencil"></i></button> <button type="button" class="btn btn-xs btn-danger btn_del_brand"><i class="fa fa-trash"></i></button>';

                    $data[] = $row; 
                }

                $output = array(
                    "draw" => isset($posts['draw'])?$posts['draw']:'',
                    "recordsTotal" => $this->asm->_get_assets_issues($posts,$param,TRUE),
                    "recordsFiltered" => $this->asm->_get_assets_issues($posts,$param,TRUE),
                    "data" => $data,
                );
                
                echo json_encode($output);

            }else{
                redirect($this->data['base_url']);
            }
        }else{
            redirect($this->data['base_url']);
        }
    }
}

MMCT - 2023