2010-02-18 21:38:43 -08:00
|
|
|
/*
|
|
|
|
|
* autocomplete-customer.js
|
|
|
|
|
*
|
2010-03-17 15:51:35 -07:00
|
|
|
* used in customers/add.ctp
|
2010-02-18 21:38:43 -08:00
|
|
|
*
|
2010-03-29 16:36:29 -07:00
|
|
|
* Not an autocomplete anymore, updates a dialog box with similar customer names to try and stop duplicate entries.
|
2010-02-18 21:38:43 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
|
|
2010-03-15 20:51:08 -07:00
|
|
|
$("#dialog").hide();
|
2010-03-15 15:59:08 -07:00
|
|
|
|
2010-03-15 20:51:08 -07:00
|
|
|
/*If the user has entered 3 or more characters. Check to see if its similar to existing customers. */
|
|
|
|
|
$("#customerName").change(function () {
|
2011-06-29 00:25:33 -07:00
|
|
|
getSimilar();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getSimilar() {
|
2010-03-15 20:51:08 -07:00
|
|
|
if($("#customerName").val().length >= 3) {
|
2010-03-15 20:20:38 -07:00
|
|
|
|
2010-03-15 20:51:08 -07:00
|
|
|
$.post("/customers/similarCustomers", $("#customerName").serialize(), function(data) {
|
|
|
|
|
$("#similarCustList").html(data);
|
|
|
|
|
});
|
2010-03-15 20:20:38 -07:00
|
|
|
|
2010-03-15 20:51:08 -07:00
|
|
|
|
|
|
|
|
$("#dialog").dialog({
|
|
|
|
|
position: 'right',
|
|
|
|
|
width: 400
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
2011-06-29 00:25:33 -07:00
|
|
|
}
|
2010-03-15 20:51:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#CustomerCountryName").autocomplete({
|
|
|
|
|
source: "/countries/completeCountry",
|
|
|
|
|
minLength: 3,
|
|
|
|
|
select: function(event, ui) {
|
|
|
|
|
$("#CustomerCountryId").val(ui.item.id);
|
|
|
|
|
|
|
|
|
|
if(ui.item.value == 'Australia') {
|
|
|
|
|
$("#ABN").show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$("#ABN").hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2010-02-18 21:38:43 -08:00
|
|
|
});
|