$(document).ready(function(){ // invoice page, run.inc.php $(".run-invoicing").click(function(){ // disable the button. $(this).attr('disabled','disabled'); $("#invprogressbar").progressbar({ display_text: 2, use_percentage: true }); $.ajax({ url : "/system/invoices/run.php", type: "POST", data: 'billmonth='+$(this).attr('href'), complete:function(){ $("#invprogressbar .bar").attr('data-percentage', 100); $("#invprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } }); t = setTimeout("updateStatus('"+$(this).attr('href')+"')", 1000); return false; }); $(".run-pdf").click(function(){ // disable the button. $(this).attr('disabled','disabled'); $("#pdfprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); $.ajax({ url : "/system/invoices/run_pdf.php", type: "POST", data: 'billmonth='+$(this).attr('href'), complete:function(){ $("#pdfprogressbar .bar").attr('data-percentage', 100); $("#pdfprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } }); t = setTimeout("updatePdfStatus('"+$(this).attr('href')+"')", 1000); return false; }); $(".run-email").click(function(){ // disable the button. $(this).attr('disabled','disabled'); $("#emailprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); $.ajax({ url : "/system/invoices/run_emails.php", type: "POST", data: 'billmonth='+$(this).attr('href'), complete:function(){ $("#emailprogressbar .bar").attr('data-percentage', 100); $("#emailprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } }); t = setTimeout("updateEmailStatus('"+$(this).attr('href')+"')", 1000); return false; }); }); function submit_edit_template(e){ $.post("/ajax/template/edit_template", $('#edit-template-form').serialize(), function(){ $("#editTemplate").modal('hide'); }); return false; } function updateStatus(billmonth){ $.ajax({ url: '/ajax/invoice/check_invoicing', type: "POST", data: 'billmonth='+billmonth, }).done(function(data){ //console.log(data); pbvalue = 0; var res = data.split(','); //console.log(res); if(data){ var total = res[0]; var current = res[1]; var pbvalue = Math.floor((current / total) * 100); console.log(pbvalue); if(pbvalue>0){ $("#invprogressbar .bar").attr('data-percentage', pbvalue); $("#invprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } } if(pbvalue < 100){ t = setTimeout("updateStatus('"+billmonth+"')", 1000); } //console.log(pbvalue); }); // end of ajax } function updatePdfStatus(billmonth){ $.ajax({ url: '/ajax/invoice/check_pdf', type: "POST", data: 'billmonth='+billmonth, }).done(function(data){ //console.log(data); pbvalue = 0; var res = data.split(','); //console.log(res); if(data){ var total = res[0]; var current = res[1]; var pbvalue = Math.floor((current / total) * 100); console.log(pbvalue); if(pbvalue>0){ $("#pdfprogressbar .bar").attr('data-percentage', pbvalue); $("#pdfprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } } if(pbvalue < 100){ t = setTimeout("updatePdfStatus('"+billmonth+"')", 1000); } //console.log(pbvalue); }); // end of ajax } function updateEmailStatus(billmonth){ $.ajax({ url: '/ajax/invoice/check_email', type: "POST", data: 'billmonth='+billmonth, }).done(function(data){ //console.log(data); pbvalue = 0; var res = data.split(','); //console.log(res); if(data){ var total = res[0]; var current = res[1]; var pbvalue = Math.floor((current / total) * 100); console.log(pbvalue); if(pbvalue>0){ $("#emailprogressbar .bar").attr('data-percentage', pbvalue); $("#emailprogressbar .bar").progressbar({ display_text: 2, use_percentage: true }); } } if(pbvalue < 100){ t = setTimeout("updateEmailStatus('"+billmonth+"')", 1000); } //console.log(pbvalue); }); // end of ajax }