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


/**
 * 
 */
class Section  extends BaseAdminController
{
    function __construct()
    {
        parent::__construct();
    }

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

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

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

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


    public function onAddEditSection(){
        if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){

            $section_name=post_data('section_name');
            $section_id=post_data('_section');

            $this->form_validation->set_rules('section_name', 'Section name required', 'trim|required');

            if ($this->form_validation->run() == true){
                $section_data=$this->sec->get_section(array('section_institute_id'=>$this->data['userdata']->user_id,'section_name'=>$section_name));

                if(empty($section_id)){
                    $added=$this->sec->store_section(array('section_institute_id'=>$this->data['userdata']->user_id,'section_name'=>$section_name));

                    if($added){
                        $return['success']='Section added successfully';
                    }else{
                        $return['error']='Section not added';
                    }
                }else if(!empty($section_id)){
                    $section_id=decode_data($section_id);
                    $updated=$this->sec->update_section(array('section_institute_id'=>$this->data['userdata']->user_id,'section_name'=>$section_name),array('section_id'=>$section_data->section_id));

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

                

            json_headers($return);

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


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

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


                $param['created_by']=session_userdata('admin_id');


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

                $action='';

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

                    $row = array();

                    $row[]  =   $no;
                    $row[]  =   $section->section_name; 
                    
                    $row[]  =   '<button class="btn btn-xs btn-info btn_edit_section" data-section="'.encode_data($section->section_id).'" data-name="'.$section->section_name.'"><i class="fa fa-edit"></i></button>';
                    //<button class="btn btn-xs btn-danger" data-section="'.encode_data($section->section_id).'"><i class="fa fa-trash"></i></button>';

                    $data[] = $row; 
                }

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

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

MMCT - 2023