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,17 +35,25 @@ function initializeSelect2() {
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());
@@ -56,14 +64,11 @@ 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
setupChangeEventHandlers();
}
function enableEndDatePicker(startDate) {
@@ -72,21 +77,23 @@ function enableEndDatePicker(startDate) {
// Enable the input
$("#date_to").prop("disabled", false);
// Destroy existing datepicker
// 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());
@@ -104,11 +111,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());
@@ -120,21 +129,6 @@ function initializeEndDatePicker() {
// Calendar icons and click handlers removed since bootstrap datepicker handles these automatically
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 initializeDataTable() {
console.log("Initializing DataTable...");