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/AssetsStore.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');


/**
 * 
 */
class AssetsStore  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')){

            if($this->asm_access=='yes'){
                $this->data['page_title']='Assets Store';
                $view='asm/vw_assets_store';
            }else{
                $this->data['page_title']='Assets Store';
                $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 onAddEditAsstesStores(){
        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_store=post_data('_assets_store');
                $assets_store_name=post_data('assets_store_name');
                $assets_store_email=post_data('assets_store_email');
                $assets_store_phone_no=post_data('assets_store_phone_no');
                $assets_store_address=post_data('assets_store_address');
                $store_status=post_data('assets_store_status');

                if(empty($_assets_store)){
                    $data_to_add=array(
                        'store_inst_id'=>$inst_id,
                        'store_inst_type'=>$inst_type,
                        'store_name'=>$assets_store_name,
                        'store_address'=>$assets_store_address,
                        'store_email'=>$assets_store_email,
                        'store_phone'=>$assets_store_phone_no,
                        'store_created_by'=>$user_id,
                        'store_status'=>$store_status
                    );

                    $added=$this->asm->store_assets_stores($data_to_add);

                    if($added){
                        $return['success']='Store added successfully';
                    }else{
                        $return['error']='Store not added';
                    }
                }else{
                    $store_id=decode_data($_assets_store);

                    $data_to_add=array(
                        'store_inst_id'=>$inst_id,
                        'store_inst_type'=>$inst_type,
                        'store_name'=>$assets_store_name,
                        'store_address'=>$assets_store_address,
                        'store_email'=>$assets_store_email,
                        'store_phone'=>$assets_store_phone_no,
                        'store_updated_by'=>$user_id,
                        'store_updated_at'=>date('Y-m-d H:i:s'),
                        'store_status'=>$store_status
                    );

                    $added=$this->asm->update_assets_stores($data_to_add,array('store_id'=>$store_id,'store_inst_id'=>$inst_id,'store_inst_type'=>$inst_type));
                    
                    if($added){
                        $return['success']='Store updated successfully';
                    }else{
                        $return['error']='Store not updated';
                    }
                }

                json_headers($return);

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


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

                $store_id=post_data('store_id');

                $store_id=decode_data($store_id);

                $data_found=$this->asm->get_assets_stores(array('store_id'=>$store_id));

                if(!empty($data_found)){

                    $deleted=$this->asm->delete_assets_stores(array('store_id'=>$store_id));

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

                }else{
                    $return['error']='Data npot found.';
                }

                json_headers($return);

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


    public function onSearchAssetsStoresList(){
        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,
                    'store_name'
                );

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

                $param['column_search'] = array('store_name');
                $param['order'] = array('store_id' => 'ASC');
                $posts=$this->input->post();

                $list = $this->asm->_get_assets_stores($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->store_name;

                    if($asm->store_status=='active'){
                        $status='<span class="badge badge-sm badge-success">Active</span>';
                    }else if($asm->store_status=='inactive'){
                        $status='<span class="badge badge-sm badge-danger">Inactive</span>';
                    }

                    $row[]  =   $status;
                    
                    $row[]  =   '<button type="button" class="btn btn-xs btn-dark btn_edit_store" data-store_id="'.encode_data($asm->store_id).'" data-store_name="'.$asm->store_name.'" data-store_status="'.$asm->store_status.'" data-store_email="'.$asm->store_email.'" data-store_phone="'.$asm->store_phone.'" data-store_address="'.$asm->store_address.'"><i class="fa fa-pencil"></i></button> <button type="button" class="btn btn-xs btn-danger btn_del_store" data-store_id="'.encode_data($asm->store_id).'"><i class="fa fa-trash"></i></button>';

                    $data[] = $row; 
                }

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

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

MMCT - 2023