266 lines
9.7 KiB
PHP
266 lines
9.7 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Validation;
|
|
|
|
use App\Models\ProjektAllgemeinflaechen;
|
|
use App\Models\Projekte;
|
|
use App\Models\ProjektInhaltsverzeichnis;
|
|
use App\Models\ProjektMethode;
|
|
use App\Models\ProjektOrientierungZuAbschlaege;
|
|
use App\Models\ProjektPlatzhalter;
|
|
use App\Models\ProjektRaeumealle;
|
|
use Filament\Notifications\Notification;
|
|
|
|
class GutachtenValidation
|
|
{
|
|
public static function controll($record)
|
|
{
|
|
/**
|
|
* ProjektAllgemeinflaechen
|
|
*/
|
|
$res = ProjektAllgemeinflaechen::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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ProjektRaeumealle
|
|
*/
|
|
$res = ProjektRaeumealle::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 = ProjektOrientierungZuAbschlaege::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 = ProjektOrientierungZuAbschlaege::where('projekte_id', $record->id)->where('nicht_in_orientierung', false)->get();
|
|
foreach ($res as $value) {
|
|
if (! $value->orientierung_id && ! $value->nicht_in_orientierung) {
|
|
Notification::make()
|
|
->title('Orientierung Zu und Abschläge')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Bei der Top Nummer <b>'.$value->top_nummer.'</b> fehlt die <u>Orientierung</u>.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
if (! $value->orientierung_id && ! $value->type) {
|
|
Notification::make()
|
|
->title('Orientierung Zu und Abschläge')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Bei der Top Nummer <b>'.$value->top_nummer.'</b> fehlt der <u>Type</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]);
|
|
}
|
|
}
|