[ Avaa Bypassed ]




Upload:

Command:

www-data@18.117.157.139: ~ $
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

/* * *****************Notice.php**********************************
 * @product name    : University Management System Express
 * @type            : Class
 * @class name      : Notice
 * @description     : Manage school academic notice for student, guardian, teacer and employee.  
 * @author          : Farid Ahmed, Webmaster, BDU 	
 * @url             : https://bdu.ac.bd/      
 * @support         : farid0001@bdu.ac.bd	
 * @copyright       : BDU ICT Team	 	
 * ********************************************************** */

class Notice extends MY_Controller {

    public $data = array();

    function __construct() {
        parent::__construct();
        $this->load->model('Notice_Model', 'notice', true);        
    }

    
    /*****************Function index**********************************
    * @type            : Function
    * @function name   : index
    * @description     : Load "Notice List" user interface                 
    *                       
    * @param           : null
    * @return          : null 
    * ********************************************************** */
    public function index($school_id = null) {

        check_permission(VIEW);
        
        $this->data['notices'] = $this->notice->get_notice_list($school_id);
        $this->data['roles'] = $this->notice->get_list('roles', array('status' => 1), '', '', '', 'id', 'ASC');
        
        $this->data['filter_school_id'] = $school_id;
        $this->data['schools'] = $this->schools;
        
        $this->data['list'] = TRUE;
        $this->layout->title($this->lang->line('manage_notice') . ' | ' . SMS);
        $this->layout->view('notice/index', $this->data);
    }

    
    /*****************Function add**********************************
    * @type            : Function
    * @function name   : add
    * @description     : Load "Add new Notice" user interface                 
    *                    and process to store "Notice" into database 
    * @param           : null
    * @return          : null 
    * ********************************************************** */
    public function add() {

        check_permission(ADD);

        if ($_POST) {
            $this->_prepare_notice_validation();
            if ($this->form_validation->run() === TRUE) {
                $data = $this->_get_posted_notice_data();

                $insert_id = $this->notice->insert('notices', $data);
                if ($insert_id) {
                    
                    create_log('Has been created a notice : '.$data['title']);
                    success($this->lang->line('insert_success'));
                    redirect('announcement/notice/index/'.$data['school_id']);
                    
                } else {
                    error($this->lang->line('insert_failed'));
                    redirect('announcement/notice/add');
                }
            } else {
                error($this->lang->line('insert_failed'));
                $this->data['post'] = $_POST;
            }
        }

        $this->data['notices'] = $this->notice->get_notice_list();
        $this->data['roles'] = $this->notice->get_list('roles', array('status' => 1), '', '', '', 'id', 'ASC');
        $this->data['schools'] = $this->schools;
        
        $this->data['add'] = TRUE;
        $this->layout->title($this->lang->line('add') . ' | ' . SMS);
        $this->layout->view('notice/index', $this->data);
    }



