diff --git a/app/Enums/InvoiceTypes.php b/app/Enums/InvoiceTypes.php index 40a9d0b..a6e3f91 100644 --- a/app/Enums/InvoiceTypes.php +++ b/app/Enums/InvoiceTypes.php @@ -4,20 +4,31 @@ enum InvoiceTypes: string { - case EARNING = 'Tržba'; - case EXPENSE = 'Výdaj'; - case SALARY = 'Mzda'; - case VOUCHER = 'Poukaz'; - case OTHER = 'Ostatní'; + case EARNING = 'T'; + case EXPENSE = 'V'; + case SALARY = 'M'; + case VOUCHER = 'P'; + case OTHER = 'O'; + + public function getReadableFormat(): string + { + return match ($this) { + self::EARNING => 'Tržba', + self::EXPENSE => 'Výdaj', + self::SALARY => 'Mzda', + self::VOUCHER => 'Poukaz', + default => 'Ostatní' + }; + } public static function getHtmlSpan(string $type): string { return match ($type) { - 'T' => ''.self::EARNING->value.'', - 'V' => ''.self::EXPENSE->value.'', - 'M' => ''.self::SALARY->value.'', - 'P' => ''.self::VOUCHER->value.'', - default => ''.self::OTHER->value.'', + 'T' => ''.self::EARNING->getReadableFormat().'', + 'V' => ''.self::EXPENSE->getReadableFormat().'', + 'M' => ''.self::SALARY->getReadableFormat().'', + 'P' => ''.self::VOUCHER->getReadableFormat().'', + default => ''.self::OTHER->getReadableFormat().'', }; } } diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 2ee1cad..453a8d9 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -43,6 +43,18 @@ public function show(string $id): BinaryFileResponse return response()->download(storage_path('app/public/invoice/'.$id.'.png')); } + public function create(): View + { + return view('admin.invoices.create'); + } + + public function store(Request $request): RedirectResponse + { + Invoice::create($request->all()); + + return to_route('invoices.index')->with('success', 'Faktura byla úspěšně vytvořena.'); + } + /** * Show the form for editing the specified resource. */ diff --git a/resources/views/admin/customers/create.latte b/resources/views/admin/customers/create.latte index 0bc77d5..501cdfe 100644 --- a/resources/views/admin/customers/create.latte +++ b/resources/views/admin/customers/create.latte @@ -41,7 +41,7 @@
- +
diff --git a/resources/views/admin/customers/edit.latte b/resources/views/admin/customers/edit.latte index 9d8c332..a5aaa41 100644 --- a/resources/views/admin/customers/edit.latte +++ b/resources/views/admin/customers/edit.latte @@ -43,7 +43,7 @@
- +
diff --git a/resources/views/admin/invoices/create.latte b/resources/views/admin/invoices/create.latte new file mode 100644 index 0000000..f74e57b --- /dev/null +++ b/resources/views/admin/invoices/create.latte @@ -0,0 +1,43 @@ +{layout '../../layout.latte'} + +{block content} +
+
+ +

Nová faktura

+
+ +
+ {csrf_field()|noescape} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+
+{/block} diff --git a/resources/views/admin/invoices/edit.latte b/resources/views/admin/invoices/edit.latte index 2f0ee82..2e2119d 100644 --- a/resources/views/admin/invoices/edit.latte +++ b/resources/views/admin/invoices/edit.latte @@ -38,7 +38,7 @@
- +
diff --git a/resources/views/admin/invoices/index.latte b/resources/views/admin/invoices/index.latte index 73d7633..d0925d5 100644 --- a/resources/views/admin/invoices/index.latte +++ b/resources/views/admin/invoices/index.latte @@ -5,7 +5,10 @@

Faktury

- +
@@ -46,7 +49,7 @@ {if $invoice->type === 'P' && file_exists(storage_path('app/public/voucher/').$invoice->name.'.png')} - name.'png')}disabled{/if}> + name.'png')}disabled{/if}> {/if} diff --git a/resources/views/admin/vin/edit.latte b/resources/views/admin/vin/edit.latte index 9a13e88..35f57ea 100644 --- a/resources/views/admin/vin/edit.latte +++ b/resources/views/admin/vin/edit.latte @@ -42,7 +42,7 @@
- +
diff --git a/resources/views/admin/vin/index.latte b/resources/views/admin/vin/index.latte index effb0ff..19e4c7d 100644 --- a/resources/views/admin/vin/index.latte +++ b/resources/views/admin/vin/index.latte @@ -17,7 +17,7 @@

Nové VIN

- - + diff --git a/routes/web.php b/routes/web.php index 719f802..3e7e1e9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,7 +36,7 @@ Route::group(['middleware' => 'auth', 'prefix' => 'admin'], function () { Route::get('/', [AdminController::class, 'dashboard'])->name('dashboard'); - Route::resource('invoices', InvoicesController::class)->except('create','store','destroy'); + Route::resource('invoices', InvoicesController::class)->except('destroy'); Route::resource('customers', CustomersController::class)->except('show'); Route::group(['prefix' => 'customers'], function () {