Files
nutzwerte_fi4/app/Actions/Validation/GutachtenValidation.php
T
2025-10-21 18:00:44 +02:00

255 lines
9.2 KiB
PHP

<?php
namespace App\Actions\Validation;
use App\Models\Allgemeinflaechen;
use App\Models\OrientierungZuAbschlaege;
use App\Models\Projekte;
use App\Models\ProjektInhaltsverzeichnis;
use App\Models\ProjektMethode;
use App\Models\ProjektPlatzhalter;
use App\Models\Raeumealle;
use Filament\Notifications\Notification;
class GutachtenValidation
{
public static function controll($record)
{
/**
* Allgemeinflaechen
*/
$res = Allgemeinflaechen::where('projekte_id', $record->id)->get();
if (! $res->count()) {
Notification::make()
->title('Allgemeinflächen')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Die Tabelle der <b>Allgemeinflächen</b> ist leer.')
->send();
return false;
}
foreach ($res as $value) {
if (! $value->geschoss) {
Notification::make()
->title('Allgemeinflächen')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für die Allgemeinfläche <b>'.$value->raumart.'</b> fehlt die Angabe des <u>Geschoßes</u>.')
->send();
return false;
}
if (! $value->raumart) {
Notification::make()
->title('Allgemeinflächen')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für eine Allgemeinfläche im Geschoss <b>'.$value->geschoss.'</b> fehlt die Angabe der <u>Raumart</u>.')
->send();
return false;
}
if ($value->flaeche == 0) {
Notification::make()
->title('Allgemeinflächen')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für die Allgemeinfläche <b>'.$value->raumart.'</b> fehlt die Angabe der <u>Fläche</u>.')
->send();
return false;
}
}
/**
* Raeumealle
*/
$res = Raeumealle::where('projekte_id', $record->id)->get();
if (! $res->count()) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Die Tabelle <b>Räume Alle</b> ist leer.')
->send();
return false;
}
foreach ($res as $value) {
if (! $value->top_nummer) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum <b>'.$value->raumart.'</b> im Geschoss <b>'.$value->geschoss.'</b> fehlt die Angabe der <u>Top Nummer</u>.')
->send();
return false;
}
if (! $value->geschoss) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum <b>'.$value->raumart.'</b> mit der Top Nummer <b>'.$value->top_nummer.'</b> fehlt die Angabe der <u>Geschoßes</u>.')
->send();
return false;
}
if (! $value->raumart) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum mit der Top Nummer <b>'.$value->top_nummer.'</b> im Geschoßes <b>'.$value->geschoss.'</b> fehlt die Angabe der <u>Raumart</u>.')
->send();
return false;
}
if ($value->flaeche == 0) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für die Raumart <b>'.$value->raumart.'</b> mit der Top Nummer <b>'.$value->top_nummer.'</b> im Geschoss <b>'.$value->geschoss.'</b> fehlt die Angabe der <u>Fläche</u>.')
->send();
return false;
}
if ($value->faktor == 0) {
Notification::make()
->title('Räume Alle')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für die Raumart <b>'.$value->raumart.'</b> mit der Top Nummer <b>'.$value->top_nummer.'</b> im Geschoss <b>'.$value->geschoss.'</b> fehlt die Angabe des <u>Faktors</u>.')
->send();
return false;
}
}
/**
* Projekt Methode
*/
$res = ProjektMethode::where('projekte_id', $record->id)->get();
if (! $res->count()) {
Notification::make()
->title('Räume Methoden')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Die Tabelle <b>Raum Methode</b> ist leer.')
->send();
return false;
}
foreach ($res as $value) {
if (! $value->methode_id) {
Notification::make()
->title('Räume Methoden')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum <b>'.$value->raumart.'</b> fehlt die <u>Methode</u>.')
->send();
return false;
}
if ($value->faktor == 0) {
Notification::make()
->title('Räume Methoden')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum <b>'.$value->raumart.'</b> fehlt die Angabe des <u>Faktors</u>.')
->send();
return false;
}
}
/**
* Orientierung Zu und Abschläge
*/
$res = OrientierungZuAbschlaege::where('projekte_id', $record->id)->get();
if (! $res->count()) {
Notification::make()
->title('Orientierung Zu und Abschläge')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Die Tabelle <b>Orientierung Zu und Abschläge</b> ist leer.')
->send();
return false;
}
$res = OrientierungZuAbschlaege::where('projekte_id', $record->id)->where('nicht_in_orientierung', false)->get();
foreach ($res as $value) {
if (! $value->orientierung_id) {
Notification::make()
->title('Orientierung Zu und Abschläge')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Für den Raum <b>'.$value->raumart.'</b> mit der Top Nummer <b>'.$value->top_nummer.'</b> fehlt die <u>Orientierung</u>.')
->send();
return false;
}
}
/**
* ProjektInhaltsverzeichnis
*/
$res = ProjektInhaltsverzeichnis::where('projekte_id', $record->id)->get();
if (! $res->count()) {
Notification::make()
->title('Inhaltsverzeichnis')
->info()
->icon('heroicon-o-exclamation-triangle')
->body('Inhaltsverzeichnis fehlt!')
->duration(10000)
->send();
return false;
}
/**
* ProjektPlatzhalter
*/
$res = ProjektPlatzhalter::where('projekte_id', $record->id)->whereNull('platzhaltertext')->orWhere('platzhaltertext', '=', '')->get();
if ($res->count()) {
Notification::make()
->title('Platzhalter')
->info()
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->body('Bitte füllen Sie die fehlenden Platzhalter aus. Sollten die fehlenden Platzhalter nicht mehr gebraucht werden löschen Sie diese aus dem Text und generieren sie die Platzhalter Tabelle neu.')
->send();
return false;
}
Notification::make()
->title('Evaluation')
->success()
->duration(10000)
->body('Die Evaluierung des Projektes war erfolgreich.')
->send();
Projekte::where('id', $record->id)->update(['evaluation_gutachten' => 1]);
}
}