diff --git a/application/Invoice/Invoice.php b/application/Invoice/Invoice.php index a1aa651ae..22efe830d 100644 --- a/application/Invoice/Invoice.php +++ b/application/Invoice/Invoice.php @@ -143,7 +143,7 @@ XINON GmbH"; if(!$subject || !$from || !$from_name || !$to) { - $this->log->warn("Invoice ".$this->invoice_number." could not be sent. Values missing. (subject: '$subject', from: '$from_name', from_email: '$from', to: '$to')"); + $this->log->warn(__METHOD__.": Invoice ".$this->invoice_number." could not be sent. Values missing. (subject: '$subject', from: '$from_name', from_email: '$from', to: '$to')"); return false; } else { $email = new Emailnotification(); diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php index e758919f5..e1c9e59cb 100644 --- a/application/Invoice/InvoiceController.php +++ b/application/Invoice/InvoiceController.php @@ -725,7 +725,12 @@ class InvoiceController extends mfBaseController { continue; } - $invoice->sendByEmail(); + if(!$invoice->sendByEmail()) { + echo "Error sending ".$invoice->invoice_number." to ".$invoice->email."\n"; + continue; + } + $invoice->date_delivered = date("U"); + $invoice->save(); if($invoice->total < 0) { // Gutschriften auch an Xinon @@ -734,6 +739,8 @@ class InvoiceController extends mfBaseController { } + + return true; } diff --git a/scripts/invoice/send-invoice-pdfs.php b/scripts/invoice/send-invoice-pdfs.php index ef81448a3..e58b1a28f 100644 --- a/scripts/invoice/send-invoice-pdfs.php +++ b/scripts/invoice/send-invoice-pdfs.php @@ -16,10 +16,5 @@ $me = new User(1); define("INTERNAL_USER_ID", $me->id); define("INTERNAL_USER_USERNAME", $me->username); -$invoice = InvoiceModel::getFirst(["invoice_number" => "RN2024-X026813"]); -var_dump($invoice); -$invoice->sendByEmail("jantscher@xinon.at"); -exit; - $ic = new InvoiceController(); $ic->_sendEmailInvoices(); \ No newline at end of file diff --git a/scripts/invoice/test-for-missing-pdfs.php b/scripts/invoice/test-for-missing-pdfs.php index 428e38c74..905665ec2 100644 --- a/scripts/invoice/test-for-missing-pdfs.php +++ b/scripts/invoice/test-for-missing-pdfs.php @@ -18,12 +18,12 @@ $me = new User(1); foreach(InvoiceModel::getAll() as $invoice) { $pdf = $invoice->pdf; - if(!$pdf || !$pdf->id || !$pdf->file_id) { + if(!$pdf || !$pdf->name) { echo $invoice->invoice_number." missing pdf file link\n"; continue; } - if(!file_exists($pdf->file->getFullPath())) { + if(!file_exists($pdf->getFullPath())) { echo $invoice->invoice_number." PDF (".$pdf->file->getFullPath().") file does not exist\n"; } }