754 lines
27 KiB
JavaScript
754 lines
27 KiB
JavaScript
|
|
|
||
|
|
// ===============
|
||
|
|
// Search Licenses
|
||
|
|
// ===============
|
||
|
|
|
||
|
|
$(document).ready(function () {
|
||
|
|
|
||
|
|
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Input Masks
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".date-mask").inputmask({alias: "datetime",
|
||
|
|
inputFormat: "mm/dd/yyyy",
|
||
|
|
placeholder: "MM/DD/YYYY",
|
||
|
|
showMaskOnHover: false});
|
||
|
|
|
||
|
|
$(".numeric-mask").inputmask("9{0,9}", {showMaskOnHover: false});
|
||
|
|
$(".zip-mask").inputmask("9{5}", {showMaskOnHover: false, removeMaskOnSubmit: true});
|
||
|
|
$('.money-mask').inputmask('currency', {
|
||
|
|
prefix: '$',
|
||
|
|
groupSeparator: ',',
|
||
|
|
digits: 2,
|
||
|
|
digitsOptional: false,
|
||
|
|
autoGroup: true,
|
||
|
|
removeMaskOnSubmit: true
|
||
|
|
});
|
||
|
|
|
||
|
|
// --------------
|
||
|
|
// Select Pickers
|
||
|
|
// --------------
|
||
|
|
|
||
|
|
$(".multiple-dropdown").selectpicker({noneSelectedText: "Choose...",
|
||
|
|
style: "",
|
||
|
|
styleBase: "form-select form-select-sm",
|
||
|
|
iconBase: "bi",
|
||
|
|
actionsBox: true,
|
||
|
|
selectedTextFormat: "count",
|
||
|
|
virtualScroll: true,
|
||
|
|
size: 10,
|
||
|
|
selectOnTab: true,
|
||
|
|
container: "body",
|
||
|
|
liveSearch: true});
|
||
|
|
|
||
|
|
|
||
|
|
// ------------
|
||
|
|
// Date Pickers
|
||
|
|
// ------------
|
||
|
|
|
||
|
|
$("#commercial_license_begin_date_from").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.begin_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
$("#commercial_license_begin_date_to").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.begin_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
$("#commercial_license_expire_date_from").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.expire_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
$("#commercial_license_expire_date_to").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.expire_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
// ---------------------
|
||
|
|
// Show Calendar Buttons
|
||
|
|
// ---------------------
|
||
|
|
|
||
|
|
$(".btnBeginDateFromCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#commercial_license_begin_date_from").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".btnBeginDateToCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#commercial_license_begin_date_to").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".btnExpireDateFromCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#commercial_license_expire_date_from").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".btnExpireDateToCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#commercial_license_expire_date_to").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
function restoreValue(selector, value) {
|
||
|
|
if (value === undefined || value === null) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var $field = $(selector);
|
||
|
|
|
||
|
|
if ($field.hasClass("multiple-dropdown") && $.fn.selectpicker) {
|
||
|
|
if ($field.prop("multiple") && !Array.isArray(value)) {
|
||
|
|
value = (value === "") ? [] : String(value).split(",");
|
||
|
|
}
|
||
|
|
|
||
|
|
$field.selectpicker("val", value);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$field.val(value).trigger("change");
|
||
|
|
}
|
||
|
|
|
||
|
|
restoreValue("#license_search_type", $sessionStorage.license_search_type);
|
||
|
|
restoreValue("#license_last_name", $sessionStorage.license_last_name);
|
||
|
|
restoreValue("#license_first_name", $sessionStorage.license_first_name);
|
||
|
|
restoreValue("[name='license_county[]']", $sessionStorage.license_county);
|
||
|
|
restoreValue("#license_city", $sessionStorage.license_city);
|
||
|
|
restoreValue("#license_type", $sessionStorage.license_type);
|
||
|
|
restoreValue("#license_gender", $sessionStorage.license_gender);
|
||
|
|
restoreValue("#license_ethnicity", $sessionStorage.license_ethnicity);
|
||
|
|
restoreValue("#license_start_date", $sessionStorage.license_start_date);
|
||
|
|
restoreValue("#license_expire_date", $sessionStorage.license_expire_date);
|
||
|
|
restoreValue("#commercial_license_company_or_last_name", $sessionStorage.commercial_license_company_or_last_name);
|
||
|
|
restoreValue("#license_code", $sessionStorage.license_code);
|
||
|
|
restoreValue("#commercial_license_number", $sessionStorage.commercial_license_number);
|
||
|
|
restoreValue("#commercial_license_total_tag_qty_from", $sessionStorage.commercial_license_total_tag_qty_from);
|
||
|
|
restoreValue("#commercial_license_total_tag_qty_to", $sessionStorage.commercial_license_total_tag_qty_to);
|
||
|
|
restoreValue("#commercial_license_begin_date_from", $sessionStorage.commercial_license_begin_date_from);
|
||
|
|
restoreValue("#commercial_license_begin_date_to", $sessionStorage.commercial_license_begin_date_to);
|
||
|
|
restoreValue("#commercial_license_expire_date_from", $sessionStorage.commercial_license_expire_date_from);
|
||
|
|
restoreValue("#commercial_license_expire_date_to", $sessionStorage.commercial_license_expire_date_to);
|
||
|
|
|
||
|
|
$(".search-dropdown").selectpicker("refresh");
|
||
|
|
|
||
|
|
// ------------
|
||
|
|
// Date Pickers
|
||
|
|
// ------------
|
||
|
|
|
||
|
|
$("#license_start_date").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.license_start_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
$("#license_expire_date").datepicker({format: "mm-dd-yyyy",
|
||
|
|
container: "div.license_expire_date",
|
||
|
|
keyboardNavigation: false,
|
||
|
|
showOnFocus: false,
|
||
|
|
autoclose: true,
|
||
|
|
endDate: "0d",
|
||
|
|
orientation: "left bottom",
|
||
|
|
todayBtn: "linked",
|
||
|
|
todayHighlight: true});
|
||
|
|
|
||
|
|
// ---------------------
|
||
|
|
// Show Calendar Buttons
|
||
|
|
// ---------------------
|
||
|
|
|
||
|
|
$(".btnLicenseStartDateCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#license_start_date").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
$(".btnLicenseExpireDateCalendar").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#license_expire_date").focus().datepicker("show");
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
$("#license_search_type").on("change", function () {
|
||
|
|
|
||
|
|
let licenseType = $(this).val();
|
||
|
|
|
||
|
|
// Show the appropriate section
|
||
|
|
if (licenseType == 1) { // Residential
|
||
|
|
$("#commercial_search").addClass("d-none");
|
||
|
|
$("#recreational_search").removeClass("d-none");
|
||
|
|
$("#license_last_name").focus();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
if (licenseType == 2) { // Commercial
|
||
|
|
$("#recreational_search").addClass("d-none");
|
||
|
|
$("#commercial_search").removeClass("d-none");
|
||
|
|
$("#commercial_license_company_or_last_name").focus();
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$("#license_search_type").trigger("change");
|
||
|
|
|
||
|
|
$("#licenses_per_page").val($sessionStorage.licenses_per_page || "20");
|
||
|
|
|
||
|
|
// ---------------
|
||
|
|
// Per Page Change
|
||
|
|
// ---------------
|
||
|
|
|
||
|
|
$("#licenses_per_page").on("change", function () {
|
||
|
|
|
||
|
|
$sessionStorage.licenses_per_page = $(this).val();
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchLicenses";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------------
|
||
|
|
// Pagination Buttons
|
||
|
|
// ------------------
|
||
|
|
|
||
|
|
$(".btnPagination").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchLicenses";
|
||
|
|
$sessionStorage.pagination = $(this).data("pagination");
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
delete $sessionStorage.pagination;
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// =================
|
||
|
|
// Process Enter Key
|
||
|
|
// =================
|
||
|
|
|
||
|
|
$(document).on('keypress', function (e) {
|
||
|
|
if (e.which === 13) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#searchLicenses").submit();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------------------
|
||
|
|
// Filter the License Rows
|
||
|
|
// -----------------------
|
||
|
|
|
||
|
|
$("#filter").on("keyup", function () {
|
||
|
|
|
||
|
|
const filter = $(this).val().toLowerCase().trim();
|
||
|
|
|
||
|
|
const $matchingLicenses = $(".license-row").hide().filter(function () {
|
||
|
|
return $(this).text().toLowerCase().indexOf(filter) > -1;
|
||
|
|
});
|
||
|
|
|
||
|
|
$matchingLicenses.show();
|
||
|
|
|
||
|
|
const noVisibleLicenses = $matchingLicenses.length === 0;
|
||
|
|
const $licensesTableWrapper = $("#licenses-table").closest(".table-responsive");
|
||
|
|
|
||
|
|
if (noVisibleLicenses) {
|
||
|
|
$(".filter-error").removeClass("d-none");
|
||
|
|
$(".print_page_buttons").addClass("d-none");
|
||
|
|
$licensesTableWrapper.addClass("d-none");
|
||
|
|
} else {
|
||
|
|
$(".filter-error").addClass("d-none");
|
||
|
|
$(".print_page_buttons").removeClass("d-none");
|
||
|
|
$licensesTableWrapper.removeClass("d-none");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// ----------------
|
||
|
|
// Clear the filter
|
||
|
|
// ----------------
|
||
|
|
|
||
|
|
$("#filter").on("keydown", function (e) {
|
||
|
|
if (e.key === "Escape") {
|
||
|
|
$(this).val("").trigger("keyup");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------------
|
||
|
|
// Clear Filter Button
|
||
|
|
// -------------------
|
||
|
|
|
||
|
|
$(".btnClearFilter").on("click", function () {
|
||
|
|
|
||
|
|
$("#filter").val("").trigger("change");
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchLicenses";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$(".licensenumber-autocomplete").autoComplete({
|
||
|
|
resolverSettings: {
|
||
|
|
url: "main.php?Xaction=FWCLicenses.getAutoCompleteLicenseNumbers",
|
||
|
|
queryKey: "commercial_license_number",
|
||
|
|
requestThrottling: 0
|
||
|
|
},
|
||
|
|
noResultsText: "No Matching License Numbers Found.",
|
||
|
|
bootstrapVersion: "4"
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
// ---------------------
|
||
|
|
// Export Licenses - CSV
|
||
|
|
// ---------------------
|
||
|
|
|
||
|
|
$(".btnExportCSV").on("click", function (e) {
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
$sessionStorage.action = "Export_LicensesToExcel.export";
|
||
|
|
$sessionStorage.subscription_reference = $sessionStorage.subscription_serial;
|
||
|
|
$sessionStorage.pagination = "off";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
// Submit in a new tab
|
||
|
|
formSubmit($sessionStorage, "_blank");
|
||
|
|
|
||
|
|
// Hide spinner immediately, since the main page isn't going anywhere
|
||
|
|
setTimeout(function () {
|
||
|
|
$("#spinner-dialog").modal("hide");
|
||
|
|
}, 2000); // optional: add a slight delay so it feels responsive
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// --------------------------
|
||
|
|
// Print Search Results - PDF
|
||
|
|
// --------------------------
|
||
|
|
|
||
|
|
$(".btnPrintSearchResultsPDF").on("click", function (e) {
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
$sessionStorage.action = "Print_LicensesPDF.print";
|
||
|
|
$sessionStorage.subscription_reference = $sessionStorage.subscription_serial;
|
||
|
|
$sessionStorage.pagination = "off";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
// Submit in a new tab
|
||
|
|
formSubmit($sessionStorage, "_blank");
|
||
|
|
|
||
|
|
// Hide spinner immediately, since the main page isn't going anywhere
|
||
|
|
setTimeout(function () {
|
||
|
|
$("#spinner-dialog").modal("hide");
|
||
|
|
}, 2000); // optional: add a slight delay so it feels responsive
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Save Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnSearch").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#searchLicenses").submit();
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Home Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnHome").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------------
|
||
|
|
// Reset Search Button
|
||
|
|
// -------------------
|
||
|
|
|
||
|
|
$(".btnReset").on("click", function () {
|
||
|
|
|
||
|
|
clearForm($('#searchLicenses'));
|
||
|
|
|
||
|
|
$sessionStorage = clearLicenseSessionVariableFilters($sessionStorage);
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchLicenses";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ---------------
|
||
|
|
// Validate Inputs
|
||
|
|
// ---------------
|
||
|
|
|
||
|
|
$("#searchLicenses").submit(function (e) {
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
var license_search_type = $("#license_search_type"),
|
||
|
|
selected_license_search_type = $("option:selected", license_search_type).val(),
|
||
|
|
license_last_name = $("#license_last_name"),
|
||
|
|
license_first_name = $("#license_first_name"),
|
||
|
|
recreational_license_county = $("#recreational_search [name='license_county[]']"),
|
||
|
|
commercial_license_county = $("#commercial_search [name='license_county[]']"),
|
||
|
|
license_county = selected_license_search_type === "2" ? commercial_license_county : recreational_license_county,
|
||
|
|
license_city = $("#license_city"),
|
||
|
|
license_type = $("#license_type"),
|
||
|
|
license_gender = $("#license_gender"),
|
||
|
|
license_ethnicity = $("#license_ethnicity"),
|
||
|
|
license_start_date = $("#license_start_date"),
|
||
|
|
license_expire_date = $("#license_expire_date"),
|
||
|
|
commercial_license_company_or_last_name = $("#commercial_license_company_or_last_name"),
|
||
|
|
license_code = $("#license_code"),
|
||
|
|
commercial_license_number = $("#commercial_license_number"),
|
||
|
|
commercial_license_total_tag_qty_from = $("#commercial_license_total_tag_qty_from"),
|
||
|
|
commercial_license_total_tag_qty_to = $("#commercial_license_total_tag_qty_to"),
|
||
|
|
commercial_license_begin_date_from = $("#commercial_license_begin_date_from"),
|
||
|
|
commercial_license_begin_date_to = $("#commercial_license_begin_date_to"),
|
||
|
|
commercial_license_expire_date_from = $("#commercial_license_expire_date_from"),
|
||
|
|
commercial_license_expire_date_to = $("#commercial_license_expire_date_to"),
|
||
|
|
form_error = $("#search-form-error");
|
||
|
|
|
||
|
|
clearInputErrors();
|
||
|
|
|
||
|
|
|
||
|
|
// Function to display errors and hide spinner
|
||
|
|
function showError(message, element) {
|
||
|
|
$("#spinner-dialog").modal("hide");
|
||
|
|
createInputError(form_error, message);
|
||
|
|
if (element)
|
||
|
|
createInputError(element, "");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "") {
|
||
|
|
return showError("Search Type Required");
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "1" && [license_last_name, license_first_name, license_county, license_city, license_type, license_gender, license_ethnicity, license_start_date, license_expire_date].every(isBlank)) {
|
||
|
|
return showError("Please provide a search criteria.");
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && [commercial_license_company_or_last_name, license_code, commercial_license_number, license_county, commercial_license_total_tag_qty_from, commercial_license_total_tag_qty_to, commercial_license_begin_date_from, commercial_license_begin_date_to, commercial_license_expire_date_from, commercial_license_expire_date_to].every(isBlank)) {
|
||
|
|
return showError("Please provide a search criteria.");
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_total_tag_qty_from)) && (!isBlank(commercial_license_total_tag_qty_to)) && parseInt(commercial_license_total_tag_qty_from.val(), 10) > parseInt(commercial_license_total_tag_qty_to.val(), 10)) {
|
||
|
|
createInputError(commercial_license_total_tag_qty_from, "Quantity is greater than To Quantity");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "1" && (!isBlank(license_start_date)) && (!license_start_date.inputmask("isComplete"))) {
|
||
|
|
createInputError(license_start_date, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "1" && (!isBlank(license_expire_date)) && (!license_expire_date.inputmask("isComplete"))) {
|
||
|
|
createInputError(license_expire_date, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
let startDate = new Date(license_start_date.val()),
|
||
|
|
endDate = new Date(license_expire_date.val());
|
||
|
|
|
||
|
|
if (selected_license_search_type === "1" && startDate > endDate) {
|
||
|
|
createInputError(license_start_date, "Date is after End Date");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_begin_date_from)) && (!commercial_license_begin_date_from.inputmask("isComplete"))) {
|
||
|
|
createInputError(commercial_license_begin_date_from, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_begin_date_to)) && (!commercial_license_begin_date_to.inputmask("isComplete"))) {
|
||
|
|
createInputError(commercial_license_begin_date_to, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_expire_date_from)) && (!commercial_license_expire_date_from.inputmask("isComplete"))) {
|
||
|
|
createInputError(commercial_license_expire_date_from, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_expire_date_to)) && (!commercial_license_expire_date_to.inputmask("isComplete"))) {
|
||
|
|
createInputError(commercial_license_expire_date_to, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
let commercialBeginDateFrom = new Date(commercial_license_begin_date_from.val()),
|
||
|
|
commercialBeginDateTo = new Date(commercial_license_begin_date_to.val()),
|
||
|
|
commercialExpireDateFrom = new Date(commercial_license_expire_date_from.val()),
|
||
|
|
commercialExpireDateTo = new Date(commercial_license_expire_date_to.val());
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_begin_date_from)) && (!isBlank(commercial_license_begin_date_to)) && commercialBeginDateFrom > commercialBeginDateTo) {
|
||
|
|
createInputError(commercial_license_begin_date_from, "Date is after End Date");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (selected_license_search_type === "2" && (!isBlank(commercial_license_expire_date_from)) && (!isBlank(commercial_license_expire_date_to)) && commercialExpireDateFrom > commercialExpireDateTo) {
|
||
|
|
createInputError(commercial_license_expire_date_from, "Date is after End Date");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchLicenses";
|
||
|
|
$sessionStorage.step = "search";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
$sessionStorage.license_search_type = license_search_type.val();
|
||
|
|
$sessionStorage.license_last_name = license_last_name.val();
|
||
|
|
$sessionStorage.license_first_name = license_first_name.val();
|
||
|
|
$sessionStorage.license_county = license_county.val();
|
||
|
|
$sessionStorage.license_city = license_city.val();
|
||
|
|
$sessionStorage.license_type = license_type.val();
|
||
|
|
$sessionStorage.license_gender = license_gender.val();
|
||
|
|
$sessionStorage.license_ethnicity = license_ethnicity.val();
|
||
|
|
$sessionStorage.license_start_date = license_start_date.val();
|
||
|
|
$sessionStorage.license_expire_date = license_expire_date.val();
|
||
|
|
$sessionStorage.commercial_license_company_or_last_name = commercial_license_company_or_last_name.val();
|
||
|
|
$sessionStorage.license_code = license_code.val();
|
||
|
|
$sessionStorage.commercial_license_number = commercial_license_number.val();
|
||
|
|
$sessionStorage.commercial_license_total_tag_qty_from = commercial_license_total_tag_qty_from.val();
|
||
|
|
$sessionStorage.commercial_license_total_tag_qty_to = commercial_license_total_tag_qty_to.val();
|
||
|
|
$sessionStorage.commercial_license_begin_date_from = commercial_license_begin_date_from.val();
|
||
|
|
$sessionStorage.commercial_license_begin_date_to = commercial_license_begin_date_to.val();
|
||
|
|
$sessionStorage.commercial_license_expire_date_from = commercial_license_expire_date_from.val();
|
||
|
|
$sessionStorage.commercial_license_expire_date_to = commercial_license_expire_date_to.val();
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------------
|
||
|
|
// Column Heading Sort
|
||
|
|
// -------------------
|
||
|
|
|
||
|
|
if (($sessionStorage.licenses_order_by || "") !== "") {
|
||
|
|
|
||
|
|
$("th[data-order-by = '" + ($sessionStorage.licenses_order_by || "") + "']").append('<i class="' + ($sessionStorage.licenses_order_icon || "") + ' text-danger ms-1 me-0"/>');
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$("th.sortable").on("click", function (e) {
|
||
|
|
|
||
|
|
if ($(e.target).data("order-by") !== ($sessionStorage.licenses_order_by || "")) { // New Column
|
||
|
|
|
||
|
|
$sessionStorage.licenses_order_by = $(e.target).data("order-by");
|
||
|
|
$sessionStorage.licenses_order_direction = "asc";
|
||
|
|
$sessionStorage.licenses_order_icon = "bi bi-arrow-up";
|
||
|
|
|
||
|
|
} else {
|
||
|
|
|
||
|
|
switch ($sessionStorage.licenses_order_direction) {
|
||
|
|
|
||
|
|
case "" :
|
||
|
|
|
||
|
|
$sessionStorage.licenses_order_by = $(e.target).data("order-by");
|
||
|
|
$sessionStorage.licenses_order_direction = "asc";
|
||
|
|
$sessionStorage.licenses_order_icon = "bi bi-arrow-up";
|
||
|
|
break;
|
||
|
|
|
||
|
|
case "asc" :
|
||
|
|
|
||
|
|
$sessionStorage.licenses_order_by = $(e.target).data("order-by");
|
||
|
|
$sessionStorage.licenses_order_direction = "desc";
|
||
|
|
$sessionStorage.licenses_order_icon = "bi bi-arrow-down";
|
||
|
|
break;
|
||
|
|
|
||
|
|
case "desc" :
|
||
|
|
|
||
|
|
$sessionStorage.licenses_order_by = "";
|
||
|
|
$sessionStorage.licenses_order_direction = "";
|
||
|
|
$sessionStorage.licenses_order_icon = "";
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------------
|
||
|
|
// Select All Button
|
||
|
|
// -----------------
|
||
|
|
|
||
|
|
$(".btnSelectAll").on("click", function (e) {
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
$(".selection-checkbox:input:checkbox").prop("checked", true);
|
||
|
|
|
||
|
|
$(".btnDeselectAll, .btnExportSelected").removeClass("d-none");
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------------
|
||
|
|
// Deselect All Button
|
||
|
|
// -------------------
|
||
|
|
|
||
|
|
$(".btnDeselectAll").on("click", function (e) {
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
$(".selection-checkbox:input:checkbox").prop("checked", false);
|
||
|
|
|
||
|
|
$(".btnDeselectAll, .btnExportSelected").addClass("d-none");
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------------------
|
||
|
|
// Toggle a Select Checkbox
|
||
|
|
// ------------------------
|
||
|
|
|
||
|
|
$(".license-row").on("click touch", function (e) {
|
||
|
|
|
||
|
|
if (!($(e.target).hasClass("selection-area"))) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
var $this = $(e.target), checked = ($this.closest("tr").find("input[name='selected[]']").prop("checked"));
|
||
|
|
|
||
|
|
// Toggle the selected Checkbox.
|
||
|
|
|
||
|
|
$this.closest("tr").find("input[name='selected[]']").prop("checked", !checked);
|
||
|
|
|
||
|
|
if ($("input[name='selected[]']:checked").length === 0) {
|
||
|
|
$(".btnDeselectAll, .btnExportSelected").addClass("d-none");
|
||
|
|
} else {
|
||
|
|
$(".btnDeselectAll, .btnExportSelected").removeClass("d-none");
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
function clearForm($form) {
|
||
|
|
|
||
|
|
// Clear text, number, masked inputs, and textareas
|
||
|
|
$form.find('input:not([type=checkbox]):not([type=radio]), textarea').val('').trigger('change');
|
||
|
|
|
||
|
|
// Clear checkboxes and radios
|
||
|
|
$form.find('input[type=checkbox], input[type=radio]').prop('checked', false).trigger('change');
|
||
|
|
|
||
|
|
// Clear bootstrap-select controls before refreshing their rendered buttons
|
||
|
|
if ($.fn.selectpicker) {
|
||
|
|
$form.find('.multiple-dropdown').selectpicker('val', []);
|
||
|
|
$form.find('.search-dropdown').each(function () {
|
||
|
|
$(this).selectpicker('val', $(this).prop('multiple') ? [] : '');
|
||
|
|
});
|
||
|
|
$form.find('.search-dropdown, .multiple-dropdown').selectpicker('refresh');
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clear standard selects
|
||
|
|
$form.find('select').not('.search-dropdown, .multiple-dropdown').val('').trigger('change');
|
||
|
|
|
||
|
|
// Clear jQuery UI / Bootstrap datepickers
|
||
|
|
$form.find('.date-mask').each(function () {
|
||
|
|
if ($(this).data('datepicker')) {
|
||
|
|
$(this).datepicker('clearDates');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function clearLicenseSessionVariableFilters(sessionStorage) {
|
||
|
|
|
||
|
|
delete sessionStorage.license_search_type;
|
||
|
|
delete sessionStorage.license_last_name;
|
||
|
|
delete sessionStorage.license_first_name;
|
||
|
|
delete sessionStorage.license_county;
|
||
|
|
delete sessionStorage.license_city;
|
||
|
|
delete sessionStorage.license_type;
|
||
|
|
delete sessionStorage.license_gender;
|
||
|
|
delete sessionStorage.license_ethnicity;
|
||
|
|
delete sessionStorage.license_start_date;
|
||
|
|
delete sessionStorage.license_expire_date;
|
||
|
|
delete sessionStorage.commercial_license_company_or_last_name;
|
||
|
|
delete sessionStorage.license_code;
|
||
|
|
delete sessionStorage.commercial_license_number;
|
||
|
|
delete sessionStorage.commercial_license_total_tag_qty_from;
|
||
|
|
delete sessionStorage.commercial_license_total_tag_qty_to;
|
||
|
|
delete sessionStorage.commercial_license_begin_date_from;
|
||
|
|
delete sessionStorage.commercial_license_begin_date_to;
|
||
|
|
delete sessionStorage.commercial_license_expire_date_from;
|
||
|
|
delete sessionStorage.commercial_license_expire_date_to;
|
||
|
|
delete sessionStorage.licenses_order_by;
|
||
|
|
delete sessionStorage.licenses_order_direction;
|
||
|
|
delete sessionStorage.licenses_order_icon;
|
||
|
|
delete sessionStorage.pagination;
|
||
|
|
|
||
|
|
return sessionStorage;
|
||
|
|
}
|
||
|
|
|
||
|
|
function printElement(selector) {
|
||
|
|
const content = document.querySelector(selector).innerHTML;
|
||
|
|
const original = document.body.innerHTML;
|
||
|
|
|
||
|
|
document.body.innerHTML = content;
|
||
|
|
window.print();
|
||
|
|
document.body.innerHTML = original;
|
||
|
|
location.reload(); // restores JS state
|
||
|
|
}
|