205 lines
7.8 KiB
JavaScript
205 lines
7.8 KiB
JavaScript
$(document).ready(function() {
|
||
$(".rowShowHide").hide();
|
||
$(".tablesShowHide").hide();
|
||
// Listener odpowiadaj<61>cy za akcje po klikni<6E>ciu na przycisk "Exportuj do programu Excel"
|
||
$("#excelEksport").click(excelExport);
|
||
|
||
$(".showTables").bind("click", function() {
|
||
if ($(this).attr("class") == "plusStyle showTables") {
|
||
//pobieramy nast<73>pny wiersz tabeli kt<6B>r<EFBFBD> chcemy pokazac po czym go wyswietlamy
|
||
var nextTBody = $(this).parent().parent().parent().next();
|
||
while ($(nextTBody).attr("id") != "stopTables") {
|
||
//sprawdzamy czy kategoria
|
||
if ($(nextTBody).attr("class") == "tablesorter-infoOnly tablesShowHide") {
|
||
$(nextTBody).show();
|
||
}
|
||
nextTBody = $(nextTBody).next();
|
||
}
|
||
$(this).html("[-]");
|
||
$(this).attr("class", "plusStyle hideTables");
|
||
} else if ($(this).attr("class") == "plusStyle hideTables") {
|
||
//pobieramy nast<73>pny wiersz tabeli kt<6B>r<EFBFBD> chcemy schowac po czym go chowamy
|
||
var nextTBody = $(this).parent().parent().parent().next();
|
||
while ($(nextTBody).attr("id") != "stopTables") {
|
||
//tu chowamy wszystko wi<77>c nie sprawdzamy kategori
|
||
$(nextTBody).hide();
|
||
var changePlusMinus = $(nextTBody).children().children();
|
||
if ($(changePlusMinus[0]).children("a").attr("class") == "hideRows") {
|
||
$(changePlusMinus[0]).children("a").attr("class", "showRows");
|
||
$(changePlusMinus[0]).children("a").html("[+]");
|
||
}
|
||
nextTBody = $(nextTBody).next();
|
||
}
|
||
$(this).html("[+]");
|
||
$(this).attr("class", "plusStyle showTables");
|
||
}
|
||
});
|
||
$(".showRows").bind("click", function() {
|
||
if ($(this).attr("class") == "showRows") {
|
||
//pobieramy nast<73>pny wiersz tabeli kt<6B>r<EFBFBD> chcemy pokazac po czym go wyswietlamy
|
||
var nextTBody = $(this).parent().parent().parent().next();
|
||
while ($(nextTBody).attr("id") != "stopRows") {
|
||
$(nextTBody).show();
|
||
nextTBody = $(nextTBody).next();
|
||
}
|
||
$(this).html("[-]");
|
||
$(this).attr("class", "hideRows");
|
||
} else if ($(this).attr("class") == "hideRows") {
|
||
//pobieramy nast<73>pny wiersz tabeli kt<6B>r<EFBFBD> chcemy schowac po czym go chowamy
|
||
var nextTBody = $(this).parent().parent().parent().next();
|
||
while ($(nextTBody).attr("id") != "stopRows") {
|
||
$(nextTBody).hide();
|
||
nextTBody = $(nextTBody).next();
|
||
}
|
||
$(this).html("[+]");
|
||
$(this).attr("class", "showRows");
|
||
}
|
||
});
|
||
|
||
//dodatkowe dane dla kontrahenta
|
||
$(".showProducts").click(function() {
|
||
if ($(this).attr("class") === "showProducts") {
|
||
var parent = $(this).parent();
|
||
var children = $(parent).children();
|
||
var contractor = $(children[1]).attr("contractor");
|
||
|
||
var category = $(this).attr("category");
|
||
var subcategory = $(this).attr("subcategory");
|
||
var date_from = $("#date_from").attr("value");
|
||
var date_to = $("#date_to").attr("value");
|
||
var type = $("#type option:selected").attr("value");
|
||
var user = $("#user option:selected").attr("value");
|
||
var Con = {
|
||
contractor: contractor,
|
||
date_from: date_from,
|
||
date_to: date_to,
|
||
type: type,
|
||
category: category,
|
||
subcategory: subcategory,
|
||
user: user
|
||
};
|
||
|
||
$(this).attr("class", "hideProducts");
|
||
var ajax_url = "index.php?module=EcmReports&action=ReportSalesByProducts&to_pdf=1";
|
||
$.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: "Prosz<73> czeka<6B>..."
|
||
});
|
||
$.ajax({
|
||
type: "POST",
|
||
url: ajax_url,
|
||
dataType: "text",
|
||
success: function(data) {
|
||
var parparent = $(parent).parent();
|
||
parparent.after("<tr class='productsTable'><td colspan='8'>" + data + "</td></tr>");
|
||
$.unblockUI();
|
||
},
|
||
data: Con
|
||
});
|
||
} else if ($(this).attr("class") === "hideProducts") {
|
||
var parent = $(this).parent().parent();
|
||
$(parent).next().remove(".productsTable");
|
||
$(this).attr("class", "showProducts");
|
||
}
|
||
});
|
||
|
||
$.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(',', '.').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'
|
||
});
|
||
|
||
//assign the sortStart event
|
||
$("#myTable thead").click(function() {
|
||
//alert($(this).attr("id"));
|
||
$(".productsTable").remove();
|
||
var minus = $(".hideProducts");
|
||
$.each(minus, function() {
|
||
$(this).html("[+]");
|
||
$(this).attr("class", "showProducts");
|
||
});
|
||
});
|
||
|
||
// call the tablesorter plugin
|
||
$("#myTable").tablesorter({
|
||
theme: 'blue',
|
||
});
|
||
});
|
||
|
||
|
||
function pdfExport() {
|
||
var url = $(location).attr('href');
|
||
url = url + "&toPDF=1&to_pdf=1";
|
||
window.open(url,"_blank");
|
||
|
||
}
|
||
function xlsExport() {
|
||
var url = $(location).attr('href');
|
||
url = url + "&toPDF=1&to_pdf=1&to_xls=1";
|
||
window.open(url,"_blank");
|
||
|
||
}
|
||
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<6B>czony niepowodzeniem!');
|
||
}
|
||
});
|
||
} |