small InvoiceJob update

This commit is contained in:
Frank Schubert
2024-08-29 15:29:47 +02:00
parent b713e803c9
commit c9552055dd
2 changed files with 28 additions and 7 deletions

View File

@@ -413,10 +413,25 @@ $pagination_entity_name = "Rechnungen";
let status = JSON.parse(job.result);
if(!status) return;
let status_text = "";
let count = 0;
if(job.task == "make-invoice-pdf") {
$("#job-" + job.id + " .status-text").text(status.created + " Rechungs-PDFs erstellt");
status_text = status.created + " Emails versendet";
count = status.created;
} else if(job.task == "send-invoice-email") {
$("#job-" + job.id + " .status-text").text(status.sent + " Emails versendet");
status_text = status.sent + " Emails versendet";
count = status.sent;
}
let old_count = 0;
let m = $("#job-" + job.id + " .status-text").text().match(/^(\d+)/);
if(m) {
old_count = m[1];
}
if(old_count != count) {
$("#job-" + job.id + " .status-text").fadeOut();
$("#job-" + job.id + " .status-text").promise().done(() => {$("#job-" + job.id + " .status-text").text(status_text).fadeIn()});
}
$("#job-" + job.id + " .status").text(job.status ? job.status : "neu");
@@ -442,7 +457,7 @@ $pagination_entity_name = "Rechnungen";
}
$(document).ready(() => {
<?php if(is_array($pdf_jobs) && is_array($email_jobs)): ?>
<?php if((is_array($pdf_jobs) && count($pdf_jobs)) || (is_array($email_jobs)) && count($email_jobs)): ?>
status_update = setTimeout(updateStatus, 1000);
<?php endif; ?>
});

View File

@@ -904,23 +904,29 @@ class InvoiceController extends mfBaseController {
try {
$pdf_file = $pdf->getFullPath();
} catch (Exception $e) {
$this->log->error("File for Invoice ".$invoice->id." not found");
$this->log->error(__METHOD__.": File for Invoice ".$invoice->id." not found");
continue;
}
if(!file_exists($pdf_file)) {
//echo "Datei ".$pdf->filename." nicht gefunden\n";
$this->log->error(__METHOD__.": Datei ".$pdf->filename." nicht gefunden");
continue;
}
if($invoice->total == 0) {
//echo "Skipping ".$invoice->invoice_number." because total is zero\n";
$this->log->info(__METHOD__.": Skipping ".$invoice->invoice_number." because total is zero");
$invoice->date_delivered = date("U");
$invoice->save();
continue;
}
if(!$invoice->sendByEmail()) {
$this->log->warning("Error sending ".$invoice->invoice_number." to ".$invoice->email);
$this->log->warning(__METHOD__.": Error sending ".$invoice->invoice_number." to ".$invoice->email);
$invoice->date_delivered = date("U");
$invoice->save();
continue;
}
$invoice->date_delivered = date("U");
$invoice->save();