BBnepal-Accounts/library/application/views/lms-admin/books.php

121 lines
4.9 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<main class="common_margin" id="main">
<div class="main-wrap">
<div class="dashboard-cover">
<div class="subject_r">
<div class="subject_rsec">
<a href="javascript:history.back()"><button class="btn btn-dark btn-sm">Back</button></a>
<?php if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success mt-4"><strong>Success!</strong> <?php echo $this->session->flashdata('success'); ?></div>
<?php } ?>
<div class="alert alert-danger mt-4" id="errShow" style="display:none;"><strong>Failure!</strong> Book is having dependent data you can not delete this book.</div>
<div class="alert alert-success mt-4" id="successshow" style="display:none;"><strong>Success!</strong> Book has been deleted successfully.</div>
<div class="common-heading">
<h2>Books</h2>
<div class="dashboard-btn-wrap">
<div class="bookImport-cover">
<form id="importForm" action="<?= base_url(); ?>importBooks" method="POST" enctype="multipart/form-data">
<input id="upload_file" name="upload_file" type="file" accept=".csv" class="bookImport" />
<label class="bookUploadLbl">Import Books from CSV </label>
</form>
</div>
<a href="<?= base_url(); ?>add-edit-book/0"><button class="btn btn-success btn-sm">+ Add Book</button></a>
</div>
</div>
<div class="select_div">
<select class="form-control txtData" name="category_id" id="category_id" onchange="getBookData(this.value)">
<option value="" selected disabled>Select Category</option>
<?php if (isset($categoryData) && !empty($categoryData)) {
foreach ($categoryData as $cData) { ?>
<option value="<?= $cData['id']; ?>"><?= $cData['name']; ?></option>
<?php }
} ?>
</select>
</div>
<div class="" id="bookLists">
<?php
if (isset($bookDetail))
echo $bookDetail;
?>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End right-top side-->
</div>
<!-- <script src="assets/js/jquery-3.2.1.slim.min.js"></script> -->
<script src="<?= base_url(); ?>assets-lms/js/jquery-3.4.1.min.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/popper.min.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/bootstrap.min.js"></script>
<script defer src="<?= base_url(); ?>assets-lms/js/all.js"></script>
<script defer src="<?= base_url(); ?>assets-lms/js/main.js"></script>
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>
<script>
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
});
//table js
$('#tbl').DataTable({
"lengthMenu": [
[5, 10, 25, 50, -1],
[5, 10, 25, 50, "All"]
]
});
//table js end
//multiple select js start
$('select').selectpicker();
//multiple select js end
</script>
<script>
function getBookData(cat_id) {
$.ajax({
type: 'post',
url: '<?= base_url(); ?>LmsAdmin/ajaxGetBookLists',
data: {
'categoryId': cat_id
},
success: function(result) {
result = result.trim();
$('#bookLists').empty();
$('#bookLists').html(result);
}
});
}
function deleteBook(bookId) {
$.ajax({
type: 'post',
url: '<?= base_url(); ?>LmsAdmin/deleteBookData',
data: {
'bookId': bookId
},
success: function(result) {
if (result == 0) {
$('#successshow').hide();
$('#errShow').show();
} else if (result == 1) {
$('#errShow').hide();
$('#successshow').show();
setTimeout(() => {
location.reload();
}, 2000);
}
}
});
}
</script>
<script>
$(document).ready(function() {
$('#upload_file').change(function() {
$('#importForm').submit();
});
});
</script>