This commit is contained in:
salam committed 2026-07-05 18:14:23 +02:00
1 parent 16c0aa24fe
commit 4a509c6a16
16 files changed
+168 -82

No files matched your search

+61 -7
View File
@@ -9,12 +9,12 @@ use App\Models\ProjektInhaltsverzeichnis;
use App\Models\ProjektMethode;
use App\Models\ProjektObjekte;
use App\Models\ProjektObjekteImDetail;
use App\Models\ProjektPlatzhalter;
// use App\Models\ProjektPlatzhalter;
use Filament\Notifications\Notification;
class GutachtenValidation
{
public static function controll($record)
public static function run(Projekte $record)
{
/**
* Projekt
@@ -49,7 +49,7 @@ class GutachtenValidation
->duration(10000)
->body('Die Tabelle der <b>Allgemeinflächen</b> ist leer.')
->send();
return false;
}
foreach ($res as $value) {
@@ -61,7 +61,7 @@ class GutachtenValidation
->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) {
@@ -83,21 +83,73 @@ class GutachtenValidation
->duration(10000)
->body('Für die Allgemeinfläche <b>'.$value->raumart.'</b> fehlt die Angabe der <u>Fläche</u>.')
->send();
return false;
}
}
/**
* jedes objekt hat mindestens ein objekt im detail
*/
$res = ProjektObjekte::where('projekte_id', $record->id)->get();
$collect = [];
foreach ($res as $value) {
$res2 = ProjektObjekteImDetail::where('projekte_id', $record->id)->where('projekt_objekte_id', $value->id)->first();
if(!$res2){
$collect[] = $value->top_nummer;
}
}
if($collect){
Notification::make()
->title('Fehler bei Verbindungen von Objekt zu Objekt im Detail')
->body('Für die <u>Objekte</u>:<div class="py-2 text-gray-500">'.implode(', ', $collect).'</div>fehlen die <u>Objekte im Detail</u>. Daten können nochmals hochladen werden.')
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->danger()
->send();
return false;
}
/**
* jedes objekt im detail hat eine Verbindung zu einem objekt
*/
$res = ProjektObjekteImDetail::where('projekte_id', $record->id)->get();
$collect=[];
foreach ($res as $value) {
$res2 = ProjektObjekte::where('projekte_id', $record->id)->where('id', $value->projekt_objekte_id)->first();
if(!$res2){
$collect[] = $value->geschoss .' '.$value->raumart;
}
}
if($collect){
Notification::make()
->title('Fehler bei Verbindungen von Objekt im Detail zu Objekt')
->body('Für die <u>Objekte im Detail</u>: <div class="py-2 text-gray-500">'.implode(', ', $collect).'</div>fehlt das<u>Objekte</u>. Daten können nochmals hochladen werden.')
->icon('heroicon-o-exclamation-triangle')
->duration(10000)
->danger()
->send();
return false;
}
/**
* ProjektObjekteImDetail + raumart
* -> cosistent
* ProjektMethode + raumart
*/
$raumarts_oid = ProjektObjekteImDetail::where('projekte_id', $record->id)->groupBy('raumart')->pluck('raumart')->toArray();
$raumarts_meth = ProjektMethode::where('projekte_id', $record->id)->pluck('raumart')->toArray();
$extra_oid = array_diff($raumarts_oid, $raumarts_meth);
$extra_meth = array_diff($raumarts_meth, $raumarts_oid);
// dd($extra_oid, $raumarts_meth);
if ($extra_oid) {
$titel = \count($extra_oid) == 1 ? 'Für diese "Raumart" aus "Objekte im Detail" ist keine "Raum Methode" definiert' : 'Für diese "Raumarten" aus "Objekte im Detail" sind keine "Raum Methoden" definiert';
@@ -202,7 +254,7 @@ class GutachtenValidation
->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) {
@@ -281,7 +333,7 @@ class GutachtenValidation
->body('Inhaltsverzeichnis fehlt!')
->duration(10000)
->send();
return false;
}
@@ -309,5 +361,7 @@ class GutachtenValidation
->send();
Projekte::where('id', $record->id)->update(['evaluation_gutachten' => 1]);
return true;
}
}