Added view rights against plant on view report and Updated alignments and filter query logic on resource
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
This commit is contained in:
@@ -6,8 +6,6 @@ use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction as ActionsFilam
|
|||||||
use App\Filament\Exports\ProductionQuantityExporter;
|
use App\Filament\Exports\ProductionQuantityExporter;
|
||||||
use App\Filament\Imports\ProductionQuantityImporter;
|
use App\Filament\Imports\ProductionQuantityImporter;
|
||||||
use App\Filament\Resources\ProductionQuantityResource\Pages;
|
use App\Filament\Resources\ProductionQuantityResource\Pages;
|
||||||
use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
|
|
||||||
use App\Forms\Components\PlantSelect;
|
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
@@ -18,29 +16,25 @@ use Carbon\Carbon;
|
|||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Hidden;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Forms\Get;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Livewire\Livewire;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
// use Filament\Forms\Components\View;
|
|
||||||
use Filament\Tables\Actions\FilamentExportBulkAction;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
// use Filament\Forms\Components\View;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
class ProductionQuantityResource extends Resource
|
class ProductionQuantityResource extends Resource
|
||||||
{
|
{
|
||||||
|
|
||||||
protected static ?string $model = ProductionQuantity::class;
|
protected static ?string $model = ProductionQuantity::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
@@ -52,7 +46,6 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 1;
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
|
||||||
// public $plant_id;
|
// public $plant_id;
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
@@ -69,6 +62,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->columnSpan(2) // 1
|
->columnSpan(2) // 1
|
||||||
->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::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
||||||
@@ -81,13 +75,11 @@ class ProductionQuantityResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('block_name', null);
|
$set('block_name', null);
|
||||||
if (!$plantId)
|
if (! $plantId) {
|
||||||
{
|
|
||||||
$set('pqPlantError', 'Please select a plant first.');
|
$set('pqPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
$set('pqPlantError', null);
|
$set('pqPlantError', null);
|
||||||
}
|
}
|
||||||
@@ -138,15 +130,14 @@ class ProductionQuantityResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
|
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
|
||||||
|
|
||||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if ($get('id')) {
|
||||||
{
|
|
||||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||||
if($getBlock->block_id)
|
if ($getBlock->block_id) {
|
||||||
{
|
|
||||||
$set('block_name', $getBlock->block_id);
|
$set('block_name', $getBlock->block_id);
|
||||||
$set('pqBlockError', null);
|
$set('pqBlockError', null);
|
||||||
}
|
}
|
||||||
@@ -160,10 +151,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
if (! $blockId) {
|
if (! $blockId) {
|
||||||
$set('pqBlockError', 'Please select a block first.');
|
$set('pqBlockError', 'Please select a block first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
$set('pqBlockError', null);
|
$set('pqBlockError', null);
|
||||||
}
|
}
|
||||||
@@ -194,11 +184,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
})
|
})
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if ($get('id')) {
|
||||||
{
|
|
||||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||||
if($getShift->shift_id)
|
if ($getShift->shift_id) {
|
||||||
{
|
|
||||||
$set('shift_id', $getShift->shift_id);
|
$set('shift_id', $getShift->shift_id);
|
||||||
$set('pqShiftError', null);
|
$set('pqShiftError', null);
|
||||||
}
|
}
|
||||||
@@ -209,10 +197,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
if (! $curShiftId) {
|
if (! $curShiftId) {
|
||||||
$set('pqShiftError', 'Please select a shift first.');
|
$set('pqShiftError', 'Please select a shift first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
$set('pqShiftError', null);
|
$set('pqShiftError', null);
|
||||||
}
|
}
|
||||||
@@ -246,11 +233,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
return optional(ProductionQuantity::latest()->first())->line_id;
|
return optional(ProductionQuantity::latest()->first())->line_id;
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if ($get('id')) {
|
||||||
{
|
|
||||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||||
if($getShift->line_id)
|
if ($getShift->line_id) {
|
||||||
{
|
|
||||||
$set('line_id', $getShift->line_id);
|
$set('line_id', $getShift->line_id);
|
||||||
$set('pqLineError', null);
|
$set('pqLineError', null);
|
||||||
}
|
}
|
||||||
@@ -265,10 +250,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
if (! $lineId) {
|
if (! $lineId) {
|
||||||
$set('pqLineError', 'Please select a line first.');
|
$set('pqLineError', 'Please select a line first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
$set('pqLineError', null);
|
$set('pqLineError', null);
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
@@ -296,7 +280,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
// 'x-on:change' => "\$wire.dispatch('filtersUpdated')", // Dispatch Livewire event from Alpine.js
|
// 'x-on:change' => "\$wire.dispatch('filtersUpdated')", // Dispatch Livewire event from Alpine.js
|
||||||
// ])
|
// ])
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'x-on:change' => "\$wire.dispatch('filtersUpdated', { lineId: \$event.target.value })"
|
'x-on:change' => "\$wire.dispatch('filtersUpdated', { lineId: \$event.target.value })",
|
||||||
])
|
])
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('pqLineError') ? 'border-red-500' : '',
|
'class' => $get('pqLineError') ? 'border-red-500' : '',
|
||||||
@@ -328,21 +312,20 @@ class ProductionQuantityResource extends Resource
|
|||||||
// $latestProductionOrder = ProductionQuantity::latest()->first()->production_order;
|
// $latestProductionOrder = ProductionQuantity::latest()->first()->production_order;
|
||||||
// return $latestProductionOrder ?? null;
|
// return $latestProductionOrder ?? null;
|
||||||
$latestProduction = ProductionQuantity::latest()->first();
|
$latestProduction = ProductionQuantity::latest()->first();
|
||||||
|
|
||||||
return $latestProduction ? $latestProduction->production_order : null;
|
return $latestProduction ? $latestProduction->production_order : null;
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
if (! is_numeric($get('production_order')) || ! preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order'))) {
|
||||||
{
|
|
||||||
$set('item_code', null);
|
$set('item_code', null);
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('serial_number', null);
|
$set('serial_number', null);
|
||||||
$set('production_order', null);
|
$set('production_order', null);
|
||||||
$set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
|
$set('prodOrdError', 'Must be a numeric value with 7 to 14 digits.');
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('item_code', null);
|
$set('item_code', null);
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
// $set('item_description', null);
|
// $set('item_description', null);
|
||||||
@@ -350,6 +333,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
$set('production_order', $state);
|
$set('production_order', $state);
|
||||||
$set('prodOrdError', null);
|
$set('prodOrdError', null);
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
// if (empty($state)) {
|
// if (empty($state)) {
|
||||||
// }
|
// }
|
||||||
@@ -971,6 +955,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('production_order')
|
Tables\Columns\TextColumn::make('production_order')
|
||||||
@@ -1049,6 +1034,7 @@ class ProductionQuantityResource 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::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -1071,6 +1057,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Line::where('plant_id', $plantId)
|
return Line::where('plant_id', $plantId)
|
||||||
->pluck('name', 'id');
|
->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
@@ -1089,6 +1076,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Block::where('plant_id', $get('Plant'))->pluck('name', 'id');
|
return Block::where('plant_id', $get('Plant'))->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -1133,10 +1121,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
return Item::distinct()->whereHas('productionQuantities')->pluck('code', 'id');
|
return Item::whereHas('productionQuantities')->distinct()->pluck('code', 'id');
|
||||||
}
|
} else {
|
||||||
else {
|
return Item::whereHas('productionQuantities')->where('plant_id', $plantId)->distinct()->pluck('code', 'id');
|
||||||
return Item::where('plant_id', $plantId)->whereHas('productionQuantities')->distinct()->pluck('code', 'id');
|
|
||||||
}
|
}
|
||||||
// return Item::whereHas('stickerMasters', function ($query) use ($pId) {
|
// return Item::whereHas('stickerMasters', function ($query) use ($pId) {
|
||||||
// if ($pId) {
|
// if ($pId) {
|
||||||
@@ -1156,8 +1143,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
if (! $plantId) {
|
if (! $plantId) {
|
||||||
return ProductionQuantity::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status');
|
return ProductionQuantity::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status');
|
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1171,24 +1157,15 @@ class ProductionQuantityResource extends Resource
|
|||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
$lineId = $get('Line');
|
$lineId = $get('Line');
|
||||||
$shiftId = $get('Shift');
|
$shiftId = $get('Shift');
|
||||||
if (!$plantId && !$lineId && !$shiftId)
|
if (! $plantId && ! $lineId && ! $shiftId) {
|
||||||
{
|
|
||||||
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
} elseif ($plantId && ! $lineId && ! $shiftId) {
|
||||||
else if ($plantId && !$lineId && !$shiftId)
|
|
||||||
{
|
|
||||||
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
} elseif ($plantId && $lineId && ! $shiftId) {
|
||||||
else if ($plantId && $lineId && !$shiftId)
|
|
||||||
{
|
|
||||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
} elseif ($plantId && ! $lineId && $shiftId) {
|
||||||
else if ($plantId && !$lineId && $shiftId)
|
|
||||||
{
|
|
||||||
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
} else { // if ($plantId && $lineId && $shiftId)
|
||||||
else// if ($plantId && $lineId && $shiftId)
|
|
||||||
{
|
|
||||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1212,16 +1189,22 @@ class ProductionQuantityResource extends Resource
|
|||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($plant = $data['Plant'] ?? null) {
|
if (! empty($data['Plant'])) {// if ($plant = $data['Plant'] ?? null) {
|
||||||
$query->where('plant_id', $plant);
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shift = $data['Shift'] ?? null) {
|
if (! empty($data['Shift'])) {// if ($shift = $data['Shift'] ?? null) {
|
||||||
$query->where('shift_id', $shift);
|
$query->where('shift_id', $data['Shift']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($line = $data['Line'] ?? null) {
|
if (! empty($data['Line'])) {// if ($line = $data['Line'] ?? null) {
|
||||||
$query->where('line_id', $line);
|
$query->where('line_id', $data['Line']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['production_order'])) {
|
if (! empty($data['production_order'])) {
|
||||||
@@ -1244,12 +1227,12 @@ class ProductionQuantityResource extends Resource
|
|||||||
$query->where('operator_id', $data['operator_id']);
|
$query->where('operator_id', $data['operator_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($from = $data['created_from'] ?? null) {
|
if (! empty($data['created_from'])) {// if ($from = $data['created_from'] ?? null) {
|
||||||
$query->where('created_at', '>=', $from);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($to = $data['created_to'] ?? null) {
|
if (! empty($data['created_to'])) {// if ($to = $data['created_to'] ?? null) {
|
||||||
$query->where('created_at', '<=', $to);
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return $query;
|
// return $query;
|
||||||
@@ -1259,6 +1242,12 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant: Choose plant to filter records.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['Shift'])) {
|
if (! empty($data['Shift'])) {
|
||||||
@@ -1298,7 +1287,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
@@ -1370,7 +1359,6 @@ class ProductionQuantityResource extends Resource
|
|||||||
return 'Production Reports';
|
return 'Production Reports';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public function triggerChartUpdate(): void
|
// public function triggerChartUpdate(): void
|
||||||
// {
|
// {
|
||||||
// if (session()->has('select_plant') && session()->has('select_line')) {
|
// if (session()->has('select_plant') && session()->has('select_line')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user