diff --git a/app/Http/Controllers/ReservaController.php b/app/Http/Controllers/ReservaController.php index ce3e87c..13d66b5 100644 --- a/app/Http/Controllers/ReservaController.php +++ b/app/Http/Controllers/ReservaController.php @@ -368,9 +368,12 @@ public function destroy(Request $request, Reserva $reserva) $parent_id = $reserva->parent_id; $purge = !is_null($request->input('purge')); + $justificativa = $request->input('justificativa_recusa'); + $reserva->removerTarefa_AprovacaoAutomatica(); - if(config('salas.emailConfigurado')) Mail::queue(new DeleteReservaMail($reserva, $purge)); + if(config('salas.emailConfigurado')) + Mail::queue(new DeleteReservaMail($reserva, $purge, $justificativa)); if($purge){ Reserva::where('parent_id', $reserva->parent_id)->delete(); diff --git a/app/Http/Controllers/SalaController.php b/app/Http/Controllers/SalaController.php index 8e042ce..fa3fc5b 100644 --- a/app/Http/Controllers/SalaController.php +++ b/app/Http/Controllers/SalaController.php @@ -204,6 +204,7 @@ public function update(SalaRequest $request, Sala $sala) 'periodo_letivo_id' => $validated['periodo_letivo'], 'aprovacao' => $validated['aprovacao'], 'prazo_aprovacao' => $validated['prazo_aprovacao'], + 'exige_justificativa_recusa' => $validated['exige_justificativa_recusa'], ] ); diff --git a/app/Http/Requests/SalaRequest.php b/app/Http/Requests/SalaRequest.php index d791071..28b2051 100644 --- a/app/Http/Requests/SalaRequest.php +++ b/app/Http/Requests/SalaRequest.php @@ -44,6 +44,7 @@ public function rules() 'instrucoes_reserva' => 'nullable', 'aceite_reserva' => 'nullable', 'prazo_aprovacao' => 'nullable|integer', + 'exige_justificativa_recusa' => 'required|integer', ]; } diff --git a/app/Mail/DeleteReservaMail.php b/app/Mail/DeleteReservaMail.php index 0d24251..240391d 100644 --- a/app/Mail/DeleteReservaMail.php +++ b/app/Mail/DeleteReservaMail.php @@ -12,19 +12,21 @@ class DeleteReservaMail extends Mailable { - use Queueable, SerializesModels; + use Queueable; // SerializesModels provocava erro de reserva já deletada e tendo acessá-la private $reserva; private $purge; + private $justificativa; /** * Create a new message instance. * * @return void */ - public function __construct(Reserva $reserva, bool $purge = false) + public function __construct(Reserva $reserva, bool $purge = false, string $justificativa = null) { $this->reserva = $reserva; $this->purge = $purge; + $this->justificativa = $justificativa; } /** @@ -40,7 +42,8 @@ public function build() ->to($user->email) ->with([ 'reserva' => $this->reserva, - 'purge' => $this->purge + 'purge' => $this->purge, + 'justificativa' => $this->justificativa ]); } } diff --git a/database/migrations/2026_01_14_113400_add_exige_justificativa_recusa_column_to_restricoes_table.php b/database/migrations/2026_01_14_113400_add_exige_justificativa_recusa_column_to_restricoes_table.php new file mode 100644 index 0000000..7808a22 --- /dev/null +++ b/database/migrations/2026_01_14_113400_add_exige_justificativa_recusa_column_to_restricoes_table.php @@ -0,0 +1,32 @@ +boolean('exige_justificativa_recusa')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('restricoes', function (Blueprint $table) { + $table->dropColumn('exige_justificativa_recusa'); + }); + } +} diff --git a/database/migrations/2026_01_15_142100_add_justificativa_recusa_column_to_reservas_table.php b/database/migrations/2026_01_15_142100_add_justificativa_recusa_column_to_reservas_table.php new file mode 100644 index 0000000..fd58861 --- /dev/null +++ b/database/migrations/2026_01_15_142100_add_justificativa_recusa_column_to_reservas_table.php @@ -0,0 +1,32 @@ +text('justificativa_recusa')->nullable()->after('status'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('reservas', function (Blueprint $table) { + $table->dropColumn('justificativa_recusa'); + }); + } +} diff --git a/resources/views/emails/delete_reserva.blade.php b/resources/views/emails/delete_reserva.blade.php index d9f8939..3796377 100644 --- a/resources/views/emails/delete_reserva.blade.php +++ b/resources/views/emails/delete_reserva.blade.php @@ -15,6 +15,14 @@
Data: {{$reserva->data}}
@endif +@if (!empty($justificativa)) +Mensagem automática do sistema de reserva de salas: {{route('home')}}
\ No newline at end of file +Mensagem automática do sistema de reserva de salas: {{route('home')}}
diff --git a/resources/views/reserva/partials/fields.blade.php b/resources/views/reserva/partials/fields.blade.php index c9fcb39..70de0b9 100644 --- a/resources/views/reserva/partials/fields.blade.php +++ b/resources/views/reserva/partials/fields.blade.php @@ -21,7 +21,7 @@ @if ($reserva->status == 'pendente')