FIX_From date to date search in po and igr module

This commit is contained in:
VE10-Sanjeev 2024-08-13 11:09:28 +00:00
parent 5238af125a
commit 9d6f10531a
2 changed files with 222 additions and 99 deletions

View File

@ -1,43 +1,36 @@
<style>
.pagination {
margin: 0px !important;
}
</style>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<!-- Latest DataTables Buttons CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.3.4/css/buttons.dataTables.min.css">
<style>
.dataTables_wrapper .dataTables_length select {
background-color:white !important;
}
.dataTables_wrapper .dataTables_filter input {
background-color: white !important;
}
button.dt-button, div.dt-button, a.dt-button, input.dt-button {
background-color: white !important;
}
.dataTables_length, label{
display: flex !important;
}
.dataTables_wrapper .dataTables_filter {
text-align: center;
.Date-filter-form {
display: flex;
align-items: center;
gap: 10px; /* Adjust the gap as needed */
}
.dataTables_wrapper .dataTables_length {
float: left;
.Date-filter-form input, .Date-filter-form button {
padding: 5px;
font-size: 14px;
}
.dataTables_wrapper .dt-buttons {
float: right;
.Date-filter-form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
.dataTables_wrapper .clear {
clear: both;
.Date-filter-form button:hover {
background-color: #0056b3;
}
.icon-button {
background: none;
border: none;
cursor: pointer;
color: #007bff;
font-size: 18px;
}
.icon-button:hover {
color: #0056b3;
}
th, td {
white-space: nowrap;
}
.dataTables_wrapper {
width: 100%;
overflow-x: auto;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
@ -77,6 +70,18 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<form class="Date-filter-form" id="DateRangeFilter" >
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input type="text" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input type="text" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit">Search</button>
<i class="fa fa-repeat" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<table id="dataTableHistoriek" class="table table-bordered table-hover editableTable" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
@ -178,19 +183,84 @@
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- <script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->
<!-- Latest DataTables JS -->
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<!-- Latest DataTables Buttons JS -->
<script src="https://cdn.datatables.net/buttons/2.3.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.13.6/sorting/datetime-moment.js"></script>
<script>
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>
<script>
$(document).ready(function() {
// Initialize the DataTable
var table = $('#dataTableHistoriek').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"columnDefs": [{
"targets": 1,
"type": "date-eu"
}],
"aaSorting": [
[1, "desc"]
],
"info": true,
"autoWidth": true,
"pageLength": 10,
"lengthMenu": [10, 25, 50, 100],
});
// Initialize the datepickers
$("#fromDate").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function(selectedDate) {
var minDate = $(this).datepicker("getDate");
$("#toDate").datepicker("option", "minDate", minDate);
}
});
$("#toDate").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function(selectedDate) {
var maxDate = $(this).datepicker("getDate");
$("#fromDate").datepicker("option", "maxDate", maxDate);
}
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").datepicker("setDate", null);
$("#toDate").datepicker("setDate", null);
$("#toDate").datepicker("option", "minDate", null);
$("#fromDate").datepicker("option", "maxDate", null);
table.draw();
});
// Date range filter
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $("#fromDate").datepicker("getDate");
var toDate = $("#toDate").datepicker("getDate");
var dateStr = data[1]; // Assuming the date is in the first column
// Convert dateStr to Date object
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
if (!fromDate || !toDate) {
return true; // No filter if dates are not selected
}
return date >= fromDate && date <= toDate;
}
);
// Handle form submission
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw();
});
});
</script>
<!-- <script>
$(function () {
$.fn.dataTable.moment('DD-MM-YYYY');
$('#dataTableHistoriek').DataTable({
@ -225,4 +295,4 @@
]
});
});
</script>
</script> -->

View File

@ -13,6 +13,34 @@
th {
white-space: nowrap;
}
.Date-filter-form {
display: flex;
align-items: center;
gap: 10px; /* Adjust the gap as needed */
}
.Date-filter-form input, .Date-filter-form button {
padding: 5px;
font-size: 14px;
}
.Date-filter-form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
.Date-filter-form button:hover {
background-color: #0056b3;
}
.icon-button {
background: none;
border: none;
cursor: pointer;
color: #007bff;
font-size: 18px;
}
.icon-button:hover {
color: #0056b3;
}
</style>
<style>
@ -47,6 +75,18 @@
<center><b><h3 class="box-title">View Inward Gate Register </h3></b></center>
</div>
<div class="row">
<form class="Date-filter-form" id="DateRangeFilter" >
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input type="text" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input type="text" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit">Search</button>
<i class="fa fa-repeat" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="col-md-12">
<table id="Inwardgateregistertable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
@ -1483,72 +1523,85 @@ function deleteBill(Billno,i){
}
</script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>
<script>
$(document).ready(function() {
$.fn.dataTable.moment('DD-MM-YYYY HH:mm A');
$('#Inwardgateregistertable').DataTable({
// Initialize the DataTable
var table = $('#Inwardgateregistertable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 0, "desc" ]],
"order": [[0, "desc"]],
"pageLength": 10,
"lengthMenu": [5, 10, 20, 50, 100, 200, 500],
"columnDefs": [{
"targets": 1,
"type": "date-eu"
}],
"aaSorting": [
[1, "desc"]
],
"info": true,
"autoWidth": true,
"dom": "<'row'<'col-sm-3'l><'col-sm-6 text-center'f><'col-sm-3 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [
{
extend: 'excelHtml5',
text: 'Export to Excel',
title: 'Inward Gate Register',
exportOptions: {
columns: ':visible:not(:first-child):not(:last-child)' // Exclude first and last columns
}
},
{
extend: 'pdfHtml5',
text: 'Export to PDF',
title: 'Inward Gate Register',
customize: function (doc) {
doc.content[1].margin = [ 10, 0, 10, 0 ]; // left, top, right, bottom
doc.pageSize = 'A4'; // Ensure it's A4
doc.pageOrientation = 'landscape'; // Set landscape orientation
doc.defaultStyle.fontSize = 10; // Set default font size
doc.styles.tableHeader.fontSize = 12; // Set font size for header
},
exportOptions: {
columns: ':visible:not(:first-child):not(:last-child)' // Exclude first and last columns
}
"pageLength": 10,
"lengthMenu": [10, 25, 50, 100],
});
// Initialize the datepickers
$("#fromDate").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function(selectedDate) {
var minDate = $(this).datepicker("getDate");
$("#toDate").datepicker("option", "minDate", minDate);
}
});
$("#toDate").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function(selectedDate) {
var maxDate = $(this).datepicker("getDate");
$("#fromDate").datepicker("option", "maxDate", maxDate);
}
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").datepicker("setDate", null);
$("#toDate").datepicker("setDate", null);
$("#toDate").datepicker("option", "minDate", null);
$("#fromDate").datepicker("option", "maxDate", null);
table.draw();
});
// Date range filter
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $("#fromDate").datepicker("getDate");
var toDate = $("#toDate").datepicker("getDate");
var dateStr = data[1]; // Assuming the date is in the first column
// Convert dateStr to Date object
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
if (!fromDate || !toDate) {
return true; // No filter if dates are not selected
}
]
return date >= fromDate && date <= toDate;
}
);
// Handle form submission
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw();
});
});
</script>
<style>
.dataTables_wrapper .col-sm-3 .dataTables_length {
float: left;
}
.dataTables_wrapper .col-sm-6 .dataTables_filter {
float: none;
text-align: center;
}
.dataTables_wrapper .col-sm-3 .dt-buttons {
float: right;
}
</style>
<script>
function appendExistingFilesFileds(data){
const base_url = '<?php echo base_url(); ?>';