-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added controller, view and PDF for volume distribution
- Loading branch information
1 parent
eaf8016
commit 98f5a00
Showing
9 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\DeliveryNote; | ||
use App\Models\Invoice; | ||
use Framework\Database\Query\ColType; | ||
use Framework\Database\Query\Condition; | ||
use Framework\Facades\Http; | ||
use Framework\PDF\PDF; | ||
use Framework\Routing\BaseController; | ||
use Framework\Routing\ControllerInterface; | ||
|
||
class VolumeDistributionPdfController extends BaseController implements ControllerInterface | ||
{ | ||
public function execute(): void | ||
{ | ||
if (Http::requestMethod() === 'GET') { | ||
view('statistics.volumeDistribution'); | ||
return; | ||
} | ||
|
||
if (Http::requestMethod() === 'POST') { | ||
if (Http::param('invoiceYear', '') === '') { | ||
Http::redirect('showSupplierPayouts'); | ||
} | ||
|
||
$filename = 'Mengenverteilung ' . Http::param('invoiceYear'); | ||
|
||
(new PDF()) | ||
->createPDF(setting('invoiceAuthor'), $filename, $filename, render('pdf.volumeDistribution', ['year' => Http::param('invoiceYear')])) | ||
->showInBrowser($filename); | ||
return; | ||
} | ||
|
||
Http::redirect('/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/** @var string $year */ | ||
|
||
use Framework\Database\Database; | ||
use Framework\Facades\Format; | ||
use Framework\Facades\Http; | ||
use Framework\Message\Message; | ||
use Framework\Message\Type; | ||
|
||
?> | ||
|
||
<table cellpadding="5" cellspacing="0" style="width: 100%;"> | ||
<tr> | ||
<td width="100%"> | ||
|
||
<h1 style="text-align: center;">Mengenverteilung <?= $year ?></h1><br> | ||
|
||
<table cellpadding="5" cellspacing="0" style="width: 100%;" border="0"> | ||
|
||
<tr style="background-color: #4a8a16; padding:5px; color:white;"> | ||
<td style="padding:5px;"><b>Flurstück</b></td> | ||
<td><b>Name</b></td> | ||
<td><b>Menge in <?= setting('massUnit') ?></b></td> | ||
</tr> | ||
|
||
<?php | ||
|
||
$dataSet = Database::prepared( | ||
'SELECT plots.nr, plots.name, SUM(volumeDistributions.amount) AS amount ' . | ||
'FROM deliveryNotes ' . | ||
'RIGHT JOIN volumeDistributions ON deliveryNotes.id = volumeDistributions.deliveryNoteId ' . | ||
'LEFT JOIN plots ON volumeDistributions.plotId = plots.id ' . | ||
'WHERE deliveryNotes.year = ? ' . | ||
'GROUP BY plots.nr', | ||
'i', | ||
$year | ||
); | ||
|
||
if ($dataSet === false) { | ||
Message::setMessage('An unkown error occured while creating the PDF', Type::Error); | ||
Http::redirect('/showVolumeDistribution'); | ||
} | ||
|
||
$totalAmount = 0; | ||
|
||
while ($row = $dataSet->fetch_assoc()) { | ||
$totalAmount += $row['amount']; | ||
?> | ||
<tr> | ||
<td style="text-align: left;"><?= $row['nr'] ?></td> | ||
<td style="text-align: left;"><?= $row['name'] ?></td> | ||
<td style="text-align: right;"><?= Format::Decimal($row['amount']) ?></td> | ||
</tr> | ||
<?php } ?> | ||
|
||
</table> | ||
|
||
</td></tr></table> | ||
|
||
<hr> | ||
|
||
<table cellpadding="5" cellspacing="0" style="width: 100%;" border="0"> | ||
<tr> | ||
<td colspan="3"><b>Gesamtmenge in <?= setting('massUnit') ?>: </b></td> | ||
<td style="text-align: right;"><b><?= Format::Decimal($totalAmount) ?></b></td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?= component('layout.header') ?> | ||
|
||
<h1><?= __('ShowVolumeDistribution') ?></h1> | ||
|
||
<form method="post"> | ||
<?= component('invoiceYearSelect', ['notEmpty' => '']) ?><br> | ||
|
||
<button><?= __('Show') ?></button> | ||
</form> | ||
|
||
<?= component('layout.footer') ?> |