Add JS files

This commit is contained in:
2025-05-12 15:45:17 +00:00
parent 7ddd15c4fa
commit 967007b0c7
3239 changed files with 1157078 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
$(document).ready(function () {
$("#clearProduct").on('click', clearProduct);
$("#selectProduct").on('click', selectProduct);
$("#clearAccount").on('click', clearAccount);
$("#selectAccount").on('click', selectAccount);
$("#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 clearProduct() {
console.log('Czyszczenie wybranego produktu');
$('#productId').val('');
$('#productName').val('');
console.log('Gotowe!');
}
function selectProduct() {
open_popup('EcmProducts', 600, 400, '', true, false, {'call_back_function': 'set_return', 'form_name': 'AnalysisProductSale', 'field_to_name_array': {'id': 'productId', 'name': 'productName'}}, 'single', true);
}
function selectAccount() {
open_popup('Accounts', 600, 400, '', true, false, {'call_back_function': 'set_return', 'form_name': 'AnalysisProductSale', 'field_to_name_array': {'id': 'accountId', 'name': 'accountName'}}, 'single', true);
}
function clearAccount() {
console.log('Czyszczenie zaznaczonego kontrahenta');
$('#accountId').val('');
$('#accountName').val('');
}
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var a = new Array();
var table = document.getElementById("myTable");
for (var i = 0, row; row = table.rows[i]; i++) {
a[i] = new Array();
for (var j = 0, col; col = row.cells[j]; j++) {
a[i][j]=row.cells[j].textContent;
if(j>0 && i > 0){
a[i][j] = a[i][j].replace(".", "").replace(".", "");
a[i][j] = parseFloat(a[i][j].replace(",", "."));
}
}
}
// Calculate the width and height of the Array
var w = a.length ? a.length : 0,
h = a[0] instanceof Array ? a[0].length : 0;
// In case it is a zero matrix, no transpose routine needed.
if(h === 0 || w === 0) { t=[]; }
/**
* @var {Number} i Counter
* @var {Number} j Counter
* @var {Array} t Transposed data is stored in this array.
*/
var i, j, t = [];
// Loop through every item in the outer array (height)
for(i=0; i<h-1; i++) {
// Insert a new row (array)
t[i] = [];
// Loop through every item per item in outer array (width)
for(j=0; j<w; j++) {
// Save transposed data.
t[i][j] = a[j][i];
}
}
if(t.length==1){
return;
}
var data = google.visualization.arrayToDataTable(t);
formatter = new google.visualization.NumberFormat({
suffix: ' zł',
fractionDigits: '2',
decimalSymbol: ',',
groupingSymbol: '.',
});
for (i = 1; i < data.getNumberOfColumns(); i++) {
formatter.format(data, i);
}
var options = {
title: 'Wykres porównawczy',
isStacked: true,
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}

View File

@@ -0,0 +1,102 @@
$(document).ready(function () {
$("#clearProduct").on('click', clearProduct);
$("#selectProduct").on('click', selectProduct);
$("#clearAccount").on('click', clearAccount);
$("#selectAccount").on('click', selectAccount);
$("#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 clearProduct() {
console.log('Czyszczenie wybranego produktu');
$('#productId').val('');
$('#productName').val('');
console.log('Gotowe!');
}
function selectProduct() {
open_popup('EcmProducts', 600, 400, '', true, false, {'call_back_function': 'set_return', 'form_name': 'AnalysisProductSale', 'field_to_name_array': {'id': 'productId', 'name': 'productName'}}, 'single', true);
}
function selectAccount() {
open_popup('Accounts', 600, 400, '', true, false, {'call_back_function': 'set_return', 'form_name': 'AnalysisProductSale', 'field_to_name_array': {'id': 'accountId', 'name': 'accountName'}}, 'single', true);
}
function clearAccount() {
console.log('Czyszczenie zaznaczonego kontrahenta');
$('#accountId').val('');
$('#accountName').val('');
}
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var a = new Array();
var html = "";
var table = document.getElementById("myTable");
for (var i = 0, row; row = table.rows[i]; i++) {
a[i] = new Array();
for (var j = 0, col; col = row.cells[j]; j++) {
a[i][j]=row.cells[j].textContent;
if(j>0 && i > 0){
a[i][j] = a[i][j].replace(".", "").replace(".", "");
a[i][j] = parseFloat(a[i][j].replace(",", "."));
}
}
}
// Calculate the width and height of the Array
var w = a.length ? a.length : 0,
h = a[0] instanceof Array ? a[0].length : 0;
// In case it is a zero matrix, no transpose routine needed.
if(h === 0 || w === 0) { t=[]; }
/**
* @var {Number} i Counter
* @var {Number} j Counter
* @var {Array} t Transposed data is stored in this array.
*/
var i, j, t = [];
// Loop through every item in the outer array (height)
for(i=0; i<h-1; i++) {
// Insert a new row (array)
t[i] = [];
// Loop through every item per item in outer array (width)
for(j=0; j<w-1; j++) {
// Save transposed data.
t[i][j] = a[j][i];
}
}
var data = google.visualization.arrayToDataTable(t);
formatter = new google.visualization.NumberFormat({
suffix: ' zł',
fractionDigits: '2',
decimalSymbol: ',',
groupingSymbol: '.',
});
for (i = 1; i < data.getNumberOfColumns(); i++) {
formatter.format(data, i);
}
var options = {
title: 'Wykres porównawczy',
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}

View File

@@ -0,0 +1,73 @@
$(document).ready(
function() {
}
);
function SearchProduct(index) {
/*
* var searchKey = $('#name_'+index).val(); if (searchKey.length < 6 &&
* searchKey != '%') { $('#search_auto_id_'+index).hide(); } else {
*
*
* setTimeout(function() { if (searchKey == $('#name_'+index).val()) { var
* params = { job : 'searchProductsAutocomplite', searchKey : searchKey,
* searchStock : $("#productSearchStock :selected").val(), searchStockId :
* $("#stock_id").val(), index: index, };
*
* $.ajax({ type : "POST", url : ajaxsearch_url, dataType : "json", async :
* false, success : function(data) { if (data != '-1'){
* $('#search_auto_id_'+index).html(''); var content=''; $.each(data,
* function( index, value ) {
*
* content+='<li value="'+value.id+'">'+value.name+'</li>'; });
* $('#search_auto_id_'+index).append(content);
* $('#search_auto_id_'+index).show(); } }, data : params }); } }, 1000); }
*/
// prevent html escape
$["ui"]["autocomplete"].prototype["_renderItem"] = function (ul, item) {
return $("<li></li>").data("item.autocomplete", item).append(
$("<a></a>").html(item.label)).appendTo(ul);
};
// prevent html escape end
if ($("#product_id").val() == '') {
$("#product_name" )
.autocomplete(
{
source: function (request, response) {
$
.ajax({
type: "POST",
url: "index.php?module=EcmProducts&action=javahelper&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "searchProductsAutocomplite",
term: request.term,
searchStock: '1',
searchStockId: $("#stock")
.val(),
index: index
},
success: function (data) {
response(data);
}
});
},
minLength: 6,
select: function (event, ui) {
var url = ui.item.id;
if (url != '') {
$('#product_id').val( ui.item.id);
$('#product_name').val( ui.item.value);
}
},
html: false,
open: function (event, ui) {
$(".ui-autocomplete").css("z-index", 1000);
}
});
}
}

View File

@@ -0,0 +1,43 @@
$(document).ready(function(){
$(".rowShowHide").hide();
$(".tablesShowHide").hide();
// Listener odpowiadający za akcje po kliknięciu na przycisk "Exportuj do programu Excel"
$(".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");
}
});
});

