117 lines
3.4 KiB
JavaScript
Executable File
117 lines
3.4 KiB
JavaScript
Executable File
//START:
|
|
$(document).ready(
|
|
function() {
|
|
var checkgen;
|
|
// confirm exit
|
|
window.onbeforeunload = confirmExit;
|
|
// prevent submit by enter press
|
|
lockEnter();
|
|
// categories
|
|
getCategoriesList();
|
|
|
|
$("#stock_in").change(function() {
|
|
$("#stock_in_id").val(($("#stock_in :selected").val()));
|
|
});
|
|
$("#stock_out").change(function() {
|
|
$("#stock_out_id").val(($("#stock_out :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)) {
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocMoves');
|
|
} else if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() == true)) {
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocMoves');
|
|
getItems();
|
|
}
|
|
$("#stock_in").change(function() {
|
|
$("#stock_in_id").val(($("#stock_in :selected").val()));
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocMoves');
|
|
});
|
|
if($("#stock_in").val()!='') {
|
|
$("#stock_in_d").val(($("#stock_in :selected").val()));
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmStockDocMoves');
|
|
}
|
|
|
|
// handle setItems
|
|
setITEMS = function() {
|
|
var formname = 'EditView';
|
|
if (check_form_(formname) == true) {
|
|
SetTab('ITEMS');
|
|
checkProducts();
|
|
//disable stock change
|
|
$("#stock_in").prop("disabled", true);
|
|
$("#stock_out").prop("disabled", true);
|
|
}
|
|
};
|
|
// wyszukiwanie start
|
|
$('#searchProductsInput').keyup(function() {
|
|
// stronicowanie od 1 strony przy zmianie szukanego produktu
|
|
$('#searchStart').val(0);
|
|
searchProducts();
|
|
});
|
|
AddSearchRecord();
|
|
$(".loading_panel").css("display", "none");
|
|
});
|
|
// handle save
|
|
var check_form_ = check_form;
|
|
check_form = function(formname,event) {
|
|
window.onbeforeunload = null;
|
|
// zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete
|
|
if(event.clientY==0 && event.clientX==0){
|
|
return false;
|
|
}
|
|
if (items.length == 0 || items[0].product_id=='') {
|
|
alert("Brak produktów");
|
|
return false;
|
|
}
|
|
$(".loading_panel").css("display", "block");
|
|
$("#register_date").prop("disabled", false);
|
|
$("#assigned_user_name").prop("disabled", false);
|
|
|
|
var consigns = checkConsignmentsValues();
|
|
if (consigns != true) {
|
|
setITEMS('ITEMS');
|
|
alert('Brak wymaganych informacji o partiach produktu.');
|
|
$(".loading_panel").css("display", "none");
|
|
return false;
|
|
}
|
|
|
|
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 {
|
|
clearEmpty();
|
|
$("#position_list").val(JSON.stringifyNoSecurity(items));
|
|
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;
|
|
}
|
|
});
|
|
}
|