Skip to content

Commit

Permalink
Added view and controller to edit the invoice settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterZydra committed Feb 20, 2024
1 parent 26be655 commit 14386d5
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
43 changes: 43 additions & 0 deletions app/Http/Controllers/EditInvoiceSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Http\Controllers;

use App\Models\Setting;
use Framework\Facades\Http;
use Framework\Routing\BaseController;
use Framework\Routing\ControllerInterface;

class EditInvoiceSettings extends BaseController implements ControllerInterface
{
public function execute(): void
{
if (Http::requestMethod() === 'GET') {
view('settings.editInvoice');
return;
}

if (Http::requestMethod() === 'POST') {
$this->settingFromParam('invoiceSenderName');
$this->settingFromParam('invoiceSenderStreet');
$this->settingFromParam('invoiceSenderPostalCode');
$this->settingFromParam('invoiceSenderCity');
$this->settingFromParam('invoiceSenderAddition');

$this->settingFromParam('invoiceBankName');
$this->settingFromParam('invoiceIBAN');
$this->settingFromParam('invoiceBIC');

$this->settingFromParam('invoiceAuthor');
$this->settingFromParam('invoiceName');

Http::redirect('/');
}

Http::redirect('/');
}

private function settingFromParam(string $name): void
{
Setting::findByName($name)->setValue(Http::param($name))->save();
}
}
3 changes: 3 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Http\Controllers\ActiveSuppliers;
use App\Http\Controllers\DeliveryNoteController;
use App\Http\Controllers\EditImprintSettings;
use App\Http\Controllers\EditInvoiceSettings;
use App\Http\Controllers\EditVolumeDistributionController;
use App\Http\Controllers\InvoiceController;
use App\Http\Controllers\PlotController;
Expand Down Expand Up @@ -60,6 +61,8 @@

Router::addController('editImprintSettings', new EditImprintSettings());
Router::addController('editImprintSettings', new EditImprintSettings(), 'POST');
Router::addController('editInvoiceSettings', new EditInvoiceSettings());
Router::addController('editInvoiceSettings', new EditInvoiceSettings(), 'POST');

