Prepare Excel reports.

This commit is contained in:
2025-01-17 13:43:19 +01:00
parent 6427dfdc5d
commit fda3e13ca9
8 changed files with 126 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ExcelController extends Controller
{
public function export(Request $request): JsonResponse
{
return response()->json($request->all());
}
}

24
lang/de/excel.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
return [
/*
|------------------------------------------------- -------------------------
| Übersetzungen allgemeiner und bereichsunspezifischer Daten
|------------------------------------------------- -------------------------
|
| Die folgenden Sprachzeilen werden für alles verwendet, das nicht in eine
| spezielle Kategorie passt.
|
*/
'Excel export' => 'Excel Export',
'Choose data' => 'Datenauswahl',
'Choose data hint' => 'Wähle die Daten, für die der Excel Report generiert werden soll.',
'Report' => 'Report',
'Generate' => 'Generieren',
'Outgoing invoices' => 'Ausgangsrechnungen',
'Incoming payments' => 'Zahlungseingang',
];

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" {{ $attributes->merge(['class' => 'size-8 p-1']) }}>
<path d="M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm90.9 233.3c-8.1-10.5-23.2-12.3-33.7-4.2s-12.3 23.2-4.2 33.7L161.6 320l-44.5 57.3c-8.1 10.5-6.3 25.5 4.2 33.7s25.5 6.3 33.7-4.2L192 359.1l37.1 47.6c8.1 10.5 23.2 12.3 33.7 4.2s12.3-23.2 4.2-33.7L222.4 320l44.5-57.3c8.1-10.5 6.3-25.5-4.2-33.7s-25.5-6.3-33.7 4.2L192 280.9l-37.1-47.6z"/>
</svg>

After

Width:  |  Height:  |  Size: 696 B

View File

@@ -0,0 +1,64 @@
<x-app-layout>
<x-slot name="header">
<h2 class="grow font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('excel.Excel export') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
<div class="max-w" x-data="excelForm">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('excel.Choose data') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("excel.Choose data hint") }}
</p>
<div class="flex flex-row space-x-4 items-center mt-8">
<x-input-label for="from" :value="__('invoice.From')"/>
<x-text-input type="date" id="from" name="from" x-model="data.from"/>
<x-input-label for="end" :value="__('invoice.End')"/>
<x-text-input type="date" id="end" name="end" x-model="data.end"/>
<x-input-label for="report" :value="__('excel.Report')"/>
<select name="report" id="report" x-model="data.report" class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-1/4">
<option value="invoice">{{ __('excel.Outgoing invoices') }}</option>
<option value="payment">{{ __('excel.Incoming payments') }}</option>
</select>
</div>
</header>
<x-primary-button @click="submit" class="mt-8" x-show="data.report !== ''">{{ __('excel.Generate') }}</x-primary-button>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function excelForm() {
return {
data: {
from: "{{ \Illuminate\Support\Facades\Date::now()->firstOfMonth()->format('Y-m-d') }}",
end: "{{ \Illuminate\Support\Facades\Date::now()->format('Y-m-d') }}",
report: 'invoice',
},
submit() {
axios.post('/excel', this.data)
.then(function(response) {
console.log(response.data);
}).catch(function(error) {
console.log(error);
})
}
}
}
</script>

View File

@@ -1,8 +1,13 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.Invoices') }}
</h2>
<div class="flex flex-row w-full">
<h2 class="grow font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.Invoices') }}
</h2>
<a href="{{ route('excel') }}" class="relative flex flex-row">
<x-excel-icon class="text-gray-800 cursor-pointer"/>
</a>
</div>
</x-slot>
<div class="py-12">
@@ -18,7 +23,6 @@
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Add new invoice by clicking add") }}
</p>
</header>
<a class="mt-6 inline-block" href="{{ route('invoice.create') }}"><x-primary-button>{{ __('form.Add') }}</x-primary-button></a>
</section>

View File

@@ -1,8 +1,13 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.Payments') }}
</h2>
<div class="flex flex-row w-full">
<h2 class="grow font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.Payments') }}
</h2>
<a href="{{ route('excel') }}" class="relative flex flex-row">
<x-excel-icon class="text-gray-800 cursor-pointer"/>
</a>
</div>
</x-slot>
<div class="py-12">
@@ -14,7 +19,6 @@
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('invoice.Add new payment') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Add new payment by clicking add") }}
</p>

View File

@@ -3,6 +3,7 @@
use App\Http\Controllers\Api\AddressController;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\CustomerController;
use App\Http\Controllers\Api\ExcelController;
use App\Http\Controllers\Api\InvoiceController;
use App\Http\Controllers\Api\InvoiceitemController;
use App\Http\Controllers\Api\MailController;
@@ -38,6 +39,7 @@ Route::group(['as' => 'api.'], function () {
Route::post('/sendInvoice', [MailController::class, 'sendInvoice'])->name('sendInvoice');
Route::get('/payment-filter/{start}/{end}', [PaymentController::class, 'indexFilter'])->name('payment.index');
Route::apiResource('/invoice.payment', PaymentController::class)->shallow();
Route::post('/excel', [ExcelController::class, 'export'])->name('excel.export');
});

View File

@@ -33,6 +33,7 @@ Route::middleware('auth')->group(function () {
Route::get('/invoice/{id}/xml-download', [EController::class, 'downloadInvoice'])->name('invoice.eDownload');
Route::get('/invoice/{id}/mail', [InvoiceController::class, 'mail'])->name('invoice.mail');
Route::resource('/payment', PaymentController::class)->only(['index', 'create', 'edit']);
Route::get('/excel', function() { return view('excel'); })->name('excel');
});
require __DIR__.'/auth.php';