From 2094fd66a22e7f53b69300775b30ec5e67cef86c Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 10 Jul 2024 19:10:51 +0200 Subject: [PATCH] Added Address Invoice view --- Layout/default/Address/View.php | 9 ++- Layout/default/Address/invoice.php | 95 +++++++++++++++++++++++ application/Address/AddressController.php | 23 ++++++ application/Invoice/InvoiceController.php | 28 +++++-- application/Invoice/InvoiceModel.php | 20 ++++- 5 files changed, 164 insertions(+), 11 deletions(-) create mode 100644 Layout/default/Address/invoice.php diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php index 4c5d12823..03016cfe0 100644 --- a/Layout/default/Address/View.php +++ b/Layout/default/Address/View.php @@ -22,8 +22,13 @@
diff --git a/Layout/default/Address/invoice.php b/Layout/default/Address/invoice.php new file mode 100644 index 000000000..ac7980afe --- /dev/null +++ b/Layout/default/Address/invoice.php @@ -0,0 +1,95 @@ + + + +
+
+
+
+ +
+

Personen & Firmen

+
+
+
+ + +
+
+ + + +
+
+ +
+
+

Rechnungen

+ +
getCompanyOrName()?>
+
street?>
+
zip?> city?>
+
country->name?>
+ + + + + + + + + + + + + + + + + + + + + + + +
TypRechnungsnummerRechnungsdatumBetrag NettoBetrag BruttoZahlungsartVersand
+
    + owner_id == $address->id):?> +
  • Vertragsinhaber
  • + + billingaddress_id == $address->id):?> +
  • Rechnungsempfänger
  • + +
+
$invoice->id])?>"> invoice_number?>invoice_date)?>">€ total, 2, ",", ".")?>">€ total_gross, 2, ",", ".")?>billing_type == "sepa") ? "Einzug" : "Einzahlung" ?>billing_delivery == "email") ? "Email (".$invoice->email.")" : "Postversand" ?>
+ + + +
+
+ +
+ +
+ + + + + +
+
+ + \ No newline at end of file diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php index 1d9e26bd9..7a25bec41 100644 --- a/application/Address/AddressController.php +++ b/application/Address/AddressController.php @@ -140,6 +140,29 @@ class AddressController extends mfBaseController { $this->redirect("Address"); } + } + + protected function invoiceAction() { + $this->layout()->setTemplate("Address/invoice"); + + $address_id = $this->request->address_id; + if(!is_numeric($address_id) || $address_id < 1) { + $this->layout()->setFlash("Addresse nicht gefunden", "error"); + $this->redirect("Address"); + } + + $address = new Address($address_id); + if(!$address->id) { + $this->layout()->setFlash("Addresse nicht gefunden", "error"); + $this->redirect("Address"); + } + + $invoices = InvoiceModel::search(["owner_or_billingaddress_id" => $address->id], false, "invoice_date DESC"); + $this->layout()->set("invoices", $invoices); + $this->layout()->set("address", $address); + + + } protected function editAction() { diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php index 3cd43e629..032439849 100644 --- a/application/Invoice/InvoiceController.php +++ b/application/Invoice/InvoiceController.php @@ -15,6 +15,9 @@ class InvoiceController extends mfBaseController { } protected function indexAction() { + if(!$this->me->is("Billing")) { + $this->redirect("Dashboard"); + } $this->layout()->setTemplate("Invoice/Index"); if ($this->request->resetFilter) { @@ -99,6 +102,7 @@ class InvoiceController extends mfBaseController { $ifile = InvoiceFileModel::createFromInvoice($invoice); if(!$ifile) { $this->layout()->setFlash("Fehler beim PDF erstellen"); + $this->redirect("Invoice"); } $pdf = $ifile->file; } @@ -106,8 +110,9 @@ class InvoiceController extends mfBaseController { $pdf_path = $pdf->getFullPath(); $filename = $pdf->filename; - if(!file_exists($filename)) { + if(!file_exists($pdf_path)) { $this->layout()->setFlash("PDF-Datei nicht gefunden"); + $this->redirect("Invoice"); } header('Content-Type: application/octet-stream'); @@ -177,6 +182,10 @@ class InvoiceController extends mfBaseController { protected function runInvoicingAction() { + if(!$this->me->is("Billing")) { + $this->redirect("Dashboard"); + } + $i = 0; $p = 0; @@ -564,6 +573,9 @@ class InvoiceController extends mfBaseController { } protected function exportBmdAction() { + if(!$this->me->is("Billing")) { + $this->redirect("Dashboard"); + } /* * satzart;konto;gkonto;belegnr;belegdatum;buchsymbol;buchcode;prozent;steuercode;betrag;steuer;text;kost;bank-iban-nr;bank-swiftcode;bank-mandatsid;bank-mandatsdatum;bank-mandatskz;bank-letztereinzug;zvsperre;bankeinzug * 0;234941;40010;TEST-1;23.01.2024;AR;1;20;1;1,2;-0,2;RNTEST-01;;AT293828200003027919;RZSTAT2G282;KJ2813;13.01.2023;0;;0;1 @@ -695,6 +707,10 @@ class InvoiceController extends mfBaseController { } protected function sendInvoicesAction() { + if(!$this->me->is("Billing")) { + $this->redirect("Dashboard"); + } + $r = $this->request; $type = $r->type; @@ -751,6 +767,10 @@ class InvoiceController extends mfBaseController { } public function printInvoices() { + if(!$this->me->is("Billing")) { + $this->redirect("Dashboard"); + } + $start = $this->request->delivery_start_date; $end = $this->request->delivery_end_date; @@ -819,19 +839,15 @@ class InvoiceController extends mfBaseController { $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); unlink($tmp_file1); unlink($tmp_file2); - //exit; - if(!file_exists($output_filepath)) { $this->layout()->setFlash("Fehler beim PDFs zusammenführen: Ausgabedatei nicht gefunden", "error"); $this->redirect("Invoice"); diff --git a/application/Invoice/InvoiceModel.php b/application/Invoice/InvoiceModel.php index 9542a70ae..45345e299 100644 --- a/application/Invoice/InvoiceModel.php +++ b/application/Invoice/InvoiceModel.php @@ -301,13 +301,27 @@ class InvoiceModel { } } + if(array_key_exists("owner_id", $filter)) { + $owner_id = $filter['owner_id']; + if(is_numeric($owner_id)) { + $where .= " AND Invoice.owner_id=$owner_id"; + } + } + if(array_key_exists("billingaddress_id", $filter)) { - $Invoiceaddress_id = $filter['billingaddress_id']; - if(is_numeric($Invoiceaddress_id)) { - $where .= " AND Invoice.billingaddress_id=$Invoiceaddress_id"; + $billingaddress_id = $filter['billingaddress_id']; + if(is_numeric($billingaddress_id)) { + $where .= " AND Invoice.billingaddress_id=$billingaddress_id"; } } + if(array_key_exists("owner_or_billingaddress_id", $filter)) { + $address_id = $filter['owner_or_billingaddress_id']; + if(is_numeric($address_id)) { + $where .= " AND (Invoice.owner_id=$address_id OR Invoice.billingaddress_id=$address_id)"; + } + } + if(array_key_exists("customer_number", $filter)) { $customer_number = $filter['customer_number']; if(is_numeric($customer_number)) {