CHANGE_ALL_TABLE_FROM_TO_SEARCH_DATE

This commit is contained in:
aadhavan valli 2024-09-18 16:18:53 +05:30
parent bb07cb8dbb
commit 3a60759b94
19 changed files with 667 additions and 569 deletions

View File

@ -68,9 +68,9 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
@ -138,14 +138,14 @@
}
echo $option ?></td>
<td><?php
if ($record->DeliveryOption == 0) {
$Ddt = new DateTime($record->DeliveryDate);
$Deliverydt = $Ddt->format('d-m-Y');
echo $Deliverydt;
} else if ($record->DeliveryOption == 1) {
$Deliverydt = '';
echo $Deliverydt;
} ?></td>
if ($record->DeliveryOption == 0) {
$Ddt = new DateTime($record->DeliveryDate);
$Deliverydt = $Ddt->format('d-m-Y');
echo $Deliverydt;
} else if ($record->DeliveryOption == 1) {
$Deliverydt = '';
echo $Deliverydt;
} ?></td>
<td><?php echo $record->DeliverySchedule ?></td>
@ -237,17 +237,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -255,11 +257,17 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();

View File

@ -100,10 +100,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -134,9 +134,9 @@
?>
<tr id="<?php echo $index; ?>">
<td><?php $Pdt = new DateTime($record->PODate);
$PODate = $Pdt->format('d-m-Y');
echo $PODate
?></td>
$PODate = $Pdt->format('d-m-Y');
echo $PODate
?></td>
<td><?php echo $record->PONO ?></td>
<td><?php echo $record->ReqType ?></td>
@ -170,14 +170,14 @@
}
echo $option ?></td>
<td><?php
if ($record->DeliveryOption == 0) {
$Ddt = new DateTime($record->DeliveryDate);
$Deliverydt = $Ddt->format('d-m-Y');
echo $Deliverydt;
} else if ($record->DeliveryOption == 1) {
$Deliverydt = '';
echo $Deliverydt;
} ?></td>
if ($record->DeliveryOption == 0) {
$Ddt = new DateTime($record->DeliveryDate);
$Deliverydt = $Ddt->format('d-m-Y');
echo $Deliverydt;
} else if ($record->DeliveryOption == 1) {
$Deliverydt = '';
echo $Deliverydt;
} ?></td>
<td><?php echo $record->DeliverySchedule ?></td>
<?php $statusCode = $record->StatusCode;
@ -282,17 +282,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -300,8 +302,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -42,7 +42,7 @@
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
@ -58,10 +58,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -180,17 +180,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -198,8 +200,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -98,10 +98,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -217,17 +217,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -235,8 +237,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -56,10 +56,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -238,17 +238,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -256,8 +258,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -273,10 +273,10 @@
<span class="Date-filter-form" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="button" class="range_search_button" id="DateRangeFilter"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -307,21 +307,21 @@
foreach ($ReqList as $record) {
?>
<tr id="<?php echo $index; ?>">
<td align="center"><input type="checkbox" name="chk<?php echo $index; ?>" id="chk<?php echo $index; ?>" onclick="selectReqNo(<?php echo $index; ?>)" />&nbsp;</td>
<td align="center">
<td align="left"><input type="checkbox" name="chk<?php echo $index; ?>" id="chk<?php echo $index; ?>" onclick="selectReqNo(<?php echo $index; ?>)" />&nbsp;</td>
<td align="left">
<?php
$dt = new DateTime($record->ReqDate);
$RequestedDate = $dt->format('d-m-Y');
echo $RequestedDate;
?>
</td>
<td align="center"><a data-toggle="modal" data-target="#RequisitionDtlsModal" data-id="<%=index%>" data-userid="<?php echo $record->ReqNo ?>"><u><?php echo $record->ReqNo; ?> </u></a></td>
<td align="center"><?php echo $record->ReqType; ?></td>
<td align="left"><a data-toggle="modal" data-target="#RequisitionDtlsModal" data-id="<%=index%>" data-userid="<?php echo $record->ReqNo ?>"><u><?php echo $record->ReqNo; ?> </u></a></td>
<td align="left"><?php echo $record->ReqType; ?></td>
<td><?php echo $record->FirstName; ?></td>
<td align="center"><?php echo $record->TotalNoofLineItems; ?></td>
<td align="center"><?php echo $record->PolineItems; ?></td>
<td align="center"><?php echo $record->PartilallyLineItems; ?></td>
<td align="center"><?php echo $record->newLineItem; ?></td>
<td align="left"><?php echo $record->TotalNoofLineItems; ?></td>
<td align="left"><?php echo $record->PolineItems; ?></td>
<td align="left"><?php echo $record->PartilallyLineItems; ?></td>
<td align="left"><?php echo $record->newLineItem; ?></td>
<td><?php echo $record->StatusName; ?></td>
<td><?php echo $record->DepartmentName; ?></td>
<td><?php echo $record->Designation; ?></td>
@ -405,31 +405,38 @@
});
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[1]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").click(function(e) {

