351 lines
11 KiB
JavaScript
351 lines
11 KiB
JavaScript
//var ajax_url = "index.php?module=EcmReports&action=summary_javahelper&to_pdf=1";
|
|
var isHide = true;
|
|
var vatIsHide = true;
|
|
var showAndHideButton;
|
|
$(document).ready(function(){
|
|
$.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..."
|
|
});
|
|
showAndHideButton = $( "#showGroupButton" );
|
|
showAndHideVatButton = $("#showVatButton");
|
|
hideGroups();
|
|
hideVats();
|
|
|
|
showAndHideButton.click(showOrHideGroups);
|
|
showAndHideVatButton.click(showOrHideVats);
|
|
|
|
|
|
|
|
$("#excelEksport").click( excelExport );
|
|
$("#pdfEksport").click( pdfExport );
|
|
|
|
$.tablesorter.addParser({
|
|
// use a unique id
|
|
id: 'saas',
|
|
is: function(s, table, cell) {
|
|
// s is the text from the cell
|
|
// table is the current table (as a DOM element; not jQuery object)
|
|
// cell is the current table cell (DOM element)
|
|
// return false if you don't want this parser to be auto detected
|
|
return false;
|
|
},
|
|
format: function(s, table, cell, cellIndex) {
|
|
// s is the text from the cell
|
|
// table is the current table (as a DOM element; not jQuery object)
|
|
// cell is the current table cell (DOM element)
|
|
// cellIndex is the current cell's column index
|
|
// format your data for normalization
|
|
// (i.e. do something to get and/or modify your data, then return it)
|
|
return s.replace('.', '').replace(',', '.');
|
|
},
|
|
// flag for filter widget (true = ALWAYS search parsed values; false = search cell text)
|
|
parsed: false,
|
|
// set the type to either numeric or text (text uses a natural sort function
|
|
// so it will work for everything, but numeric is faster for numbers
|
|
type: 'numeric'
|
|
});
|
|
|
|
// call the tablesorter plugin
|
|
$("table").tablesorter({
|
|
// extra css class applied to the table row containing the filters & the inputs within that row
|
|
filter_cssFilter : '',
|
|
|
|
// If there are child rows in the table (rows with class name from "cssChildRow" option)
|
|
// and this option is true and a match is found anywhere in the child row, then it will make that row
|
|
// visible; default is false
|
|
filter_childRows : false,
|
|
|
|
// if true, filters are collapsed initially, but can be revealed by hovering over the grey bar immediately
|
|
// below the header row. Additionally, tabbing through the document will open the filter row when an input gets focus
|
|
filter_hideFilters : false,
|
|
|
|
// Set this option to false to make the searches case sensitive
|
|
filter_ignoreCase : true,
|
|
|
|
// jQuery selector string of an element used to reset the filters
|
|
filter_reset : '.reset',
|
|
|
|
// Use the $.tablesorter.storage utility to save the most recent filters
|
|
filter_saveFilters : true,
|
|
|
|
// Delay in milliseconds before the filter widget starts searching; This option prevents searching for
|
|
// every character while typing and should make searching large tables faster.
|
|
filter_searchDelay : 300,
|
|
|
|
// Set this option to true to use the filter to find text from the start of the column
|
|
// So typing in "a" will find "albert" but not "frank", both have a's; default is false
|
|
filter_startsWith : false,
|
|
|
|
// if false, filters are collapsed initially, but can be revealed by hovering over the grey bar immediately
|
|
// below the header row. Additionally, tabbing through the document will open the filter row when an input gets focus
|
|
filter_hideFilters : false,
|
|
|
|
theme: 'blue',
|
|
widthFixed : false,
|
|
// initialize zebra striping of the table
|
|
widgets: ['zebra','stickyHeaders', 'filter'],
|
|
// change the default striping class names
|
|
// updated in v2.1 to use widgetOptions.zebra = ["even", "odd"]
|
|
// widgetZebra: { css: [ "normal-row", "alt-row" ] } still works
|
|
widgetOptions : {
|
|
zebra : [ "normal-row", "alt-row" ]
|
|
}
|
|
});
|
|
|
|
function KeyPress(e) {
|
|
var evtobj = window.event? event : e
|
|
if (evtobj.keyCode == 68 && evtobj.ctrlKey && evtobj.altKey)
|
|
{
|
|
$.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: "Sprawdzam wartości..."
|
|
});
|
|
|
|
setTimeout( function() {
|
|
check();
|
|
}, 1000 );
|
|
|
|
}
|
|
}
|
|
|
|
document.onkeydown = KeyPress;
|
|
|
|
});
|
|
|
|
// Sprawdza poprawność wyników
|
|
function check() {
|
|
|
|
var sum = $('#myTable > tbody > tr').children(".gs");
|
|
var summ = 0;
|
|
var gs1 = 0;
|
|
var gs2 = 0;
|
|
var gs3 = 0;
|
|
|
|
for( var i = 0; i < sum.length; i++ ) {
|
|
|
|
summ = parseFloat( $(sum[i]).html().replace('.','').replace(',','.') );
|
|
gs1 = parseFloat( $(sum[i]).next().html().replace('.','').replace(',','.') );
|
|
gs2 = parseFloat( $(sum[i]).next().next().html().replace('.','').replace(',','.') );
|
|
gs3 = parseFloat( $(sum[i]).next().next().next().html().replace('.','').replace(',','.') );
|
|
gs4 = parseFloat( $(sum[i]).next().next().next().next().html().replace('.','').replace(',','.') );
|
|
|
|
|
|
if( Math.round(summ) == Math.round((gs1+gs2+gs3+gs4)))
|
|
{
|
|
$(sum[i]).css("background-color", "#CDE28B")
|
|
}
|
|
else
|
|
{
|
|
$(sum[i]).css("background-color", "#FF5C3E")
|
|
}
|
|
|
|
}
|
|
|
|
// Sprawdzanie kosztów
|
|
sum = $('#myTable > tbody > tr').children(".gc");
|
|
|
|
for( var i = 0; i < sum.length; i++ ) {
|
|
|
|
summ = parseFloat( $(sum[i]).html().replace('.','').replace(',','.') );
|
|
gs1 = parseFloat( $(sum[i]).next().html().replace('.','').replace(',','.') );
|
|
gs2 = parseFloat( $(sum[i]).next().next().html().replace('.','').replace(',','.') );
|
|
gs3 = parseFloat( $(sum[i]).next().next().next().html().replace('.','').replace(',','.') );
|
|
gs4 = parseFloat( $(sum[i]).next().next().next().next().html().replace('.','').replace(',','.') );
|
|
|
|
|
|
if( Math.round(summ) == Math.round((gs1+gs2+gs3)))
|
|
{
|
|
$(sum[i]).css("background-color", "#CDE28B")
|
|
}
|
|
else
|
|
{
|
|
$(sum[i]).css("background-color", "#FF5C3E")
|
|
}
|
|
|
|
}
|
|
|
|
$.unblockUI();
|
|
|
|
};
|
|
|
|
function excelExport() {
|
|
var url = $(location).attr('href').replace("ListDailySales", "ListDailySalesToExcelFile");
|
|
url = url + "&to_pdf=1";
|
|
console.log(url);
|
|
|
|
var fileUrl = url.slice(0, url.indexOf("index")) + "modules/EcmReports/ExcelFiles/DailySales.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 pdfExport() {
|
|
var url = $(location).attr('href');
|
|
url = url + "&toPDF=1&to_pdf=1";
|
|
|
|
window.location.href = url;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
function showOrHideGroups() {
|
|
if( isHide == true ) {
|
|
showGroups();
|
|
isHide = false;
|
|
} else {
|
|
hideGroups();
|
|
isHide = true;
|
|
}
|
|
}
|
|
|
|
function showGroups() {
|
|
$(".columnSpectrum").show();
|
|
$(".nettoValue").addClass("groupActive");
|
|
$(".nettoValueG").addClass("groupActiveG");
|
|
$(".nettoValueGL").addClass("groupActiveGL");
|
|
|
|
$("#showGroupButton").attr("value", "Ukryj podział na grupy produktowe");
|
|
|
|
var filter_row = $("#myTable thead");
|
|
var child = $(filter_row).children("tr");
|
|
$(filters).find("[data-column='6']").parent().css("border", "1px solid red");
|
|
|
|
var filters = $(child).next();
|
|
$(filters).find("[data-column='6']").parent().show();
|
|
$(filters).find("[data-column='7']").parent().show();
|
|
$(filters).find("[data-column='8']").parent().show();
|
|
$(filters).find("[data-column='12']").parent().show();
|
|
$(filters).find("[data-column='15']").parent().show();
|
|
$(filters).find("[data-column='16']").parent().show();
|
|
$(filters).find("[data-column='17']").parent().show();
|
|
$(filters).find("[data-column='18']").parent().show();
|
|
}
|
|
|
|
function hideGroups() {
|
|
$(".columnSpectrum").hide();
|
|
$(".nettoValue").removeClass("groupActive");
|
|
$(".nettoValue").removeClass("groupActive");
|
|
$(".nettoValueG").removeClass("groupActiveG");
|
|
$(".nettoValueGL").removeClass("groupActiveGL");
|
|
$("#showGroupButton").attr("value", "Pokaż podział na grupy produktowe")
|
|
|
|
if( vatIsHide == false )
|
|
$(".nettoValueVat").addClass("groupActive");
|
|
|
|
var filter_row = $("#myTable thead");
|
|
var child = $(filter_row).children("tr");
|
|
|
|
setTimeout(function(){
|
|
var filters = $(child).next();
|
|
$(filters).find("[data-column='6']").parent().hide();
|
|
$(filters).find("[data-column='7']").parent().hide();
|
|
$(filters).find("[data-column='8']").parent().hide();
|
|
$(filters).find("[data-column='12']").parent().hide();
|
|
$(filters).find("[data-column='15']").parent().hide();
|
|
$(filters).find("[data-column='16']").parent().hide();
|
|
$(filters).find("[data-column='17']").parent().hide();
|
|
$(filters).find("[data-column='18']").parent().hide();
|
|
}, 700);
|
|
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
function showOrHideVats() {
|
|
if( vatIsHide == true ) {
|
|
showVats();
|
|
vatIsHide = false;
|
|
} else {
|
|
hideVats();
|
|
vatIsHide = true;
|
|
}
|
|
}
|
|
|
|
function showVats() {
|
|
$(".columnVatSpectrum").show();
|
|
$(".nettoValueVat").addClass("groupActive");
|
|
$(".vataValue").addClass("groupActiveG");
|
|
$(".vatbValue").addClass("groupActiveG");
|
|
$(".vatcValue").addClass("groupActiveGL");
|
|
|
|
$("#showVatButton").attr("value", "Ukryj kolumny z VAT");
|
|
|
|
var filter_row = $("#myTable thead");
|
|
var child = $(filter_row).children("tr");
|
|
|
|
var filters = $(child).next();
|
|
$(filters).find("[data-column='9']").parent().show();
|
|
$(filters).find("[data-column='10']").parent().show();
|
|
$(filters).find("[data-column='11']").parent().show();
|
|
|
|
}
|
|
|
|
function hideVats() {
|
|
$(".columnVatSpectrum").hide();
|
|
$(".vataValue").removeClass("groupActive");
|
|
$(".vatbValue").removeClass("groupActiveG");
|
|
$(".vatcValue").removeClass("groupActiveGL");
|
|
$("#showVatButton").attr("value", "Pokaż kolumny z VAT");
|
|
|
|
if(isHide != false)
|
|
$(".nettoValueVat").removeClass("groupActive");
|
|
|
|
var filter_row = $("#myTable thead");
|
|
var child = $(filter_row).children("tr");
|
|
|
|
setTimeout(function(){
|
|
var filters = $(child).next();
|
|
$(filters).find("[data-column='9']").parent().hide();
|
|
$(filters).find("[data-column='10']").parent().hide();
|
|
$(filters).find("[data-column='11']").parent().hide();
|
|
}, 700);
|
|
|
|
|
|
$.unblockUI();
|
|
|
|
}
|
|
//-----------------------------------------------------------------------------
|