if (Auth::hasRole('Administrator')) {
Router::addModel('user', new UserController());
Expand Down
9 changes: 9 additions & 0 deletions resources/Lang/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'Actions' => 'Aktions',
'AddDeliveryNote' => 'Lieferschein hinzufügen',
'AddInvoice' => 'Rechnung hinzufügen',
'Addition' => 'Zusatz',
'AddPlot' => 'Flurstück hinzufügen',
'AddPrice' => 'Preis hinzufügen',
'AddProduct' => 'Produkt hinzufügen',
Expand All @@ -15,6 +16,9 @@
'Administration' => 'Administration',
'Administrator' => 'Administrator',
'Amount' => 'Menge',
'Author' => 'Autor',
'Bank' => 'Bank',
'BIC' => 'BIC',
'ChangePassword' => 'Passwort ändern',
'City' => 'Stadt',
'Create' => 'Erstellen',
Expand All @@ -30,6 +34,7 @@
'EditDeliveryNote' => 'Lieferschein bearbeiten',
'EditImprint' => 'Impressum bearbeiten',
'EditInvoice' => 'Rechnung bearbeiten',
'EditInvoiceData' => 'Rechnungsdaten bearbeiten',
'EditPlot' => 'Flurstück bearbeiten',
'EditPrice' => 'Preis bearbeiten',
'EditProduct' => 'Produkt bearbeiten',
Expand All @@ -44,11 +49,13 @@
'FullPayout' => 'Volle Auszahlung',
'German' => 'Deutsch',
'Home' => 'Startseite',
'IBAN' => 'IBAN',
'Imprint' => 'Impressum',
'InsertSearchText' => 'Suchtext eingeben...',
'InvalidDataTypeForField' => 'Ungültiger Datentyp für das Feld "%s"',
'InvalidVolumeDistributionData' => 'Ungültige Mengenverteilungsdaten',
'Invoice' => 'Rechnung',
'InvoiceName' => 'Rechnungsname',
'IsDiscontinued' => 'Ist abgekündigt',
'IsLocked' => 'Ist gesperrt',
'IsPaid' => 'Ist bezahlt',
Expand All @@ -57,6 +64,7 @@
'Login' => 'Anmelden',
'Logout' => 'Abmelden',
'Maintainer' => 'Betreiber',
'Miscellaneous' => 'Sonstiges',
'MyAccount' => 'Mein Konto',
'MyData' => 'Meine Daten',
'MyDeliveryNotes' => 'Meine Lieferscheine',
Expand All @@ -83,6 +91,7 @@
'RepeatNewPassword' => 'Neues Passwort wiederholen',
'Responsible' => 'Verantwortlicher',
'Save' => 'Speichern',
'Sender' => 'Absender',
'Setting' => 'Einstellung',
'ShowActiveSuppliers' => 'Aktive Lieferanten anzeigen',
'ShowAllDeliveryNotes' => 'Alle Lieferschein anzeigen',
Expand Down
9 changes: 9 additions & 0 deletions resources/Lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'Actions' => 'Actions',
'AddDeliveryNote' => 'Add delivery note',
'AddInvoice' => 'Add invoice',
'Addition' => 'Addition',
'AddPlot' => 'Add plot',
'AddPrice' => 'Add price',
'AddProduct' => 'Add product',
Expand All @@ -15,6 +16,9 @@
'Administration' => 'Administration',
'Administrator' => 'Administrator',
'Amount' => 'Amount',
'Author' => 'Author',
'Bank' => 'Bank',
'BIC' => 'BIC',
'ChangePassword' => 'Change password',
'City' => 'City',
'Create' => 'Create',
Expand All @@ -30,6 +34,7 @@
'EditDeliveryNote' => 'Edit delivery note',
'EditImprint' => 'Edit imprint',
'EditInvoice' => 'Edit invoice',
'EditInvoiceData' => 'Edit invoice data',
'EditPlot' => 'Edit plot',
'EditPrice' => 'Edit price',
'EditProduct' => 'Edit product',
Expand All @@ -44,11 +49,13 @@
'FullPayout' => 'Full payout',
'German' => 'German',
'Home' => 'Home',
'IBAN' => 'IBAN',
'Imprint' => 'Imprint',
'InsertSearchText' => 'Insert search text...',
'InvalidDataTypeForField' => 'Invalid data type for field "%s"',
'InvalidVolumeDistributionData' => 'Invalid volume distribution data',
'Invoice' => 'Invoice',
'InvoiceName' => 'Invoice name',
'IsDiscontinued' => 'Is discontinued',
'IsLocked' => 'Is locked',
'IsPaid' => 'Is paid',
Expand All @@ -57,6 +64,7 @@
'Login' => 'Login',
'Logout' => 'Logout',
'Maintainer' => 'Maintainer',
'Miscellaneous' => 'Miscellaneous',
'MyAccount' => 'My account',
'MyData' => 'My data',
'MyDeliveryNotes' => 'My delivery notes',
Expand All @@ -83,6 +91,7 @@
'RepeatNewPassword' => 'Repeat new password',
'Responsible' => 'Responsible',
'Save' => 'Save',
'Sender' => 'Sender',
'Setting' => 'Setting',
'ShowActiveSuppliers' => 'Show active suppliers',
'ShowAllDeliveryNotes' => 'Show all delivery notes',
Expand Down
2 changes: 1 addition & 1 deletion resources/Views/auth/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<div class="box">
<strong><?= __('SystemSettings') ?></strong><br>
<a href="editImprintSettings"><?= __('EditImprint') ?></a><br>
<a href="editInvoiceData.php">Rechnungsdaten bearbeiten</a>
<a href="editInvoiceSettings"><?= __('EditInvoiceData') ?></a>
</div>

<div class="box">
Expand Down
45 changes: 45 additions & 0 deletions resources/Views/settings/editInvoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?= component('layout.header') ?>

<h1><?= __('EditInvoiceData') ?></h1>

<form method="post">
<h2><?= __('Sender') ?></h2>

<label for="invoiceSenderName" class="required"><?= __('Name') ?>:</label><br>
<input id="invoiceSenderName" name="invoiceSenderName" type="text" value="<?= setting('invoiceSenderName') ?>" autofocus required><br>

<label for="invoiceSenderStreet" class="required"><?= __('Street') ?>:</label><br>
<input id="invoiceSenderStreet" name="invoiceSenderStreet" type="text" value="<?= setting('invoiceSenderStreet') ?>" required><br>

<label for="invoiceSenderPostalCode" class="required"><?= __('PostalCode') ?>:</label><br>
<input id="invoiceSenderPostalCode" name="invoiceSenderPostalCode" type="text" value="<?= setting('invoiceSenderPostalCode') ?>" required><br>

<label for="invoiceSenderCity" class="required"><?= __('City') ?>:</label><br>
<input id="invoiceSenderCity" name="invoiceSenderCity" type="text" value="<?= setting('invoiceSenderCity') ?>" required><br>

<label for="invoiceSenderAddition"><?= __('Addition') ?>:</label><br>
<input id="invoiceSenderAddition" name="invoiceSenderAddition" type="text" value="<?= setting('invoiceSenderAddition') ?>"><br>

<h2><?= __('Bank') ?></h2>

<label for="invoiceBankName" class="required"><?= __('Name') ?>:</label><br>
<input id="invoiceBankName" name="invoiceBankName" type="text" value="<?= setting('invoiceBankName') ?>" required><br>

<label for="invoiceIBAN" class="required"><?= __('IBAN') ?>:</label><br>
<input id="invoiceIBAN" name="invoiceIBAN" type="text" value="<?= setting('invoiceIBAN') ?>" required><br>

<label for="invoiceBIC" class="required"><?= __('BIC') ?>:</label><br>
<input id="invoiceBIC" name="invoiceBIC" type="text" value="<?= setting('invoiceBIC') ?>" required><br>

<h2><?= __('Miscellaneous') ?></h2>

<label for="invoiceAuthor" class="required"><?= __('Author') ?>:</label><br>
<input id="invoiceAuthor" name="invoiceAuthor" type="text" value="<?= setting('invoiceAuthor') ?>" required><br>

<label for="invoiceName" class="required"><?= __('InvoiceName') ?>:</label><br>
<input id="invoiceName" name="invoiceName" type="text" value="<?= setting('invoiceName') ?>" required><br>

<button><?= __('Save') ?></button>
</form>

<?= component('layout.footer') ?>

0 comments on commit 14386d5

Please sign in to comment.