stock module 1 vadivel J 02-12-2025
This commit is contained in:
parent
19137a3098
commit
a5c1637970
@ -204,14 +204,28 @@
|
|||||||
<form action="<?= base_url('gasStockDetails'); ?>" method="post">
|
<form action="<?= base_url('gasStockDetails'); ?>" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-3">
|
<div class="col-md-3">
|
||||||
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
|
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
|
||||||
class="form-control mt-2" data-provide="datepicker"
|
class="form-control mt-2" data-provide="datepicker"
|
||||||
data-date-format="M-yyyy" data-date-min-view-mode="1">
|
data-date-format="M-yyyy" data-date-min-view-mode="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-2">
|
<div class="form-group col-md-3">
|
||||||
<button type="submit" class="btn btn-success"> Change Month </button>
|
<button type="submit" class="btn btn-success"> Change Month </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="dropdown float-right">
|
||||||
|
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
|
<a style="cursor:pointer"
|
||||||
|
class="dropdown-item" data-toggle="modal" data-target="#filterModalId">Filter</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -412,6 +426,81 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modal -->
|
||||||
|
|
||||||
|
<!-- filter modal -->
|
||||||
|
<div class="modal fade" id="filterModalId" tabindex="-1" role="dialog" aria-labelledby="filterModalLabelId" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-md">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="filterModalLabelId">Filter Options</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$currentDateInDmY = date('d-m-Y');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$startDate = DateTime::createFromFormat('M-Y', $month);
|
||||||
|
|
||||||
|
if ($startDate) {
|
||||||
|
$startDate->modify('first day of this month');
|
||||||
|
$daysInMonth = $startDate->format('t');
|
||||||
|
$dateArray = [];
|
||||||
|
|
||||||
|
for ($i = 0; $i < $daysInMonth; $i++) {
|
||||||
|
$dateArray[] = $startDate->format('d-m-Y');
|
||||||
|
$startDate->modify('+1 day');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Invalid date format.";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- From Date Filter -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="fromDateFilter">Select From Date</label>
|
||||||
|
<select id="fromDateFilter" name="fromDateFilter" class="form-control">
|
||||||
|
<?php if (!empty($dateArray)) : ?>
|
||||||
|
<?php foreach ($dateArray as $index => $date) : ?>
|
||||||
|
<option value="<?= $date ?>" ><?= $date ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- To Date Filter -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="toDateFilter">Select Date</label>
|
||||||
|
<select id="toDateFilter" name="toDateFilter" class="form-control">
|
||||||
|
<?php if (!empty($dateArray)) : ?>
|
||||||
|
<?php foreach ($dateArray as $date) : ?>
|
||||||
|
<option value="<?= $date ?>" <?= ($date == $currentDateInDmY) || ($date == $dateArray[9]) ?"selected" :" " ?> ><?= $date ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary float-right" onclick="customFilterDate()">Filter</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
<!-- filter modal end -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -617,3 +706,53 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function customFilterDate(){
|
||||||
|
|
||||||
|
let fromDate = $('#fromDateFilter').val(); //01-12-2024
|
||||||
|
let toDate = $('#toDateFilter').val(); //05-12-2024
|
||||||
|
|
||||||
|
$('#gasStockDetailsTableId').find('tbody tr').each(function() {
|
||||||
|
const rowCells = $(this).find('td');
|
||||||
|
let tableDate = rowCells.eq(0).text();
|
||||||
|
let result = checkDateRange(fromDate,toDate,tableDate);
|
||||||
|
if (result) {
|
||||||
|
$(this).show();
|
||||||
|
} else {
|
||||||
|
$(this).hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#filterModalId').modal('hide');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkDateRange(fromDate, toDate, tableDate) {
|
||||||
|
// Convert the dates to a comparable format (YYYY-MM-DD)
|
||||||
|
let from = convertToDate(fromDate);
|
||||||
|
let to = convertToDate(toDate);
|
||||||
|
let table = convertToDate(tableDate);
|
||||||
|
|
||||||
|
// Return true if the table date is within the range
|
||||||
|
return table >= from && table <= to;
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertToDate(dateString) {
|
||||||
|
// Convert from DD-MM-YYYY to YYYY-MM-DD for comparison
|
||||||
|
let parts = dateString.split('-');
|
||||||
|
return new Date(parts[2], parts[1] - 1, parts[0]); // Year, Month (0-based), Day
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#fromDateFilter ').select2();
|
||||||
|
$('#toDateFilter ').select2();
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user