266 lines
9.4 KiB
PHP
266 lines
9.4 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Validation;
|
|
|
|
use App\Models\Gutachter;
|
|
use App\Models\ProjektAllgemeinflaechen;
|
|
use App\Models\Projekte;
|
|
use App\Models\ProjektInhaltsverzeichnis;
|
|
use App\Models\ProjektMethode;
|
|
use App\Models\ProjektObjekte;
|
|
use App\Models\ProjektObjekteImDetail;
|
|
use App\Models\ProjektPlatzhalter;
|
|
use Filament\Notifications\Notification;
|
|
|
|
class GutachtenValidation
|
|
{
|
|
public static function controll($record)
|
|
{
|
|
/**
|
|
* Projekt
|
|
*/
|
|
$pro = Projekte::where('id', $record->id)->first();
|
|
|
|
/**
|
|
* Gutachter
|
|
*/
|
|
$res = Gutachter::where('konto_id', auth()->user()->konto_id)->where('id', $pro->gutachter_id)->first();
|
|
if (! $res->digitale_signatur_stempel) {
|
|
Notification::make()
|
|
->title('Gutacher')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Es fehlt der Stempel für die <b>Digitale Signatur</b>.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* ProjektAllgemeinflaechen
|
|
*/
|
|
$res = ProjektAllgemeinflaechen::where('projekte_id', $record->id)->get();
|
|
if (! $res->count()) {
|
|
Notification::make()
|
|
->title('Tabelle 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('Tabelle 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('Tabelle 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('Tabelle 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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ProjektObjekte + nicht_in_orientierung
|
|
*/
|
|
$res = ProjektObjekte::where('projekte_id', $record->id)->get();
|
|
if (! $res->count()) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Die Tabelle <b>Objekte</b> ist leer.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
$res = ProjektObjekte::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('Tabelle Objekte')
|
|
->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('Tabelle Objekte')
|
|
->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;
|
|
}
|
|
}
|
|
/**
|
|
* ProjektObjekte & ProjektObjekteImDetail
|
|
*/
|
|
$res = ProjektObjekte::with('projektobjekteimdetail')->where('projekte_id', $record->id)->get();
|
|
if (! $res->count()) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte im Detail')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Die Tabelle <b>Objekte im Detail</b> ist leer.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
|
|
foreach ($res as $value) {
|
|
|
|
if (! count($value->projektobjekteimdetail)) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Der Top Nummer <b>'.$value->top_nummer.'</b> sind keine Räume zugeordnet.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
if (! $value->top_nummer) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Für den Raum mit der ID <b>'.$value->id.'</b> fehlt die Angabe der <u>Top Nummer</u>.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
if (! $value->projektobjekteimdetail->first()->raumart) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte im Detail')
|
|
->info()
|
|
->icon('heroicon-o-exclamation-triangle')
|
|
->duration(10000)
|
|
->body('Beim Objekt Top Nummer <b>'.$value->top_nummer.'</b> fehlt die Angabe der <u>Raumart</u>.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
if (! $value->projektobjekteimdetail->first()->flaeche) {
|
|
Notification::make()
|
|
->title('Tabelle Objekte im Detail')
|
|
->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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Projekt Methode
|
|
*/
|
|
$res = ProjektMethode::where('projekte_id', $record->id)->get();
|
|
if (! $res->count()) {
|
|
Notification::make()
|
|
->title('Tabelle 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('Tabelle 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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ProjektInhaltsverzeichnis
|
|
*/
|
|
$res = ProjektInhaltsverzeichnis::where('projekte_id', $record->id)->get();
|
|
if (! $res->count()) {
|
|
Notification::make()
|
|
->title('Tabelle 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('Tabelle 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('Evaluierung')
|
|
->success()
|
|
->duration(10000)
|
|
->body('Die Evaluierung des Projektes war erfolgreich.')
|
|
->send();
|
|
|
|
Projekte::where('id', $record->id)->update(['evaluation_gutachten' => 1]);
|
|
}
|
|
}
|