var ajax_url = "index.php?module=EcmPaymentStates&action=javahelper&to_pdf=1";
var winien = [];
var ma = [];
var sum_ma = 0;
$(document).ready(function(){
$.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'
});
// 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" ]
}
});
$('#date_to').on('inputchange', function() {
setTimeout(function() {
if($("#show_after_d").val()=='checked'){
submit();
}
}, 1000);
});
});
$.event.special.inputchange = {
setup : function() {
var self = this, val;
$.data(this, 'timer', window.setInterval(function() {
val = self.value;
if ($.data(self, 'cache') != val) {
$.data(self, 'cache', val);
$(self).trigger('inputchange');
}
}, 20));
},
teardown : function() {
window.clearInterval($.data(this, 'timer'));
},
add : function() {
$.data(this, 'cache', this.value);
}
};
function showNote(id){
window.open('index.php?module=EcmPaymentStates&action=createPDF&to_pdf=1&record2='+id+'&show=yes','_blank');
$('.hide_all').hide('slow');
}
function showDetails(id) {
$('.hide_all').hide('slow');
$("#details_"+id).show('slow');
var params = {
job : 'getDetails',
id : id,
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "text",
success : function(data) {
console.log(data);
if (data != '-1')
$("#details_div_"+id).html(data);
},
data : params
});
}
function hideDetails(id) {
$("#details_"+id).hide('slow');
}
function makeNote() {
var string='';
$("input[name='winien[]']:checked").each(function(){
if($(this).val()!=''){
console.log($(this).val());
string+=$(this).val()+',';
}
});
$("#id_list").val(string);
$("#submitNote").click();
}
function sendNote(id){
var params = {
job : 'sendNote',
ids : id,
parent_id: $('#account_id').val(),
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
async : false,
success : function(data) {
if(data==1)alert('Email został wysłany!');
},
data : params
});
}
function createMonit(typ){
var string='';
if($("input[name='winien[]']:checked").length>0){
$("input[name='winien[]']:checked").each(function(){
if($(this).val()!=''){
console.log($(this).val());
string+=$(this).val()+',';
}
});
if(typ==0){
var params = {
job : 'createMonit',
ids : string,
parent_id: $('#account_id').val(),
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
async : false,
success : function(data) {
if(data==1)alert('Email został wysłany!');
},
data : params
});
} else {
window.open('index.php?module=EcmPaymentStates&action=makeMonit&to_pdf=1&aa='+string+'&show=yes2','_blank');
}
} else {
alert('Wybierz transakcje!');
}
}
function showSettlePanel() {
$(".settle_panel").css("display", "block");
//prepare data
winien.length = 0;
ma.length = 0;
$("input[name='winien[]']:checked").each(function(){winien.push($(this).val());});
$("input[name='ma[]']:checked").each(function(){ma.push($(this).val());});
var table_winien = 'Strona Winien:
';
$.each(winien, function(index, value) {
var params = {
job : 'getTransaction',
id : value,
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
async : false,
success : function(data) {
if (data != '-1') {
var unsettled = (parseFloat(data.value)-parseFloat(data.settled));
table_winien+='
';
table_winien+='
'+data.name+'
';
table_winien+='
'+FormatNumber(unsettled)+'
';
table_winien+='
';
table_winien+=''
table_winien+='
';
table_winien+='
';
}
},
data : params
});
});
table_winien+='
';
var table_ma = '
';
$.each(ma, function(index, value) {
var params = {
job : 'getTransaction',
id : value,
};
$.ajax({
type : "POST",
url : ajax_url,
dataType : "json",
async : false,
success : function(data) {
if (data != '-1') {
var unsettled = (parseFloat(data.value)-parseFloat(data.settled));
table_ma+='