This commit is contained in:
salam committed 2026-05-14 12:01:20 +02:00
1 parent 48deb69379
commit e34fa82499
16 files changed
+235 -228

No files matched your search

+45 -49
View File
@@ -16,13 +16,11 @@ class ImportObjekteDirect
$data = explode(PHP_EOL, $data['upload_data']);
$has_objekte = ProjektObjekte::where('projekte_id', $projekte_id)->count();
$has_detail = ProjektObjekteImDetail::where('projekte_id', $projekte_id)->count();
$new_objekte = 0;
$new_detail = 0;
$update_objekte = 0;
$update_detail = 0;
$projekt_objekte_check = 0;
$has_objekte_im_detail = ProjektObjekteImDetail::where('projekte_id', $projekte_id)->count();
$new_objekte_im_detail = 0;
$update_objekte_im_detail = 0;
foreach ($data as $row) {
$row = str_replace(';', '|', $row);
@@ -35,69 +33,67 @@ class ImportObjekteDirect
if (is_numeric($flaeche) && $flaeche > 0) {
$projekt_objekte = ProjektObjekte::firstOrCreate([
'projekte_id' => $projekte_id,
'top_nummer' => $top_nummer,
]);
$objekt = ProjektObjekte::where('projekte_id', $projekte_id)
->where('top_nummer', $top_nummer)
->first();
if ($projekt_objekte->new) { // some way to check
if ($projekt_objekte_check != $projekt_objekte->id) {
$new_objekte++;
}
} else {
if ($projekt_objekte_check != $projekt_objekte->id) {
$update_objekte++;
}
if ($objekt === null) {
$new_objekte++;
$objekt = new ProjektObjekte(['projekte_id' => $projekte_id, 'top_nummer' => $top_nummer]);
$objekt->save();
}
$projekt_objekte_check = $projekt_objekte->id;
$prokectimdetail = ProjektObjekteImDetail::firstOrCreate(
['projekte_id' => $projekte_id, 'projekt_objekte_id' => $projekt_objekte->id, 'geschoss' => $geschoss, 'raumart' => $raumart],
['flaeche' => $flaeche]
);
$objektImDetail = ProjektObjekteImDetail::where('projekte_id', $projekte_id)
->where('projekt_objekte_id', $objekt->id)
->where('geschoss', $geschoss)
->where('raumart', $raumart)
->first();
if ($prokectimdetail->new) { // some way to check
$new_detail++;
if ($objektImDetail === null) {
$new_objekte_im_detail++;
$objektImDetail = new ProjektObjekteImDetail([
'projekte_id' => $projekte_id,
'projekt_objekte_id' => $objekt->id,
'geschoss' => $geschoss,
'raumart' => $raumart,
]);
} else {
$update_detail++;
$update_objekte_im_detail++;
}
$objektImDetail->flaeche = $flaeche;
$objektImDetail->save();
}
}
Notification::make()
->title('Objekte im Detail wurden erfolgreich importiert')
->success()
->send();
/** @var User $user * */
$recipient = Auth::user();
Notification::make()
->title('Objekte im Detail wurden erfolgreich importiert')
->body(self::getBody($has_objekte, $has_detail, $new_objekte, $new_detail, $update_objekte, $update_detail))
->body(self::getBody($has_objekte, $has_objekte_im_detail, $new_objekte, $new_objekte_im_detail, $update_objekte_im_detail))
->success()
->send()
->sendToDatabase($recipient);
}
public static function getBody($has_objekte, $has_detail, $new_objekte, $new_detail, $update_objekte, $update_detail)
public static function getBody($has_objekte, $has_objekte_im_detail, $new_objekte, $new_objekte_im_detail, $update_objekte_im_detail)
{
return new HtmlString('<div class="grid grid-cols-2 gap-2 w-full">
<div class="col-span-2">Objekte</div>
<div>Bestehende</div>
<div>'.$has_objekte.'</div>
<div>Geänderte</div>
<div>'.$update_objekte.'</div>
<div>Neue</div>
<div>'.$new_objekte.'</div>
<div class="col-span-2">Objekte im Detail</div>
<div>Bestehende</div>
<div>'.$has_detail.'</div>
<div>Geänderte</div>
<div>'.$update_detail.'</div>
<div>Neue</div>
<div>'.$new_detail.'</div>
return new HtmlString('<div class="grid grid-cols-4 gap-1 w-full">
<div class="col-span-4 text-gray-500 font-bold">Objekte</div>
<div class="col-span-3 text-primary-500">Vorher</div>
<div class="text-primary-500">'.$has_objekte.'</div>
<div class="col-span-3 text-success-500">Neu</div>
<div class="text-success-500">'.$new_objekte.'</div>
<div class="col-span-4 text-gray-500 font-bold">Objekte im Detail</div>
<div class="col-span-3 text-primary-500">Vorher</div>
<div class="text-primary-500">'.$has_objekte_im_detail.'</div>
<div class="col-span-3 text-success-500">Neu</div>
<div class="text-success-500">'.$new_objekte_im_detail.'</div>
<div class="col-span-3 text-warning-500">Aktualisiert</div>
<div class="text-warning-500">'.$update_objekte_im_detail.'</div>
</div>');
}
}