601 lines
18 KiB
JavaScript
601 lines
18 KiB
JavaScript
|
|
|
||
|
|
// ============================
|
||
|
|
// Search Recreational 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});
|
||
|
|
|
||
|
|
|
||
|
|
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_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);
|
||
|
|
|
||
|
|
$(".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");
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
$("#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.searchRecreationalLicenses";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------------
|
||
|
|
// Pagination Buttons
|
||
|
|
// ------------------
|
||
|
|
|
||
|
|
$(".btnPagination").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchRecreationalLicenses";
|
||
|
|
$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();
|
||
|
|
$("#searchRecreationalLicenses").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.searchRecreationalLicenses";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------------------------
|
||
|
|
// Export Selected Permits - CSV
|
||
|
|
// -----------------------------
|
||
|
|
|
||
|
|
$(".btnExportCSV").on("click", function (e) {
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
var selected = $("input[name='selected[]']:checked").map(function () {
|
||
|
|
return $(this).val();
|
||
|
|
}).get();
|
||
|
|
|
||
|
|
console.log(selected);
|
||
|
|
|
||
|
|
$sessionStorage.action = "Export_SelectedRecreationalLicenses_CSV.export";
|
||
|
|
$sessionStorage.selected_licenses = selected;
|
||
|
|
// $sessionStorage.subscription_reference = $sessionStorage.subscription_serial;
|
||
|
|
|
||
|
|
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_RecreationalLicensesPDF.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
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// --------------------------------------
|
||
|
|
// Export All Recreational Licenses - CSV
|
||
|
|
// --------------------------------------
|
||
|
|
|
||
|
|
$(".btnExportSearchResultsCSV").on("click", function (e) {
|
||
|
|
|
||
|
|
$sessionStorage.action = "Export.createExportRequest";
|
||
|
|
|
||
|
|
$sessionStorage.searchRecreationalLicenses = "Export.usersExports";
|
||
|
|
$sessionStorage.export_license_type = "recreational";
|
||
|
|
$sessionStorage.report_type = "csv";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// --------------------------------------
|
||
|
|
// Export All Recreational Licenses - PDF
|
||
|
|
// --------------------------------------
|
||
|
|
|
||
|
|
$(".btnPrintAllRecordsPDF").on("click", function (e) {
|
||
|
|
|
||
|
|
$sessionStorage.action = "Export.createExportRequest";
|
||
|
|
$sessionStorage.export_license_type = "recreational";
|
||
|
|
$sessionStorage.report_type = "pdf";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Save Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnSearch").on("click", function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
$("#searchRecreationalLicenses").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($('#searchRecreationalLicenses'));
|
||
|
|
|
||
|
|
$sessionStorage = clearLicenseSessionVariableFilters($sessionStorage);
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchRecreationalLicenses";
|
||
|
|
$sessionStorage.step = "prompt";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ---------------
|
||
|
|
// Validate Inputs
|
||
|
|
// ---------------
|
||
|
|
|
||
|
|
$("#searchRecreationalLicenses").submit(function (e) {
|
||
|
|
|
||
|
|
$("#spinner-dialog").modal("show");
|
||
|
|
|
||
|
|
var license_last_name = $("#license_last_name"),
|
||
|
|
license_first_name = $("#license_first_name"),
|
||
|
|
license_county = $("#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"),
|
||
|
|
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 ([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 ((!isBlank(license_start_date)) && (!license_start_date.inputmask("isComplete"))) {
|
||
|
|
createInputError(license_start_date, "Date is incomplete");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ((!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 (startDate > endDate) {
|
||
|
|
createInputError(license_start_date, "Date is after End Date");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
$sessionStorage.action = "FWCLicenses.searchRecreationalLicenses";
|
||
|
|
$sessionStorage.step = "search";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
$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.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_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.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
|
||
|
|
}
|