    /*****************Function resume**********************************
    * @type            : Function
    * @function name   : resume
    * @description     : validate resume                  
    *                       
    * @param           : null
    * @return          : boolean true/false 
    * ********************************************************** */
    public function notice_file() {
        if ($_FILES['pdf_file']['name']) {
            $name = $_FILES['pdf_file']['name'];
            $ext = pathinfo($name, PATHINFO_EXTENSION);
            if ($ext == 'pdf') {
                return TRUE;
            } else {
                $this->form_validation->set_message('pdf_file', $this->lang->line('select_valid_file_format'));
                return FALSE;
            }
        }
    }

    
    /*****************Function edit**********************************
    * @type            : Function
    * @function name   : edit
    * @description     : Load Update "Notice" user interface                 
    *                    with populated "Notice" value 
    *                    and process update "Notice" database    
    * @param           : $id integer value
    * @return          : null 
    * ********************************************************** */
    public function edit($id = null) {

        check_permission(EDIT);

        if(!is_numeric($id)){
            error($this->lang->line('unexpected_error'));
            redirect('announcement/notice/index');
        }
        
        if ($_POST) {
            $this->_prepare_notice_validation();
            if ($this->form_validation->run() === TRUE) {
                $data = $this->_get_posted_notice_data();
                $updated = $this->notice->update('notices', $data, array('id' => $this->input->post('id')));

                if ($updated) {
                    
                    create_log('Has been updated a notice : '.$data['title']);  
                    
                    success($this->lang->line('update_success'));
                    redirect('announcement/notice/index/'.$data['school_id']);
                } else {
                    error($this->lang->line('update_failed'));
                    redirect('announcement/notice/edit/' . $this->input->post('id'));
                }
            } else {
                error($this->lang->line('update_failed'));
                $this->data['notice'] = $this->notice->get_single('notices', array('id' => $this->input->post('id')));
            }
        }

        if ($id) {
            $this->data['notice'] = $this->notice->get_single('notices', array('id' => $id));

            if (!$this->data['notice']) {
                redirect('announcement/notice/index');
            }
        }

        $this->data['notices'] = $this->notice->get_notice_list();
        $this->data['roles'] = $this->notice->get_list('roles', array('status' => 1), '', '', '', 'id', 'ASC');
        $this->data['school_id'] = $this->data['notice']->school_id;
        $this->data['filter_school_id'] = $this->data['notice']->school_id;
        $this->data['schools'] = $this->schools;
        
        $this->data['edit'] = TRUE;
        $this->layout->title($this->lang->line('edit') . ' | ' . SMS);
        $this->layout->view('notice/index', $this->data);
    }

    
    /*****************Function view**********************************
    * @type            : Function
    * @function name   : view
    * @description     : Load user interface with specific notice data                 
    *                       
    * @param           : $id integer value
    * @return          : null 
    * ********************************************************** */
    public function view($id = null) {

        check_permission(VIEW);

         if(!is_numeric($id)){
            error($this->lang->line('unexpected_error'));
            redirect('announcement/notice/index');
        }
        
        $this->data['notices'] = $this->notice->get_notice_list();
        $this->data['roles'] = $this->notice->get_list('roles', array('status' => 1), '', '', '', 'id', 'ASC');
        
        $this->data['notice'] = $this->notice->get_single_notice($id);
        $this->data['detail'] = TRUE;
        $this->layout->title($this->lang->line('view') . ' ' . $this->lang->line('notice') . ' | ' . SMS);
        $this->layout->view('notice/index', $this->data);
    }

    
        
           
     /*****************Function get_single_notice**********************************
     * @type            : Function
     * @function name   : get_single_notice
     * @description     : "Load single notice information" from database                  
     *                    to the user interface   
     * @param           : null
     * @return          : null 
     * ********************************************************** */
    public function get_single_notice(){
        
       $notice_id = $this->input->post('notice_id');
       
       $this->data['notice'] = $this->notice->get_single_notice($notice_id);
       echo $this->load->view('notice/get-single-notice', $this->data);
    }

        
    /*****************Function _prepare_notice_validation**********************************
    * @type            : Function
    * @function name   : _prepare_notice_validation
    * @description     : Process "Notice" user input data validation                 
    *                       
    * @param           : null
    * @return          : null 
    * ********************************************************** */
    private function _prepare_notice_validation() {
        $this->load->library('form_validation');
        $this->form_validation->set_error_delimiters('<div class="error-message" style="color: red;">', '</div>');

        $this->form_validation->set_rules('school_id', $this->lang->line('school_name'), 'trim|required');
        $this->form_validation->set_rules('role_id', $this->lang->line('notice_for'), 'trim|required');
        $this->form_validation->set_rules('title', $this->lang->line('notice') . ' ' . $this->lang->line('title'), 'trim|required|callback_title');
        $this->form_validation->set_rules('date', $this->lang->line('date'), 'trim|required');
        //$this->form_validation->set_rules('notice', $this->lang->line('notice'), 'trim|required');
    }

    
    /*****************Function title**********************************
    * @type            : Function
    * @function name   : title
    * @description     : Unique check for "Notice title" data/value                  
    *                       
    * @param           : null
    * @return          : boolean true/false 
    * ********************************************************** */ 
    public function title() {
        if ($this->input->post('id') == '') {
            $notice = $this->notice->duplicate_check($this->input->post('school_id'), $this->input->post('title'), $this->input->post('date'));
            if ($notice) {
                $this->form_validation->set_message('title', $this->lang->line('already_exist'));
                return FALSE;
            } else {
                return TRUE;
            }
        } else if ($this->input->post('id') != '') {
            $notice = $this->notice->duplicate_check($this->input->post('school_id'),$this->input->post('title'), $this->input->post('date'), $this->input->post('id'));
            if ($notice) {
                $this->form_validation->set_message('title', $this->lang->line('already_exist'));
                return FALSE;
            } else {
                return TRUE;
            }
        }
    }



