From 98f5a00a9e8c35858a12868e88041aa0c4260812 Mon Sep 17 00:00:00 2001 From: MasterZydra Date: Wed, 21 Feb 2024 20:44:06 +0100 Subject: [PATCH] Added controller, view and PDF for volume distribution --- .../VolumeDistributionPdfController.php | 38 +++++++++++ app/routes.php | 4 ++ framework/Facades/Format.php | 8 ++- resources/Lang/de.php | 1 + resources/Lang/en.php | 1 + .../Views/Components/invoiceYearSelect.php | 5 +- resources/Views/auth/home.php | 2 +- resources/Views/pdf/volumeDistribution.php | 68 +++++++++++++++++++ .../Views/statistics/volumeDistribution.php | 11 +++ 9 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 app/Http/Controllers/VolumeDistributionPdfController.php create mode 100644 resources/Views/pdf/volumeDistribution.php create mode 100644 resources/Views/statistics/volumeDistribution.php diff --git a/app/Http/Controllers/VolumeDistributionPdfController.php b/app/Http/Controllers/VolumeDistributionPdfController.php new file mode 100644 index 0000000..6648a8b --- /dev/null +++ b/app/Http/Controllers/VolumeDistributionPdfController.php @@ -0,0 +1,38 @@ +createPDF(setting('invoiceAuthor'), $filename, $filename, render('pdf.volumeDistribution', ['year' => Http::param('invoiceYear')])) + ->showInBrowser($filename); + return; + } + + Http::redirect('/'); + } +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 9a32bf2..1760292 100644 --- a/app/routes.php +++ b/app/routes.php @@ -25,6 +25,7 @@ use App\Http\Controllers\User\LoginController; use App\Http\Controllers\User\LogoutController; use App\Http\Controllers\UserController; +use App\Http\Controllers\VolumeDistributionPdfController; use Framework\Authentication\Auth; use Framework\Cli\Controllers\WebCliController; use Framework\Facades\Http; @@ -68,6 +69,9 @@ Router::addController('showSupplierPayouts', new SupplierPayoutsController()); Router::addController('showSupplierPayouts', new SupplierPayoutsController(), 'POST'); + Router::addController('showVolumeDistribution', new VolumeDistributionPdfController()); + Router::addController('showVolumeDistribution', new VolumeDistributionPdfController(), 'POST'); + if (Auth::hasRole('Administrator')) { Router::addModel('user', new UserController()); } diff --git a/framework/Facades/Format.php b/framework/Facades/Format.php index e6012ff..3ddc9fb 100644 --- a/framework/Facades/Format.php +++ b/framework/Facades/Format.php @@ -22,6 +22,12 @@ public static function IBAN(string $IBAN): string /** Format the given value to e.g. `X.XXX,XX EUR` */ public static function Currency(float $value): string { - return number_format($value, 2, ',', '.') . ' ' . setting('currencyUnit'); + return self::Decimal($value) . ' ' . setting('currencyUnit'); + } + + /** Format the given value to e.g. `X.XXX,XX` */ + public static function Decimal(float $value): string + { + return number_format($value, 2, ',', '.'); } } \ No newline at end of file diff --git a/resources/Lang/de.php b/resources/Lang/de.php index 7a08c05..91c12d2 100644 --- a/resources/Lang/de.php +++ b/resources/Lang/de.php @@ -109,6 +109,7 @@ 'ShowAllSuppliers' => 'Alle Lieferanten anzeigen', 'ShowAllUsers' => 'Alle Benutzer anzeigen', 'ShowPayouts' => 'Auszahlungen anzeigen', + 'ShowVolumeDistribution' => 'Mengenverteilung anzeigen', 'Street' => 'Straße', 'Subdistrict' => 'Gemarkung', 'Supplier' => 'Lieferant', diff --git a/resources/Lang/en.php b/resources/Lang/en.php index ca60bc7..866280b 100644 --- a/resources/Lang/en.php +++ b/resources/Lang/en.php @@ -110,6 +110,7 @@ 'ShowAllUsers' => 'Show all users', 'ShowDeliveryNotes' => 'Show all delivery notes', 'ShowPayouts' => 'Show payouts', + 'ShowVolumeDistribution' => 'Show volume distribution', 'Street' => 'Street', 'Subdistrict' => 'Subdistrict', 'Supplier' => 'Supplier', diff --git a/resources/Views/Components/invoiceYearSelect.php b/resources/Views/Components/invoiceYearSelect.php index 5e67163..2985574 100644 --- a/resources/Views/Components/invoiceYearSelect.php +++ b/resources/Views/Components/invoiceYearSelect.php @@ -6,6 +6,7 @@ // Optional passed variables: // $selected => Id that should be selected +// $notEmpty => Do not show the "Please select" entry $dataSet = Database::executeBuilder(QueryBuilder::new('invoices')->select('DISTINCT year')->orderBy('year', SortOrder::Desc)); @@ -19,7 +20,9 @@ ?>