Merge branch 'fronkdev' into 'master'

PreorderBilling: now copying invoice PDFs to Fibu transfer dir

See merge request fronk/thetool!1233
This commit is contained in:
Frank Schubert
2025-04-17 13:30:37 +00:00
2 changed files with 37 additions and 0 deletions

View File

@@ -172,6 +172,9 @@ RML Infrastruktur GmbH";
$tpl = new Layout();
$tpl->setTemplate("Emailtemplates/preorder-invoice/rml/invoice-email");
if($this->owner_id) {
$tpl->setTemplate("Emailtemplates/preorder-invoice/rml/invoice-email-anb");
}
$pdf_vars = [
"invoice" => $this

View File

@@ -874,6 +874,7 @@ class PreorderBillingInvoiceController extends mfBaseController {
$csv .= "$csv_line\n";
}
/*echo $csv;
@@ -902,6 +903,39 @@ class PreorderBillingInvoiceController extends mfBaseController {
]);
$file->save();
// save invoice PDFs to bmd export transfer path
foreach($invoices as $invoice) {
$pdf = $invoice->pdf;
if(!$pdf || !$pdf->name || !file_exists($pdf->getFullPath())) {
$ifile = PreorderBillingInvoiceFile::createFromInvoice($invoice);
if(!$ifile) {
$this->layout()->setFlash("Fehler beim PDF erstellen");
$this->redirect("PreorderBillingInvoice");
}
$pdf = $ifile->file;
}
$pdf_file = false;
try {
$pdf_file = $pdf->getFullPath();
} catch (Exception $e) {
$this->log->error(__METHOD__.": File for Invoice ".$invoice->id." not found");
continue;
}
if(!file_exists($pdf_file)) {
$this->log->error(__METHOD__.": Datei ".$pdf->filename." nicht gefunden");
continue;
}
// copy pdf file to bmd export transfer directory
$transfer_path = $netowner_config["bmd-export-transfer-path"];
$transfer_file = "$transfer_path/".$invoice->invoice_number.".pdf";
if(!copy($pdf_file, $transfer_file)) {
$this->log->error(__METHOD__.": Error copying ".$pdf_file." to ".$transfer_file);
}
}
// copy csv file to bmd export transfer directory
$transfer_path = $netowner_config["bmd-export-transfer-path"];
$transfer_file = "$transfer_path/$filename";