270 lines
9.7 KiB
PHP
270 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\ProjektObjekte;
|
|
use App\Models\ProjektObjekteImDetail;
|
|
use App\Models\ProjektPlatzhalter;
|
|
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('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) {
|
|
|
|
$raeume = $value->ProjektObjekteImDetail->toArray();
|
|
$raeume = $raeume[0] ?? [];
|
|
|
|
if (! count($raeume)) {
|
|
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 (! $raeume['geschoss']) {
|
|
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 des <u>Geschoßes</u>.')
|
|
->send();
|
|
|
|
return false;
|
|
}
|
|
if (! $raeume['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 (! $raeume['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;
|
|
}
|
|
// KANN 0 SEIN
|
|
// if ($value->faktor == 0) {
|
|
// 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 Angabe des <u>Faktors</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]);
|
|
}
|
|
}
|