100 lines
2.5 KiB
JavaScript
100 lines
2.5 KiB
JavaScript
//START:
|
|
$(document).ready(
|
|
function() {
|
|
// confirm exit
|
|
window.onbeforeunload = confirmExit;
|
|
// prevent submit by enter press
|
|
lockEnter();
|
|
// categories
|
|
getCategoriesList();
|
|
// searchProductInput change
|
|
$('#searchProductsInput').keyup(function() {
|
|
searchProducts();
|
|
});
|
|
$("#stock").change(function() {
|
|
$("#stock_id").val(($("#stock :selected").val()));
|
|
});
|
|
DrawHeaders();
|
|
|
|
$("#register_date").prop("disabled", true);
|
|
$("#assigned_user_name").prop("disabled", true);
|
|
$("#register_date_trigger").hide();
|
|
$("#btn_assigned_user_name").hide();
|
|
$("#btn_clr_assigned_user_name").hide();
|
|
|
|
if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() != true)) {
|
|
generateNumber();
|
|
} else if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() == true)) {
|
|
generateNumber();
|
|
getItems();
|
|
}
|
|
// handle setItems
|
|
setITEMS = function() {
|
|
var formname = 'EditView';
|
|
if (check_form_(formname) == true) {
|
|
SetTab('ITEMS');
|
|
checkProducts();
|
|
//disable stock change
|
|
$("#stock").prop("disabled", true);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
});
|
|
// handle save
|
|
var check_form_ = check_form;
|
|
check_form = function(formname) {
|
|
|
|
window.onbeforeunload = null;
|
|
if (items.length == 0) {
|
|
alert("Brak produktów");
|
|
return false;
|
|
}
|
|
|
|
if ($('#type').val() == '2dcd99ce-c2fe-6bbd-6d1a-5512a569c4e0' || $('#type').val() == '1') {
|
|
$.each(items, function(i, v) {
|
|
if (!v.product_id || v.product_id=="") return;
|
|
if (!v.product_consignment_id || v.product_consignment_id=="") {
|
|
alert("Nie wybrano partii");
|
|
return false;
|
|
}
|
|
})
|
|
}
|
|
|
|
$(".loading_panel").css("display", "block");
|
|
$("#register_date").prop("disabled", false);
|
|
$("#assigned_user_name").prop("disabled", false);
|
|
|
|
$("#position_list").val(JSON.stringifyNoSecurity(items));
|
|
|
|
var check = checkProducts();
|
|
|
|
$(".loading_panel").css("display", "none");
|
|
if (check_form_(formname) == false || check == false) {
|
|
$("#register_date").prop("disabled", true);
|
|
$("#assigned_user_name").prop("disabled", true);
|
|
window.onbeforeunload = confirmExit;
|
|
$(".loading_panel").css("display", "none");
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
|
|
};
|
|
function confirmExit() {
|
|
return "";
|
|
}
|
|
|
|
function lockEnter() {
|
|
// prevent default
|
|
$(window).keydown(function(event) {
|
|
if (event.keyCode == 13 && $(":focus").prop('tagName')!='TEXTAREA') {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
}
|