diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsCommand.php b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsCommand.php new file mode 100644 index 0000000..341b025 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsCommand.php @@ -0,0 +1,22 @@ +request = $request; + } + + public function execute(): ChangeCostUnitDetailsResponse { + $response = new ChangeCostUnitDetailsResponse(); + + $this->request->costUnit->distance_allowance = $this->request->distanceAllowance->getAmount(); + $this->request->costUnit->mail_on_new = $this->request->mailOnNew; + $this->request->costUnit->billing_deadline = $this->request->billingDeadline; + + $response->success = $this->request->costUnit->save(); + return $response; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsRequest.php b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsRequest.php new file mode 100644 index 0000000..ab3abae --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsRequest.php @@ -0,0 +1,22 @@ +costUnit = $costUnit; + $this->distanceAllowance = $distanceAllowance; + $this->mailOnNew = $mailOnNew; + $this->billingDeadline = $billingDeadline; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsResponse.php b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsResponse.php new file mode 100644 index 0000000..38ceb70 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitDetails/ChangeCostUnitDetailsResponse.php @@ -0,0 +1,11 @@ +success = false; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateCommand.php b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateCommand.php new file mode 100644 index 0000000..da4be16 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateCommand.php @@ -0,0 +1,21 @@ +request = $request; + } + + public function execute() : ChangeCostUnitStateResponse { + $response = new ChangeCostUnitStateResponse(); + + $this->request->costUnit->allow_new = $this->request->allowNew; + $this->request->costUnit->archived = $this->request->isArchived; + $response->success = $this->request->costUnit->save(); + + return $response; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateRequest.php b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateRequest.php new file mode 100644 index 0000000..918f136 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateRequest.php @@ -0,0 +1,18 @@ +costUnit = $costUnit; + $this->allowNew = $allowNew; + $this->isArchived = $isArchived; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateResponse.php b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateResponse.php new file mode 100644 index 0000000..5c486bf --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitState/ChangeCostUnitStateResponse.php @@ -0,0 +1,11 @@ +success = false; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersCommand.php b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersCommand.php new file mode 100644 index 0000000..b1bff4d --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersCommand.php @@ -0,0 +1,31 @@ +request = $request; + } + + public function execute() : ChangeCostUnitTreasurersResponse { + $response = new ChangeCostUnitTreasurersResponse(); + + try { + $this->request->costUnit->resetTreasurers(); + + foreach ($this->request->treasurers as $treasurer) { + $this->request->costUnit->tresurers()->attach($treasurer); + } + + $this->request->costUnit->save(); + } catch (\Throwable $th) { + $response->success = false; + } + + return $response; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersRequest.php b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersRequest.php new file mode 100644 index 0000000..340d436 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersRequest.php @@ -0,0 +1,15 @@ +treasurers = $treasurers; + $this->costUnit = $costUnit; + } +} diff --git a/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersResponse.php b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersResponse.php new file mode 100644 index 0000000..17f7718 --- /dev/null +++ b/app/Domains/CostUnit/Actions/ChangeCostUnitTreasurers/ChangeCostUnitTreasurersResponse.php @@ -0,0 +1,7 @@ +request = $request; + } + + public function execute() : CreateCostUnitResponse { + $response = new CreateCostUnitResponse(); + $costUnit = CostUnit::create([ + 'name' => $this->request->name, + 'tenant' => app('tenant')->slug, + 'type' => $this->request->type, + 'billing_deadline' => $this->request->billingDeadline, + 'distance_allowance' => $this->request->distanceAllowance->getAmount(), + 'mail_on_new' => $this->request->mailOnNew, + 'allow_new' => true, + 'archived' => false, + + ]); + return $response; + } +} diff --git a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitRequest.php b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitRequest.php new file mode 100644 index 0000000..cf32770 --- /dev/null +++ b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitRequest.php @@ -0,0 +1,23 @@ +name = $name; + $this->type = $type; + $this->distanceAllowance = $distanceAllowance; + $this->mailOnNew = $mailOnNew; + $this->billingDeadline = $billingDeadline; + } +} diff --git a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php new file mode 100644 index 0000000..c58891d --- /dev/null +++ b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php @@ -0,0 +1,7 @@ +costUnits->getById($costUnitId); + + $changeStatRequest = new ChangeCostUnitStateRequest($costUnit, false, false); + return $this->changeCostUnitState($changeStatRequest, 'Der CostUnit wurde geschlossen.'); + } + + public function open(int $costUnitId) : JsonResponse { + $costUnit = $this->costUnits->getById($costUnitId); + + $changeStatRequest = new ChangeCostUnitStateRequest($costUnit, true, false); + return $this->changeCostUnitState($changeStatRequest, 'Der CostUnit wurde geöffnet.'); + } + + public function archive(int $costUnitId) : JsonResponse { + $costUnit = $this->costUnits->getById($costUnitId); + + $changeStatRequest = new ChangeCostUnitStateRequest($costUnit, false, true); + return $this->changeCostUnitState($changeStatRequest, 'Der CostUnit wurde archiviert.'); + } + + private function changeCostUnitState(ChangeCostUnitStateRequest $request, string $responseMessage) : JsonResponse { + $changeStatCommand = new ChangeCostUnitStateCommand($request); + + if ($changeStatCommand->execute()) { + return response()->json([ + 'status' => 'success', + 'message' => $responseMessage + ]); + }; + + return response()->json([ + 'status' => 'error', + 'message' => 'Ein Fehler ist aufgetreten.' + ]); + } +} diff --git a/app/Domains/CostUnit/Controllers/CreateController.php b/app/Domains/CostUnit/Controllers/CreateController.php new file mode 100644 index 0000000..8229fd4 --- /dev/null +++ b/app/Domains/CostUnit/Controllers/CreateController.php @@ -0,0 +1,35 @@ +render(); + } + + public function createCostUnitRunningJob(Request $request) : JsonResponse { + $createCostUnitRequest = new CreateCostUnitRequest( + $request->get('cost_unit_name'), + CostUnitType::COST_UNIT_TYPE_RUNNING_JOB, + Amount::fromString($request->get('distance_allowance')), + $request->get('mail_on_new') + ); + + $createCostUnitCommand = new CreateCostUnitCommand($createCostUnitRequest); + $result = $createCostUnitCommand->execute(); + session()->put('message', 'Die laufende Tätigkeit wurde erfolgreich angelegt.'); + + return response()->json([]); + } +} diff --git a/app/Domains/CostUnit/Controllers/EditController.php b/app/Domains/CostUnit/Controllers/EditController.php new file mode 100644 index 0000000..9bc5192 --- /dev/null +++ b/app/Domains/CostUnit/Controllers/EditController.php @@ -0,0 +1,58 @@ +costUnits->getById($costUnitId); + if (null === $costUnit) { + return response()->json([ + 'status' => 'error', + 'message' => 'Die Kotenstelle konnte nicht geladen werden.' + ]); + } + + return response()->json([ + 'status' => 'success', + 'costUnit' => new CostUnitResource($costUnit)->toArray(request()) + ]); + } + + public function update(Request $request, int $costUnitId) : JsonResponse { + $costUnit = $this->costUnits->getById($costUnitId); + if (null === $costUnit) { + return response()->json([ + 'status' => 'error', + 'message' => 'Die Kotenstelle konnte nicht geladen werden.' + ]); + } + + $saveParams = $request->get('formData'); + $distanceAllowance = Amount::fromString($saveParams['distanceAllowance']); + $billingDeadline = isset($saveParams['billingDeadline']) ? \DateTime::createFromFormat('Y-m-d', $saveParams['billingDeadline']) : null; + + $request = new ChangeCostUnitDetailsRequest($costUnit, $distanceAllowance, $saveParams['mailOnNew'], $billingDeadline); + $command = new ChangeCostUnitDetailsCommand($request); + $result = $command->execute(); + + if (!$result->success) { + return response()->json([ + 'status' => 'error', + 'message' => 'Bei der Verarbeitung ist ein Fehler aufgetreten.' + ]); + } + + return response()->json([ + 'status' => 'success', + 'message' => 'Die Kostenstellendetails wurden erfolgreich gespeichert.', + ]); + } +} diff --git a/app/Domains/CostUnit/Controllers/ListController.php b/app/Domains/CostUnit/Controllers/ListController.php new file mode 100644 index 0000000..145ae00 --- /dev/null +++ b/app/Domains/CostUnit/Controllers/ListController.php @@ -0,0 +1,50 @@ + 1 + ]); + return $inertiaProvider->render(); + } + + public function listCurrentEvents(Request $request) : JsonResponse { + + return response()->json([ + 'cost_unit_title' => 'Aktuelle Veranstaltungen', + 'cost_units' => $this->costUnits->getCurrentEvents(), + ]); + } + + public function listCurrentRunningJobs(Request $request) : JsonResponse { + return response()->json([ + 'cost_unit_title' => 'Laufende Tätigkeiten', + 'cost_units' => $this->costUnits->getRunningJobs(), + ]); + } + + public function listClosedCostUnits(Request $request) : JsonResponse { + return response()->json([ + 'cost_unit_title' => 'Geschlossene Kostenstellen', + 'cost_units' => $this->costUnits->getClosedCostUnits(), + ]); + } + + public function listArchivedCostUnits(Request $request) : JsonResponse { + return response()->json([ + 'cost_unit_title' => 'Archivierte Kostenstellen', + 'cost_units' => $this->costUnits->getArchivedCostUnits(), + ]); + } + + +} diff --git a/app/Domains/CostUnit/Controllers/TreasurersEditController.php b/app/Domains/CostUnit/Controllers/TreasurersEditController.php new file mode 100644 index 0000000..2137e2d --- /dev/null +++ b/app/Domains/CostUnit/Controllers/TreasurersEditController.php @@ -0,0 +1,54 @@ +costUnits->getById($costUnitId); + if (null === $costUnit) { + return response()->json([ + 'status' => 'error', + 'message' => 'Die Kostenstelle konnte nicht geladen werden.' + ]); + } + + + + return response()->json([ + 'status' => 'success', + 'costUnit' => new CostUnitResource($costUnit)->toArray(request()) + ]); + } + + public function update(Request $request, int $costUnitId) : JsonResponse { + $costUnit = $this->costUnits->getById($costUnitId); + if (null === $costUnit) { + return response()->json([ + 'status' => 'error', + 'message' => 'Die Kostenstelle konnte nicht geladen werden.' + ]); + } + + $changeTreasurersRequest = new ChangeCostUnitTreasurersRequest($costUnit, $request->get('selectedTreasurers')); + $changeTreasurersCommand = new ChangeCostUnitTreasurersCommand($changeTreasurersRequest); + if ($changeTreasurersCommand->execute()) { + return response()->json([ + 'status' => 'success', + 'message' => 'Die Schatzis wurden erfolgreich gespeichert.' + ]); + } + + return response()->json([ + 'status' => 'error', + 'message' => 'Beim Bearbeiten der Kostenstelle ist ein Fehler aufgetreten.' + ]); + } +} diff --git a/app/Domains/CostUnit/Routes/api.php b/app/Domains/CostUnit/Routes/api.php new file mode 100644 index 0000000..bd8b4b5 --- /dev/null +++ b/app/Domains/CostUnit/Routes/api.php @@ -0,0 +1,49 @@ +group(function () { + Route::middleware(IdentifyTenant::class)->group(function () { + Route::prefix('cost-unit')->group(function () { + Route::middleware(['auth'])->group(function () { + Route::post('/create-running-job', [CreateController::class, 'createCostUnitRunningJob']); + + + Route::prefix('/{costUnitId}') ->group(function () { + Route::post('/close', [ChangeStateController::class, 'close']); + Route::post('/open', [ChangeStateController::class, 'open']); + Route::post('/archive', [ChangeStateController::class, 'archive']); + + Route::get('/details', EditController::class); + Route::post('/details', [EditController::class, 'update']); + + Route::get('/treasurers', TreasurersEditController::class); + Route::post('/treasurers', [TreasurersEditController::class, 'update']); + + }); + + + + Route::prefix('open')->group(function () { + Route::get('/current-events', [ListController::class, 'listCurrentEvents']); + Route::get('/current-running-jobs', [ListController::class, 'listCurrentRunningJobs']); + Route::get('/closed-cost-units', [ListController::class, 'listClosedCostUnits']); + Route::get('/archived-cost-units', [ListController::class, 'listArchivedCostUnits']); + }); + + + }); + }); + }); + }); diff --git a/app/Domains/CostUnit/Routes/web.php b/app/Domains/CostUnit/Routes/web.php new file mode 100644 index 0000000..ed6271c --- /dev/null +++ b/app/Domains/CostUnit/Routes/web.php @@ -0,0 +1,39 @@ +group(function () { + Route::prefix('cost-unit')->group(function () { + Route::middleware(['auth'])->group(function () { + Route::get('/create', [CreateController::class, 'showForm']); + Route::get('/list', ListController::class); + }); + + + + }); + Route::get('/register', [RegistrationController::class, 'loginForm']); + Route::get('/register/verifyEmail', [EmailVerificationController::class, 'verifyEmailForm']); + + Route::get('/reset-password', [ResetPasswordController::class, 'resetPasswordForm']); + + route::get('/logout', LogOutController::class); + route::post('/login', [LoginController::class, 'doLogin']); + route::get('/login', [LoginController::class, 'loginForm']); + + +}); + + + diff --git a/app/Domains/CostUnit/Views/Create.vue b/app/Domains/CostUnit/Views/Create.vue new file mode 100644 index 0000000..fc510b6 --- /dev/null +++ b/app/Domains/CostUnit/Views/Create.vue @@ -0,0 +1,78 @@ + + + diff --git a/app/Domains/CostUnit/Views/Edit.vue b/app/Domains/CostUnit/Views/Edit.vue new file mode 100644 index 0000000..aca6b6a --- /dev/null +++ b/app/Domains/CostUnit/Views/Edit.vue @@ -0,0 +1,83 @@ + + + diff --git a/app/Domains/CostUnit/Views/List.vue b/app/Domains/CostUnit/Views/List.vue new file mode 100644 index 0000000..019cf68 --- /dev/null +++ b/app/Domains/CostUnit/Views/List.vue @@ -0,0 +1,84 @@ + + + diff --git a/app/Domains/CostUnit/Views/Partials/CostUnitDetails.vue b/app/Domains/CostUnit/Views/Partials/CostUnitDetails.vue new file mode 100644 index 0000000..ebf091d --- /dev/null +++ b/app/Domains/CostUnit/Views/Partials/CostUnitDetails.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/app/Domains/CostUnit/Views/Partials/ListCostUnits.vue b/app/Domains/CostUnit/Views/Partials/ListCostUnits.vue new file mode 100644 index 0000000..a8a1ccd --- /dev/null +++ b/app/Domains/CostUnit/Views/Partials/ListCostUnits.vue @@ -0,0 +1,255 @@ + + + + + diff --git a/app/Domains/CostUnit/Views/Partials/Treasurers.vue b/app/Domains/CostUnit/Views/Partials/Treasurers.vue new file mode 100644 index 0000000..331ebee --- /dev/null +++ b/app/Domains/CostUnit/Views/Partials/Treasurers.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/app/Domains/UserManagement/Controllers/RegistrationController.php b/app/Domains/UserManagement/Controllers/RegistrationController.php index 986a72b..4d9b346 100644 --- a/app/Domains/UserManagement/Controllers/RegistrationController.php +++ b/app/Domains/UserManagement/Controllers/RegistrationController.php @@ -24,7 +24,11 @@ class RegistrationController extends CommonController { } - $inertiaProvider = new InertiaProvider('UserManagement/Registration', ['errors' => $errors, 'appName' => app('tenant')->name]); + $inertiaProvider = new InertiaProvider('UserManagement/Registration', [ + 'errors' => $errors, + 'appName' => app('tenant')->name, + 'tenant' => app('tenant'), + ]); return $inertiaProvider->render(); } diff --git a/app/Domains/UserManagement/Routes/api.php b/app/Domains/UserManagement/Routes/api.php index ed20b73..bb8f8f6 100644 --- a/app/Domains/UserManagement/Routes/api.php +++ b/app/Domains/UserManagement/Routes/api.php @@ -4,14 +4,12 @@ use App\Domains\UserManagement\Controllers\EmailVerificationController; use App\Domains\UserManagement\Controllers\RegistrationController; use App\Domains\UserManagement\Controllers\ResetPasswordController; use App\Middleware\IdentifyTenant; +use App\Providers\GlobalDataProvider; use Illuminate\Support\Facades\Route; use Inertia\Inertia; Route::prefix('v1') ->group(function () { Route::middleware(IdentifyTenant::class)->group(function () { - Route::post('/register', [RegistrationController::class, 'doRegistration']); - Route::post('/register/confirmEmail', [EmailVerificationController::class, 'doVerification']); - Route::post('/reset-password', [ResetPasswordController::class, 'doResetPassword']); }); }); diff --git a/app/Domains/UserManagement/Views/Registration.vue b/app/Domains/UserManagement/Views/Registration.vue index b00b885..ca7f363 100644 --- a/app/Domains/UserManagement/Views/Registration.vue +++ b/app/Domains/UserManagement/Views/Registration.vue @@ -98,7 +98,7 @@ const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute