155 lines
4.6 KiB
JavaScript
Executable File
155 lines
4.6 KiB
JavaScript
Executable File
//START:
|
|
$(document).ready(
|
|
|
|
function() {
|
|
//set sizes
|
|
$("#parent_name").attr("size", "70");
|
|
$("#parent_name_copy").attr("size", "70");
|
|
$("#contact_name").attr("size", "70");
|
|
setInterval(function () {
|
|
$("#EditView_parent_name_results").children().width('370');
|
|
$("#EditView_contact_name_results").children().width('370');
|
|
}, 50);
|
|
//change parent select button
|
|
$("#btn_clr_parent_name").children().attr("src","themes/default/images/id-ff-add.png" );
|
|
$("#btn_clr_parent_name").attr("title","Dodaj" );
|
|
$("#btn_clr_parent_name").click(createAccount);
|
|
//change contact select button
|
|
$("#btn_clr_contact_name").children().attr("src","themes/default/images/id-ff-add.png" );
|
|
$("#btn_clr_contact_name").attr("title","Dodaj" );
|
|
$("#btn_clr_contact_name").click(createContact);
|
|
//discount
|
|
console.log('halu');
|
|
$("#discount").css("width", "40");
|
|
$("#discount").val("0");
|
|
$("#discount").blur(function() {
|
|
console.log('halu');
|
|
if (UnformatNumber($('#discount').val()) > 100) $('#discount').val('100');
|
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
|
for (var index = 0; index != count; index++)
|
|
calculateRow(index);
|
|
$('#discount_tmp').val(UnformatNumber($('#discount').val()));
|
|
});
|
|
// confirm exit
|
|
window.onbeforeunload = confirmExit;
|
|
// prevent submit by enter press
|
|
lockEnter();
|
|
// parent info
|
|
var previousVal;
|
|
var pollInterval = setInterval(function() {
|
|
var val = $('#parent_id').val();
|
|
if (val !== previousVal) {
|
|
if ($('#parent_id').val() == '') return;
|
|
$(".loading_panel").css("display", "block");
|
|
setTimeout(function() {
|
|
getParentInfo($("#parent_id").val(), 'Accounts');
|
|
}, 1000);
|
|
}
|
|
previousVal = val;
|
|
}, 500);
|
|
//newProduct
|
|
var previousVal2;
|
|
var prodInterval = setInterval(function() {
|
|
var val = $('#newProductId').val();
|
|
if (val !== previousVal2) {
|
|
if ($('#newProductId').val() == '') return;
|
|
$(".loading_panel").css("display", "block");
|
|
setTimeout(function() {
|
|
AddProduct(items.length-1, val);
|
|
}, 500);
|
|
}
|
|
previousVal2 = val;
|
|
}, 500);
|
|
// categories
|
|
getCategoriesList();
|
|
// its vat free change
|
|
$("#no_tax").change(function() {
|
|
// calculate totals
|
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
|
|
// thead row
|
|
for (var index = 0; index != count; index++)
|
|
calculateRow(index);
|
|
});
|
|
|
|
DrawHeaders();
|
|
|
|
if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() != true)) {
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmQuotes');
|
|
$(".loading_panel").css("display", "none");
|
|
} else if (($("#new_number").val() == true)
|
|
&& ($("#duplicate").val() == true)) {
|
|
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmQuotes');
|
|
getParentInfo($("#parent_id").val(),
|
|
'Accounts');
|
|
getItems();
|
|
$(".loading_panel").css("display", "none");
|
|
} else {
|
|
getParentInfo($("#parent_id").val(),
|
|
'Accounts');
|
|
getItems();
|
|
}
|
|
|
|
// handle setItems
|
|
setITEMS = function() {
|
|
var formname = 'EditView';
|
|
if (check_form_(formname) == true) {
|
|
SetTab('ITEMS');
|
|
}
|
|
};
|
|
// wyszukiwanie start
|
|
$('#searchProductsInput').keyup(function() {
|
|
// stronicowanie od 1 strony przy zmianie szukanego produktu
|
|
$('#searchStart').val(0);
|
|
searchProducts();
|
|
});
|
|
AddSearchRecord();
|
|
});
|
|
|
|
// handle save
|
|
var check_form_ = check_form;
|
|
check_form = function(formname,event) {
|
|
// zapobiega zapisywaniu dokumentu firefox bug, w przypadku nacisniecia enter w polu z autocomplete
|
|
if(event.clientY==0 && event.clientX==0){
|
|
return false;
|
|
}
|
|
window.onbeforeunload = null;
|
|
if (items.length == 0 || items[0].product_id=='') {
|
|
alert("Brak produktów");
|
|
return false;
|
|
}
|
|
// usuwa rekord pomocniczy
|
|
clearEmpty();
|
|
$(".loading_panel").css("display", "block");
|
|
// calculate totals
|
|
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 - thead row
|
|
for (var index = 0; index != count; index++)
|
|
calculateRow(index);
|
|
|
|
$("#total_netto").val($("#t_netto").val());
|
|
$("#total_brutto").val($("#t_brutto").val());
|
|
$("#total_discount").val($("#disc").val());
|
|
$("#position_list").val(JSON.stringifyNoSecurity(items));
|
|
if (check_form_(formname) == false) {
|
|
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;
|
|
}
|
|
});
|
|
}
|