wip ImportObjekteDirect
This commit is contained in:
1 parent
fe826c3bab
commit
5e1bb7ddcf
6 files changed
+44
-14
No files matched your search
@@ -15,12 +15,14 @@ class Nutzwertberechnung
|
||||
|
||||
$objekte = LadeProjekt::project($projekte_id, false);
|
||||
|
||||
// dd($objekte);
|
||||
|
||||
$html = '';
|
||||
foreach ($objekte as $topnr => $methoden) {
|
||||
|
||||
if (PdfGenerator::$projekt) {
|
||||
$html .= '<table autosize="1">';
|
||||
} else {
|
||||
$html .= '<table autosize="1" style="page-break-inside:avoid;">';
|
||||
}
|
||||
$html .= '<thead><tr>';
|
||||
$html .= '<th class="bl bt bg-user-set">Top Nr.</th>';
|
||||
$html .= '<th class="bt bb bg-user-set">Geschoß</th>';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekte;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use App\Models\User;
|
||||
@@ -29,9 +30,15 @@ class ImportObjekteDirect
|
||||
$top_nummer = trim($cells[0]);
|
||||
$geschoss = trim($cells[1]);
|
||||
$raumart = trim($cells[2]);
|
||||
|
||||
$projekt_methode = ProjektMethode::firstOrNew([
|
||||
'projekte_id' => $projekte_id,
|
||||
'raumart' => $raumart,
|
||||
]);
|
||||
|
||||
$flaeche = (float) str_replace(',', '.', trim($cells[3]));
|
||||
|
||||
if (is_numeric($flaeche) && $flaeche > 0) {
|
||||
if (is_numeric($flaeche) && $flaeche > 0 && $projekt_methode->id) {
|
||||
|
||||
$objekt = ProjektObjekte::where('projekte_id', $projekte_id)
|
||||
->where('top_nummer', $top_nummer)
|
||||
@@ -46,8 +53,8 @@ class ImportObjekteDirect
|
||||
|
||||
$objektImDetail = ProjektObjekteImDetail::where('projekte_id', $projekte_id)
|
||||
->where('projekt_objekte_id', $objekt->id)
|
||||
->where('projekt_methode_id', $projekt_methode->id)
|
||||
->where('geschoss', $geschoss)
|
||||
->where('raumart', $raumart)
|
||||
->first();
|
||||
|
||||
if ($objektImDetail === null) {
|
||||
@@ -56,6 +63,7 @@ class ImportObjekteDirect
|
||||
$objektImDetail = new ProjektObjekteImDetail([
|
||||
'projekte_id' => $projekte_id,
|
||||
'projekt_objekte_id' => $objekt->id,
|
||||
'projekt_methode_id' => $projekt_methode->id,
|
||||
'geschoss' => $geschoss,
|
||||
'raumart' => $raumart,
|
||||
]);
|
||||
|
||||
@@ -106,15 +106,15 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
|
||||
return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
}),
|
||||
ImportColumn::make('raumart')
|
||||
->validationAttribute('Raumart')
|
||||
->example('Stiegenhaus')
|
||||
->rules(['required', 'max:32'])
|
||||
->castStateUsing(function (string $state) {
|
||||
$state = trim($state);
|
||||
// ImportColumn::make('raumart')
|
||||
// ->validationAttribute('Raumart')
|
||||
// ->example('Stiegenhaus')
|
||||
// ->rules(['required', 'max:32'])
|
||||
// ->castStateUsing(function (string $state) {
|
||||
// $state = trim($state);
|
||||
|
||||
return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
}),
|
||||
// return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
// }),
|
||||
ImportColumn::make('flaeche')
|
||||
->label('Fläche')
|
||||
->validationAttribute('Fläche')
|
||||
@@ -137,7 +137,7 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$projektObjekteImDetailDeleted = ProjektObjekteImDetail::where('projekte_id', self::$projekte_id)
|
||||
$projektMethodenDeleted = ProjektMethode::where('projekte_id', self::$projekte_id)
|
||||
->whereNotIn('raumart', self::$raumarts)
|
||||
->delete();
|
||||
|
||||
@@ -146,6 +146,9 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
->whereNotIn('top_nummer', self::$top_nummers)
|
||||
->delete();
|
||||
|
||||
$methodenIds = ProjektMethode::where('projekte_id', self::$projekte_id)->pluck('id')->toArray();
|
||||
$projektObjekteImDetailDeleted = ProjektObjekteImDetail::where('projekte_id', self::$projekte_id)->whereNotIn('projekt_methode_id', $methodenIds)->delete();
|
||||
|
||||
$body = ' Der Import der Objekte ist abgeschlossen. Es wurden '.Number::format($import->successful_rows).' Zeile(n) importiert.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
@@ -155,8 +158,9 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
$body .= '<br/><br/>';
|
||||
$body .= 'Bestehende Objekte: '.self::$count_have.'<br/ >';
|
||||
$body .= 'Neue Objekte: '.self::$count_new.'<br/>';
|
||||
$body .= 'Objekte im Detail gelöscht: '.$projektObjekteImDetailDeleted.'<br/>';
|
||||
$body .= 'Projekt Methoden: '.$projektMethodenDeleted.'<br/>';
|
||||
$body .= 'Objekte gelöscht: '.$projektObjekteDeleted;
|
||||
$body .= 'Objekte im Detail gelöscht: '.$projektObjekteImDetailDeleted;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,20 @@ class ProjekteForm
|
||||
->belowContent('Farbe von Rahmen und Rändern bei Tabellen und Boxen.'),
|
||||
])->columns(4)
|
||||
->columnSpanFull(),
|
||||
Tab::make('PDF')
|
||||
->icon('phosphor-file-pdf')
|
||||
->schema([
|
||||
Radio::make('pdf_nutzwerte_tabellen_umbruch')
|
||||
->label('PDF Nutzwertberechnung')
|
||||
->aboveContent('Bei Tabellen die nicht mehr komplett auf eine Seite passen.')
|
||||
->options([
|
||||
'0' => 'Tabellen zusammenhalten und eine neue Seite beginnen',
|
||||
'1' => 'Tabellen umbrechen',
|
||||
])->afterStateUpdated(function ($record, ?string $state) {
|
||||
Projekte::where('id', $record->id)->update(['pdf_nutzwerte_tabellen_umbruch' => $state]);
|
||||
})->live(),
|
||||
])->columns(2)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
|
||||
])->columnSpanFull(),
|
||||
|
||||
@@ -22,6 +22,7 @@ class Projekte extends Model
|
||||
'schmuckfarbe_header',
|
||||
'farbe_borders',
|
||||
'evaluation_gutachten',
|
||||
'pdf_nutzwerte_tabellen_umbruch',
|
||||
'bezahlt_am',
|
||||
];
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ return new class extends Migration
|
||||
$table->string('schmuckfarbe_header')->nullable();
|
||||
$table->string('farbe_borders')->nullable();
|
||||
$table->boolean('evaluation_gutachten')->default(0);
|
||||
$table->boolean('pdf_nutzwerte_tabllen_umbruch')->default(0);
|
||||
$table->timestamp('bezahlt_am')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
Reference in new issue
Block a user