GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.128.198.90 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/../css/../grievance/application/controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller Class For Handling All Requests Related To Course * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Course extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('session'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->model("CourseManagement"); } public function index() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $viewData['non_del_inst_course'] = $this->CourseManagement->getNonDeletedCoursesOfInstitute($this->session->userdata('inst_id'))->result(); $this->load->view('courses', $viewData); } else { redirect("Home/"); } } public function createNewCourse() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $this->load->view('add_course'); } else { redirect("Dashboard/"); } } public function saveNewCourse() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $this->form_validation->set_rules('courseName', 'Course Name', 'trim|required', array('required' => 'Course Name Can Not Be Blank.')); $this->form_validation->set_rules('courseFullName', 'Course Full Name', 'trim|required', array('required' => 'Course Full Name Can Not Be Blank')); $this->form_validation->set_rules('courseDurationYrs', 'Course Duration(In Years)', 'trim|required|numeric', array('required' => 'Course Duration In Years Is Required.')); $this->form_validation->set_rules('courseDurationSems', 'Total Semesters', 'trim|required|numeric', array('required' => 'Total Semesters Is Required.')); $this->form_validation->set_rules('coursePopulatFlag', 'Academic Pattern', 'trim|required', array('required' => 'Course Academic Pattern Is Required.')); if ($this->form_validation->run() == FALSE) { $this->createNewCourse(); } else { $newCourseInfo = array( 'course_name' => $this->input->post('courseName'), 'course_full_name' => $this->input->post('courseFullName'), 'course_no_of_years' => $this->input->post('courseDurationYrs'), 'course_no_of_sems' => $this->input->post('courseDurationSems'), 'course_populate_flag' => $this->input->post('coursePopulatFlag'), 'course_added_on' => date("Y-m-d H:i:s"), 'course_added_by' => $this->session->userdata('id'), 'course_updated_on' => date("Y-m-d H:i:s"), 'course_updated_by' => $this->session->userdata('id'), 'clg_id' => $this->session->userdata('inst_id') ); if ($this->CourseManagement->createNewCourse($newCourseInfo)) { $this->session->set_flashdata('successMessage', 'Course Created Successfully.'); redirect("Course"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating Course. Try Later.'); $this->createNewCourse(); } } } else { redirect("Home/"); } } public function toggleCourseActiveStatus($course_id, $toUpdateStatus) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $courseUpdateData = array( 'course_id' => $course_id, 'course_active_status' => $toUpdateStatus, 'course_updated_on' => date("Y-m-d H:i:s"), 'course_updated_by' => $this->session->userdata('id') ); if ($this->CourseManagement->updateCourseInfo($courseUpdateData)) { $this->session->set_flashdata('successMessage', 'Course Status Updated Successfully.'); redirect("Course"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Course Status. Try Later.'); redirect("Course"); } } else { redirect("Home/"); } } public function deleteCourse($course_id) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $courseDeleteData = array( 'course_id' => $course_id, 'course_updated_on' => date("Y-m-d H:i:s"), 'course_updated_by' => $this->session->userdata('id'), 'course_delete_status' => 'T' ); if ($this->CourseManagement->updateCourseInfo($courseDeleteData)) { $this->session->set_flashdata('successMessage', 'Course Deleted Successfully.'); redirect("Course"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Course. Try Later.'); redirect("Course"); } } else { redirect("Home/"); } } public function editCourse($course_id) { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $viewData['course_info'] = $this->CourseManagement->getCourseInfoById($course_id)->result()[0]; $this->load->view('edit_course', $viewData); } else { redirect("Home/"); } } public function updateCourse() { if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) { $this->form_validation->set_rules('courseName', 'Course Name', 'trim|required', array('required' => 'Course Name Can Not Be Blank.')); $this->form_validation->set_rules('courseFullName', 'Course Full Name', 'trim|required', array('required' => 'Course Full Name Can Not Be Blank')); $this->form_validation->set_rules('courseDurationYrs', 'Course Duration(In Years)', 'trim|required|numeric', array('required' => 'Course Duration In Years Is Required.')); $this->form_validation->set_rules('courseDurationSems', 'Total Semesters', 'trim|required|numeric', array('required' => 'Total Semesters Is Required.')); $this->form_validation->set_rules('coursePopulatFlag', 'Academic Pattern', 'trim|required', array('required' => 'Course Academic Pattern Is Required.')); if ($this->form_validation->run() == FALSE) { $this->editCourse($this->input->post('courseId')); } else { $courseUpdateInfo = array( 'course_id' => $this->input->post('courseId'), 'course_name' => $this->input->post('courseName'), 'course_full_name' => $this->input->post('courseFullName'), 'course_no_of_years' => $this->input->post('courseDurationYrs'), 'course_no_of_sems' => $this->input->post('courseDurationSems'), 'course_populate_flag' => $this->input->post('coursePopulatFlag'), 'course_added_on' => date("Y-m-d H:i:s"), 'course_added_by' => $this->session->userdata('id'), 'course_updated_on' => date("Y-m-d H:i:s"), 'course_updated_by' => $this->session->userdata('id'), 'clg_id' => $this->session->userdata('inst_id') ); if ($this->CourseManagement->updateCourseInfo($courseUpdateInfo)) { $this->session->set_flashdata('successMessage', 'Course Updated Successfully.'); redirect("Course"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updated Course. Try Later.'); $this->editCourse($this->input->post('courseId')); } } } else { redirect("Home/"); } } public function getSemsOrYearsOfGivenCourse() { $course_id = $_POST['course_id']; $query = $this->CourseManagement->getCourseInfoById($course_id); $courseInfo = $query->result()[0]; if ($courseInfo->course_populate_flag == 'Y') { $durationFlag = "Year"; $duration = $courseInfo->course_no_of_years; } else { $durationFlag = "Sem"; $duration = $courseInfo->course_no_of_sems; } $options = "<option value=''>-Select Year/Semester-</option>"; for ($i = $duration; $i > 0; $i--) { $options .= "<option value='" . $i . "-" . $durationFlag . "' >" . $i . " $durationFlag</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'duration_list' => $options ); echo json_encode($responseData); } public function getSemsOrYearsOfGivenCourseForEdit() { $course_id = $_POST['course_id']; $sem_or_year = $_POST['sem_or_year']; $query = $this->CourseManagement->getCourseInfoById($course_id); $courseInfo = $query->result()[0]; if ($courseInfo->course_populate_flag == 'Y') { $durationFlag = "Year"; $duration = $courseInfo->course_no_of_years; } else { $durationFlag = "Sem"; $duration = $courseInfo->course_no_of_sems; } $options = "<option value=''>-Select Year/Semester-</option>"; for ($i = $duration; $i > 0; $i--) { $selected = ""; if ($sem_or_year == $i . "-" . $durationFlag) { $selected = "selected"; } $options .= "<option value='" . $i . "-" . $durationFlag . "' $selected>" . $i . " $durationFlag</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'duration_list' => $options ); echo json_encode($responseData); } }