135 lines
3.3 KiB
JavaScript
Executable File
135 lines
3.3 KiB
JavaScript
Executable File
//START:
|
|
$(document).ready(
|
|
function() {
|
|
var checkgen;
|
|
// confirm exit
|
|
window.onbeforeunload = confirmExit;
|
|
// prevent submit by enter press
|
|
lockEnter();
|
|
// categories
|
|
getCategoriesList();
|
|
// searchProductInput change
|
|
$('#searchProductsInput').keyup(function() {
|
|
searchProducts();
|
|
});
|
|
$('#parent_id').on('inputchange',
|
|
function() {
|
|
$(".loading_panel").css("display", "block");
|
|
setTimeout(function() {
|
|
getParentInfo($("#parent_id").val(), 'Accounts');
|
|
}, 1000);
|
|
});
|
|
$("#kind").change(function() {
|
|
if($("#kind").val()=='import'){
|
|
$("#import_table").show(); $("#import_title").show();
|
|
}else{
|
|
$("#import_table").hide(); $("#import_title").hide();
|
|
}
|
|
});
|
|
DrawHeaders();
|
|
|
|
//("#register_date").prop("disabled", true);
|
|
$("#assigned_user_name").prop("disabled", true);
|
|
//$("#register_date_trigger").hide();
|
|
$("#import_table").hide();
|
|
$("#import_title").hide();
|
|
$("#btn_assigned_user_name").hide();
|
|
$("#btn_clr_assigned_user_name").hide();
|
|
if($("#kind").val()=='import'){
|
|
$("#import_table").show(); $("#import_title").show();
|
|
}else{
|
|
$("#import_table").hide(); $("#import_title").hide();
|
|
}
|
|
|
|
$(".loading_panel").css("display", "none");
|
|
if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() != true)) {
|
|
checkgen=1;
|
|
|
|
} else if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() == true)) {
|
|
checkgen=1;
|
|
getItems();
|
|
} else {
|
|
checkgen=0;
|
|
getItems();
|
|
}
|
|
$("#stock").change(function() {
|
|
$("#stock_id").val(($("#stock :selected").val()));
|
|
if(checkgen==1){
|
|
generateNumber();
|
|
}
|
|
});
|
|
if($("#stock_id").val()!='') {
|
|
$("#stock_id").val(($("#stock :selected").val()));
|
|
if(checkgen==1){
|
|
generateNumber();
|
|
}
|
|
}
|
|
// make pz from other doc
|
|
if ($("#out_id").val()
|
|
&& $("#out_module").val()) {
|
|
getItems2();
|
|
}
|
|
// handle setItems
|
|
setITEMS = function() {
|
|
var formname = 'EditView';
|
|
if (check_form_(formname) == true) {
|
|
SetTab('ITEMS');
|
|
checkProducts();
|
|
calculateTotal();
|
|
//disable stock change
|
|
$("#stock").prop("disabled", true);
|
|
}
|
|
};
|
|
|
|
});
|
|
// handle save
|
|
var check_form_ = check_form;
|
|
check_form = function(formname) {
|
|
if (confirm('Czy potwierdzić Dokument PZ?')) {
|
|
$("#status").val("accepted");
|
|
} else {
|
|
$("#status").val("registered");
|
|
}
|
|
window.onbeforeunload = null;
|
|
if (items.length == 0) {
|
|
alert("Brak produktów");
|
|
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;
|
|
}
|
|
});
|
|
}
|