View File

@@ -0,0 +1,123 @@
$(document).ready(function(){
$("#clearTrader").on('click', clearTrader);
$("#selectTrader").on('click', selectTrader);
Calendar.setup ({
inputField : "date_from",
daFormat : "%d.%m.%Y",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
});
Calendar.setup ({
inputField : "date_to",
daFormat : "%d.%m.%Y",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
});
$.tablesorter.addParser({
// set a unique id
id: 'money',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
return s.replace('.','').replace(',','.');
},
// set type, either numeric or text
type: 'numeric'
});
$.tablesorter.addParser({
// set a unique id
id: 'INCOME_OVERHEAD',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
var position = s.indexOf("(");
var cutted_string = trim(s.substring(0,position));
cutted_string = cutted_string.replace('.','').replace(',','.');
return cutted_string;
},
// set type, either numeric or text
type: 'numeric'
});
$("#myTable").tablesorter({
theme: 'blue',
sortList: [[0,0], [3,0]],
headers: {
1: {
sorter:'money'
},
3: {
sorter:'money'
},
4: {
sorter:'money'
},
5: {
sorter:'INCOME_OVERHEAD'
},
}
});
});
function generateXLS(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByContractor&to_pdf=1&to_xls=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function generatePDF(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByContractor&to_pdf=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function clearTrader() {
console.log('Czyszczenie wybranego sprzedawcy');
$('#trader').val('');
console.log('Gotowe!');
}
function selectTrader() {
open_popup('Users', 600, 400, '', true, false, {'call_back_function': 'setTrader', 'form_name': 'ReportSalesByProduct', 'field_to_name_array': {'id': 'id'}}, 'single', true);
}
function setTrader(selectedTrader){
$("#trader").val(selectedTrader.name_to_value_array.id);
}

View File

@@ -0,0 +1,156 @@
$(document).ready(function(){
$("#clearTrader").on('click', clearTrader);
$("#selectTrader").on('click', selectTrader);
$("#clearAccount").on('click', clearAccount);
$("#selectAccount").on('click', selectAccount);
Calendar.setup ({
inputField : "date_from",
daFormat : "%d.%m.%Y",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
});
Calendar.setup ({
inputField : "date_to",
daFormat : "%d.%m.%Y",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
});
$.tablesorter.addParser({
// set a unique id
id: 'money',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
return s.replace('.','').replace(',','.');
},
// set type, either numeric or text
type: 'numeric'
});
$.tablesorter.addParser({
// set a unique id
id: 'date',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
s = trim(s);
s = s.replace(/\s/g, "");
var date_split = s.split(".");
var tmp = "" + date_split[2] +"" + date_split[1] +"" + date_split[0];
return tmp;
},
// set type, either numeric or text
type: 'numeric'
});
$.tablesorter.addParser({
// set a unique id
id: 'INCOME_OVERHEAD',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
var position = s.indexOf("(");
var cutted_string = trim(s.substring(0,position));
cutted_string = cutted_string.replace('.','').replace(',','.');
return cutted_string;
},
// set type, either numeric or text
type: 'numeric'
});
$("#myTable").tablesorter({
theme: 'blue',
sortList: [[1,0], [3,0]],
headers: {
1: {
sorter:'date'
},
3: {
sorter:'money'
},
4: {
sorter:'money'
},
5: {
sorter:'money'
},
6: {
sorter:'INCOME_OVERHEAD'
},
}
});
});
function generateXLS(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByDocument&to_pdf=1&to_xls=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function generatePDF(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByDocument&to_pdf=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function clearTrader() {
console.log('Czyszczenie wybranego sprzedawcy');
$('#trader').val('');
console.log('Gotowe!');
}
function selectTrader() {
open_popup('Users', 600, 400, '', true, false, {'call_back_function': 'setTrader', 'form_name': 'ReportSalesByProduct', 'field_to_name_array': {'id': 'id'}}, 'single', true);
}
function setTrader(selectedTrader){
$("#trader").val(selectedTrader.name_to_value_array.id);
}
function clearAccount() {
console.log('Czyszczenie wybranego sprzedawcy');
$('#account_id').val('');
$('#account_name').val('');
console.log('Gotowe!');
}
function selectAccount() {
open_popup('Accounts', 800, 500, '', true, false, {'call_back_function': 'set_return', 'form_name': 'ReportSalesByDocument', 'field_to_name_array': {"id":"account_id","name":"account_name"}}, 'single', true);
}

View File

@@ -0,0 +1,33 @@
function generateXLS(){
var data = {};
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByGroup&to_pdf=1&to_xls=1',
dataType: "html",
data: data,
async: false,
success: function(response){
console.log(response);
var new_window = window.open(response);
}
});
}
function generatePDF(){
var data = {};
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByGroup&to_pdf=1&to_pdf_gen=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
}
});
}

