Files
crm.twinpol.com/modules/EcmReports/javascript/ReportSalesByContractor2.js

204 lines
7.9 KiB
JavaScript
Raw Normal View History

2025-05-12 15:45:17 +00:00
$(document).ready(function(){
$(".rowShowHide").hide();
$(".tablesShowHide").hide();
$(".categoryShowHide").hide();
// Listener odpowiadający za akcje po kliknięciu na przycisk "Exportuj do programu Excel"
$("#excelEksport").click( excelExport );
$("#pdfEksport").click( pdfExport );
function pdfExport() {
var url = $(location).attr('href');
url = url + "&toPDF=1&to_pdf=1";
window.location.href = url;
}
function excelExport() {
var url = $(location).attr('href').replace("ReportSalesByContractor", "ReportSalesByContractorToExcelFile");
var fileUrl = url.slice(0, url.indexOf("index")) + "modules/EcmReports/ExcelFiles/ReportSalesByContractor.xls";
url = url + "&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: "Trwa generowanie pliku..."
});
$.ajax({
url: url,
success: function(data){
$.unblockUI();
window.location.href = fileUrl
},
error: function(){
$.unblockUI();
alert('Eksport zakończony niepowodzeniem!');
}
});
}
$(".showTablesContractor").bind("click",function(){
if($(this).attr("class")=="plusStyle showTablesContractor")
{
//pobieramy następny wiersz tabeli którą chcemy pokazac po czym go wyswietlamy
var nextTBody = $(this).parent().parent().parent().next();
while($(nextTBody).attr("id")!="stopCategory")
{
//sprawdzamy czy kategoria
if($(nextTBody).attr("class")=="tablesorter-infoOnly categoryShowHide")
{
$(nextTBody).show();
}
nextTBody=$(nextTBody).next();
}
$(this).html("[-]");
$(this).attr("class","plusStyle hideTablesContractor");
}else if($(this).attr("class")=="plusStyle hideTablesContractor")
{
//pobieramy następny wiersz tabeli którą chcemy schowac po czym go chowamy
var nextTBody = $(this).parent().parent().parent().next();
while($(nextTBody).attr("id")!="stopCategory")
{
//tu chowamy wszystko wię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("[+]");
}else if($(changePlusMinus[0]).children("a").attr("class")=="plusStyle hideTables")
{
$(changePlusMinus[0]).children("a").attr("class","plusStyle showTables");
$(changePlusMinus[0]).children("a").html("[+]");
}
nextTBody=$(nextTBody).next();
}
$(this).html("[+]");
$(this).attr("class","plusStyle showTablesContractor");
}
});
$(".showTables").bind("click",function(){
if($(this).attr("class")=="plusStyle showTables")
{
//pobieramy następny wiersz tabeli którą 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ępny wiersz tabeli którą chcemy schowac po czym go chowamy
var nextTBody = $(this).parent().parent().parent().next();
while($(nextTBody).attr("id")!="stopTables")
{
//tu chowamy wszystko wię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ępny wiersz tabeli którą 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ępny wiersz tabeli którą 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");
}
});
$.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
$("table").tablesorter({
theme: 'blue',
// initialize zebra striping of the table
widgets: ['zebra','staticRow'],
// 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" ]
}
});
});