Search Payment Destination
Or we can help you search for the agency or payment type
"
);
$this = $(this).find(".alert:first");
$this.addClass("in");
setTimeout(function() {
$this.slideUp(500, function(){ $(this).remove(); });
}, 5000);
return this;
};
}( jQuery ));
var $loadPayLocationAlertsDiv = $("div[id=loadPayLocationAlerts]");
var $loadPayLocationForm = $("form[id=loadPayLocationForm]");
var $loadPayLocationId = $("input[id=payLocationId]");
var $loadPayLocationFormValidator = $loadPayLocationForm.validate({
onfocusout: false,
onkeyup: false,
onclick: false,
errorElement: "label",
errorClass: "error",
errorPlacement: function(error, element) {
error.insertAfter(element);
},
highlight: function(element, errorClass, validClass) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element, errorClass, validClass) {
$(element).closest('.form-group').removeClass('has-error');
}
});
$loadPayLocationId.autocomplete({
source: function(request, response) {
$(".ui-menu").hide();
var searchTerm = $loadPayLocationId.val();
var regexPattern = new RegExp("^[a-zA-Z0-9- ]*$");
if (regexPattern.test(searchTerm)) {
$.ajax({
method : "GET",
url: "/gps/user/lookup/autocomplete/paymentLocations/gpn/" + searchTerm,
dataType : "json",
success: function(data) {
if (data.status == "FAIL") {
$loadPayLocationAlertsDiv.createAlert("danger", "Unable to search for Pay Location Code.");
return;
}
response(data.result.paymentLocations);
},
error: function(jqXHR, textStatus, errorThrown) {
if (textStatus != "error") {
$loadPayLocationAlertsDiv.createAlert("danger", "Unable to search for Pay Location Code.");
}
}
});
} else {
$loadPayLocationAlertsDiv.createAlert("danger", "Cannot search Pay Location Codes due to invalid input. Please remove any non-alphanumeric characters.");
}
},
minLength : 2,
delay: 250,
select: function (event, ui) {
event.preventDefault();
$( "#payLocationId" ).val(ui.item.data);
}
});
var $searchPayLocationAlertsDiv = $("div[id=searchPayLocationAlerts]");
var $searchPayLocationForm = $("form[id=searchPayLocationForm]");
var $payLocationTypeSelect = $("select[id=payLocationType]");
var $payLocationStateDiv = $("div[id=payLocationStateDiv]");
var $payLocationStateSelect = $("select[id=payLocationState]");
var $payLocationAgencyDiv = $("div[id=payLocationAgencyDiv]");
var $payLocationAgencySelect = $("select[id=payLocationAgency]");
var $payLocationIdDiv = $("div[id=payLocationIdSelectDiv]");
var $payLocationIdSelect = $("select[id=payLocationIdSelect]");
var $continueDiv = $("div[id=continueDiv]");
var $searchPayLocationFormValidator = $searchPayLocationForm.validate({
onfocusout: false,
onkeyup: false,
onclick: false,
errorElement: "label",
errorClass: "error",
errorPlacement: function(error, element) {
error.insertAfter(element);
},
highlight: function(element, errorClass, validClass) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element, errorClass, validClass) {
$(element).closest('.form-group').removeClass('has-error');
}
});
$payLocationTypeSelect.add($payLocationStateSelect).on("change", function() {
$payLocationAgencySelect.find("option").not(":first").remove();
$payLocationIdSelect.find("option").not(":first").remove();
if ($payLocationTypeSelect ==="" || $payLocationStateSelect.val() === "") {
return false;
}
$.ajax({
method : "POST",
url : "/gps/user/lookup/agency",
data : $searchPayLocationForm.serialize(),
dataType : "json",
success: function(data) {
if (data.status == "FAIL") {
$searchPayLocationAlertsDiv.createAlert("danger", "Unable to perform search for agency.");
return;
}
if ($.isEmptyObject(data.result)) {
$searchPayLocationAlertsDiv.createAlert("info", "No agencies found for criteria.");
return;
}
$.each(data.result, function(key, value) {
org.owasp.esapi.ESAPI.initialize();
$payLocationAgencySelect.append($('
').val(value).html($ESAPI.encoder().encodeForHTML(value)));
});
},
error: function(jqXHR, textStatus, errorThrown) {
$searchPayLocationAlertsDiv.createAlert("danger", "Unable to perform search for agency.");
return;
}
});
});
$payLocationAgencySelect.on("change", function() {
$payLocationIdSelect.find("option").not(":first").remove();
if ($payLocationTypeSelect.val() === "" ||
$payLocationStateSelect.val() === "" ||
$payLocationAgencySelect.val() === "") {
return false;
}
$.ajax({
method : "POST",
url : "/gps/user/lookup/payLocation",
data : $searchPayLocationForm.serialize(),
dataType : "json",
success: function(data) {
if (data.status == "FAIL") {
if ($.isEmptyObject(data.errors)) {
createSearchPayLocationAlert("Unable to perform search for Pay Locations.");
} else {
$.each(data.errors, function(index, value) {
createSearchPayLocationAlert(value);
});
}
return false;
}
if ($.isEmptyObject(data.result)) {
createSearchPayLocationAlert("No Pay Locations found for criteria.");
return false;
}
$.each(data.result, function(key, value) {
org.owasp.esapi.ESAPI.initialize();
var strValue = $ESAPI.encoder().encodeForHTML(value);
var strKey = $ESAPI.encoder().encodeForHTML(key);
$payLocationIdSelect.append($('
').val(key).html(strValue + " / " + strKey));
});
},
error: function(jqXHR, textStatus, errorThrown) {
createSearchPayLocationAlert("Unable to perform search for Pay Locations.");
return;
}
});
});
});