View File

@@ -0,0 +1,37 @@
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Profit'],
['2014', 1000, 400, 200],
['2015', 1170, 460, 250],
['2016', 660, 1120, 300],
['2017', 1030, 540, 350]
]);
var options = {
chart: {
title: 'Company Performance',
subtitle: 'Sales, Expenses, and Profit: 2014-2017',
},
bars: 'vertical',
vAxis: {format: 'decimal'},
height: 400,
colors: ['#1b9e77', '#d95f02', '#7570b3']
};
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
var btns = document.getElementById('btn-group');
btns.onclick = function (e) {
if (e.target.tagName === 'BUTTON') {
options.vAxis.format = e.target.id === 'none' ? '' : e.target.id;
chart.draw(data, google.charts.Bar.convertOptions(options));
}
}
}

View File

@@ -0,0 +1,136 @@
$(document).ready(function(){
$("#clearTrader").on('click', clearTrader);
$("#selectTrader").on('click', selectTrader);
$("#clearAccount").on('click', clearAccount);
$("#selectAccount").on('click', selectAccount);
Calendar.setup ({
inputField : "date_from",
daFormat : "%d.%m.%Y",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
});
Calendar.setup ({
inputField : "date_to",
daFormat : "%d.%m.%Y",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
});
$.tablesorter.addParser({
// set a unique id
id: 'money',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
return s.replace('.','').replace(',','.');
},
// set type, either numeric or text
type: 'numeric'
});
$.tablesorter.addParser({
// set a unique id
id: 'INCOME_OVERHEAD',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
var position = s.indexOf("(");
var cutted_string = trim(s.substring(0,position));
cutted_string = cutted_string.replace('.','').replace(',','.');
return cutted_string;
},
// set type, either numeric or text
type: 'numeric'
});
$("#myTable").tablesorter({
theme: 'blue',
sortList: [[0,0], [3,0]],
headers: {
1: {
sorter:'money'
},
3: {
sorter:'money'
},
4: {
sorter:'money'
},
5: {
sorter:'INCOME_OVERHEAD'
},
}
});
});
function generateXLS(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByProduct&to_pdf=1&to_xls=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function generatePDF(){
var data = {}
$.each($("#SearchTable").find('input, select'), function (key,input){
data[$(input).prop('name')] = $(input).val();
});
$.ajax({
type: "POST",
url: 'index.php?module=EcmReports&action=ReportSalesByProduct&to_pdf=1',
dataType: "html",
data: data,
async: false,
success: function(response){
var new_window = window.open(response);
},
// dataType: 'html',
});
}
function clearTrader() {
console.log('Czyszczenie wybranego sprzedawcy');
$('#trader').val('');
console.log('Gotowe!');
}
function selectTrader() {
open_popup('Users', 600, 400, '', true, false, {'call_back_function': 'setTrader', 'form_name': 'ReportSalesByProduct', 'field_to_name_array': {'id': 'id'}}, 'single', true);
}
function setTrader(selectedTrader){
$("#trader").val(selectedTrader.name_to_value_array.id);
}
function clearAccount() {
console.log('Czyszczenie wybranego sprzedawcy');
$('#account_id').val('');
$('#account_name').val('');
console.log('Gotowe!');
}
function selectAccount() {
open_popup('Accounts', 800, 500, '', true, false, {'call_back_function': 'set_return', 'form_name': 'ReportSalesByProduct', 'field_to_name_array': {"id":"account_id","name":"account_name"}}, 'single', true);
}

View File

@@ -0,0 +1,136 @@
$(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 xlsExport() {
var url = $(location).attr('href');
url = url + "&toPDF=1&to_pdf=1&to_xls=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();
$('.kategoriawz').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;
}
}

View File

@@ -0,0 +1,205 @@
$(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!');
}
});
}