    /*****************Function resource**********************************
    * @type            : Function
    * @function name   : resource
    * @description     : validate resourceresource                  
    *                       
    * @param           : null
    * @return          : boolean true/false 
    * ********************************************************** */
    public function resource_pdf() {
        if ($_FILES['resource_pdf']['name']) {
            $name = $_FILES['resource_pdf']['name'];
            $ext = pathinfo($name, PATHINFO_EXTENSION);
            if ($ext == 'pdf') {
                return TRUE;
            } else {
                $this->form_validation->set_message('resource_pdf', $this->lang->line('select_valid_file_format'));
                return FALSE;
            }
        }
    }


    /*****************Function resource_pdf**********************************
    * @type            : Function
    * @function name   : resource_pdf
    * @description     : process to upload teacher profile resource_pdf in the server                  
    *                     and return resource_pdf file name  
    * @param           : null
    * @return          : $return_resource_pdf string value 
    * ********************************************************** */
    private function _upload_resource_pdf() {
        $prev_resume = $this->input->post('prev_resume');
        $resume = $_FILES['resource_pdf']['name'];
        $resume_type = $_FILES['resource_pdf']['type'];
        $return_resume = '';

        if ($resume != "") {
            if ($resume_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
                    $resume_type == 'application/msword' || $resume_type == 'text/plain' ||
                    $resume_type == 'application/vnd.ms-office' || $resume_type == 'application/pdf') {

                $destination = 'assets/uploads/resources/';

                $file_type = explode(".", $resume);
                $extension = strtolower($file_type[count($file_type) - 1]);
                $resume_path = 'resource_pdf-' . time() . '-department.' . $extension;

                move_uploaded_file($_FILES['resource_pdf']['tmp_name'], $destination . $resume_path);

                // need to unlink previous photo
                if ($prev_resume != "") {
                    if (file_exists($destination . $prev_resume)) {
                        @unlink($destination . $prev_resume);
                    }
                }

                $return_resume = $resume_path;
            }
        } else {
            $return_resume = $prev_resume;
        }

        return $return_resume;
    }

    
    /*****************Function _get_posted_notice_data**********************************
    * @type            : Function
    * @function name   : _get_posted_notice_data
    * @description     : Prepare "Notice" user input data to save into database                  
    *                       
    * @param           : null
    * @return          : $data array(); value 
    * ********************************************************** */
    private function _get_posted_notice_data() {

        $items = array();
        $items[] = 'school_id';
        $items[] = 'role_id';
        $items[] = 'title';
        $items[] = 'notice';
        $items[] = 'is_view_on_web';



        
        $data = elements($items, $_POST);

        $data['date'] = date('Y-m-d', strtotime($this->input->post('date')));

        if ($this->input->post('id')) {
            $data['modified_at'] = date('Y-m-d H:i:s');
            $data['modified_by'] = logged_in_user_id();
        } else {
            $data['status'] = 1;
            $data['created_at'] = date('Y-m-d H:i:s');
            $data['created_by'] = logged_in_user_id();
        }

         if($_FILES['resource_pdf']['name']) {
            $data['pdf_file'] = $this->_upload_resource_pdf();
        }  

        return $data;
    }


   

    
    /*****************Function delete**********************************
    * @type            : Function
    * @function name   : delete
    * @description     : delete "Notice" from database                  
    *                       
    * @param           : $id integer value
    * @return          : null 
    * ********************************************************** */
    public function delete($id = null) {

        check_permission(VIEW);

        if(!is_numeric($id)){
            error($this->lang->line('unexpected_error'));
            redirect('announcement/notice/index');
        }
        
        $notice = $this->notice->get_single('notices', array('id' => $id));
        
        if ($this->notice->delete('notices', array('id' => $id))) {
            
            create_log('Has been deleted a notice : '.$notice->title);
            success($this->lang->line('delete_success'));
            
        } else {
            error($this->lang->line('delete_failed'));
        }
       redirect('announcement/notice/index/'.$notice->school_id);
    }

}

Filemanager

Name Type Size Permission Actions
Holiday.php File 13.13 KB 0777
News.php File 15.17 KB 0777
Notice.php File 15.87 KB 0777
index.html File 131 B 0777