Compare commits
15 Commits
df0904e6c1
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7244028d02 | ||
|
|
8104da98d4 | ||
|
|
1d51067355 | ||
|
|
1fd2538048 | ||
|
|
d8fdf02417 | ||
|
|
1031a972de | ||
|
|
f5173d9861 | ||
|
|
9602be624d | ||
|
|
85c7a3e286 | ||
|
|
6071c8b898 | ||
|
|
9bf5337383 | ||
|
|
621cf13565 | ||
|
|
6c334359b2 | ||
|
|
fd444a7749 | ||
|
|
f7a421681e |
@@ -51,7 +51,8 @@ class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
|
|||||||
|
|
||||||
// Add daily target and produced quantity for each date
|
// Add daily target and produced quantity for each date
|
||||||
foreach ($this->dates as $date) {
|
foreach ($this->dates as $date) {
|
||||||
$mapped[] = $row['daily_target'] ?? 0;
|
// $mapped[] = $row['daily_target_dynamic'] ?? 0;
|
||||||
|
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
|
||||||
$mapped[] = $row['produced_quantity'][$date] ?? 0;
|
$mapped[] = $row['produced_quantity'][$date] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Imports;
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
@@ -23,11 +24,33 @@ class ProductionPlanImporter extends Importer
|
|||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ImportColumn::make('created_at')
|
// ImportColumn::make('created_at')
|
||||||
|
// ->requiredMapping()
|
||||||
|
// ->exampleHeader('Created DateTime')
|
||||||
|
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||||
|
// ->label('Created DateTime')
|
||||||
|
// ->rules(['required']),
|
||||||
|
|
||||||
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Created DateTime')
|
->exampleHeader('Plant Code')
|
||||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
->example(['1000', '1000'])
|
||||||
->label('Created DateTime')
|
->label('Plant Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('line')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->example(['4 inch pump line', '4 inch pump line'])
|
||||||
|
->label('Line Name')
|
||||||
|
->relationship(resolveUsing: 'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('item')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Item Code')
|
||||||
|
->example(['123456', '210987'])
|
||||||
|
->label('Item Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plan_quantity')
|
ImportColumn::make('plan_quantity')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -36,175 +59,111 @@ class ProductionPlanImporter extends Importer
|
|||||||
->label('Plan Quantity')
|
->label('Plan Quantity')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
ImportColumn::make('production_quantity')
|
// ImportColumn::make('production_quantity')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Production Quantity')
|
// ->exampleHeader('Production Quantity')
|
||||||
->example(['0', '0'])
|
// ->example(['0', '0'])
|
||||||
->label('Production Quantity')
|
// ->label('Production Quantity')
|
||||||
->numeric()
|
// ->numeric()
|
||||||
->rules(['required', 'integer']),
|
// ->rules(['required', 'integer']),
|
||||||
ImportColumn::make('line')
|
|
||||||
->requiredMapping()
|
// ImportColumn::make('block_reference')
|
||||||
->exampleHeader('Line Name')
|
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||||
->example(['4 inch pump line', '4 inch pump line'])
|
// ->exampleHeader('Block Name')
|
||||||
->label('Line Name')
|
// ->example(['Block A', 'Block A'])
|
||||||
->relationship(resolveUsing:'name')
|
// ->label('Block Name')
|
||||||
->rules(['required']),
|
// ->rules(['required']), // Or remove if not required
|
||||||
ImportColumn::make('block_reference')
|
// ImportColumn::make('shift')
|
||||||
->requiredMapping() // Or optionalMapping() if not always present
|
// ->requiredMapping()
|
||||||
->exampleHeader('Block Name')
|
// ->exampleHeader('Shift Name') // ID
|
||||||
->example(['Block A', 'Block A'])
|
// ->example(['Day', 'Night']) // '2', '7'
|
||||||
->label('Block Name')
|
// ->label('Shift Name') // ID
|
||||||
->rules(['required']), // Or remove if not required
|
// ->relationship(resolveUsing: 'name')
|
||||||
ImportColumn::make('shift')
|
// ->rules(['required']),
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Shift Name') //ID
|
// ImportColumn::make('updated_at')
|
||||||
->example(['Day', 'Night']) //'2', '7'
|
// ->requiredMapping()
|
||||||
->label('Shift Name') // ID
|
// ->exampleHeader('Updated DateTime')
|
||||||
->relationship(resolveUsing: 'name')
|
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||||
->rules(['required']),
|
// ->label('Updated DateTime')
|
||||||
ImportColumn::make('plant')
|
// ->rules(['required']),
|
||||||
->requiredMapping()
|
// ImportColumn::make('operator_id')
|
||||||
->exampleHeader('Plant Name')
|
// ->requiredMapping()
|
||||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
// ->exampleHeader('Operator ID')
|
||||||
->label('Plant Name')
|
// ->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||||
->relationship(resolveUsing:'name')
|
// ->label('Operator ID')
|
||||||
->rules(['required']),
|
// ->rules(['required']),
|
||||||
ImportColumn::make('updated_at')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Updated DateTime')
|
|
||||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
|
||||||
->label('Updated DateTime')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('operator_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Operator ID')
|
|
||||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
|
||||||
->label('Operator ID')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolveRecord(): ?ProductionPlan
|
public function resolveRecord(): ?ProductionPlan
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
$plantCod = $this->data['plant'];
|
||||||
|
$itemCod = $this->data['item'];
|
||||||
|
$plant = null;
|
||||||
$line = null;
|
$line = null;
|
||||||
$block = null;
|
$block = null;
|
||||||
if (!$plant) {
|
|
||||||
$warnMsg[] = "Plant not found";
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
|
} else {
|
||||||
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (! $plant) {
|
||||||
|
$warnMsg[] = 'Plant not found';
|
||||||
|
} else {
|
||||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||||
//block_reference
|
|
||||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
|
||||||
}
|
|
||||||
if (!$line) {
|
|
||||||
$warnMsg[] = "Line not found";
|
|
||||||
}
|
|
||||||
$shift = null;
|
|
||||||
if (!$block) {
|
|
||||||
$warnMsg[] = "Block not found";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
|
||||||
}
|
|
||||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
|
||||||
if (!$shift) {
|
|
||||||
$warnMsg[] = "Shift not found";
|
|
||||||
}
|
|
||||||
if (Str::length($this->data['plan_quantity']) < 0 || !is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
|
||||||
$warnMsg[] = "Invalid plan quantity found";
|
|
||||||
}
|
|
||||||
if (Str::length($this->data['production_quantity']) < 0 || !is_numeric($this->data['production_quantity']) || $this->data['production_quantity'] < 0) {
|
|
||||||
$warnMsg[] = "Invalid production quantity found";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fromDate = $this->data['created_at'];
|
if (! $line) {
|
||||||
$toDate = $this->data['updated_at'];
|
$warnMsg[] = 'Line not found';
|
||||||
|
|
||||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
|
||||||
|
|
||||||
$fdateTime = null;
|
|
||||||
$tdateTime = null;
|
|
||||||
// Try parsing with multiple formats
|
|
||||||
foreach ($formats as $format) {
|
|
||||||
try {
|
|
||||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
|
||||||
break;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// Optionally collect warning messages
|
|
||||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($formats as $format) {
|
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
|
||||||
try {
|
$warnMsg[] = 'Invalid item code found';
|
||||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
} else {
|
||||||
break;
|
$item = Item::where('code', $itemCod)->first();
|
||||||
} catch (\Exception $e) {
|
|
||||||
// Optionally collect warning messages
|
|
||||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fDateOnly = '';
|
if (! $item) {
|
||||||
if (!isset($fdateTime)) {
|
$warnMsg[] = 'Item not found';
|
||||||
// throw new \Exception('Invalid date time format');
|
|
||||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$fDateOnly = $fdateTime->toDateString();
|
|
||||||
}
|
|
||||||
if (!isset($tdateTime)) {
|
|
||||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($fdateTime) && isset($tdateTime)) {
|
$plantId = $plant->id;
|
||||||
if ($fdateTime->greaterThan($tdateTime)) {
|
|
||||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
|
||||||
}
|
|
||||||
|
if(!$itemAgaPlant){
|
||||||
|
$warnMsg[] = 'Item not found against plant code';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!$fromDate) {
|
$user = Filament::auth()->user();
|
||||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
// }
|
|
||||||
// else if (!$toDate) {
|
|
||||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
// }
|
|
||||||
|
|
||||||
$user = User::where('name', $this->data['operator_id'])->first();
|
$operatorName = $user->name;
|
||||||
if (!$user) {
|
|
||||||
$warnMsg[] = "Operator ID not found";
|
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||||
|
$warnMsg[] = 'Invalid plan quantity found';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
}
|
} else {
|
||||||
else { //if (empty($warnMsg))
|
|
||||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||||
->where('shift_id', $shift->id)
|
|
||||||
->where('line_id', $line->id)
|
->where('line_id', $line->id)
|
||||||
->whereDate('created_at', $fDateOnly)
|
->where('item_id', $itemAgaPlant->id)
|
||||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
|
||||||
->latest()
|
->latest()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($productionPlan) {
|
if ($productionPlan) {
|
||||||
// if($productionPlan->production_quantity)
|
|
||||||
// {
|
|
||||||
// throw new RowImportFailedException("{$productionPlan->created_at}, {$productionPlan->production_quantity}");
|
|
||||||
// }
|
|
||||||
// $warnMsg[] = "Production plan already exist on '{$fDateOnly}'!";
|
|
||||||
|
|
||||||
$productionPlan->update([
|
$productionPlan->update([
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
// 'production_quantity' => $productionPlan->production_quantity,
|
'operator_id' => $operatorName,
|
||||||
// 'created_at' => $productionPlan->created_at,//$fdateTime->format('Y-m-d H:i:s'),
|
|
||||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
|
||||||
'operator_id' => $this->data['operator_id'],
|
|
||||||
]);
|
]);
|
||||||
$productionPlan->save();
|
$productionPlan->save();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,28 +171,23 @@ class ProductionPlanImporter extends Importer
|
|||||||
ProductionPlan::updateOrCreate([
|
ProductionPlan::updateOrCreate([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'line_id' => $line->id,
|
'line_id' => $line->id,
|
||||||
'shift_id' => $shift->id,
|
'item_id' => $itemAgaPlant->id,
|
||||||
|
// 'shift_id' => $shift->id,
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
'production_quantity' => $this->data['production_quantity'],
|
'created_at' =>now(),
|
||||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
'updated_at' => now(),
|
||||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
'operator_id' => $operatorName,
|
||||||
'operator_id' => $this->data['operator_id'],
|
|
||||||
]);
|
]);
|
||||||
return null;
|
|
||||||
// return ProductionPlan::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// return new ProductionPlan();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
{
|
{
|
||||||
$body = 'Your production plan import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
$body = 'Your production plan import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -82,6 +82,9 @@ class ItemResource extends Resource
|
|||||||
Forms\Components\TextInput::make('category')
|
Forms\Components\TextInput::make('category')
|
||||||
->label('Category')
|
->label('Category')
|
||||||
->placeholder('Scan the Category'),
|
->placeholder('Scan the Category'),
|
||||||
|
Forms\Components\TextInput::make('category')
|
||||||
|
->label('Category')
|
||||||
|
->placeholder('Scan the Category'),
|
||||||
Forms\Components\TextInput::make('code')
|
Forms\Components\TextInput::make('code')
|
||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid code')
|
->placeholder('Scan the valid code')
|
||||||
|
|||||||
@@ -5,23 +5,23 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\LineExporter;
|
use App\Filament\Exports\LineExporter;
|
||||||
use App\Filament\Imports\LineImporter;
|
use App\Filament\Imports\LineImporter;
|
||||||
use App\Filament\Resources\LineResource\Pages;
|
use App\Filament\Resources\LineResource\Pages;
|
||||||
use App\Filament\Resources\LineResource\RelationManagers;
|
use App\Models\Block;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Forms\Set;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Forms\Set;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\Rules\Unique;
|
use Illuminate\Validation\Rules\Unique;
|
||||||
|
|
||||||
@@ -48,22 +48,22 @@ class LineResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->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(Line::latest()->first())->plant_id;
|
return optional(Line::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('lPlantError', 'Please select a plant first.');
|
$set('lPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('lPlantError', null);
|
$set('lPlantError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -72,6 +72,39 @@ class LineResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Select::make('block_id')
|
||||||
|
->label('Block')
|
||||||
|
->relationship('block', 'name')
|
||||||
|
->required()
|
||||||
|
// ->nullable(),
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (! $get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Block::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->default(function () {
|
||||||
|
return optional(Block::latest()->first())->plant_id;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$blockId = $get('block_id');
|
||||||
|
if (! $blockId) {
|
||||||
|
$set('lblockError', 'Please select a Block first.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$set('lblockError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('lblockError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('lblockError') ? $get('lblockError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid name')
|
->placeholder('Scan the valid name')
|
||||||
@@ -97,12 +130,11 @@ class LineResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$lineNam = $get('name');
|
$lineNam = $get('name');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
if (!$lineNam) {
|
if (! $lineNam) {
|
||||||
$set('lNameError', 'Scan the valid name.');
|
$set('lNameError', 'Scan the valid name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// $exists = Line::where('name', $lineNam)
|
// $exists = Line::where('name', $lineNam)
|
||||||
// ->where('plant_id', $get('plant_id'))
|
// ->where('plant_id', $get('plant_id'))
|
||||||
// ->exists();
|
// ->exists();
|
||||||
@@ -156,6 +188,9 @@ class LineResource extends Resource
|
|||||||
'Base FG Line' => 'Base FG Line',
|
'Base FG Line' => 'Base FG Line',
|
||||||
'SFG Line' => 'SFG Line',
|
'SFG Line' => 'SFG Line',
|
||||||
'FG Line' => 'FG Line',
|
'FG Line' => 'FG Line',
|
||||||
|
'Process Base FG Line' => 'Process Base FG Line',
|
||||||
|
'Process SFG Line' => 'Process SFG Line',
|
||||||
|
'Process FG Line' => 'Process FG Line',
|
||||||
'Machining Cell' => 'Machining Cell',
|
'Machining Cell' => 'Machining Cell',
|
||||||
'Blanking Cell' => 'Blanking Cell',
|
'Blanking Cell' => 'Blanking Cell',
|
||||||
'Forming Cell' => 'Forming Cell',
|
'Forming Cell' => 'Forming Cell',
|
||||||
@@ -168,12 +203,11 @@ class LineResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$lineTyp = $get('type');
|
$lineTyp = $get('type');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
if (!$lineTyp) {
|
if (! $lineTyp) {
|
||||||
$set('lTypeError', 'Scan the valid type.');
|
$set('lTypeError', 'Scan the valid type.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('lTypeError', null);
|
$set('lTypeError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -198,13 +232,13 @@ class LineResource extends Resource
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($partValidationColumns as $column) {
|
foreach ($partValidationColumns as $column) {
|
||||||
$set($column . '_visible', false);
|
$set($column.'_visible', false);
|
||||||
$set($column, null);
|
$set($column, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$partValidDispColumns = [
|
$partValidDispColumns = [
|
||||||
'work_group1_actual_id', 'work_group2_actual_id', 'work_group3_actual_id', 'work_group4_actual_id', 'work_group5_actual_id',
|
'work_group1_actual_id', 'work_group2_actual_id', 'work_group3_actual_id', 'work_group4_actual_id', 'work_group5_actual_id',
|
||||||
'work_group6_actual_id', 'work_group7_actual_id', 'work_group8_actual_id', 'work_group9_actual_id', 'work_group10_actual_id'
|
'work_group6_actual_id', 'work_group7_actual_id', 'work_group8_actual_id', 'work_group9_actual_id', 'work_group10_actual_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($partValidDispColumns as $column) {
|
foreach ($partValidDispColumns as $column) {
|
||||||
@@ -234,11 +268,11 @@ class LineResource extends Resource
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
//->required(fn (callable $get) => $get('no_of_operation') >= 1),
|
// ->required(fn (callable $get) => $get('no_of_operation') >= 1),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('work_group1_actual_id')
|
Forms\Components\TextInput::make('work_group1_actual_id')
|
||||||
->label('Work Group Center 1')
|
->label('Work Group Center 1')
|
||||||
->hidden(fn (callable $get) => !$get('work_group1_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group1_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
@@ -255,14 +289,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group1_id_error', null);
|
$set('work_group1_id_error', null);
|
||||||
$set('work_group1_id', null);
|
$set('work_group1_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group1_id_error', null);
|
$set('work_group1_id_error', null);
|
||||||
$set('work_group1_id', null);
|
$set('work_group1_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group1_id_error', 'Invalid plant name.');
|
$set('work_group1_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,8 +306,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group1_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group1_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,10 +334,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group1_actual_id', '');
|
$set('work_group1_actual_id', '');
|
||||||
$set('work_group1_id', null);
|
$set('work_group1_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group1_id_error', null);
|
$set('work_group1_id_error', null);
|
||||||
$set('work_group1_id', $workGroupRecord->id);
|
$set('work_group1_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -315,7 +351,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group2_actual_id')
|
Forms\Components\TextInput::make('work_group2_actual_id')
|
||||||
->label('Work Group Center 2')
|
->label('Work Group Center 2')
|
||||||
->hidden(fn (callable $get) => !$get('work_group2_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group2_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -332,14 +368,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group2_id_error', null);
|
$set('work_group2_id_error', null);
|
||||||
$set('work_group2_id', null);
|
$set('work_group2_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group2_id_error', null);
|
$set('work_group2_id_error', null);
|
||||||
$set('work_group2_id', null);
|
$set('work_group2_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group2_id_error', 'Invalid plant name.');
|
$set('work_group2_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,8 +385,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group2_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group2_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,10 +408,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group2_actual_id', '');
|
$set('work_group2_actual_id', '');
|
||||||
$set('work_group2_id', null);
|
$set('work_group2_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group2_id_error', null);
|
$set('work_group2_id_error', null);
|
||||||
$set('work_group2_id', $workGroupRecord->id);
|
$set('work_group2_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -387,7 +425,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group3_actual_id')
|
Forms\Components\TextInput::make('work_group3_actual_id')
|
||||||
->label('Work Group Center 3')
|
->label('Work Group Center 3')
|
||||||
->hidden(fn (callable $get) => !$get('work_group3_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group3_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -404,14 +442,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group3_id_error', null);
|
$set('work_group3_id_error', null);
|
||||||
$set('work_group3_id', null);
|
$set('work_group3_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group3_id_error', null);
|
$set('work_group3_id_error', null);
|
||||||
$set('work_group3_id', null);
|
$set('work_group3_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group3_id_error', 'Invalid plant name.');
|
$set('work_group3_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,8 +459,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group3_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group3_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,10 +482,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group3_actual_id', '');
|
$set('work_group3_actual_id', '');
|
||||||
$set('work_group3_id', null);
|
$set('work_group3_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group3_id_error', null);
|
$set('work_group3_id_error', null);
|
||||||
$set('work_group3_id', $workGroupRecord->id);
|
$set('work_group3_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -459,7 +499,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group4_actual_id')
|
Forms\Components\TextInput::make('work_group4_actual_id')
|
||||||
->label('Work Group Center 4')
|
->label('Work Group Center 4')
|
||||||
->hidden(fn (callable $get) => !$get('work_group4_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group4_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -476,14 +516,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group4_id_error', null);
|
$set('work_group4_id_error', null);
|
||||||
$set('work_group4_id', null);
|
$set('work_group4_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group4_id_error', null);
|
$set('work_group4_id_error', null);
|
||||||
$set('work_group4_id', null);
|
$set('work_group4_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group4_id_error', 'Invalid plant name.');
|
$set('work_group4_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,8 +533,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group4_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group4_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,10 +556,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group4_actual_id', '');
|
$set('work_group4_actual_id', '');
|
||||||
$set('work_group4_id', null);
|
$set('work_group4_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group4_id_error', null);
|
$set('work_group4_id_error', null);
|
||||||
$set('work_group4_id', $workGroupRecord->id);
|
$set('work_group4_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -531,7 +573,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group5_actual_id')
|
Forms\Components\TextInput::make('work_group5_actual_id')
|
||||||
->label('Work Group Center 5')
|
->label('Work Group Center 5')
|
||||||
->hidden(fn (callable $get) => !$get('work_group5_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group5_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -548,14 +590,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group5_id_error', null);
|
$set('work_group5_id_error', null);
|
||||||
$set('work_group5_id', null);
|
$set('work_group5_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group5_id_error', null);
|
$set('work_group5_id_error', null);
|
||||||
$set('work_group5_id', null);
|
$set('work_group5_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group5_id_error', 'Invalid plant name.');
|
$set('work_group5_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,8 +607,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group5_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group5_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,10 +630,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group5_actual_id', '');
|
$set('work_group5_actual_id', '');
|
||||||
$set('work_group5_id', null);
|
$set('work_group5_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group5_id_error', null);
|
$set('work_group5_id_error', null);
|
||||||
$set('work_group5_id', $workGroupRecord->id);
|
$set('work_group5_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -603,7 +647,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group6_actual_id')
|
Forms\Components\TextInput::make('work_group6_actual_id')
|
||||||
->label('Work Group Center 6')
|
->label('Work Group Center 6')
|
||||||
->hidden(fn (callable $get) => !$get('work_group6_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group6_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -620,14 +664,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group6_id_error', null);
|
$set('work_group6_id_error', null);
|
||||||
$set('work_group6_id', null);
|
$set('work_group6_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group6_id_error', null);
|
$set('work_group6_id_error', null);
|
||||||
$set('work_group6_id', null);
|
$set('work_group6_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group6_id_error', 'Invalid plant name.');
|
$set('work_group6_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,8 +681,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group6_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group6_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,10 +704,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group6_actual_id', '');
|
$set('work_group6_actual_id', '');
|
||||||
$set('work_group6_id', null);
|
$set('work_group6_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group6_id_error', null);
|
$set('work_group6_id_error', null);
|
||||||
$set('work_group6_id', $workGroupRecord->id);
|
$set('work_group6_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -675,7 +721,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group7_actual_id')
|
Forms\Components\TextInput::make('work_group7_actual_id')
|
||||||
->label('Work Group Center 7')
|
->label('Work Group Center 7')
|
||||||
->hidden(fn (callable $get) => !$get('work_group7_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group7_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -692,14 +738,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group7_id_error', null);
|
$set('work_group7_id_error', null);
|
||||||
$set('work_group7_id', null);
|
$set('work_group7_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group7_id_error', null);
|
$set('work_group7_id_error', null);
|
||||||
$set('work_group7_id', null);
|
$set('work_group7_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group7_id_error', 'Invalid plant name.');
|
$set('work_group7_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,8 +755,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group7_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group7_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,10 +778,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group7_actual_id', '');
|
$set('work_group7_actual_id', '');
|
||||||
$set('work_group7_id', null);
|
$set('work_group7_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group7_id_error', null);
|
$set('work_group7_id_error', null);
|
||||||
$set('work_group7_id', $workGroupRecord->id);
|
$set('work_group7_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -747,7 +795,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group8_actual_id')
|
Forms\Components\TextInput::make('work_group8_actual_id')
|
||||||
->label('Work Group Center 8')
|
->label('Work Group Center 8')
|
||||||
->hidden(fn (callable $get) => !$get('work_group8_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group8_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -764,14 +812,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group8_id_error', null);
|
$set('work_group8_id_error', null);
|
||||||
$set('work_group8_id', null);
|
$set('work_group8_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group8_id_error', null);
|
$set('work_group8_id_error', null);
|
||||||
$set('work_group8_id', null);
|
$set('work_group8_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group8_id_error', 'Invalid plant name.');
|
$set('work_group8_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,8 +829,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group8_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group8_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,10 +852,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group8_actual_id', '');
|
$set('work_group8_actual_id', '');
|
||||||
$set('work_group8_id', null);
|
$set('work_group8_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group8_id_error', null);
|
$set('work_group8_id_error', null);
|
||||||
$set('work_group8_id', $workGroupRecord->id);
|
$set('work_group8_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -819,7 +869,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group9_actual_id')
|
Forms\Components\TextInput::make('work_group9_actual_id')
|
||||||
->label('Work Group Center 9')
|
->label('Work Group Center 9')
|
||||||
->hidden(fn (callable $get) => !$get('work_group9_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group9_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -836,14 +886,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group9_id_error', null);
|
$set('work_group9_id_error', null);
|
||||||
$set('work_group9_id', null);
|
$set('work_group9_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group9_id_error', null);
|
$set('work_group9_id_error', null);
|
||||||
$set('work_group9_id', null);
|
$set('work_group9_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group9_id_error', 'Invalid plant name.');
|
$set('work_group9_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,8 +903,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group9_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group9_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,10 +926,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group9_actual_id', '');
|
$set('work_group9_actual_id', '');
|
||||||
$set('work_group9_id', null);
|
$set('work_group9_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group9_id_error', null);
|
$set('work_group9_id_error', null);
|
||||||
$set('work_group9_id', $workGroupRecord->id);
|
$set('work_group9_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -891,7 +943,7 @@ class LineResource extends Resource
|
|||||||
|
|
||||||
Forms\Components\TextInput::make('work_group10_actual_id')
|
Forms\Components\TextInput::make('work_group10_actual_id')
|
||||||
->label('Work Group Center 10')
|
->label('Work Group Center 10')
|
||||||
->hidden(fn (callable $get) => !$get('work_group10_id_visible'))
|
->hidden(fn (callable $get) => ! $get('work_group10_id_visible'))
|
||||||
->default('')
|
->default('')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -908,14 +960,16 @@ class LineResource extends Resource
|
|||||||
if ($state == null || trim($state) == '') {
|
if ($state == null || trim($state) == '') {
|
||||||
$set('work_group10_id_error', null);
|
$set('work_group10_id_error', null);
|
||||||
$set('work_group10_id', null);
|
$set('work_group10_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$set('work_group10_id_error', null);
|
$set('work_group10_id_error', null);
|
||||||
$set('work_group10_id', null);
|
$set('work_group10_id', null);
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('work_group10_id_error', 'Invalid plant name.');
|
$set('work_group10_id_error', 'Invalid plant name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,8 +977,9 @@ class LineResource extends Resource
|
|||||||
->where('name', $state)
|
->where('name', $state)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
if (! $workGroupRecord) {
|
||||||
$set('work_group10_id_error', 'Work group does not exist for this plant in master.');
|
$set('work_group10_id_error', 'Work group does not exist for this plant in master.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,10 +1000,9 @@ class LineResource extends Resource
|
|||||||
->send();
|
->send();
|
||||||
$set('work_group10_actual_id', '');
|
$set('work_group10_actual_id', '');
|
||||||
$set('work_group10_id', null);
|
$set('work_group10_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('work_group10_id_error', null);
|
$set('work_group10_id_error', null);
|
||||||
$set('work_group10_id', $workGroupRecord->id);
|
$set('work_group10_id', $workGroupRecord->id);
|
||||||
}
|
}
|
||||||
@@ -984,6 +1038,7 @@ class LineResource 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('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -991,6 +1046,11 @@ class LineResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('block.name')
|
||||||
|
->label('Block')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->label('Line')
|
->label('Line')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -1142,14 +1202,14 @@ class LineResource extends Resource
|
|||||||
->label('Import Lines')
|
->label('Import Lines')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(LineImporter::class)
|
->importer(LineImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import line');
|
return Filament::auth()->user()->can('view import line');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Lines')
|
->label('Export Lines')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(LineExporter::class)
|
->exporter(LineExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export line');
|
return Filament::auth()->user()->can('view export line');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
|||||||
use App\Filament\Exports\ProductionPlanExporter;
|
use App\Filament\Exports\ProductionPlanExporter;
|
||||||
use App\Filament\Imports\ProductionPlanImporter;
|
use App\Filament\Imports\ProductionPlanImporter;
|
||||||
use App\Filament\Resources\ProductionPlanResource\Pages;
|
use App\Filament\Resources\ProductionPlanResource\Pages;
|
||||||
use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
@@ -16,19 +16,18 @@ 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\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
use Illuminate\Support\Facades\Request;
|
|
||||||
|
|
||||||
class ProductionPlanResource extends Resource
|
class ProductionPlanResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -55,22 +54,22 @@ class ProductionPlanResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->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(ProductionPlan::latest()->first())->plant_id;
|
return optional(ProductionPlan::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('block_name', null);
|
$set('block_name', null);
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('ppPlantError', 'Please select a plant first.');
|
$set('ppPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('ppPlantError', null);
|
$set('ppPlantError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -79,102 +78,6 @@ class ProductionPlanResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('block_name')
|
|
||||||
->required()
|
|
||||||
// ->nullable()
|
|
||||||
->label('Block')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (!$get('plant_id')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Block::where('plant_id', $get('plant_id'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->default(function () {
|
|
||||||
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
|
|
||||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
|
||||||
})
|
|
||||||
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
if($get('id'))
|
|
||||||
{
|
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
|
||||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
|
||||||
if($getBlock->block_id)
|
|
||||||
{
|
|
||||||
$set('block_name', $getBlock->block_id);
|
|
||||||
$set('ppBlockError', null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$blockId = $get('block_name');
|
|
||||||
$set('shift_id', null);
|
|
||||||
|
|
||||||
if (!$blockId) {
|
|
||||||
$set('ppBlockError', 'Please select a block first.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('ppBlockError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('ppBlockError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('ppBlockError') ? $get('ppBlockError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required()
|
|
||||||
// ->nullable()
|
|
||||||
->autofocus(true)
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (!$get('plant_id') || !$get('block_name')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Shift::where('plant_id', $get('plant_id'))
|
|
||||||
->where('block_id', $get('block_name'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->default(function () {
|
|
||||||
return optional(ProductionPlan::latest()->first())->shift_id;
|
|
||||||
})
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
if($get('id'))
|
|
||||||
{
|
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
|
||||||
if($getShift->shift_id)
|
|
||||||
{
|
|
||||||
$set('shift_id', $getShift->shift_id);
|
|
||||||
$set('ppShiftError', null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$curShiftId = $get('shift_id');
|
|
||||||
$set('line_id', null);
|
|
||||||
|
|
||||||
if (!$curShiftId) {
|
|
||||||
$set('ppShiftError', 'Please select a shift first.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('ppShiftError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('ppShiftError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('ppShiftError') ? $get('ppShiftError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
->required()
|
->required()
|
||||||
@@ -185,7 +88,7 @@ class ProductionPlanResource extends Resource
|
|||||||
// ->toArray() // Convert collection to array
|
// ->toArray() // Convert collection to array
|
||||||
// )
|
// )
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (!$get('plant_id') || !$get('block_name') || !$get('shift_id')) {
|
if (! $get('plant_id')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,207 +100,54 @@ class ProductionPlanResource extends Resource
|
|||||||
// ->default(function () {
|
// ->default(function () {
|
||||||
// return optional(ProductionPlan::latest()->first())->line_id;
|
// return optional(ProductionPlan::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 = ProductionPlan::where('id', $get('id'))->first();
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
// if ($getShift->line_id) {
|
||||||
if($getShift->line_id)
|
// $set('line_id', $getShift->line_id);
|
||||||
{
|
// $set('ppLineError', null);
|
||||||
$set('line_id', $getShift->line_id);
|
// }
|
||||||
$set('ppLineError', null);
|
// } else {
|
||||||
}
|
// $currentDT = Carbon::now()->toDateTimeString();
|
||||||
}
|
// $set('created_at', $currentDT);
|
||||||
else
|
// $set('update_date', null);
|
||||||
{
|
// }
|
||||||
$currentDT = Carbon::now()->toDateTimeString();
|
|
||||||
$set('created_at', $currentDT);
|
|
||||||
$set('update_date', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lineId = $get('line_id');
|
// $lineId = $get('line_id');
|
||||||
// $set('plan_quantity', null);
|
// // $set('plan_quantity', null);
|
||||||
|
|
||||||
if (!$lineId) {
|
// if (! $lineId) {
|
||||||
$set('ppLineError', 'Please select a line first.');
|
// $set('ppLineError', 'Please select a line first.');
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$isUpdate = !empty($get('id'));
|
|
||||||
if (!$isUpdate)
|
|
||||||
{
|
|
||||||
$exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
->where('shift_id', $get('shift_id'))
|
|
||||||
->where('line_id', $get('line_id'))
|
|
||||||
->whereDate('created_at', today())
|
|
||||||
->latest()
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($exists)
|
|
||||||
{
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Production plan already updated.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
->where('shift_id', $get('shift_id'))
|
|
||||||
->where('line_id', $get('line_id'))
|
|
||||||
->whereDate('created_at', Carbon::yesterday())
|
|
||||||
->latest()
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($existShifts) //if ($existShifts->count() > 0)
|
|
||||||
{
|
|
||||||
//$currentDate = date('Y-m-d');
|
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
|
||||||
//echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Production plan already updated.');
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$currentDate = date('Y-m-d');
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
|
||||||
//echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Choosed a invalid shift.');
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//$currentDate = date('Y-m-d');
|
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
|
||||||
//echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
// here i'm updating created as yesterday
|
|
||||||
$set('created_at', $from_dt);
|
|
||||||
$set('update_date', '1');
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$currentDate = date('Y-m-d');
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
|
||||||
//echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Choosed a invalid shift.');
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $isUpdate = ! empty($get('id'));
|
||||||
|
// if (! $isUpdate) {
|
||||||
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
// //->where('shift_id', $get('shift_id'))
|
// ->where('shift_id', $get('shift_id'))
|
||||||
// ->where('line_id', $get('line_id'))
|
// ->where('line_id', $get('line_id'))
|
||||||
// ->whereDate('created_at', today())
|
// ->whereDate('created_at', today())
|
||||||
// ->latest() // Orders by created_at DESC
|
// ->latest()
|
||||||
// ->first();
|
// ->exists();
|
||||||
|
|
||||||
// if ($exists)
|
// if ($exists) {
|
||||||
// {
|
// $set('line_id', null);
|
||||||
// $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
// $set('ppLineError', 'Production plan already updated.');
|
||||||
// //->where('shift_id', $get('shift_id'))
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// ->where('shift_id', $get('shift_id'))
|
||||||
// ->where('line_id', $get('line_id'))
|
// ->where('line_id', $get('line_id'))
|
||||||
// // ->whereDate('created_at', today())
|
// ->whereDate('created_at', Carbon::yesterday())
|
||||||
// ->whereDate('created_at', today())
|
// ->latest()
|
||||||
// ->get();
|
// ->exists();
|
||||||
|
|
||||||
// foreach ($existingShifts as $shift) {
|
// if ($existShifts) { // if ($existShifts->count() > 0)
|
||||||
// $curShiftId = $shift->shift_id;
|
// // $currentDate = date('Y-m-d');
|
||||||
|
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
// $currentDate = date('Y-m-d');
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
|
||||||
// $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
|
||||||
// ->first();
|
// ->first();
|
||||||
|
|
||||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -406,39 +156,201 @@ class ProductionPlanResource extends Resource
|
|||||||
|
|
||||||
// $totalMinutes = $hRs * 60 + $miNs;
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||||
|
|
||||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
// $currentDateTime = date('Y-m-d H:i:s');
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
// // Check if current date time is within the range
|
// // Check if current date time is within the range
|
||||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
// //echo "Choosed a valid shift...";
|
// // echo "Choosed a valid shift...";
|
||||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
|
|
||||||
// $set('line_id', null);
|
// $set('line_id', null);
|
||||||
// $set('ppLineError', 'Production plan already updated.');
|
// $set('ppLineError', 'Production plan already updated.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $currentDate.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// // else {
|
// }
|
||||||
// // $set('ppLineError', 'Choosed a invalid shift...');
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// // $currentDate = date('Y-m-d');
|
||||||
|
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// // here i'm updating created as yesterday
|
||||||
|
// $set('created_at', $from_dt);
|
||||||
|
// $set('update_date', '1');
|
||||||
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $currentDate.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// // //->where('shift_id', $get('shift_id'))
|
||||||
|
// // ->where('line_id', $get('line_id'))
|
||||||
|
// // ->whereDate('created_at', today())
|
||||||
|
// // ->latest() // Orders by created_at DESC
|
||||||
|
// // ->first();
|
||||||
|
|
||||||
|
// // if ($exists)
|
||||||
|
// // {
|
||||||
|
// // $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// // //->where('shift_id', $get('shift_id'))
|
||||||
|
// // ->where('line_id', $get('line_id'))
|
||||||
|
// // // ->whereDate('created_at', today())
|
||||||
|
// // ->whereDate('created_at', today())
|
||||||
|
// // ->get();
|
||||||
|
|
||||||
|
// // foreach ($existingShifts as $shift) {
|
||||||
|
// // $curShiftId = $shift->shift_id;
|
||||||
|
|
||||||
|
// // $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// // $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
||||||
|
// // ->first();
|
||||||
|
|
||||||
|
// // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// // $hRs = (int) $hRs;
|
||||||
|
// // // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// // $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// // $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||||
|
|
||||||
|
// // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// // $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // // Check if current date time is within the range
|
||||||
|
// // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
|
// // //echo "Choosed a valid shift...";
|
||||||
|
// // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
|
||||||
|
// // $set('line_id', null);
|
||||||
|
// // $set('ppLineError', 'Production plan already updated.');
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
// // // else {
|
||||||
|
// // // $set('ppLineError', 'Choosed a invalid shift...');
|
||||||
|
// // // return;
|
||||||
|
// // // }
|
||||||
|
// // }
|
||||||
|
// // $set('ppLineError', null);
|
||||||
// // return;
|
// // return;
|
||||||
// // }
|
// // }
|
||||||
// }
|
// }
|
||||||
// $set('ppLineError', null);
|
|
||||||
// return;
|
|
||||||
// }
|
// }
|
||||||
}
|
// $set('ppLineError', null);
|
||||||
}
|
// }
|
||||||
$set('ppLineError', null);
|
// })
|
||||||
}
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('item_id', null);
|
||||||
|
$set('plan_quantity', null);
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('ppLineError') ? 'border-red-500' : '',
|
'class' => $get('ppLineError') ? 'border-red-500' : '',
|
||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
|
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->label('Item')
|
||||||
|
->reactive()
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (! $get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('code', 'id')
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('plan_quantity')
|
Forms\Components\TextInput::make('plan_quantity')
|
||||||
->required()
|
->required()
|
||||||
->integer()
|
->integer()
|
||||||
@@ -449,21 +361,18 @@ class ProductionPlanResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$planQuan = $get('plan_quantity');
|
$planQuan = $get('plan_quantity');
|
||||||
|
|
||||||
if(!$get('update_date') )
|
if (! $get('update_date')) {
|
||||||
{
|
if (! $get('id')) {
|
||||||
if(!$get('id'))
|
|
||||||
{
|
|
||||||
$currentDT = Carbon::now()->toDateTimeString();
|
$currentDT = Carbon::now()->toDateTimeString();
|
||||||
$set('created_at', $currentDT);
|
$set('created_at', $currentDT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$planQuan) {
|
if (! $planQuan) {
|
||||||
$set('ppPlanQuanError', 'Scan the valid plan quantity.');
|
$set('ppPlanQuanError', 'Scan the valid plan quantity.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('ppPlanQuanError', null);
|
$set('ppPlanQuanError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -472,29 +381,19 @@ class ProductionPlanResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
|
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('production_quantity')
|
// Forms\Components\TextInput::make('production_quantity')
|
||||||
->required()
|
// ->required()
|
||||||
->integer()
|
// ->integer()
|
||||||
->label('Production Quantity')
|
// ->label('Production Quantity')
|
||||||
->readOnly(fn (callable $get) => !$get('id'))
|
// ->readOnly(fn (callable $get) => ! $get('id'))
|
||||||
->default(0),
|
// ->default(0),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
Forms\Components\TextInput::make('update_date')
|
|
||||||
->hidden()
|
|
||||||
->reactive()
|
|
||||||
->readOnly(),
|
|
||||||
Forms\Components\DateTimePicker::make('created_at')
|
|
||||||
->label('Created DateTime')
|
|
||||||
->hidden()
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->readOnly(),
|
|
||||||
Forms\Components\Hidden::make('operator_id')
|
Forms\Components\Hidden::make('operator_id')
|
||||||
->default(Filament::auth()->user()->name),
|
->default(Filament::auth()->user()->name),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(4),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,34 +428,55 @@ class ProductionPlanResource 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('plant.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
|
->label('Item')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('plan_quantity')
|
Tables\Columns\TextColumn::make('plan_quantity')
|
||||||
->label('Plan Quantity')
|
->label('Plan Quantity')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('working_days')
|
||||||
|
->label('Working Days')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('production_quantity')
|
Tables\Columns\TextColumn::make('production_quantity')
|
||||||
->label('Production Quantity')
|
->label('Production Quantity')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
->searchable(),
|
||||||
->label('Line')
|
// Tables\Columns\TextColumn::make('line.name')
|
||||||
->alignCenter()
|
// ->label('Line')
|
||||||
->sortable(),// ->searchable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('shift.block.name')
|
// ->sortable(), // ->searchable(),
|
||||||
->label('Block')
|
// Tables\Columns\TextColumn::make('shift.block.name')
|
||||||
->alignCenter()
|
// ->label('Block')
|
||||||
->sortable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
// ->sortable(),
|
||||||
->label('Shift')
|
// Tables\Columns\TextColumn::make('shift.name')
|
||||||
->alignCenter()
|
// ->label('Shift')
|
||||||
->sortable(),// ->searchable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
// ->sortable(), // ->searchable(),
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),// ->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
@@ -584,7 +504,7 @@ class ProductionPlanResource extends Resource
|
|||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
//plant
|
// plant
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->nullable()
|
->nullable()
|
||||||
@@ -593,7 +513,8 @@ class ProductionPlanResource 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();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -602,31 +523,33 @@ class ProductionPlanResource extends Resource
|
|||||||
$set('Shift', null);
|
$set('Shift', null);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
//line
|
// line
|
||||||
Select::make('Line')
|
Select::make('Line')
|
||||||
->label('Select line')
|
->label('Select line')
|
||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
if (!$plantId ) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Line::where('plant_id', $plantId)
|
return Line::where('plant_id', $plantId)
|
||||||
->pluck('name', 'id');
|
->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
//block
|
// block
|
||||||
Select::make('Block')
|
Select::make('Block')
|
||||||
->label('Select Block')
|
->label('Select Block')
|
||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
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()
|
||||||
@@ -634,7 +557,7 @@ class ProductionPlanResource extends Resource
|
|||||||
$set('Shift', null);
|
$set('Shift', null);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
//shift
|
// shift
|
||||||
Select::make('Shift')
|
Select::make('Shift')
|
||||||
->label('Select Shift')
|
->label('Select Shift')
|
||||||
->nullable()
|
->nullable()
|
||||||
@@ -642,7 +565,7 @@ class ProductionPlanResource extends Resource
|
|||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
$blockId = $get('Block');
|
$blockId = $get('Block');
|
||||||
|
|
||||||
if (!$plantId || !$blockId) {
|
if (! $plantId || ! $blockId) {
|
||||||
return []; // Return empty if plant or block is not selected
|
return []; // Return empty if plant or block is not selected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,52 +592,66 @@ class ProductionPlanResource 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) {
|
|
||||||
$query->where('line_id', $line);
|
if (! empty($data['Line'])) {// if ($line = $data['Line'] ?? null) {
|
||||||
|
$query->where('line_id', $data['Line']);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
})
|
})
|
||||||
->indicateUsing(function (array $data) {
|
->indicateUsing(function (array $data) {
|
||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
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'])) {
|
||||||
$indicators[] = 'Shift: ' . Shift::where('id', $data['Shift'])->value('name');
|
$indicators[] = 'Shift: '.Shift::where('id', $data['Shift'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Line'])) {
|
if (! empty($data['Line'])) {
|
||||||
$indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name');
|
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: ' . $data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$indicators[] = 'To: ' . $data['created_to'];
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
@@ -726,7 +663,7 @@ class ProductionPlanResource extends Resource
|
|||||||
Tables\Actions\DeleteBulkAction::make(),
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
FilamentExportBulkAction::make('export')
|
FilamentExportBulkAction::make('export'),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
@@ -734,14 +671,14 @@ class ProductionPlanResource extends Resource
|
|||||||
->label('Import Production Plans')
|
->label('Import Production Plans')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(ProductionPlanImporter::class)
|
->importer(ProductionPlanImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import production plan');
|
return Filament::auth()->user()->can('view import production plan');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Production Plans')
|
->label('Export Production Plans')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(ProductionPlanExporter::class)
|
->exporter(ProductionPlanExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export production plan');
|
return Filament::auth()->user()->can('view export production plan');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ class Item extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'plant_id',
|
'plant_id',
|
||||||
|
'line_id',
|
||||||
'category',
|
'category',
|
||||||
'code',
|
'code',
|
||||||
'description',
|
'description',
|
||||||
'hourly_quantity',
|
'hourly_quantity',
|
||||||
'uom',
|
'uom',
|
||||||
|
'line_capacity',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function plant(): BelongsTo
|
public function plant(): BelongsTo
|
||||||
@@ -24,6 +26,11 @@ class Item extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function line(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Line::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function stickerMasters()
|
public function stickerMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(StickerMaster::class, 'item_id', 'id');
|
return $this->hasMany(StickerMaster::class, 'item_id', 'id');
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Line extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
|
"block_id",
|
||||||
"name",
|
"name",
|
||||||
"type",
|
"type",
|
||||||
"group_work_center",
|
"group_work_center",
|
||||||
@@ -34,6 +35,11 @@ class Line extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function block(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Block::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testingPanelReadings()
|
public function testingPanelReadings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TestingPanelReading::class);
|
return $this->hasMany(TestingPanelReading::class);
|
||||||
|
|||||||
@@ -12,12 +12,15 @@ class ProductionPlan extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
|
"item_id",
|
||||||
"shift_id",
|
"shift_id",
|
||||||
"created_at",
|
"created_at",
|
||||||
"line_id",
|
"line_id",
|
||||||
"plan_quantity",
|
"plan_quantity",
|
||||||
"production_quantity",
|
"production_quantity",
|
||||||
"operator_id",
|
"operator_id",
|
||||||
|
"working_days",
|
||||||
|
"leave_dates",
|
||||||
];
|
];
|
||||||
|
|
||||||
public function plant(): BelongsTo
|
public function plant(): BelongsTo
|
||||||
@@ -34,4 +37,9 @@ class ProductionPlan extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Line::class);
|
return $this->belongsTo(Line::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class ProductionQuantity extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
|
"machine_id",
|
||||||
"shift_id",
|
"shift_id",
|
||||||
"line_id",
|
"line_id",
|
||||||
"item_id",
|
"item_id",
|
||||||
@@ -50,6 +51,11 @@ class ProductionQuantity extends Model
|
|||||||
return $this->belongsTo(Item::class);
|
return $this->belongsTo(Item::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function machine(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Machine::class);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::created(function ($productionQuantity) {
|
static::created(function ($productionQuantity) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</div> --}}
|
</div> --}}
|
||||||
<div class="flex gap-6 -mt-6">
|
<div class="flex gap-6 -mt-6">
|
||||||
<!-- Scan QR Code -->
|
<!-- Scan QR Code -->
|
||||||
<div class="w-1/2">
|
<div class="w-full">
|
||||||
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
SCAN QR CODE
|
SCAN QR CODE
|
||||||
</label>
|
</label>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Last Scanned QR -->
|
<!-- Last Scanned QR -->
|
||||||
<div class="w-1/2">
|
{{-- <div class="w-1/2">
|
||||||
<label for="recent-qr-input" class="block text-sm font-medium text-gray-700 mb-2">
|
<label for="recent-qr-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
LAST SCANNED QR
|
LAST SCANNED QR
|
||||||
</label>
|
</label>
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
readonly
|
readonly
|
||||||
wire:model="recent_qr"
|
wire:model="recent_qr"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div> --}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user