Create an insecure bank application
This commit is contained in:
60
webroot/lib/View/BookingOverviewPage.php
Normal file
60
webroot/lib/View/BookingOverviewPage.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace View;
|
||||
|
||||
class BookingOverviewPage extends BankingPage
|
||||
{
|
||||
public array $bookings = [];
|
||||
public int $finalBalance = 0;
|
||||
|
||||
public function sendTitle(): void
|
||||
{
|
||||
echo 'Umsatz-Übersicht';
|
||||
}
|
||||
|
||||
protected static function bookingText(int $type, ?string $relatedName)
|
||||
{
|
||||
switch ($type) {
|
||||
case 1:
|
||||
return "Einzahlung";
|
||||
case 2:
|
||||
return "Auszahlung";
|
||||
case 3:
|
||||
if ($relatedName === null) {
|
||||
return "Überweisung ins Leere";
|
||||
} else {
|
||||
return "Überweisung an {$relatedName}";
|
||||
}
|
||||
case 4:
|
||||
if ($relatedName === null) {
|
||||
return "Überweisung aus dem Nichts";
|
||||
} else {
|
||||
return "Überweisung von {$relatedName}";
|
||||
}
|
||||
default:
|
||||
return "Unbekannter Vorgang";
|
||||
}
|
||||
}
|
||||
|
||||
public function sendMainContent(): void
|
||||
{
|
||||
$userName = htmlspecialchars($this->context->session->user->name);
|
||||
|
||||
echo "<h1>Umsatz-Übersicht für {$userName}</h1>";
|
||||
if (empty($this->bookings)) {
|
||||
echo '<p><i>Keine Buchungen</i></p>';
|
||||
}
|
||||
echo '<table>';
|
||||
foreach ($this->bookings as $booking) {
|
||||
$timeInfo = date('d.m.Y H:i', $booking['time']);
|
||||
$text = htmlspecialchars(static::bookingText($booking['type'], $booking['relatedName']));
|
||||
$comment = htmlspecialchars($booking['comment']);
|
||||
$amount = MoneyFormatter::formatAmount($booking['amount']);
|
||||
echo "<tr><td>{$timeInfo}</td><td>{$text}</td><td>{$comment}</td><td>{$amount}</td></tr>";
|
||||
}
|
||||
$final = MoneyFormatter::formatAmount($this->finalBalance);
|
||||
echo "<tr><td></td><td>Kontostand:</td><td></td><td>{$final}</td></tr>";
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user