View File

@ -83,10 +83,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -178,17 +178,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -196,8 +198,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -190,52 +190,6 @@
}
});
// 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[0]; // 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) {

View File

@ -76,10 +76,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -89,16 +89,16 @@
<table class="table table-bordered table-hover" id="expense_list_table" style="background-color:#fff;">
<thead>
<tr>
<th align="right" style="width: 10%;">Created Date</th>
<th align="left" style="width: 10%;">Created Date</th>
<!-- <th align="right">Expense Id</th> -->
<th align="right" style="width: 20%;">Supplier Name</th>
<th align="right" style="width: 25%;">Item Description</th>
<th align="right" style="width: 7%;">Cost</th>
<th align="right" style="width: 5%;">CGST</th>
<th align="right" style="width: 5%;">SGST</th>
<th align="right" style="width: 5%;">IGST</th>
<th align="right" style="width: 7%;">Total</th>
<th align="right" style="width: 8%;">Action</th>
<th align="left" style="width: 20%;">Supplier Name</th>
<th align="left" style="width: 25%;">Item Description</th>
<th align="left" style="width: 7%;">Cost</th>
<th align="left" style="width: 5%;">CGST</th>
<th align="left" style="width: 5%;">SGST</th>
<th align="left" style="width: 5%;">IGST</th>
<th align="left" style="width: 7%;">Total</th>
<th align="left" style="width: 8%;">Action</th>
</tr>
</thead>
<tbody>
@ -467,22 +467,33 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0];
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -59,6 +59,27 @@
<script src="<?php echo base_url(); ?>public/new_assets/js/pages/form-wizard.init.js"></script>
<script>
$(document).ready(function() {
form = $(".form-date-search")
.datepicker({
autoclose: true,
orientation: 'bottom',
format: 'dd-mm-yyyy',
todayHighlight: true,
endDate: '+0d'
})
.on("change", function() {
to.datepicker("option", "minDate", getDate(this));
}),
to = $(".to-date-search").datepicker({
autoclose: true,
orientation: 'bottom',
format: 'dd-mm-yyyy',
todayHighlight: true,
endDate: '+0d'
})
.on("change", function() {
from.datepicker("option", "maxDate", getDate(this));
});
var table = $('.ria_data_table').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [

View File

@ -140,10 +140,10 @@ if (empty($Status)) {
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -572,17 +572,19 @@ if (empty($Status)) {
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -590,8 +592,13 @@ if (empty($Status)) {
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -233,9 +233,11 @@ if (!empty($INRSYMBOL)) {
});
if (PaymentID != 'PT08') {
$('#otheroptiondiv').hide();
$('#Otherpayment').prop('required', false);
$('#Otherpayment').val('');
} else if (PaymentID == 'PT08') {
$('#otheroptiondiv').show();
$('#Otherpayment').prop('required', true);
}
$.each(Payment, function(pay, payobj) {
if (payobj.PaymentID == PaymentID) {
@ -2018,7 +2020,7 @@ if (!empty($INRSYMBOL)) {
<label>Description of Payable Terms<span class="badge mandatory">*</span></label>
<div>
<?php
$data = array('name' => 'Otherpayment', 'Otherpayment' => set_value('Otherpayment'), 'id' => 'Otherpayment', 'class' => 'form-control', 'required' => 'true');
$data = array('name' => 'Otherpayment', 'Otherpayment' => set_value('Otherpayment'), 'id' => 'Otherpayment', 'class' => 'form-control');
echo form_input($data);
?>
</div>
@ -4048,8 +4050,10 @@ if (!empty($INRSYMBOL)) {
$("#PaymentTerms").change(function() {
if ($('#PaymentTerms').val().trim() == 'PT08') {
$('#otheroptiondiv').show();
$('#Otherpayment').prop('required', true);
} else {
$('#otheroptiondiv').hide();
$('#Otherpayment').prop('required', false);
$('#Otherpayment').val('');
}
});

View File

@ -70,10 +70,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -184,17 +184,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -202,8 +204,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -1,119 +1,124 @@
<?php
$DraftCount = '';
$ReqNo = '';
if(!empty($Status))
{
foreach ($Status as $St)
{
$DraftCount = $St->cnt;
$ReqNo = $St->ReqNo;
}
//echo $ReqNo;
}?>
$DraftCount = '';
$ReqNo = '';
if (!empty($Status)) {
foreach ($Status as $St) {
$DraftCount = $St->cnt;
$ReqNo = $St->ReqNo;
}
//echo $ReqNo;
} ?>
<style>
#Requisition_filter {
float: inline-end;
}
#Requisition_filter {
float: inline-end;
}
#Requisition_wrapper .row .col-sm-4 {
flex-basis: 50%;
float: inline-end;
}
#Requisition_wrapper .row .col-sm-4 {
flex-basis: 50%;
float: inline-end;
}
#Requisition_paginate .pagination {
flex-basis: 50%;
float: inline-end;
margin: 0 0 15px;
}
#Requisition_paginate .pagination {
flex-basis: 50%;
float: inline-end;
margin: 0 0 15px;
}
#Requisition_wrapper .row:nth-child(3),
#Requisition_wrapper .row:nth-child(1) {
padding: 0 15px;
}
#Requisition_wrapper .row:nth-child(3),
#Requisition_wrapper .row:nth-child(1) {
padding: 0 15px;
}
#Requisition_info {
margin-top: 5px;
}
#Requisition_info {
margin-top: 5px;
}
.dataTables_wrapper {
padding-bottom: 0;
}
.dataTables_wrapper {
padding-bottom: 0;
}
span.highlight {
background-color: yellow;
}
span.highlight {
background-color: yellow;
}
</style>
<style>
.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>
.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>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Requisition List</h4>
<?php if($DraftCount == 0) { ?>
<a class="btn btn-success" href="<?php echo base_url(); ?>RequisitionForm">Raise New Requisition</a>
<?php } ?>
<?php if($DraftCount > 0 ) {?>
<p><span class="highlight">The Requisition No <b><?php echo $ReqNo;?></b> is in Draft
<?php if ($DraftCount == 0) { ?>
<a class="btn btn-success" href="<?php echo base_url(); ?>RequisitionForm">Raise New Requisition</a>
<?php } ?>
<?php if ($DraftCount > 0) { ?>
<p><span class="highlight">The Requisition No <b><?php echo $ReqNo; ?></b> is in Draft
status.</span> Please act on the requisition.<span class="highlight">Then only you can raise
New Requisition. </span></p>
<?php } ?>
New Requisition. </span></p>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="requisition_listing" class="table dt-responsive nowrap w-100">
<thead>
@ -130,41 +135,39 @@ span.highlight {
</tr>
</thead>
<tbody>
<?php
if(!empty($TotNoOfLine))
{
foreach($TotNoOfLine as $record)
{ //print_r($record);
?>
<tr>
<td> <?php $Pdt = new DateTime($record->CreatedDate );
$PODate = $Pdt->format('d-m-Y');
echo $PODate ?>
</td>
<td><?php echo $record->ReqNo ?></td>
<td><?php echo $record->ReqType ?></td>
<td><?php echo $record->TotalNoofLineItems ?></td>
<td><?php echo $record->PolineItems ?></td>
<td><?php echo $record->PartilallyLineItems ?></td>
<td> <?php echo $record->newLineItem ?></td>
<?php
if (!empty($TotNoOfLine)) {
foreach ($TotNoOfLine as $record) { //print_r($record);
?>
<tr>
<td> <?php $Pdt = new DateTime($record->CreatedDate);
$PODate = $Pdt->format('d-m-Y');
echo $PODate ?>
</td>
<td><?php echo $record->ReqNo ?></td>
<td><?php echo $record->ReqType ?></td>
<td><?php echo $record->TotalNoofLineItems ?></td>
<td><?php echo $record->PolineItems ?></td>
<td><?php echo $record->PartilallyLineItems ?></td>
<td> <?php echo $record->newLineItem ?></td>
<td><?php echo $record->StatusName ?></td>
<td><?php echo $record->StatusName ?></td>
<td> <a data-toggle="tooltip"
href="<?php echo base_url().'EditRequisitionForm?ReqNo='.$record->ReqNo.'&ReqType='.$record->ReqType; ?>"><i
class="fas fa-pencil-alt" data-toggle="tooltip"
title="<?php echo $record->ReqNo; ?> - Click here to view Requisition details"></i>&nbsp;&nbsp;&nbsp;</a>
<a data-toggle="tooltip" onclick="DeleteRow('<?php echo $record->ReqNo; ?>' )"><span
class="fas fa-trash"
title="<?php echo $record->ReqNo; ?> - Click here to Delete Requisition details"></span></a>
</td>
</tr>
<td> <a data-toggle="tooltip"
href="<?php echo base_url() . 'EditRequisitionForm?ReqNo=' . $record->ReqNo . '&ReqType=' . $record->ReqType; ?>"><i
class="fas fa-pencil-alt" data-toggle="tooltip"
title="<?php echo $record->ReqNo; ?> - Click here to view Requisition details"></i>&nbsp;&nbsp;&nbsp;</a>
<a data-toggle="tooltip" onclick="DeleteRow('<?php echo $record->ReqNo; ?>' )"><span
class="fas fa-trash"
title="<?php echo $record->ReqNo; ?> - Click here to Delete Requisition details"></span></a>
</td>
</tr>
<?php
}
}
?>
<?php
}
}
?>
</tbody>
</table>
@ -179,112 +182,117 @@ span.highlight {
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>
<script>
function DeleteRow(rowid) {
function DeleteRow(rowid) {
id = rowid;
id = rowid;
var answer = confirm(" Do you want to delete the Requisition?")
if (answer) {
var answer = confirm(" Do you want to delete the Requisition?")
if (answer) {
$.ajax({
data: {
id: id
},
type: "POST",
url: "<?php echo base_url() ?>requisitionform/DeleteReqNo",
success: function(data) {
if (data && data.message) {
alert(data.message);
location.reload(true);
} else {
alert("Error Occur");
$.ajax({
data: {
id: id
},
type: "POST",
url: "<?php echo base_url() ?>requisitionform/DeleteReqNo",
success: function(data) {
if (data && data.message) {
alert(data.message);
location.reload(true);
} else {
alert("Error Occur");
}
},
error: function(xhr, status, error) {
alert("Request failed: " + error);
}
},
error: function(xhr, status, error) {
});
}
}
alert("Request failed: " + error);
$(document).ready(function() {
// Initialize the DataTable
var table = $('#requisition_listing').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
order: [], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
}
}
$(document).ready(function() {
// Initialize the DataTable
var table = $('#requisition_listing').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
responsive: true, // Responsive table
order: [], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
}
});
);
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
});
</script>
</script>

View File

@ -127,10 +127,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button" title="Search"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -210,7 +210,7 @@
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header" style="display:block">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="standard-modalLabel">
<span id="invoice_number_display_model"></span> -
@ -295,17 +295,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -313,8 +315,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
@ -365,7 +372,7 @@
},
success: function(response) {
console.log(response);
console.log(JSON.parse(response).invoiceAttachment);
var list = JSON.parse(response).invoiceAttachment;
var attachmentsHtml = '';

View File

@ -71,10 +71,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -215,17 +215,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -233,11 +235,17 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();

View File

@ -94,10 +94,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -270,17 +270,19 @@
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
@ -288,8 +290,13 @@
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);

View File

@ -69,10 +69,10 @@
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
@ -207,31 +207,38 @@
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {

View File

@ -145,36 +145,36 @@
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">View Inward Gate Register </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">View Inward Gate Register </h4>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="view_inward_gate_register" class="table dt-responsive nowrap w-100">
<thead>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="view_inward_gate_register" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Create Date</th>
<th>Create time</th>
@ -204,45 +204,45 @@
$date = $createddate->format('d-m-Y');
$time = $createddate->format('h:i A');
?>
<tr id="<?php echo $index ?>" >
<td align="right"><?php echo $date; ?></td>
<td align="right"><?php echo $time; ?></td>
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<?php echo $index;?>" data-inx="<?php echo $index;?>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>"> <u><?php echo $record->IGRNO ?></u></a></td>
<td><a data-toggle="modal" data-target="#CostCentershow" data-id="<?php echo $index;?>" data-igno="<?php echo $record->IGRNO;?>" data-pono="<?php echo $record->PONO ?>" target="_blank"> <u><?php echo $record->PONO ?></u></a></td>
<td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td>
<td align="right"><?php
$date = new DateTime($record->DeliveryChellanDate);
echo $date->format('d-m-Y'); ?></td>
<td><?php echo $record->MaterialName ?></td>
<td><?php echo $record->ReceivedQuantity ?></td>
<td><?php echo $record->NetWeight ?></td>
<td><?php echo $record->VehicleNo ?></td>
<td><?php echo $record->DriverName ?></td>
<td><?php echo $record->TransporterName ?></td>
<td><?php echo $record->IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?></td>
<td>
<a target="_blank" href="<?php echo base_url('download-files/' . $record->IGRNO); ?>">
<i class="fa fa-download" style="text-align: center;"></i>
</a>
&nbsp;
<?php if (!empty($record->FilePath)) { ?>
<tr id="<?php echo $index ?>">
<td align="right"><?php echo $date; ?></td>
<td align="right"><?php echo $time; ?></td>
<td><a data-toggle="modal" data-target="#Igrshow" data-id="<?php echo $index; ?>" data-inx="<?php echo $index; ?>" data-userid="<?php echo $record->IGRNO ?>" data-igrstatus="<?php echo $record->IGRStatus ?>"> <u><?php echo $record->IGRNO ?></u></a></td>
<td><a data-toggle="modal" data-target="#CostCentershow" data-id="<?php echo $index; ?>" data-igno="<?php echo $record->IGRNO; ?>" data-pono="<?php echo $record->PONO ?>" target="_blank"> <u><?php echo $record->PONO ?></u></a></td>
<td><?php echo $record->SupplierName ?></td>
<td><?php echo $record->DeliveryChellanOrInvoiceNo ?></td>
<td align="right"><?php
$date = new DateTime($record->DeliveryChellanDate);
echo $date->format('d-m-Y'); ?></td>
<td><?php echo $record->MaterialName ?></td>
<td><?php echo $record->ReceivedQuantity ?></td>
<td><?php echo $record->NetWeight ?></td>
<td><?php echo $record->VehicleNo ?></td>
<td><?php echo $record->DriverName ?></td>
<td><?php echo $record->TransporterName ?></td>
<td><?php echo $record->IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?></td>
<td>
<a target="_blank" href="<?php echo base_url('download-files/' . $record->IGRNO); ?>">
<i class="fa fa-download" style="text-align: center;"></i>
</a>
&nbsp;
<?php if (!empty($record->FilePath)) { ?>
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
<?php } else if (!empty($record->file)) { ?>
<?php } else if (!empty($record->file)) { ?>
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
<?php } else { ?>
<?php } else { ?>
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
<?php } ?>
&nbsp;
<a target="_blank" data-toggle="modal" data-target="#Historyshow" data-id="<%=index%>" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>">
<i class="fa fa-history" style="text-align: center;color:#02a8b5"></i>
</a>
&nbsp;
<!-- <a class="a_tag_for_mrir" href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a> -->
</td>
</tr>
<?php } ?>
&nbsp;
<a target="_blank" data-toggle="modal" data-target="#Historyshow" data-id="<%=index%>" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>">
<i class="fa fa-history" style="text-align: center;color:#02a8b5"></i>
</a>
&nbsp;
<!-- <a class="a_tag_for_mrir" href="<?php echo base_url() . 'MRIRcontroller/igrdatavalues?IGRNO=' . $record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a> -->
</td>
</tr>
<?php
}
}
@ -583,7 +583,7 @@
$(document).ready(function() {
$("#Igrshow").on("shown.bs.modal", function(e) {
console.log("hello");
var inx = $(e.relatedTarget).data('id');
var igr = $(e.relatedTarget).data('userid');
var igrstatus = $(e.relatedTarget).data('igrstatus');
@ -839,7 +839,7 @@
});
});
});
</script>
</script>
<script>
$('#update').click(function() {
@ -1502,14 +1502,14 @@
<script src="https://cdn.datatables.net/plug-ins/1.13.6/sorting/datetime-moment.js"></script>
<script>
$(document).ready(function() {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
});
function appendExistingFilesFileds(data){
$(document).ready(function() {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(date) {
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
});
function appendExistingFilesFileds(data) {
const base_url = '<?php echo base_url(); ?>';
var filePath = data != null && data != '' ? data.FilePath : '';
var fileName = data != null && data != '' ? data.Remarks : '';
@ -1615,7 +1615,7 @@ function appendExistingFilesFileds(data){
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
order: [
[0, 'desc']
], // Default ordering (column index 0, ascending)
@ -1628,57 +1628,64 @@ function appendExistingFilesFileds(data){
});
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
console.log(toDate); // e.g., 08-09-2024
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
});
</script>