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/

[  Home  ][  C0mmand  ][  Upload File  ]

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


/**
 * 
 */
class Fees  extends BaseAdminController
{
    protected $inst_id='';
    protected $inst_parent_id='';

    function __construct()
    {
        parent::__construct();

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

        //print_obj($institute_data);die;

        $this->user_type=$this->data['userdata']->user_type;

        $this->inst_id=$institute_data['institute_id'];
        $this->inst_parent_id=$institute_data['inst_parent_id'];
    }

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

            $this->data['page_title']='Fees';

            $sessions=$this->sessm->get_session(array('session_inst_id'=>$this->data['userdata']->user_id),FALSE);
            $courses=$this->cm->get_course(array('course_inst_id'=>$this->data['userdata']->user_id),FALSE);

            $session_courses=$this->sessm->get_session_courses(array('session_inst_id'=>$this->data['userdata']->user_id),FALSE);

            $this->data['sessions']=$sessions;
            $this->data['courses']=$courses;
            $this->data['session_courses']=$session_courses;

            $this->data['fees_types']=$this->fm->get_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id));

            $this->theme->title($this->data['page_title'])->load('master/vw_fees', $this->data);
        }else{

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

    function indexFeesAddEdit($fees_id=null){
       
        if(session_userdata('isAdminLoggedin')){

            $this->data['page_title']='Fees';

            $this->data['fees_id']=$fees_id;

            $_fees_types=array();

            if($fees_id!=null){
                $fees_id=decode_data($fees_id);
                $fees_data=$this->fm->get_fees_type_data(array('fees_id'=>$fees_id));

                //print_obj($fees_data);
            }



            $fees_types=$this->fm->get_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_group'=>'Admission'),FALSE);


            if(!empty($fees_types)){
                foreach ($fees_types as $key => $value) {
                    $_fees_types[]=array(
                        'fees_type_id'=>$value->fees_type_id,
                        'fees_type'=>$value->fees_type,
                    );
                }
            }

            $this->data['fees_type']=$_fees_types;

            $sessions=$this->sessm->get_session(array('session_inst_id'=>$this->data['userdata']->user_id),FALSE);

            $_sessions=array();

            if(!empty($sessions)){
                foreach ($sessions as $key => $value) {
                    $_sessions[]=array(
                        'session_id'=>$value->session_id,
                        'session_year'=>$value->session_start_year.'-'.$value->session_end_year,
                        'selected'=>(isset($fees_data) && ($fees_data->fees_session_id==$value->session_id))?'selected':''
                    );
                }
            }

            //print_obj($_sessions);die;

            $this->data['sessions']=$_sessions;
            if(isset($fees_data) && $fees_data->fees_course_id>0){
                $courses=$this->cm->get_course(array('course_inst_id'=>$this->data['userdata']->user_id,'course_id'=>$fees_data->fees_course_id));
            }else{
                $courses=$this->cm->get_course(array('course_inst_id'=>$this->data['userdata']->user_id),FALSE);
            }
            
            $session_courses=$this->sessm->get_session_courses(array('session_inst_id'=>$this->data['userdata']->user_id),FALSE);

            $this->data['courses']=$courses;
            $this->data['session_courses']=$session_courses;

            $this->theme->title($this->data['page_title'])->load('master/vw_fees_add_edit', $this->data);
        }else{

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

    function indexFeesType(){
       
        if(session_userdata('isAdminLoggedin')){

            $this->data['page_title']='Fees Type';

            $this->theme->title($this->data['page_title'])->load('master/vw_feestype', $this->data);
        }else{

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


    public function onAddEditFeesTypes(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){
            if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){
                $fees_type=post_data('fees_type');
                $fees_type_group=post_data('fees_type_group');
                $fees_type_status = post_data('fees_type_status');
                $fees_type_id=post_data('_fees');

                $this->form_validation->set_rules('fees_type', 'Fees name required', 'trim|required');
                $this->form_validation->set_rules('fees_type_group', 'Fees head group required', 'trim|required');
                $this->form_validation->set_rules('fees_type_status', 'Fees head effect required', 'trim|required');

                if ($this->form_validation->run() == true){
                    $fees_data=$this->fm->get_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_group'=>$fees_type_group,'fees_type'=>$fees_type));

                    if(empty($fees_type_id)){
                        $added=$this->fm->store_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_group'=>$fees_type_group,'fees_type'=>$fees_type,'fees_type_status'=>$fees_type_status));

                        if($added){
                            $return['success']='Fees head added successfully';
                        }else{
                            $return['error']='Fees head not added';
                        }
                    }else if(!empty($fees_type_id)){
                        $fees_type_id=decode_data($fees_type_id);

                        $fees_data=$this->fm->get_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_id'=>$fees_type_id));

                        if(!empty($fees_data)){
                            $_fees_data=$this->fm->get_fees_type(array('fees_type_id!='=>$fees_type_id,'fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_group'=>$fees_type_group,'fees_type'=>$fees_type));

                            if(empty($_fees_data)){
                                $updated=$this->fm->update_fees_type(array('fees_type_inst_id'=>$this->data['userdata']->user_id,'fees_type_group'=>$fees_type_group,'fees_type'=>$fees_type,'fees_type_status'=>$fees_type_status),array('fees_type_id'=>$fees_data->fees_type_id));

                                if($updated){
                                    $return['success']='Fees head updated successfully';
                                }else{
                                    $return['error']='Fees head not updated';
                                }
                            }else{
                                $return['error']='Data already exists';
                            }
                        }else{
                            $return['error']='No data found to update';
                        } 
                    }
                }else{
                    $return['error']='Error occurred';
                }                

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


    public function onSearchFeesHeadList(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){
            if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){
                $param['column_order'] = array(
                    null,
                    'fees_type_group',
                    'fees_type',
                    'fees_type_effect'
                );

                $param['column_search'] = array('fees_type_group','fees_type','fees_type_effect');
                $param['order'] = array('fees_type_id' => 'ASC');
                $posts=$this->input->post();


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


                $list = $this->fm->_get_fees_type($posts,$param,FALSE,FALSE);
                
                
                $data = array();
                $no = isset($posts['start'])?$posts['start']:0;

                $action='';

                foreach ($list as $fees){
                    $no++;

                    $row = array();

                    $row[]  =   $no;
                    $row[]  =   ucwords($fees->fees_type_group); 
					$row[]  =   $fees->fees_type;
					$row[]  =   $fees->fees_type_status;
                    
                    $row[]  =   '
                    <button type="button" class="btn btn-xs btn-info btn_edit_fees" data-fees="'.encode_data($fees->fees_type_id).'" data-fees_type_group="'.$fees->fees_type_group.'" data-fees_type="'.$fees->fees_type.'" data-fees_type_effect="'.$fees->fees_type_effect.'" data-fees_type_status="'.$fees->fees_type_status.'" data-fees_type_id="'.encode_data($fees->fees_type_id).'"><i class="fa fa-edit"></i></button>';
                   // <button type="button" class="btn btn-xs btn-danger btn_delete_fees" data-fees="'.encode_data($fees->fees_type_id).'"><i class="fa fa-trash"></i></button>';

                    $data[] = $row; 
                }

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

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


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

                $user_id=$this->data['userdata']->user_id;
                $session_id=post_data('fees_session');

                $fees_academic_year='0';//post_data('fees_academic_year');
                $fees_course=post_data('fees_course');

                $fees_types=$this->input->post('fees_type');

                $total_fees_value=0;

                //print_obj($fees_types);die;

                if(!empty($fees_course) && !empty($session_id)){

                    $course_id=$fees_course;//decode_data($course_id);
                    //$session_id=post_data($session_id);

                    $course_data=$this->sessm->get_session_courses(array('session_id'=>$session_id,'session_inst_id'=>$user_id,'session_course_id'=>$course_id));

                    $course_fees=$course_data->session_course_fees;

                    

                    if(!empty($fees_types)){
                        $fees_data=$this->fm->get_fees_type_data(array('fees_inst_id'=>$user_id,'fees_session_id'=>$session_id,'fees_course_id'=>$course_id,'fees_year_id'=>$fees_academic_year));

                        if(!empty($fees_data)){
                            $this->fm->delete_fees_type_data(array('fees_inst_id'=>$user_id,'fees_session_id'=>$session_id,'fees_course_id'=>$course_id,'fees_year_id'=>$fees_academic_year));
                        }

                        foreach ($fees_types as $key => $value) {
                            $total_fees_value+=$value['type_value'];
                            $data_tostore[]=array(
                                'fees_inst_id'=>$user_id,
                                'fees_session_id'=>$session_id,
                                'fees_course_id'=>$course_id,
                                'fees_year_id'=>$fees_academic_year,
                                'fees_type_id'=>$key,
                                'fees_duration_type'=>'yearwise',
                                'fees_value'=>$value['type_value'],
                                'created_by'=>$user_id,
                                'created_at'=>date('Y-m-d')
                            );
                        }

                        if($total_fees_value<=$course_fees){
                            $total_fees=$this->fm->_get_fees_total(array('fees_inst_id'=>$user_id,'fees_session_id'=>$session_id,'fees_course_id'=>$course_id));

                            $total_fees+=$total_fees_value;
                            if($total_fees<=$course_fees){
                                $added=$this->fm->store_fees_type_data($data_tostore,TRUE);
                                if($added){
                                    $return['success']='Fees added successfully';
                                }else{
                                    $return['error']='Fees not added';
                                }
                            }else{
                                $return['error']='Fees structure of ₹ '.number_format($total_fees,2).' can not exceeds total course fees of ₹ '.number_format($course_fees,2).' for this session';
                            }
                                
                        }else{
                            $return['error']='Fees structure can not be exceeds total course fees of ₹ '.number_format($course_fees,2).' for this session';
                        }

                            
                    }else{
                        $return['error']='No data found to add 1';
                    }
                }else{
                    $return['error']='No data found to add 2';
                }

                json_headers($return);

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


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

                $param['column_order'] = array(
                    null,
                    'course_name',
                    'year_value'
                );

                $param['column_search'] = array('session_start_year','session_end_year','course_name','year_value');
                $param['order'] = array('fees_id' => 'ASC');
                $posts=$this->input->post();


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


                $list = $this->fm->_get_fees_type_data($posts,$param,FALSE,FALSE);

                //print_obj($list);die;
                
                
                $data = array();
                $no = isset($posts['start'])?$posts['start']:0;

                $action='';

                foreach ($list as $fees){
                    $no++;

                    $row = array();

                    //$total_amount=$this->fm->_get_fees_total(array('fees_inst_id'=>$fees->fees_inst_id,'fees_session_id'=>$fees->fees_session_id,'fees_course_id'=>$fees->fees_course_id,'fees_year_id'=>$fees->fees_year_id,'fees_duration_type'=>'yearwise'));

                    $row[]  =   $no;
                    $row[]  =   $fees->session_start_year.'-'.$fees->session_end_year; 
                    $row[]  =   $fees->course_name;
                    $row[]  =   $fees->year_value;
                    $row[]  =   $fees->total_fees_value;                    
                    
                    $row[]  =   '<a href="'.$this->data['base_url'].'/fees/add/'.encode_data($fees->fees_session_id).'/'.encode_data($fees->fees_year_id).'" class="btn btn-xs btn-info"><i class="fa fa-edit"></i></a>
                    <button type="button" class="btn btn-xs btn-danger btn_delete_fees"><i class="fa fa-trash"></i></button>';

                    $data[] = $row; 
                }

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

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



 
}

MMCT - 2023