Files
2025-05-12 15:45:17 +00:00

131 lines
4.3 KiB
JavaScript
Executable File

$(document).ready(function () {
$("select[name='documentsSelected']").on('change', documentsSelectedChange);
$("#clear").on('click', clearAccount);
$("#selectAccount").on('click', selectAccount);
documentsSelectedChange($("[name='documentsSelected']").val());
$("#myTable").tablesorter({
theme: 'blue',
widgetOptions: {
zebra: ["normal-row", "alt-row"]
}
});
});
function pdfExport() {
var url = $(location).attr('href');
url = url + "&toPDF=1&to_pdf=1";
window.open(url);
}
function excelExport() {
var url = $(location).attr('href').replace("ReportStocks", "ReportStocksToExcelFile");
url = url + "&to_pdf=1";
var fileUrl = url.slice(0, url.indexOf("index")) + "modules/EcmReports/ExcelFiles/ReportStocks.xls";
$.blockUI({css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
'font-weight': 'bold',
'font-size': '16px',
color: '#fff',
},
message: "Trwa generowanie pliku..."
});
$.ajax({
url: url,
success: function (data) {
$.unblockUI();
window.location.href = fileUrl
},
error: function () {
$.unblockUI();
alert('Eksport zakończony niepowodzeniem!');
}
});
}
function selectAccount() {
open_popup('Accounts', 600, 400, '', true, false, {'call_back_function': 'set_return', 'form_name': 'ReportStockDocMoves', 'field_to_name_array': {'id': 'accountId', 'name': 'accountName'}}, 'single', true);
}
function clearAccount() {
console.log('Czyszczenie zaznaczonego kontrahenta');
$('#accountId').val('');
$('#accountName').val('');
}
function documentsSelectedChange(documentsSelected) {
//Sprawdzanie czy wywolano funkcje przez parametr, czy tez przez event onchange
if (typeof documentsSelected != 'string') {
documentsSelected = $(this).val();
clearAccount();
//usuwanie zaznaczonych opcji
$(".changebox option:selected").removeAttr("selected");
}
$("#stockSelectedspan").html('Magazyn');
$('.changebox').hide();
console.log('Przy switchu: ' + documentsSelected);
switch (documentsSelected) {
case 'EcmStockDocInsideOuts':
console.log('Zmieniono dokument na: EcmStockDocInsideOuts');
$("#myTable").show();
$("#info").hide();
$('.kartotekamaterialowa').show();
break;
case 'EcmStockDocInsideIns':
console.log('Zmieniono dokument na: EcmStockDocInsideIns');
$("#myTable").show();
$("#info").hide();
$('.kartotekamaterialowa').show();
break;
case 'EcmStockDocCorrects':
console.log('Zmieniono dokument na: EcmStockDocCorrects');
$("#myTable").show();
$("#info").hide();
$('.kartotekamaterialowa').show();
break;
case 'EcmStockDocMoves':
console.log('Zmieniono dokument na: EcmStockDocMoves');
$("#stockSelectedspan").html('Z magazynu:')
$("#myTable").show();
$("#info").hide();
$('.magazyndocelowy').show();
break;
case 'EcmStockDocIns':
console.log('Zmieniono dokument na: EcmStockDocIns');
$("#myTable").show();
$("#info").hide();
$('.kontrahent').show();
break;
case 'EcmStockDocOuts':
console.log('Zmieniono dokument na: EcmStockDocOuts');
$("#myTable").show();
$("#info").hide();
$('.kontrahent').show();
break;
case 'EcmInvoiceOuts':
console.log('Zmieniono dokument na: EcmInvoiceOuts');
$("#myTable").show();
$("#info").hide();
$('.kontrahent').show();
break;
case 'EcmReceipts':
console.log('Zmieniono dokument na: EcmReceipts');
$("#myTable").show();
$("#info").hide();
$('.kontrahent').show();
break;
default:
console.log('Zmieniono dokument na: default');
$("#myTable").hide();
$("#info").show();
break;
}
}