BBnepal-Accounts/library/application/views/lms-admin/receive-book-detail.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

310 lines
15 KiB
PHP

<main class="common_margin" id="main">
<div class="main-wrap">
<div class="dashboard-cover-wrap">
<div class="subject_r">
<div class="subject_rsec">
<a href="javascript:history.back()"><button class="btn btn-dark btn-sm">Back</button></a>
<div class="alert alert-danger" id="errShow" style="display:none;"><strong>Failure!</strong> Please select book id.</div>
<div class="alert alert-success" id="success" style="display:none;"><strong>Success!</strong> The comment added successfully.</div>
<div class="alert alert-success" id="successMsg" style="display:none;"><strong>Success!</strong> The book received successfully.</div>
<div class="common-heading">
<h2><?= $title; ?></h2>
</div>
<div class="common-sub-heading">Student Details</div>
<?php
$eu_id = '';
$class = '';
$fname = '';
$lname = '';
$contact = '';
if (isset($userData) && !empty($userData)) {
$eu_id = $userData['studentId'];
$class = $userData['class_name'];
$name = $userData['name'];
$contact = $userData['mobile'];
}
?>
<div class="student_details">
<ul>
<li><label>Student ID</label><span><?= $eu_id; ?></span></li>
<li><label>Name</label><span><?= $name; ?></span></li>
</ul>
<ul>
<li><label>Contact</label><span><?= $contact; ?></span></li>
<li><label>Class</label><span><?= $class; ?></span></li>
</ul>
</div>
<div class="common-sub-heading">Issued Books</div>
<div class="">
<table id="tbl" class="display dataTable table-responsive text-center">
<thead>
<tr>
<th>S.No</th>
<th>ISBN</th>
<th>Title</th>
<th>Issued On</th>
<th>Due Date</th>
<th>Over Due</th>
<th>Late Fee</th>
<th>Received</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<?php $ttl_fee = 0;
if (isset($bookDetail) && !empty($bookDetail)) {
$i = 1;
foreach ($bookDetail as $bdata) {
$bookData = $this->db->get_where('lms_books', ['id' => $bdata['book_id']])->row_array();
$gsData = $this->LmsAdmin_Model->getGeneralSettingData('lms_general_settings');
if ($gsData) {
$late_fee = $gsData['due_fee_per_day'];
}
if ($bookData['fine_per_day'] == 0) {
$fineperday = $late_fee;
} else {
$fineperday = $bookData['fine_per_day'];
}
//calculating over due days
/*$today = date('Y-m-d');
$return_date = $bdata['return_date'];
$overdue_diff = strtotime($today)-strtotime($return_date);
$overdue_days = round($overdue_diff / 86400);
if($today>$return_date){
$oddays = $overdue_days;
$latefee = ($fineperday)*($oddays);
}elseif($today<=$return_date){
$oddays = 0;
$latefee = 0;
}*/
$issDateObj = new DateTime($bdata['issued_date']);
$issueDate = $issDateObj->format('Y-m-d');
$todayDateObj = new DateTime($npCurrDate);
$todayIs = $todayDateObj->format('Y-m-d');
$retDateObj = new DateTime($bdata['return_date']);
$returnDate = $retDateObj->format('Y-m-d');
$over_due_days = 0;
$latefee = 0;
$class = '';
$over_due_days = 0;
$date11 = date_create($returnDate);
$date22 = date_create($todayIs);
$over_due_days = $date11->diff($date22)->format("%r%a");
if ($over_due_days > 0)
$class = 'due';
if ($over_due_days < 0)
$over_due_days = 0;
if ($todayIs > $returnDate) {
$latefee = ($fineperday) * ($over_due_days);
}
?>
<tr>
<td><span class="text-center"><?= $i; ?></span></td>
<td><?= $bookData['isbn']; ?></td>
<td><?= $bookData['title']; ?></td>
<td><?= $issDateObj->format(DATE_FORMAT); ?></td>
<td><?= $retDateObj->format(DATE_FORMAT); ?></td>
<td class='<?php echo $class; ?>'><?= $over_due_days; ?> Days</td>
<td><?= $gSData['currency'] ?><?= $latefee; ?> </td>
<td>
<div class="receivCheck_cover">
<?php if ($bdata['returned_on_date'] != '') { ?>
<input type="checkbox" id="returned" class="checkbx" checked>
<?php } else { ?>
<input type="checkbox" value="<?= $bdata['id']; ?>" name="returned" id="returned" class="checkbx">
<?php } ?>
<span class="checkmark"></span>
</div>
</td>
<td>
<div class="sub_tabbtnsec">
<button class="subject_addbtn" data-toggle="modal" onclick="commentModal(<?= $bdata['id']; ?>)">+Comment</button>
</div>
</td>
</tr>
<?php
$ttl_fee += $latefee;
?>
<?php $i++;
}
} ?>
</tbody>
<tfoot>
<tr>
<td colspan="6">
<label class="mb-0" style="float: right;font-size: 13px; font-weight: 600;">Total Late Fee:</label>
</td>
<td style="font-size: 13px; font-weight: 600;">
<?= $gSData['currency'] ?><?= $ttl_fee; ?>
</td>
<td colspan="2">
<button class="btn btn-success" onclick="saveReceivedData()">Receive Book</button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End right-top side-->
</div>
<div class="book_description book_comment">
<div class="modal fade" id="bookCmnt" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<form id="commentForm" method="POST">
<input type="hidden" name="id" id="id" value="">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Comment</h4>
<div class="modal-check-box">
<div class="receivCheck_cover" style="margin: 0 0 13px;">
<input type="checkbox" class="checkbx" id="is_damaged" name="is_damaged">
<span for="is_damaged" class="checkmark"></span>
</div>
<label>Damaged Book</label>
</div>
</div>
<div class="modal-body">
<textarea class="txtData" placeholder="Add Comment" name="damaged_comment" id="damaged_comment"></textarea>
<p id="error-damaged_comment" class="modal_err"></p>
</div>
<div class="modal-footer">
<div class="dashboard-btn-wrap">
<button type="submit" class="subject_addbtn">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</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/jquery.validate.js"></script>
<script src="<?= base_url(); ?>assets-lms/js/additional-methods.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 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 defer src="<?= base_url(); ?>assets-lms/js/all.js"></script>
<script defer src="<?= base_url(); ?>assets-lms/js/main.js"></script>
<script src="<?= base_url(); ?>assets-lms/owl-carousel/js/owl.carousel.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>
$("#commentForm").validate({
errorClass: 'error',
rules: {
damaged_comment: {
required: true,
minlength: 3,
maxlength: 100
}
},
messages: {
damaged_comment: {
required: "Comment is required",
minlength: "At least 3 characters long",
maxlength: "Should not exceed 100 characters"
}
},
errorPlacement: function(error, element) {
if (element.attr("name") == "damaged_comment") {
error.appendTo($("#error-damaged_comment"));
} else {
error.appendTo(element);
}
},
submitHandler: function(form) {
var formdata = new FormData(form);
$.ajax({
type: 'post',
url: '<?= base_url(); ?>LmsAdmin/addComment',
data: formdata,
cache: false,
contentType: false,
processData: false,
success: function(result) {
if (result == 1) {
$('#bookCmnt').modal('hide');
$('#success').show();
setTimeout(() => {
location.reload();
}, 2000);
}
}
});
}
});
</script>
<script>
function commentModal(bookId) {
$('#id').val(bookId);
$("#error-damaged_comment").html('');
$('.txtData').val('');
$('#is_damaged').prop('checked', false);
$('#bookCmnt').modal('show');
}
function saveReceivedData() {
arrayVal = [];
$('input[name="returned"]:checked').each(function() {
arrayVal.push(this.value);
});
if (arrayVal != '') {
$.ajax({
type: 'post',
url: '<?= base_url(); ?>LmsAdmin/returnedBookData',
data: {
'returnedBook': arrayVal
},
success: function(result) {
// alert(result);
if (result == 1) {
$('#errShow').hide();
$('#successMsg').show();
setTimeout(() => {
location.reload();
}, 2000);
}
}
});
} else {
$('#errShow').show();
}
}
</script>
</body>
</html>