diff --git a/Layout/default/Invoice/Index.php b/Layout/default/Invoice/Index.php index 38ef41fd5..5ca715292 100644 --- a/Layout/default/Invoice/Index.php +++ b/Layout/default/Invoice/Index.php @@ -66,28 +66,28 @@ $pagination_entity_name = "Rechnungen";
-
-
-

Rechnungsversand

-
"> -
-
- - -
-
- - -
+
+
+

Rechnungsversand

+ "> +
+
+ +
-
-
- -
+
+ +
- -
+
+
+
+ +
+
+
+
diff --git a/Layout/default/Invoice/PDF_MAIN.php b/Layout/default/Invoice/PDF_MAIN.php index 01a1c80bb..a0b01e4b3 100644 --- a/Layout/default/Invoice/PDF_MAIN.php +++ b/Layout/default/Invoice/PDF_MAIN.php @@ -213,7 +213,7 @@ $this->setReturnValue(['filename' => $invoice->invoice_number . ".pdf"]); call_count, 0, ",",".")?> duration)?> price_total, 4, ",",".")?> € - price_total_gross?> € + price_total_gross, 4, ",",".")?> € diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php index 2f0d83587..78164942d 100644 --- a/application/Invoice/InvoiceController.php +++ b/application/Invoice/InvoiceController.php @@ -670,7 +670,7 @@ class InvoiceController extends mfBaseController { public function createPDFs() { $invoice_path_base = MFUPLOAD_FILE_SAVE_PATH."/".TT_INVOICE_SAVE_SUBFOLDER; - foreach(InvoiceModel::getAll() as $invoice) { + foreach(InvoiceModel::search(["billing_delivery" => "paper"]) as $invoice) { if(InvoiceFileModel::getFirst(["invoice_id" => $invoice->id])) { continue; } @@ -751,7 +751,6 @@ class InvoiceController extends mfBaseController { } public function printInvoices() { - return false; $start = $this->request->delivery_start_date; $end = $this->request->delivery_end_date; @@ -774,28 +773,62 @@ class InvoiceController extends mfBaseController { $pdf_files = []; foreach(InvoiceModel::search(["billing_delivery" => "paper", "invoice_date>=" => $start_date->getTimestamp(), "invoice_date<=" => $end_date->getTimestamp()]) as $invoice) { - $filename = $invoice->createPdf(); - if(!$filename) { - $this->layout()->setFlash("Fehler beim PDF erstellen (".$invoice->invoice_number.")", "error"); - $this->redirect("Invoice"); + $pdf = $invoice->pdf; + + if(!$pdf || !$pdf->name) { + die("PDF für ".$invoice->invoice_number." noch nicht generiert\n"); } - $pdf_files[] = $filename; + $pdf_file = $pdf->getFullPath(); + if(!file_exists($pdf_file)) { + die("Datei ".$pdf->filename." nicht gefunden\n"); + } + + $pdf_files[] = $pdf_file; } + //var_dump($pdf_files);exit; if(!count($pdf_files)) { $this->layout()->setFlash("Fehler beim PDF erstellen: Keine PDFs zum zusammenführen", "error"); $this->redirect("Invoice"); } $output_path = MFUPLOAD_FILE_SAVE_PATH."/".TT_INVOICE_SAVE_SUBFOLDER; - $output_filename = "invoices-print-".date("Y-m-d-H-i-s").".pdf"; + $output_filename = "print-invoices-".date("Y-m-d_H-i-s").".pdf"; $output_filepath = "$output_path/$output_filename"; + //var_dump($pdf_files);exit; + $i = 0; + $first = true; + $tmp_file1 = "$output_filepath.tmp1"; + $tmp_file2 = "$output_filepath.tmp2"; + $tmp_file = ""; foreach($pdf_files as $file) { - $pdf_unite_cmd = PDFUNITE_BIN_PATH." '$file' '$output_filepath'"; + if($i % 2 == 1) { + $tmp_file = $tmp_file1; + $src_file = $tmp_file2; + } else { + $tmp_file = $tmp_file2; + $src_file = $tmp_file1; + } + + if($first) { + $pdf_unite_cmd = PDFUNITE_BIN_PATH." '$file' '$tmp_file'"; + $first = false; + } else { + $pdf_unite_cmd = PDFUNITE_BIN_PATH." '$src_file' '$file' '$tmp_file'"; + } + + + //echo "$pdf_unite_cmd\n
"; shell_exec($pdf_unite_cmd); + + $i++; } + //exit; + rename($tmp_file, $output_filepath); + + //exit; if(!file_exists($output_filepath)) { $this->layout()->setFlash("Fehler beim PDFs zusammenführen: Ausgabedatei nicht gefunden", "error");