Added 'created_by', 'updated_by' columns StickerMaster screens #317
@@ -76,8 +76,12 @@ class StickerMasterExporter extends Exporter
|
|||||||
->label('MATERIAL TYPE'),
|
->label('MATERIAL TYPE'),
|
||||||
ExportColumn::make('bundle_quantity')
|
ExportColumn::make('bundle_quantity')
|
||||||
->label('BUNDLE QUANTITY'),
|
->label('BUNDLE QUANTITY'),
|
||||||
|
ExportColumn::make('created_by')
|
||||||
|
->label('CREATED BY'),
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
->label('CREATED AT'),
|
->label('CREATED AT'),
|
||||||
|
ExportColumn::make('updated_by')
|
||||||
|
->label('UPDATED BY'),
|
||||||
ExportColumn::make('updated_at')
|
ExportColumn::make('updated_at')
|
||||||
->label('UPDATED AT'),
|
->label('UPDATED AT'),
|
||||||
ExportColumn::make('deleted_at')
|
ExportColumn::make('deleted_at')
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|||||||
use Filament\Actions\Imports\ImportColumn;
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
class StickerMasterImporter extends Importer
|
class StickerMasterImporter extends Importer
|
||||||
@@ -163,8 +164,13 @@ class StickerMasterImporter extends Importer
|
|||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plantCod = $this->data['plant'];
|
$plantCod = $this->data['plant'];
|
||||||
|
$itemCod = $this->data['item'];
|
||||||
$plant = null;
|
$plant = null;
|
||||||
$item = null;
|
$item = null;
|
||||||
|
$plantId = null;
|
||||||
|
$itemId = null;
|
||||||
|
$createdBy = Filament::auth()->user()->name;
|
||||||
|
$updatedBy = Filament::auth()->user()->name;
|
||||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
$warnMsg[] = 'Invalid plant code found';
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
} else {
|
} else {
|
||||||
@@ -174,10 +180,20 @@ class StickerMasterImporter extends Importer
|
|||||||
if (! $plant) {
|
if (! $plant) {
|
||||||
$warnMsg[] = 'Plant not found';
|
$warnMsg[] = 'Plant not found';
|
||||||
} else {
|
} else {
|
||||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
$plantId = $plant->id;
|
||||||
|
if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||||
|
$warnMsg[] = 'Invalid item code found';
|
||||||
|
} else {
|
||||||
|
$item = Item::where('code', $itemCod)->first();
|
||||||
if (! $item) {
|
if (! $item) {
|
||||||
$warnMsg[] = 'Item code not found';
|
$warnMsg[] = 'Item code not found';
|
||||||
} else {
|
} else {
|
||||||
|
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||||
|
if (! $item) {
|
||||||
|
$warnMsg[] = 'Item code not found for the plant';
|
||||||
|
} else {
|
||||||
|
$itemId = $item->id;
|
||||||
|
|
||||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||||
}
|
}
|
||||||
@@ -229,6 +245,16 @@ class StickerMasterImporter extends Importer
|
|||||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { // ($this->data['material_type'] != null) &&
|
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { // ($this->data['material_type'] != null) &&
|
||||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($warnMsg)) {
|
||||||
|
$recExist = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first()?->created_by;
|
||||||
|
|
||||||
|
if ($recExist) {
|
||||||
|
$createdBy = $recExist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,8 +263,8 @@ class StickerMasterImporter extends Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
StickerMaster::updateOrCreate([
|
StickerMaster::updateOrCreate([
|
||||||
'item_id' => $item->id,
|
'item_id' => $itemId,
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plantId,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||||
@@ -265,6 +291,8 @@ class StickerMasterImporter extends Importer
|
|||||||
'load_rate' => $this->data['load_rate'],
|
'load_rate' => $this->data['load_rate'],
|
||||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||||
'material_type' => $this->data['material_type'],
|
'material_type' => $this->data['material_type'],
|
||||||
|
'created_by' => $createdBy,
|
||||||
|
'updated_by' => $updatedBy,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class StickerMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(StickerMaster::latest()->first())->plant_id;
|
return optional(StickerMaster::latest()->first())->plant_id;
|
||||||
@@ -87,7 +87,8 @@ class StickerMasterResource extends Resource
|
|||||||
$set('tube_sticker_motor', false) &
|
$set('tube_sticker_motor', false) &
|
||||||
$set('tube_sticker_pump', false) &
|
$set('tube_sticker_pump', false) &
|
||||||
$set('tube_sticker_pumpset', false) &
|
$set('tube_sticker_pumpset', false) &
|
||||||
$set('warranty_card', false)
|
$set('warranty_card', false) &
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name)
|
||||||
)
|
)
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ class StickerMasterResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$itemId = $get('item_id');
|
$itemId = $get('item_id');
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
|
||||||
// If plant_id is changed or empty, reset everything
|
// If plant_id is changed or empty, reset everything
|
||||||
if (blank($plantId)) {
|
if (blank($plantId)) {
|
||||||
@@ -207,36 +209,60 @@ class StickerMasterResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation1')
|
Forms\Components\TextInput::make('part_validation1')
|
||||||
->label('Part Validation 1')
|
->label('Part Validation 1')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation2')
|
Forms\Components\TextInput::make('part_validation2')
|
||||||
->label('Part Validation 2')
|
->label('Part Validation 2')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation3')
|
Forms\Components\TextInput::make('part_validation3')
|
||||||
->label('Part Validation 3')
|
->label('Part Validation 3')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation4')
|
Forms\Components\TextInput::make('part_validation4')
|
||||||
->label('Part Validation 4')
|
->label('Part Validation 4')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('part_validation5')
|
Forms\Components\TextInput::make('part_validation5')
|
||||||
->label('Part Validation 5 (Capacitor QR)')
|
->label('Part Validation 5 (Capacitor QR)')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('laser_part_validation1')
|
Forms\Components\TextInput::make('laser_part_validation1')
|
||||||
->label('Laser Part Validation 1')
|
->label('Laser Part Validation 1')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('laser_part_validation2')
|
Forms\Components\TextInput::make('laser_part_validation2')
|
||||||
->label('Laser Part Validation 2')
|
->label('Laser Part Validation 2')
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('panel_box_code')
|
Forms\Components\TextInput::make('panel_box_code')
|
||||||
->label('Panel Box Code')
|
->label('Panel Box Code')
|
||||||
->readOnly(fn (callable $get) => $get('material_type'))
|
->readOnly(fn (callable $get) => $get('material_type'))
|
||||||
->nullable(),
|
->nullable()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('load_rate')
|
Forms\Components\TextInput::make('load_rate')
|
||||||
->label('Load Rate')
|
->label('Load Rate')
|
||||||
@@ -245,7 +271,10 @@ class StickerMasterResource extends Resource
|
|||||||
->disabled(function ($get) {
|
->disabled(function ($get) {
|
||||||
return $get('material_type');
|
return $get('material_type');
|
||||||
})
|
})
|
||||||
->integer(),
|
->integer()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
}),
|
||||||
|
|
||||||
Forms\Components\Select::make('material_type')
|
Forms\Components\Select::make('material_type')
|
||||||
->label('Material Type')
|
->label('Material Type')
|
||||||
@@ -256,7 +285,6 @@ class StickerMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|
||||||
if ($state) {
|
if ($state) {
|
||||||
$set('panel_box_code', null);
|
$set('panel_box_code', null);
|
||||||
$set('load_rate', 0);
|
$set('load_rate', 0);
|
||||||
@@ -267,7 +295,7 @@ class StickerMasterResource extends Resource
|
|||||||
} else {
|
} else {
|
||||||
$set('bundle_quantity', 2);
|
$set('bundle_quantity', 2);
|
||||||
}
|
}
|
||||||
// $plantId = $get('plant_id');
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->nullable(),
|
->nullable(),
|
||||||
|
|
||||||
@@ -284,6 +312,7 @@ class StickerMasterResource extends Resource
|
|||||||
} elseif ($get('bundle_quantity') < 2) {
|
} elseif ($get('bundle_quantity') < 2) {
|
||||||
$set('bundle_quantity', 2);
|
$set('bundle_quantity', 2);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('serial_number_motor')
|
Forms\Components\Checkbox::make('serial_number_motor')
|
||||||
@@ -295,6 +324,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('serial_number_motor')) {
|
if ($get('serial_number_motor')) {
|
||||||
$set('serial_number_pumpset', false);
|
$set('serial_number_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
|
||||||
|
|
||||||
@@ -307,6 +337,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('serial_number_pump')) {
|
if ($get('serial_number_pump')) {
|
||||||
$set('serial_number_pumpset', false);
|
$set('serial_number_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -320,6 +351,7 @@ class StickerMasterResource extends Resource
|
|||||||
$set('serial_number_motor', false);
|
$set('serial_number_motor', false);
|
||||||
$set('serial_number_pump', false);
|
$set('serial_number_pump', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -332,6 +364,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('pack_slip_motor')) {
|
if ($get('pack_slip_motor')) {
|
||||||
$set('pack_slip_pumpset', false);
|
$set('pack_slip_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -344,6 +377,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('pack_slip_pump')) {
|
if ($get('pack_slip_pump')) {
|
||||||
$set('pack_slip_pumpset', false);
|
$set('pack_slip_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -357,6 +391,7 @@ class StickerMasterResource extends Resource
|
|||||||
$set('pack_slip_motor', false);
|
$set('pack_slip_motor', false);
|
||||||
$set('pack_slip_pump', false);
|
$set('pack_slip_pump', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -369,6 +404,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('name_plate_motor')) {
|
if ($get('name_plate_motor')) {
|
||||||
$set('name_plate_pumpset', false);
|
$set('name_plate_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -381,6 +417,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('name_plate_pump')) {
|
if ($get('name_plate_pump')) {
|
||||||
$set('name_plate_pumpset', false);
|
$set('name_plate_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -394,6 +431,7 @@ class StickerMasterResource extends Resource
|
|||||||
$set('name_plate_motor', false);
|
$set('name_plate_motor', false);
|
||||||
$set('name_plate_pump', false);
|
$set('name_plate_pump', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -406,6 +444,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('tube_sticker_motor')) {
|
if ($get('tube_sticker_motor')) {
|
||||||
$set('tube_sticker_pumpset', false);
|
$set('tube_sticker_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -418,6 +457,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('tube_sticker_pump')) {
|
if ($get('tube_sticker_pump')) {
|
||||||
$set('tube_sticker_pumpset', false);
|
$set('tube_sticker_pumpset', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
@@ -432,13 +472,24 @@ class StickerMasterResource extends Resource
|
|||||||
$set('tube_sticker_motor', false);
|
$set('tube_sticker_motor', false);
|
||||||
$set('tube_sticker_pump', false);
|
$set('tube_sticker_pump', false);
|
||||||
}
|
}
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null), // to pass null value
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null), // to pass null value
|
||||||
|
|
||||||
Forms\Components\Checkbox::make('warranty_card')
|
Forms\Components\Checkbox::make('warranty_card')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
|
})
|
||||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
@@ -465,8 +516,7 @@ class StickerMasterResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable(),
|
||||||
->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('item.code')
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -593,17 +643,24 @@ class StickerMasterResource extends Resource
|
|||||||
default => '-',
|
default => '-',
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
->label('Updated At')
|
->label('Updated At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable(),
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
->label('Deleted At')
|
->label('Deleted At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
@@ -623,8 +680,9 @@ class StickerMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
@@ -658,16 +716,21 @@ class StickerMasterResource extends Resource
|
|||||||
->reactive(),
|
->reactive(),
|
||||||
Select::make('material_type')
|
Select::make('material_type')
|
||||||
->label('Select Material Type')
|
->label('Select Material Type')
|
||||||
|
->nullable()
|
||||||
->options([
|
->options([
|
||||||
1 => 'Individual',
|
1 => 'Individual',
|
||||||
2 => 'Bundle',
|
2 => 'Bundle',
|
||||||
3 => 'Quantity',
|
3 => 'Quantity',
|
||||||
])
|
])
|
||||||
|
->searchable()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
TextInput::make('panel_box_code')
|
TextInput::make('panel_box_code')
|
||||||
->label('Search by Panel Box Code')
|
->label('Search by Panel Box Code')
|
||||||
->placeholder(placeholder: 'Enter Panel Box Code'),
|
->placeholder(placeholder: 'Enter Panel Box Code'),
|
||||||
|
TextInput::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->placeholder(placeholder: 'Enter Created By Name'),
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
->placeholder(placeholder: 'Select From DateTime')
|
->placeholder(placeholder: 'Select From DateTime')
|
||||||
@@ -678,10 +741,13 @@ class StickerMasterResource extends Resource
|
|||||||
->placeholder(placeholder: 'Select To DateTime')
|
->placeholder(placeholder: 'Select To DateTime')
|
||||||
->reactive()
|
->reactive()
|
||||||
->native(false),
|
->native(false),
|
||||||
|
TextInput::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->placeholder(placeholder: 'Enter Updated By Name'),
|
||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['item_id']) && empty($data['material_type']) && empty($data['panel_box_code']) && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['item_id']) && empty($data['material_type']) && empty($data['panel_box_code']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['updated_by'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,6 +773,10 @@ class StickerMasterResource extends Resource
|
|||||||
$query->where('panel_box_code', 'like', '%'.$data['panel_box_code'].'%');
|
$query->where('panel_box_code', 'like', '%'.$data['panel_box_code'].'%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_by'])) {
|
||||||
|
$query->where('created_by', 'like', '%'.$data['created_by'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
@@ -715,6 +785,9 @@ class StickerMasterResource extends Resource
|
|||||||
$query->where('created_at', '<=', $data['created_to']);
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['updated_by'])) {
|
||||||
|
$query->where('updated_by', 'like', '%'.$data['updated_by'].'%');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
->indicateUsing(function (array $data) {
|
->indicateUsing(function (array $data) {
|
||||||
$indicators = [];
|
$indicators = [];
|
||||||
@@ -748,6 +821,10 @@ class StickerMasterResource extends Resource
|
|||||||
$indicators[] = 'Panel Box Code: '.$data['panel_box_code'];
|
$indicators[] = 'Panel Box Code: '.$data['panel_box_code'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_by'])) {
|
||||||
|
$indicators[] = 'Created By: '.$data['created_by'];
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: '.$data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
@@ -756,6 +833,10 @@ class StickerMasterResource extends Resource
|
|||||||
$indicators[] = 'To: '.$data['created_to'];
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['updated_by'])) {
|
||||||
|
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||||
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -779,7 +860,7 @@ class StickerMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->required()
|
->required()
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class StickerMaster extends Model
|
|||||||
'load_rate',
|
'load_rate',
|
||||||
'bundle_quantity',
|
'bundle_quantity',
|
||||||
'material_type',
|
'material_type',
|
||||||
|
'created_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_at',
|
||||||
|
'updated_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function item()
|
public function item()
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE sticker_masters
|
||||||
|
ADD COLUMN created_by TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
|
||||||
|
$sql2 = <<<'SQL'
|
||||||
|
ALTER TABLE sticker_masters
|
||||||
|
ADD COLUMN updated_by TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql2);
|
||||||
|
// Schema::table('sticker_masters', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('sticker_masters', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user