add more seeder product and product category and fix daterangepicker

This commit is contained in:
2025-06-25 16:29:34 +07:00
parent e96ca0a83c
commit e5daafc8f0
17 changed files with 334 additions and 319 deletions

View File

@@ -35,22 +35,30 @@ function initializeSelect2() {
}
/**
* Initialize date pickers with bootstrap datepicker - same as stock audit
* Initialize date pickers with bootstrap datepicker - same as transaction view
*/
function initializeDatepickers() {
console.log("Initializing datepickers...");
// Initialize start date picker with bootstrap datepicker
// Check if bootstrap datepicker is available
if (typeof $.fn.datepicker === "undefined") {
console.error("Bootstrap Datepicker not available!");
return;
}
// Initialize start date picker
$("#date_from")
.datepicker({
format: "yyyy-mm-dd",
autoclose: true,
todayHighlight: true,
orientation: "bottom auto",
language: "id",
clearBtn: true,
container: "body",
orientation: "bottom left",
templates: {
leftArrow: '<i class="la la-angle-left"></i>',
rightArrow: '<i class="la la-angle-right"></i>',
},
endDate: new Date(), // Don't allow future dates
clearBtn: true,
})
.on("changeDate", function (e) {
console.log("Start date selected:", e.format());
@@ -61,18 +69,15 @@ function initializeDatepickers() {
resetEndDatePicker();
});
// Initialize end date picker with bootstrap datepicker
// Initialize end date picker
initializeEndDatePicker();
// Initially disable end date input
$("#date_to").prop("disabled", true);
// Setup change event handlers as backup
setupChangeEventHandlers();
}
/**
* Enable end date picker with minimum date constraint using bootstrap datepicker
* Enable end date picker with minimum date constraint
*/
function enableEndDatePicker(startDate) {
console.log("Enabling end date picker with min date:", startDate);
@@ -83,18 +88,20 @@ function enableEndDatePicker(startDate) {
// Remove existing datepicker
$("#date_to").datepicker("remove");
// Re-initialize with new startDate constraint using bootstrap datepicker
// Re-initialize with new startDate constraint
$("#date_to")
.datepicker({
format: "yyyy-mm-dd",
autoclose: true,
todayHighlight: true,
orientation: "bottom auto",
language: "id",
clearBtn: true,
container: "body",
orientation: "bottom left",
templates: {
leftArrow: '<i class="la la-angle-left"></i>',
rightArrow: '<i class="la la-angle-right"></i>',
},
startDate: startDate, // Set minimum date to selected start date
endDate: new Date(), // Don't allow future dates
clearBtn: true,
})
.on("changeDate", function (e) {
console.log("End date selected:", e.format());
@@ -107,7 +114,7 @@ function enableEndDatePicker(startDate) {
}
/**
* Initialize end date picker without constraints using bootstrap datepicker
* Initialize end date picker without constraints
*/
function initializeEndDatePicker() {
$("#date_to")
@@ -115,11 +122,13 @@ function initializeEndDatePicker() {
format: "yyyy-mm-dd",
autoclose: true,
todayHighlight: true,
orientation: "bottom auto",
language: "id",
clearBtn: true,
container: "body",
orientation: "bottom left",
templates: {
leftArrow: '<i class="la la-angle-left"></i>',
rightArrow: '<i class="la la-angle-right"></i>',
},
endDate: new Date(), // Don't allow future dates
clearBtn: true,
})
.on("changeDate", function (e) {
console.log("End date selected:", e.format());
@@ -129,24 +138,23 @@ function initializeEndDatePicker() {
});
}
// Calendar icons and click handlers removed since bootstrap datepicker handles these automatically
/**
* Setup change event handlers for date inputs
* Reset end date picker to initial state
*/
function setupChangeEventHandlers() {
// For bootstrap datepicker, we already handle events in the datepicker initialization
// But we can add additional handling if needed
$("#date_from").on("change", function () {
const selectedDate = $(this).val();
if (selectedDate) {
console.log("Start date change event:", selectedDate);
enableEndDatePicker(selectedDate);
} else {
console.log("Start date cleared via change event");
resetEndDatePicker();
}
});
function resetEndDatePicker() {
// Remove existing datepicker
$("#date_to").datepicker("remove");
// Clear the input value
$("#date_to").val("");
// Re-initialize without startDate constraint
initializeEndDatePicker();
// Disable the input
$("#date_to").prop("disabled", true);
console.log("End date picker reset and disabled");
}
/**
@@ -293,25 +301,6 @@ function setupFilterHandlers(table) {
});
}
/**
* Reset end date picker to initial state using bootstrap datepicker
*/
function resetEndDatePicker() {
// Remove existing datepicker
$("#date_to").datepicker("remove");
// Clear the input value
$("#date_to").val("");
// Re-initialize without startDate constraint
initializeEndDatePicker();
// Disable the input
$("#date_to").prop("disabled", true);
console.log("End date picker reset and disabled");
}
/**
* Setup additional table event handlers
*/