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

99 lines
4.0 KiB
PHP

<table id="tbl" class="display dataTable table-responsive text-center">
<thead>
<tr>
<th>Book Name</th>
<th>Student Id</th>
<th>Student Name</th>
<th>Contact</th>
<th>Issued Date</th>
<th>Remaining Days</th>
<th>Over Due</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<!-- class="due" -->
<?php
if (isset($issuedBookData) && !empty($issuedBookData)) {
foreach ($issuedBookData as $ibData) {
// print_r($ibData);
$book_name = $this->db->get_where('lms_books', ['id' => $ibData['book_id']])->row_array();
$stdIs = $ibData['eu_unique_id'];
$eu_name = $this->LmsAdmin_Model->getStudentDataById($stdIs);
$name = '';
$mobile = '';
if ($eu_name) {
$name = $eu_name['name'];
$mobile = $eu_name['mobile'];
}
$issDateObj = new DateTime($ibData['issued_date']);
$issueDate = $issDateObj->format('Y-m-d');
$todayDateObj = new DateTime($npCurrDate);
$todayIs = $todayDateObj->format('Y-m-d');
$retDateObj = new DateTime($ibData['return_date']);
$returnDate = $retDateObj->format('Y-m-d');
$remDaysClass = '';
$date1 = date_create($todayIs);
$date2 = date_create($returnDate);
$remaining_days = $date1->diff($date2)->format("%r%a");
if ($remaining_days == 0) {
$remaining_days = 'Due Today';
$remDaysClass = 'due';
} else if ($remaining_days < 0)
$remaining_days = '0 Days';
else
$remaining_days = $remaining_days . ' Days';
$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 = 'class="due" style="font-weight:500"';
if ($over_due_days < 0)
$over_due_days = 0;
?>
<tr>
<td><?= $book_name['title']; ?></td>
<td><?= $ibData['eu_unique_id']; ?></td>
<td><?= $name; ?></td>
<td><?= $mobile; ?></td>
<td>
<?= $issDateObj->format(DATE_FORMAT); ?>
</td>
<td class='<?php echo $remDaysClass; ?>' <?= !empty($ibData['returned_on_date']) ? "style='font-weight:500;'" : '' ?>> <?php echo empty($ibData['returned_on_date']) ? $remaining_days : '-' ?></td>
<td <?= $class; ?>><?= $over_due_days; ?> Days</td>
<td class="<?= !empty($ibData['returned_on_date']) ? 'text-success small' : 'text-danger' ?>">
<?= !empty($ibData['returned_on_date']) ? 'Returned' : 'Issued' ?>
</td>
</tr>
<?php
}
}
//echo 'Nepali Current date === '.$todayIs;
?>
</tbody>
</table>
<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>