Fixes for Invoice Email

This commit is contained in:
Frank Schubert
2024-07-10 16:19:57 +02:00
parent 178e71b280
commit 369bfa09b1
3 changed files with 27 additions and 6 deletions

View File

@@ -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 <?=($invoice->total < 0) ? "Gutschrift" : "Rechnung"?>.
Mit besten Grüßen,

View File

@@ -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;

View File

@@ -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) {