fix pdf methoth not showing, add in ObjekteImDetail projekt_methode_id for relation (kick out raumart for relation)
This commit is contained in:
1 parent
d95452bc9d
commit
fe826c3bab
8 files changed
+203
-37
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Projekte;
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class FixMethodRelations extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* app:fix-method-relations
|
||||
*/
|
||||
protected $signature = 'app:fixdb1 {--d}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Fix relation in table "projekt_objekte_im_details" mit "projekt_methodes" id';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Notice::note('Start FixMethodRelations', 'b');
|
||||
|
||||
$projekte = Projekte::get();
|
||||
|
||||
foreach ($projekte as $projekt) {
|
||||
|
||||
$projektid = $projekt->id;
|
||||
|
||||
$methoden = ProjektMethode::where('projekte_id', $projektid)->pluck('id', 'raumart')->toArray();
|
||||
|
||||
$res = ProjektObjekteImDetail::where('projekte_id', $projektid)->get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
|
||||
if (! $value->projekt_methode_id) {
|
||||
|
||||
if (isset($methoden[$value->raumart])) {
|
||||
$projekt_methode_id = $methoden[$value->raumart];
|
||||
|
||||
ProjektObjekteImDetail::where('id', $value->id)->update(['projekt_methode_id' => $projekt_methode_id]);
|
||||
} else {
|
||||
Notice::note('Error: Methode für Raumart '.$value->raumart.' in Projekt'.$projekt->interner_name.' Id '.$projekt->id.' Methode missing', 'r');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
class Notice
|
||||
{
|
||||
// note
|
||||
|
||||
public static function db($message, $exit = false)
|
||||
{
|
||||
echo "\e[0;35m";
|
||||
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message.PHP_EOL;
|
||||
}
|
||||
echo '-----------------------------------------------------------'.PHP_EOL;
|
||||
echo "\e[0;39m";
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static function note($message, $color = '', $exit = false)
|
||||
{
|
||||
switch ($color) {
|
||||
case 'g':
|
||||
// green
|
||||
echo "\e[0;32m";
|
||||
break;
|
||||
case 'gb':
|
||||
case 'bg':
|
||||
// bold green
|
||||
echo "\e[1;32m";
|
||||
break;
|
||||
case 'r':
|
||||
// red
|
||||
echo "\e[0;31m";
|
||||
break;
|
||||
case 'br':
|
||||
case 'rb':
|
||||
// bold red
|
||||
echo "\e[1;31m";
|
||||
break;
|
||||
case 'b':
|
||||
// blue
|
||||
echo "\e[0;34m";
|
||||
break;
|
||||
case 'bb':
|
||||
// bold blue
|
||||
echo "\e[1;34m";
|
||||
break;
|
||||
case 'y':
|
||||
// yellow
|
||||
echo "\e[0;33m";
|
||||
break;
|
||||
case 'p':
|
||||
// purple
|
||||
echo "\e[0;35m";
|
||||
break;
|
||||
case 'c':
|
||||
// cyan
|
||||
echo "\e[0;36m";
|
||||
break;
|
||||
case 'bi':
|
||||
// blue intence
|
||||
echo "\e[38;5;33m\n";
|
||||
break;
|
||||
default:
|
||||
echo "\e[0;39m";
|
||||
break;
|
||||
}
|
||||
|
||||
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL;
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message.PHP_EOL;
|
||||
}
|
||||
echo '-----------------------------------------------------------'.PHP_EOL;
|
||||
echo "\e[0;39m";
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static function html($message, $color = '', $exit = false)
|
||||
{
|
||||
switch ($color) {
|
||||
case 'g':
|
||||
echo '<div style="margin:10px; padding:3px; color:green; width=20rem; text-align:center; border:solid 1px green; background-color:lightgreen;">';
|
||||
break;
|
||||
case 'r':
|
||||
echo '<div style="margin:10px; padding:3px; color:red; width=20rem; text-align:center; border:solid 1px red; background-color:#fdd;">';
|
||||
break;
|
||||
case 'b':
|
||||
echo '<div style="margin:10px; padding:3px; color:blue; width=20rem; text-align:center; border:solid 1px blue; background-color:lightblue;">';
|
||||
break;
|
||||
default:
|
||||
echo '<div style="margin:10px; padding:3px; color:black; width=20rem; text-align:center; border:solid 1px black; background-color:#eee;">';
|
||||
break;
|
||||
}
|
||||
if (is_array($message)) {
|
||||
print_r($message);
|
||||
} else {
|
||||
echo $message;
|
||||
}
|
||||
echo '</div>';
|
||||
if ($exit) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekte;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
@@ -40,9 +41,16 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
->where('top_nummer', $this->data['top_nummer'])
|
||||
->value('id');
|
||||
|
||||
$projekt_methode_id = ProjektMethode::firstOrNew([
|
||||
'projekte_id' => self::$projekte_id,
|
||||
'raumart' => $this->data['raumart'],
|
||||
]);
|
||||
|
||||
if ($projekt_objekte_id && ProjektObjekteImDetail::where('projekte_id', self::$projekte_id)
|
||||
->where('projekt_objekte_id', $projekt_objekte_id)
|
||||
->where('raumart', $this->data['raumart'])->first()) {
|
||||
->where('projekt_methode_id', $projekt_methode_id)
|
||||
->first()
|
||||
) {
|
||||
self::$count_have++;
|
||||
} else {
|
||||
self::$count_new++;
|
||||
@@ -51,7 +59,7 @@ class ProjektObjekteImDetailImporter extends Importer
|
||||
return ProjektObjekteImDetail::firstOrNew([
|
||||
'projekte_id' => self::$projekte_id,
|
||||
'projekt_objekte_id' => $projekt_objekte_id,
|
||||
'raumart' => $this->data['raumart'],
|
||||
'projekt_methode_id' => $projekt_methode_id,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -6,6 +6,7 @@ use App\Actions\Create\CreateProjektMethoden;
|
||||
use App\Models\Aufstellung;
|
||||
use App\Models\Methode;
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
@@ -97,7 +98,9 @@ class ProjektMethodesRelationManager extends RelationManager
|
||||
DeleteAction::make()
|
||||
->iconButton()
|
||||
->modalDescription(new HtmlString('Es werden auch alle damit verbundenen <b>Räume im Detail</b> gelöscht.'))
|
||||
->after(function (Component $livewire) {
|
||||
->after(function ($record, Component $livewire) {
|
||||
ProjektObjekteImDetail::where('projekt_methode_id', $record->id)->delete();
|
||||
|
||||
$livewire->dispatch('refreshProjektObjekteImDetail');
|
||||
})->successNotification(
|
||||
Notification::make()
|
||||
|
||||
+11
-28
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use App\Filament\Imports\ImportObjekteDirect;
|
||||
use App\Models\ProjektMethode;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
@@ -18,6 +19,7 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\Summarizers\Sum;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -45,9 +47,10 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
->relationship('top_nummer', 'top_nummer', fn (Builder $query) => $query->where('projekte_id', $this->getOwnerRecord()->id))
|
||||
->required()
|
||||
->searchable(),
|
||||
TextInput::make('raumart')
|
||||
Select::make('projekt_methode_id')
|
||||
->relationship('methode', 'raumart', fn (Builder $query) => $query->where('projekte_id', $this->getOwnerRecord()->id))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->searchable(),
|
||||
TextInput::make('geschoss')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
@@ -81,7 +84,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
->searchable()
|
||||
->label('Top'),
|
||||
TextColumn::make('geschoss')->searchable(),
|
||||
TextColumn::make('raumart')->searchable()->sortable(),
|
||||
TextColumn::make('methode.raumart')->searchable()->sortable(),
|
||||
TextColumn::make('methode.faktor')
|
||||
->numeric(2, ',')
|
||||
->icon('phosphor-function')
|
||||
@@ -97,28 +100,6 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
->alignment('right')
|
||||
->label('Fläche')
|
||||
->searchable(),
|
||||
// TextInputColumn::make('flaeche')
|
||||
// ->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
// ->summarize(Sum::make()->label('Gesammt')->numeric(
|
||||
// decimalPlaces: 2,
|
||||
// )->suffix(new HtmlString(' m²')))
|
||||
// ->suffix(new HtmlString(' m²'))
|
||||
// ->width('2rem')
|
||||
// ->alignment('right')
|
||||
// ->rules(['required'])
|
||||
// ->label('Fläche')
|
||||
// ->searchable()
|
||||
// ->afterStateUpdated(function ($record, Component $livewire) {
|
||||
// $object = ProjektObjekteImDetail::find($record['id']);
|
||||
// $object->nutzwert = round($record->methode->faktor * $object->flaeche, 2);
|
||||
// $object->save();
|
||||
|
||||
// $livewire->dispatch('refreshProjektObjekteImDetail');
|
||||
|
||||
// })->validationMessages([
|
||||
// 'required' => 'Die Eingabe einer Fläche ist erforderlich.',
|
||||
// 'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
|
||||
// ]),
|
||||
TextColumn::make('nutzwert')
|
||||
->alignCenter()
|
||||
->summarize(Sum::make()->label('Gesammt'))
|
||||
@@ -134,13 +115,15 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
->options(function (): array {
|
||||
return ProjektObjekteImDetail::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('geschoss')->orderBy('geschoss')->pluck('geschoss', 'geschoss')->toArray();
|
||||
}),
|
||||
SelectFilter::make('raumart')
|
||||
SelectFilter::make('projekt_methode_id')
|
||||
->label('Methode')
|
||||
->searchable()
|
||||
->options(function (): array {
|
||||
return ProjektObjekteImDetail::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('raumart')->orderBy('raumart')->pluck('raumart', 'raumart')->toArray();
|
||||
return ProjektMethode::where('projekte_id', $this->getOwnerRecord()->id)->orderBy('raumart')->pluck('raumart', 'id')->toArray();
|
||||
}),
|
||||
])
|
||||
], FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->filtersFormColumns(4)
|
||||
->headerActions([
|
||||
Action::make('import-text')
|
||||
->icon('phosphor-upload')
|
||||
|
||||
@@ -19,6 +19,7 @@ class ProjektesTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id'),
|
||||
TextColumn::make('interner_name')
|
||||
->tooltip(fn ($record): HtmlString => new HtmlString($record->beschreibung))
|
||||
->label('Interner Name')
|
||||
|
||||
@@ -34,13 +34,8 @@ class ProjektObjekteImDetail extends Model
|
||||
return $this->belongsTo(ProjektObjekte::class, 'projekt_objekte_id', 'id');
|
||||
}
|
||||
|
||||
public function merkmale()
|
||||
{
|
||||
return $this->hasOne(ProjektMerkmale::class, 'raumart', 'raumart');
|
||||
}
|
||||
|
||||
public function methode()
|
||||
{
|
||||
return $this->belongsTo(ProjektMethode::class, 'raumart', 'raumart');
|
||||
return $this->belongsTo(ProjektMethode::class, 'projekt_methode_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user