diff --git a/Layout/default/Emailtemplates/invoice/invoice-email.php b/Layout/default/Emailtemplates/invoice/invoice-email.php index 2ec024cd5..f01634305 100644 --- a/Layout/default/Emailtemplates/invoice/invoice-email.php +++ b/Layout/default/Emailtemplates/invoice/invoice-email.php @@ -3,7 +3,7 @@ * @var Invoice $invoice */ $this->setReturnValue([ - 'subject' => "Ihre Rechnung ".$invoice->invoice_number, + 'subject' => "Ihre ".(($invoice->total < 0) ? "Gutschrift" : "Rechnung" )." ".$invoice->invoice_number, 'from_email' => "billing@xinon.at", 'from_email_name' => "XINON GmbH - Verrechnung" ]); @@ -11,7 +11,7 @@ $this->setReturnValue([ Sehr geehrte Damen und Herren, -Im Anhang erhalten Sie Ihre aktuelle Rechnung. +Im Anhang erhalten Sie Ihre aktuelle total < 0) ? "Gutschrift" : "Rechnung"?>. Mit besten Grüßen, diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php index e1c9e59cb..2f0d83587 100644 --- a/application/Invoice/InvoiceController.php +++ b/application/Invoice/InvoiceController.php @@ -103,7 +103,8 @@ class InvoiceController extends mfBaseController { $pdf = $ifile->file; } - $filename = $pdf->getFullPath(); + $pdf_path = $pdf->getFullPath(); + $filename = $pdf->filename; if(!file_exists($filename)) { $this->layout()->setFlash("PDF-Datei nicht gefunden"); @@ -113,10 +114,10 @@ class InvoiceController extends mfBaseController { header('Content-disposition: attachment; filename="'.$filename.'"'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Content-Type: ' . mime_content_type($filename)); - header("Content-Length: " . filesize($filename)); + header('Content-Type: ' . mime_content_type($pdf_path)); + header("Content-Length: " . filesize($pdf_path)); - readfile($filename); + readfile($pdf_path); exit; /*$vat = []; @@ -725,6 +726,11 @@ class InvoiceController extends mfBaseController { continue; } + if($invoice->total == 0) { + echo "Skipping ".$invoice->invoice_number." because total is zero\n"; + continue; + } + if(!$invoice->sendByEmail()) { echo "Error sending ".$invoice->invoice_number." to ".$invoice->email."\n"; continue; diff --git a/application/Invoice/InvoiceModel.php b/application/Invoice/InvoiceModel.php index ade544387..9542a70ae 100644 --- a/application/Invoice/InvoiceModel.php +++ b/application/Invoice/InvoiceModel.php @@ -315,6 +315,21 @@ class InvoiceModel { } } + if(array_key_exists("billing_type", $filter)) { + $billing_type = $db->escape($filter['billing_type']); + if($billing_type) { + $where .= " AND Invoice.billing_type LIKE '$billing_type'"; + } + } + + if(array_key_exists("billing_delivery", $filter)) { + $billing_delivery = $db->escape($filter['billing_delivery']); + if($billing_delivery) { + $where .= " AND Invoice.billing_delivery LIKE '$billing_delivery'"; + } + } + + if (array_key_exists("company", $filter)) { $company = FronkDB::singleton()->escape($filter["company"]); if ($company) {