Compare commits
135 Commits
67ee3ce0f2
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33d44b5479 | ||
|
|
5d0004160c | ||
|
|
b9be6cf10d | ||
|
|
966f72c682 | ||
|
|
88f1674f23 | ||
|
|
1c37e1bb0b | ||
|
|
c6fd61a9ba | ||
|
|
9a73751e35 | ||
|
|
3de43a9495 | ||
|
|
10081fd20e | ||
|
|
5d7b9d52f8 | ||
|
|
499fa0b2dd | ||
|
|
27b5ad2cfe | ||
|
|
4c7bed8c63 | ||
|
|
253d319587 | ||
|
|
ead2edc63b | ||
|
|
18f23ce097 | ||
|
|
198b901671 | ||
|
|
3192e32d5d | ||
|
|
61be13c367 | ||
|
|
3d139c005a | ||
|
|
4325f2695f | ||
|
|
8eeb23e2aa | ||
|
|
73611a417b | ||
|
|
37df670eab | ||
|
|
58b801b8e2 | ||
|
|
5aa2e7a871 | ||
|
|
97fb46883f | ||
|
|
e20892cc83 | ||
|
|
658db00ac8 | ||
|
|
ec8bfc8296 | ||
|
|
6dff4fb77e | ||
|
|
41d158877e | ||
|
|
0b5b0b8dd4 | ||
|
|
9c582b73a5 | ||
|
|
a67386f7a0 | ||
|
|
c8fafeb140 | ||
|
|
f58044036b | ||
|
|
a91a4ef4f7 | ||
|
|
363241b880 | ||
|
|
23908b1493 | ||
|
|
1fe0012a9b | ||
|
|
2efa172e36 | ||
|
|
a72f03b496 | ||
|
|
33ef93a23f | ||
|
|
66a7406ee3 | ||
|
|
392a563561 | ||
|
|
ed9d53b0ae | ||
|
|
4fa6d485da | ||
|
|
7e49872760 | ||
|
|
e3a60b276c | ||
|
|
8764ebcbee | ||
|
|
d66a043fa8 | ||
|
|
48f90c7b41 | ||
|
|
1735527722 | ||
|
|
c46d49898d | ||
|
|
7921694adb | ||
|
|
ac9d9cec8d | ||
|
|
dd84356591 | ||
|
|
232316f516 | ||
|
|
a292b44fa9 | ||
|
|
03fa601b34 | ||
|
|
dd19de6d84 | ||
|
|
2146fd71b7 | ||
|
|
e1f08ad453 | ||
|
|
05b2f61cc0 | ||
|
|
aebc61c9c4 | ||
|
|
37d42a34de | ||
|
|
ec0a53e308 | ||
|
|
e01dc71417 | ||
|
|
0e3f680eea | ||
|
|
fe21bdfcef | ||
|
|
e060c2069c | ||
|
|
fbb44e3f68 | ||
|
|
df6b68337a | ||
|
|
dc3ec3913c | ||
|
|
2a18cd5f63 | ||
|
|
1b8cbb6a40 | ||
|
|
0e1accaaec | ||
|
|
aae1108271 | ||
|
|
6d5184335b | ||
|
|
2b1d095437 | ||
|
|
3d3e85be0d | ||
|
|
e03f01c20a | ||
|
|
bc1e533112 | ||
|
|
d14fd4e115 | ||
|
|
d328985b1b | ||
|
|
2a9df38262 | ||
|
|
1e455088f3 | ||
|
|
b34d48fe92 | ||
|
|
a471a43b1b | ||
|
|
304f0499ca | ||
|
|
8a5641ec35 | ||
|
|
5c9c425b4b | ||
|
|
b74848fb68 | ||
|
|
a0ba1acb2a | ||
|
|
8530881733 | ||
|
|
19b9f3b1b7 | ||
|
|
73fdd25cf9 | ||
|
|
9f6f9a6274 | ||
|
|
ab534b4c46 | ||
|
|
62dcc122e8 | ||
|
|
b5973aa826 | ||
|
|
17fcaf8b20 | ||
|
|
6ff1718ca2 | ||
|
|
bba8649da7 | ||
|
|
fe54de7ac8 | ||
|
|
1704761844 | ||
|
|
0f29c0071c | ||
|
|
5aec248632 | ||
|
|
19e2d08adc | ||
|
|
4d89c27a3b | ||
|
|
7be7d038da | ||
|
|
66cea1f3ec | ||
|
|
1777f9df89 | ||
|
|
650bd88426 | ||
|
|
e2dc42e62b | ||
|
|
6cbcb2662a | ||
|
|
f4b7ce19c0 | ||
|
|
8d70882643 | ||
|
|
1f27d5147e | ||
|
|
18811583ba | ||
|
|
93e4ab2396 | ||
|
|
b4d4da99a1 | ||
|
|
060c3e9c94 | ||
|
|
b25120acf9 | ||
|
|
01f521794b | ||
|
|
ed8398b53e | ||
|
|
fff2169dd6 | ||
|
|
cb5d2c89d6 | ||
|
|
f1a7518f10 | ||
|
|
e80bafbc32 | ||
|
|
cba5a287fa | ||
|
|
e2ffde623d | ||
|
|
9bf596b389 |
@@ -49,6 +49,13 @@ class SendInvoiceDataReport extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$todayRecordExists = InvoiceDataValidation::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
if (!$todayRecordExists) {
|
||||
$this->info('No records created today. Mail not sent.');
|
||||
return;
|
||||
}
|
||||
|
||||
// if (strtolower($scheduleType) == 'daily') {
|
||||
// $startDate = now()->subDay()->setTime(10, 0, 0);//8:00
|
||||
// $endDate = now()->setTime(10, 0, 0);//8
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\InvoiceTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceInTransit;
|
||||
use App\Models\InvoiceMaster;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -52,6 +53,13 @@ class SendInvoiceTransitReport extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$todayRecordExists = InvoiceInTransit::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
if (!$todayRecordExists) {
|
||||
$this->info('No records created today. Mail not sent.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
$results = DB::table('invoice_in_transits as it')
|
||||
->join('invoice_masters as im', function ($join) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ProductionMail;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
@@ -75,59 +76,211 @@ class SendProductionReport extends Command
|
||||
|
||||
// .
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
|
||||
// $month = $startDate->month;
|
||||
// $year = $startDate->year;
|
||||
|
||||
// $workingDays = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->value('working_days') ?? 0;
|
||||
|
||||
// $totalTargetQuantity = 0;
|
||||
|
||||
// $monthlyPlan = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->sum('plan_quantity'); // / $workingDays
|
||||
|
||||
// $dailyTarget = $workingDays > 0
|
||||
// ? $monthlyPlan / $workingDays
|
||||
// : 0;
|
||||
|
||||
// $dailyTarget = round($dailyTarget, 2);
|
||||
|
||||
// // $totalTargetQuantity = round($totalTargetQuantity, 2);
|
||||
|
||||
// $monthStart = $startDate->copy()->startOfMonth();
|
||||
// $completedDays = $monthStart->diffInDays($startDate);
|
||||
|
||||
// $expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
// if (strtolower($line->type) == 'fg line') {
|
||||
// $productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
// } else {
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
// }
|
||||
|
||||
// $previousRemaining = max(0, $expectedTillYesterday - $productionQuantity);
|
||||
|
||||
// $totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'type' => $line->type,
|
||||
// 'targetQuantity' => $totalTargetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//..New Logic
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
|
||||
$month = $startDate->month;
|
||||
$year = $startDate->year;
|
||||
|
||||
$workingDays = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->value('working_days') ?? 0;
|
||||
|
||||
$monthlyPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->sum('plan_quantity');
|
||||
|
||||
/** @phpstan-ignore property.notFound */
|
||||
$dailyTarget = $workingDays > 0 ? $monthlyPlan / $workingDays : 0;
|
||||
|
||||
$dailyTarget = round($dailyTarget, 2);
|
||||
|
||||
$leaveDatesString = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->value('leave_dates');
|
||||
|
||||
$leaveDates = $leaveDatesString ? explode(',', $leaveDatesString) : [];
|
||||
|
||||
$monthStart = $startDate->copy()->startOfMonth();
|
||||
$yesterday = $startDate->copy()->subDay();
|
||||
|
||||
$completedDays = 0;
|
||||
$currentDate = $monthStart->copy();
|
||||
|
||||
while ($currentDate->lte($yesterday)) {
|
||||
|
||||
if (!in_array($currentDate->format('Y-m-d'), $leaveDates)) {
|
||||
$completedDays++;
|
||||
}
|
||||
|
||||
$currentDate->addDay();
|
||||
}
|
||||
|
||||
$expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$producedTillYesterday = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
|
||||
} else {
|
||||
|
||||
$producedTillYesterday = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
}
|
||||
|
||||
$previousRemaining = max(0, $expectedTillYesterday - $producedTillYesterday);
|
||||
|
||||
$totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
$itemIds = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->distinct()
|
||||
->pluck('item_id');
|
||||
|
||||
$totalHourlyQuantity = Item::whereIn('id', $itemIds)
|
||||
->sum('hourly_quantity');
|
||||
|
||||
$capacityQuan = $totalHourlyQuantity * 22.5;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
} else {
|
||||
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
}
|
||||
|
||||
if ($capacityQuan > 0) {
|
||||
$efficiency = ($productionQuantity / $capacityQuan) * 100;
|
||||
} else {
|
||||
$efficiency = 0;
|
||||
}
|
||||
|
||||
$efficiency = round($efficiency, 2);
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'line' => $line->name,
|
||||
'type' => $line->type,
|
||||
'targetQuantity' => $targetQuantity,
|
||||
'line' => $line->name,
|
||||
'capacityQuantity' => floor($capacityQuan),
|
||||
'targetQuantity' => floor($totalTargetQuantity),
|
||||
'productionQuantity' => $productionQuantity,
|
||||
'efficiency' => $efficiency . '%',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
// $service = new \App\Services\ProductionTargetService();
|
||||
|
||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
// $year = $startDate->year;
|
||||
// $month = $startDate->month;
|
||||
|
||||
// if (!empty($emails)) {
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new ProductionMail($tableData));
|
||||
// }
|
||||
// } else {
|
||||
// $this->info('No recipients found for ProductionMailAlert.');
|
||||
// }
|
||||
// [$records, $dates] = $service->generate(
|
||||
// $plantId,
|
||||
// $year,
|
||||
// $month,
|
||||
// );
|
||||
|
||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
// Preview in console
|
||||
$mail = new ProductionMail($scheduleType, $tableData);
|
||||
|
||||
// $mail = new ProductionMail($scheduleType,$tableData,$records,$dates);
|
||||
|
||||
$contentVars = $mail->content()->with;
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Production Report');
|
||||
$this->table(
|
||||
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
|
||||
['No', 'Plant', 'Line', 'Type', 'Capacity Quantity', 'Target Quantity', 'Production Quantity'],
|
||||
$tableData
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
|
||||
@@ -34,7 +34,7 @@ class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
|
||||
|
||||
// Add dynamic headings for each date: Target / Produced
|
||||
foreach ($this->dates as $date) {
|
||||
$headings[] = $date . ' - Line Capacity';
|
||||
$headings[] = $date . ' - Item Quantity';
|
||||
$headings[] = $date . ' - Target Plan';
|
||||
$headings[] = $date . ' - Produced Quantity';
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
|
||||
];
|
||||
|
||||
foreach ($this->dates as $date) {
|
||||
$mapped[] = $row['daily_line_capacity'][$date] ?? '-';
|
||||
$mapped[] = $row['daily_hourly_quantity'][$date] ?? '-';
|
||||
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
|
||||
$mapped[] = $row['produced_quantity'][$date] ?? '-';
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CharacteristicValue;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
@@ -28,6 +29,8 @@ class CharacteristicValueExporter extends Exporter
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('process_order')
|
||||
@@ -36,6 +39,18 @@ class CharacteristicValueExporter extends Exporter
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('spec_value')
|
||||
->label('Spec. Value')
|
||||
->formatStateUsing(function ($record) {
|
||||
|
||||
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)
|
||||
->where('item_id', $record->item_id)
|
||||
->where('line_id', $record->line_id)
|
||||
->where('machine_id', $record->machine_id)
|
||||
->first();
|
||||
|
||||
return $specVal?->lower . ' - ' . $specVal?->upper;
|
||||
}),
|
||||
ExportColumn::make('observed_value')
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -24,6 +24,8 @@ class ClassCharacteristicExporter extends Exporter
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
@@ -41,7 +43,7 @@ class ClassCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD'),
|
||||
ExportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPSTEXT'),
|
||||
->label('ZMM AMPS'),
|
||||
ExportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND'),
|
||||
ExportColumn::make('zmm_degreeofprotection')
|
||||
@@ -81,7 +83,7 @@ class ClassCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP'),
|
||||
ExportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLING FLOW'),
|
||||
->label('ZMM MINCOOLINGFLOW'),
|
||||
ExportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES'),
|
||||
ExportColumn::make('zmm_motor_model')
|
||||
@@ -204,6 +206,12 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE'),
|
||||
ExportColumn::make('zmm_beenumber')
|
||||
@@ -214,12 +222,6 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM CODECLASS'),
|
||||
ExportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE'),
|
||||
ExportColumn::make('zmm_grwt_pset')
|
||||
@@ -280,20 +282,52 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME'),
|
||||
ExportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME'),
|
||||
ExportColumn::make('marked_by')
|
||||
->label('MARKED BY'),
|
||||
ExportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED STATUS'),
|
||||
->label('MANUAL MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME'),
|
||||
ExportColumn::make('man_marked_by')
|
||||
->label('MANUAL MARKED BY'),
|
||||
ExportColumn::make('motor_marked_status')
|
||||
->label('MOTOR MARKED STATUS'),
|
||||
ExportColumn::make('motor_marked_physical_count')
|
||||
->label('MOTOR MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME'),
|
||||
ExportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY'),
|
||||
ExportColumn::make('pump_marked_status')
|
||||
->label('PUMP MARKED STATUS'),
|
||||
ExportColumn::make('pump_marked_physical_count')
|
||||
->label('PUMP MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME'),
|
||||
ExportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY'),
|
||||
ExportColumn::make('name_plate_marked_status')
|
||||
->label('NAME PLATE MARKED STATUS'),
|
||||
ExportColumn::make('name_plate_expected_time')
|
||||
->label('NAME PLATE EXPECTED TIME'),
|
||||
ExportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY'),
|
||||
ExportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME'),
|
||||
ExportColumn::make('pump_machine_name')
|
||||
->label('PUMP MACHINE NAME'),
|
||||
ExportColumn::make('name_plate_machine_name')
|
||||
->label('NAME PLATE MACHINE NAME'),
|
||||
ExportColumn::make('pumpset_machine_name')
|
||||
->label('PUMPSET MACHINE NAME'),
|
||||
ExportColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation_2')
|
||||
@@ -302,10 +336,8 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('SAMLIGHT LOGGED NAME'),
|
||||
ExportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS'),
|
||||
ExportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME'),
|
||||
ExportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME'),
|
||||
ExportColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
|
||||
@@ -28,12 +28,16 @@ class ProcessOrderExporter extends Exporter
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('PROCESS ORDER'),
|
||||
ExportColumn::make('coil_number')
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('order_quantity')
|
||||
->label('ORDER QUANTITY'),
|
||||
ExportColumn::make('updated_order_quantity')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ExportColumn::make('received_quantity')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ExportColumn::make('sfg_number')
|
||||
|
||||
@@ -26,6 +26,8 @@ class ProductCharacteristicsMasterExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'), // machine.workGroupMaster.name
|
||||
ExportColumn::make('machine.workGroupMaster.name')
|
||||
|
||||
@@ -34,6 +34,8 @@ class QualityValidationExporter extends Exporter
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('stickerMaster.item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
|
||||
@@ -28,6 +28,10 @@ class StickerMasterExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
->label('SERIAL NUMBER MOTOR'),
|
||||
ExportColumn::make('serial_number_pump')
|
||||
|
||||
143
app/Filament/Exports/StockDataMasterExporter.php
Normal file
143
app/Filament/Exports/StockDataMasterExporter.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StockDataMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StockDataMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('location')
|
||||
->label('LOCATION'),
|
||||
ExportColumn::make('bin')
|
||||
->label('BIN'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('batch')
|
||||
->label('BATCH'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('doc_no')
|
||||
->label('DOCUMENT NUMBER'),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ExportColumn::make('capacitor_scanned_status')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status_set')
|
||||
->label('SCANNED STATUS SET'),
|
||||
ExportColumn::make('panel_box_item_code')
|
||||
->label('PANEL BOX ITEM CODE'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_sno')
|
||||
->label('PANEL BOX SNO'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_quantity')
|
||||
->label('SCANNED QUANTITY'),
|
||||
ExportColumn::make('system_stock')
|
||||
->label('SYSTEM STOCK')
|
||||
->state(fn ($record) => $record->quantity),
|
||||
ExportColumn::make('scanned_stock')
|
||||
->label('SCANNED STOCK')
|
||||
->state(fn ($record) => $record->scanned_quantity),
|
||||
ExportColumn::make('duplicate_stock')
|
||||
->label('DUPLICATE STOCK')
|
||||
->state(function ($record) {
|
||||
return \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
}),
|
||||
ExportColumn::make('not_in_stock')
|
||||
->label('NOT IN STOCK')
|
||||
->state(function ($record) {
|
||||
return \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
}),
|
||||
ExportColumn::make('physical_stock')
|
||||
->label('PHYSICAL STOCK')
|
||||
->state(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = $record->scanned_quantity ?? 0;
|
||||
|
||||
return $scanned + $duplicate + $notInStock;
|
||||
}),
|
||||
|
||||
ExportColumn::make('stock_difference')
|
||||
->label('STOCK DIFFERENCE COUNT')
|
||||
->state(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = (int) $record->scanned_quantity;
|
||||
|
||||
$physicalStock = $scanned + $duplicate + $notInStock;
|
||||
|
||||
$systemStock = (int) $record->quantity;
|
||||
|
||||
$difference = $physicalStock - $systemStock;
|
||||
|
||||
return max($difference, 0);
|
||||
}),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your stock data master export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
117
app/Filament/Imports/CharacteristicApproverMasterImporter.php
Normal file
117
app/Filament/Imports/CharacteristicApproverMasterImporter.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class CharacteristicApproverMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->examples(['1000','1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->examples(['RMGLAS02','RMGLAS02'])
|
||||
->label('Work Center')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->examples(['15002635','17002635'])
|
||||
->label('Machine Name'),
|
||||
ImportColumn::make('name1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 1')
|
||||
->examples(['Suresh.D','Suresh.D'])
|
||||
->label('Approver Name 1'),
|
||||
ImportColumn::make('mail1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 1')
|
||||
->examples(['suresh@cripumps.com','suresh@cripumps.com'])
|
||||
->label('Approver Mail 1'),
|
||||
ImportColumn::make('name2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 2')
|
||||
->examples(['Ramesh.G','Ramesh.G'])
|
||||
->label('Approver Name 2'),
|
||||
ImportColumn::make('mail2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 2')
|
||||
->examples(['ramesh@cripumps.com','ramesh@cripumps.com'])
|
||||
->label('Approver Mail 2'),
|
||||
ImportColumn::make('name3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 3')
|
||||
->examples(['Ganesh.K','Ganesh.K'])
|
||||
->label('Approver Name 3'),
|
||||
ImportColumn::make('mail3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 3')
|
||||
->examples(['ganesh@cripumps.com','ganesh@cripumps.com'])
|
||||
->label('Approver Mail 3'),
|
||||
ImportColumn::make('duration1')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 1')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 1'),
|
||||
ImportColumn::make('duration2')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 2')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 2'),
|
||||
ImportColumn::make('duration3')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 3')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 3'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Characteristic Field')
|
||||
->examples(['MV SERIES','PV SERIES'])
|
||||
->label('Characteristic Field'),
|
||||
ImportColumn::make('approver_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Type')
|
||||
->examples(['Characteristic','Quality'])
|
||||
->label('Approver Type'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CharacteristicApproverMaster
|
||||
{
|
||||
// return CharacteristicApproverMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new CharacteristicApproverMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your characteristic approver master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -16,517 +16,524 @@ class ClassCharacteristicImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGLAS01')
|
||||
->label('WORK CENTER')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->exampleHeader('Aufnr')
|
||||
->example(''),
|
||||
->label('AUFNR')
|
||||
->exampleHeader('AUFNR')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('class')
|
||||
->label('Class')
|
||||
->exampleHeader('Class')
|
||||
->example(''),
|
||||
->label('CLASS')
|
||||
->exampleHeader('CLASS')
|
||||
->example('ZLASER'),
|
||||
ImportColumn::make('arbid')
|
||||
->label('Arbid')
|
||||
->exampleHeader('Arbid')
|
||||
->example(''),
|
||||
->label('ARBID')
|
||||
->exampleHeader('ARBID')
|
||||
->example('LASER'),
|
||||
ImportColumn::make('gamng')
|
||||
->label('Gamng')
|
||||
->exampleHeader('Gamng')
|
||||
->example(''),
|
||||
->label('GAMNG')
|
||||
->exampleHeader('GAMNG')
|
||||
->example('1.000'),
|
||||
ImportColumn::make('lmnga')
|
||||
->label('Lmnga')
|
||||
->exampleHeader('Lmnga')
|
||||
->example(''),
|
||||
->label('LMNGA')
|
||||
->exampleHeader('LMNGA')
|
||||
->example('1'),
|
||||
ImportColumn::make('gernr')
|
||||
->label('Gernr')
|
||||
->exampleHeader('Gernr')
|
||||
->example(''),
|
||||
->label('GERNR')
|
||||
->exampleHeader('GERNR')
|
||||
->example('12345678901234'),
|
||||
ImportColumn::make('zz1_cn_bill_ord')
|
||||
->label('zz1 ccn bill ord')
|
||||
->exampleHeader('zz1 ccn bill ord')
|
||||
->example(''),
|
||||
->label('ZZ1 CN BILL ORD')
|
||||
->exampleHeader('ZZ1 CN BILL ORD')
|
||||
->example('INDIA'),
|
||||
ImportColumn::make('zmm_amps')
|
||||
->label('zmm amps')
|
||||
->exampleHeader('zmm amps')
|
||||
->example(''),
|
||||
->label('ZMM AMPS')
|
||||
->exampleHeader('ZMM AMPS')
|
||||
->example('11A'),
|
||||
ImportColumn::make('zmm_brand')
|
||||
->label('zmm brand')
|
||||
->exampleHeader('zmm brand')
|
||||
->example(''),
|
||||
->label('ZMM BRAND')
|
||||
->exampleHeader('ZMM BRAND')
|
||||
->example('CRI'),
|
||||
ImportColumn::make('zmm_degreeofprotection')
|
||||
->label('zmm degreeofprotection')
|
||||
->exampleHeader('zmm degreeofprotection')
|
||||
->example(''),
|
||||
->label('ZMM DEGREEOFPROTECTION')
|
||||
->exampleHeader('ZMM DEGREEOFPROTECTION')
|
||||
->example('IP55'),
|
||||
ImportColumn::make('zmm_delivery')
|
||||
->label('zmm delivery')
|
||||
->exampleHeader('zmm delivery')
|
||||
->example(''),
|
||||
->label('ZMM DELIVERY')
|
||||
->exampleHeader('ZMM DELIVERY')
|
||||
->example('65MM'),
|
||||
ImportColumn::make('zmm_dir_rot')
|
||||
->label('zmm dir rot')
|
||||
->exampleHeader('zmm dir rot')
|
||||
->label('ZMM DIR ROT')
|
||||
->exampleHeader('ZMM DIR ROT')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge')
|
||||
->label('zmm discharge')
|
||||
->exampleHeader('zmm discharge')
|
||||
->example(''),
|
||||
->label('ZMM DISCHARGE')
|
||||
->exampleHeader('ZMM DISCHARGE')
|
||||
->example('17m³/h'),
|
||||
ImportColumn::make('zmm_discharge_max')
|
||||
->label('zmm discharge max')
|
||||
->exampleHeader('zmm discharge max')
|
||||
->label('ZMM DISCHARGE MAX')
|
||||
->exampleHeader('ZMM DISCHARGE MAX')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge_min')
|
||||
->label('zmm discharge min')
|
||||
->exampleHeader('zmm discharge min')
|
||||
->label('ZMM DISCHARGE MIN')
|
||||
->exampleHeader('ZMM DISCHARGE MIN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_duty')
|
||||
->label('zmm duty')
|
||||
->exampleHeader('zmm duty')
|
||||
->example(''),
|
||||
->label('ZMM DUTY')
|
||||
->exampleHeader('ZMM DUTY')
|
||||
->example('DUTY S1'),
|
||||
ImportColumn::make('zmm_eff_motor')
|
||||
->label('zmm eff motor')
|
||||
->exampleHeader('zmm eff motor')
|
||||
->label('ZMM EFF MOTOR')
|
||||
->exampleHeader('ZMM EFF MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_pump')
|
||||
->label('zmm eff pump')
|
||||
->exampleHeader('zmm eff pump')
|
||||
->label('ZMM EFF PUMP')
|
||||
->exampleHeader('ZMM EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_frequency')
|
||||
->label('zmm frequency')
|
||||
->exampleHeader('zmm frequency')
|
||||
->example(''),
|
||||
->label('ZMM FREQUENCY')
|
||||
->exampleHeader('ZMM FREQUENCY')
|
||||
->example('50Hz'),
|
||||
ImportColumn::make('zmm_head')
|
||||
->label('zmm head')
|
||||
->exampleHeader('zmm head')
|
||||
->example(''),
|
||||
->label('ZMM HEAD')
|
||||
->exampleHeader('ZMM HEAD')
|
||||
->example('77M'),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->label('zmm heading')
|
||||
->exampleHeader('zmm heading')
|
||||
->example(''),
|
||||
->label('ZMM HEADING')
|
||||
->exampleHeader('ZMM HEADING')
|
||||
->example('PRESSURE BOOSTER SYSTEM'),
|
||||
ImportColumn::make('zmm_head_max')
|
||||
->label('zmm head max')
|
||||
->exampleHeader('zmm head max')
|
||||
->example(''),
|
||||
->label('ZMM HEAD MAX')
|
||||
->exampleHeader('ZMM HEAD MAX')
|
||||
->example('96m'),
|
||||
ImportColumn::make('zmm_head_minimum')
|
||||
->label('zmm head minimum')
|
||||
->exampleHeader('zmm head minimum')
|
||||
->label('ZMM HEAD MINIMUM')
|
||||
->exampleHeader('ZMM HEAD MINIMUM')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('zmm idx eff mtr')
|
||||
->exampleHeader('zmm idx eff mtr')
|
||||
->label('ZMM IDX EFF MTR')
|
||||
->exampleHeader('ZMM IDX EFF MTR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_pump')
|
||||
->label('zmm idx eff pump')
|
||||
->exampleHeader('zmm idx eff pump')
|
||||
->label('ZMM IDX EFF PUMP')
|
||||
->exampleHeader('ZMM IDX EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_kvacode')
|
||||
->label('zmm kvacode')
|
||||
->exampleHeader('zmm kvacode')
|
||||
->label('ZMM KVACODE')
|
||||
->exampleHeader('ZMM KVACODE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_maxambtemp')
|
||||
->label('zmm maxambtemp')
|
||||
->exampleHeader('zmm maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP')
|
||||
->exampleHeader('ZMM MAXAMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mincoolingflow')
|
||||
->label('zmm mincoolingflow')
|
||||
->exampleHeader('zmm mincoolingflow')
|
||||
->label('ZMM MINCOOLINGFLOW')
|
||||
->exampleHeader('ZMM MINCOOLINGFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motorseries')
|
||||
->label('zmm motorseries')
|
||||
->exampleHeader('zmm motorseries')
|
||||
->label('ZMM MOTORSERIES')
|
||||
->exampleHeader('ZMM MOTORSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_model')
|
||||
->label('zmm motor model')
|
||||
->exampleHeader('zmm motor model')
|
||||
->label('ZMM MOTOR MODEL')
|
||||
->exampleHeader('ZMM MOTOR MODEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_outlet')
|
||||
->label('zmm outlet')
|
||||
->exampleHeader('zmm outlet')
|
||||
->example(''),
|
||||
->label('ZMM OUTLET')
|
||||
->exampleHeader('ZMM OUTLET')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_phase')
|
||||
->label('zmm phase')
|
||||
->exampleHeader('zmm phase')
|
||||
->example(''),
|
||||
->label('ZMM PHASE')
|
||||
->exampleHeader('ZMM PHASE')
|
||||
->example('3Ph'),
|
||||
ImportColumn::make('zmm_pressure')
|
||||
->label('zmm pressure')
|
||||
->exampleHeader('zmm pressure')
|
||||
->example(''),
|
||||
->label('ZMM PRESSURE')
|
||||
->exampleHeader('ZMM PRESSURE')
|
||||
->example('16bar'),
|
||||
ImportColumn::make('zmm_pumpflowtype')
|
||||
->label('zmm pumpflowtype')
|
||||
->exampleHeader('zmm pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE')
|
||||
->exampleHeader('ZMM PUMPFLOWTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpseries')
|
||||
->label('zmm pumpseries')
|
||||
->exampleHeader('zmm pumpseries')
|
||||
->label('ZMM PUMPSERIES')
|
||||
->exampleHeader('ZMM PUMPSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pump_model')
|
||||
->label('zmm pump model')
|
||||
->exampleHeader('zmm pump model')
|
||||
->example(''),
|
||||
->label('ZMM PUMP MODEL')
|
||||
->exampleHeader('ZMM PUMP MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_ratedpower')
|
||||
->label('zmm ratedpower')
|
||||
->exampleHeader('zmm ratedpower')
|
||||
->example(''),
|
||||
->label('ZMM RATEDPOWER')
|
||||
->exampleHeader('ZMM RATEDPOWER')
|
||||
->example('5.5kW/7.5HP'),
|
||||
ImportColumn::make('zmm_region')
|
||||
->label('zmm region')
|
||||
->exampleHeader('zmm region')
|
||||
->label('ZMM REGION')
|
||||
->exampleHeader('ZMM REGION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactor')
|
||||
->label('zmm servicefactor')
|
||||
->exampleHeader('zmm servicefactor')
|
||||
->label('ZMM SERVICEFACTOR')
|
||||
->exampleHeader('ZMM SERVICEFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('zmm servicefactormaximumamps')
|
||||
->exampleHeader('zmm servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->exampleHeader('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_speed')
|
||||
->label('zmm speed')
|
||||
->exampleHeader('zmm speed')
|
||||
->example(''),
|
||||
->label('ZMM SPEED')
|
||||
->exampleHeader('ZMM SPEED')
|
||||
->example('2900rpm'),
|
||||
ImportColumn::make('zmm_suction')
|
||||
->label('zmm suction')
|
||||
->exampleHeader('zmm suction')
|
||||
->example(''),
|
||||
->label('ZMM SUCTION')
|
||||
->exampleHeader('ZMM SUCTION')
|
||||
->example('65mm'),
|
||||
ImportColumn::make('zmm_suctionxdelivery')
|
||||
->label('zmm suctionxdelivery')
|
||||
->exampleHeader('zmm suctionxdelivery')
|
||||
->example(''),
|
||||
->label('ZMM SUCTIONXDELIVERY')
|
||||
->exampleHeader('ZMM SUCTIONXDELIVERY')
|
||||
->example('50 x 50mm'),
|
||||
ImportColumn::make('zmm_supplysource')
|
||||
->label('zmm supplysource')
|
||||
->exampleHeader('zmm supplysource')
|
||||
->example(''),
|
||||
->label('ZMM SUPPLYSOURCE')
|
||||
->exampleHeader('ZMM SUPPLYSOURCE')
|
||||
->example('AC SUPPLY'),
|
||||
ImportColumn::make('zmm_temperature')
|
||||
->label('zmm temperature')
|
||||
->exampleHeader('zmm temperature')
|
||||
->example(''),
|
||||
->label('ZMM TEMPERATURE')
|
||||
->exampleHeader('ZMM TEMPERATURE')
|
||||
->example('90°C'),
|
||||
ImportColumn::make('zmm_thrustload')
|
||||
->label('zmm thrustload')
|
||||
->exampleHeader('zmm thrustload')
|
||||
->label('ZMM THRUSTLOAD')
|
||||
->exampleHeader('ZMM THRUSTLOAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_volts')
|
||||
->label('zmm volts')
|
||||
->exampleHeader('zmm volts')
|
||||
->example(''),
|
||||
->label('ZMM VOLTS')
|
||||
->exampleHeader('ZMM VOLTS')
|
||||
->example('415V'),
|
||||
ImportColumn::make('zmm_wire')
|
||||
->label('zmm wire')
|
||||
->exampleHeader('zmm wire')
|
||||
->label('ZMM WIRE')
|
||||
->exampleHeader('ZMM WIRE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_package')
|
||||
->label('zmm package')
|
||||
->exampleHeader('zmm package')
|
||||
->label('ZMM PACKAGE')
|
||||
->exampleHeader('ZMM PACKAGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pvarrayrating')
|
||||
->label('zmm pvarrayrating')
|
||||
->exampleHeader('zmm pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING')
|
||||
->exampleHeader('ZMM PVARRAYRATING')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi')
|
||||
->label('zmm isi')
|
||||
->exampleHeader('zmm isi')
|
||||
->example(''),
|
||||
->label('ZMM ISI')
|
||||
->exampleHeader('ZMM ISI')
|
||||
->example('Y'),
|
||||
ImportColumn::make('zmm_isimotor')
|
||||
->label('zmm isimotor')
|
||||
->exampleHeader('zmm isimotor')
|
||||
->example(''),
|
||||
->label('ZMM ISIMOTOR')
|
||||
->exampleHeader('ZMM ISIMOTOR')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_isipump')
|
||||
->label('zmm isipump')
|
||||
->exampleHeader('zmm isipump')
|
||||
->label('ZMM ISIPUMP')
|
||||
->exampleHeader('ZMM ISIPUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isipumpset')
|
||||
->label('zmm isipumpset')
|
||||
->exampleHeader('zmm isipumpset')
|
||||
->example(''),
|
||||
->label('ZMM ISIPUMPSET')
|
||||
->exampleHeader('ZMM ISIPUMPSET')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_pumpset_model')
|
||||
->label('zmm pumpset model')
|
||||
->exampleHeader('zmm pumpset model')
|
||||
->example(''),
|
||||
->label('ZMM PUMPSET MODEL')
|
||||
->exampleHeader('ZMM PUMPSET MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_stages')
|
||||
->label('zmm stages')
|
||||
->exampleHeader('zmm stages')
|
||||
->example(''),
|
||||
->label('ZMM STAGES')
|
||||
->exampleHeader('ZMM STAGES')
|
||||
->example('7'),
|
||||
ImportColumn::make('zmm_headrange')
|
||||
->label('zmm headrange')
|
||||
->exampleHeader('zmm headrange')
|
||||
->label('ZMM HEADRANGE')
|
||||
->exampleHeader('ZMM HEADRANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_overall_efficiency')
|
||||
->label('zmm overall efficiency')
|
||||
->exampleHeader('zmm overall efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY')
|
||||
->exampleHeader('ZMM OVERALL EFFICIENCY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_connection')
|
||||
->label('zmm connection')
|
||||
->exampleHeader('zmm connection')
|
||||
->example(''),
|
||||
->label('ZMM CONNECTION')
|
||||
->exampleHeader('ZMM CONNECTION')
|
||||
->example('STAR/DELTA'),
|
||||
ImportColumn::make('zmm_min_bore_size')
|
||||
->label('zmm min bore size')
|
||||
->exampleHeader('zmm min bore size')
|
||||
->label('ZMM MIN BORE SIZE')
|
||||
->exampleHeader('ZMM MIN BORE SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isireference')
|
||||
->label('zmm isireference')
|
||||
->exampleHeader('zmm isireference')
|
||||
->label('ZMM ISIREFERENCE')
|
||||
->exampleHeader('ZMM ISIREFERENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_category')
|
||||
->label('zmm category')
|
||||
->exampleHeader('zmm category')
|
||||
->example(''),
|
||||
->label('ZMM CATEGORY')
|
||||
->exampleHeader('ZMM CATEGORY')
|
||||
->example('B'),
|
||||
ImportColumn::make('zmm_submergence')
|
||||
->label('zmm submergence')
|
||||
->exampleHeader('zmm submergence')
|
||||
->label('ZMM SUBMERGENCE')
|
||||
->exampleHeader('ZMM SUBMERGENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorstart')
|
||||
->label('zmm capacitorstart')
|
||||
->exampleHeader('zmm capacitorstart')
|
||||
->label('ZMM CAPACITORSTART')
|
||||
->exampleHeader('ZMM CAPACITORSTART')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorrun')
|
||||
->label('zmm capacitorrun')
|
||||
->exampleHeader('zmm capacitorrun')
|
||||
->label('ZMM CAPACITORRUN')
|
||||
->exampleHeader('ZMM CAPACITORRUN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inch')
|
||||
->label('zmm inch')
|
||||
->exampleHeader('zmm inch')
|
||||
->label('ZMM INCH')
|
||||
->exampleHeader('ZMM INCH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_type')
|
||||
->label('zmm motor type')
|
||||
->exampleHeader('zmm motor type')
|
||||
->example(''),
|
||||
->label('ZMM MOTOR TYPE')
|
||||
->exampleHeader('ZMM MOTOR TYPE')
|
||||
->example('TEFC'),
|
||||
ImportColumn::make('zmm_dismantle_direction')
|
||||
->label('zmm dismantle direction')
|
||||
->exampleHeader('zmm dismantle direction')
|
||||
->label('ZMM DISMANTLE DIRECTION')
|
||||
->exampleHeader('ZMM DISMANTLE DIRECTION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ovrall')
|
||||
->label('zmm eff ovrall')
|
||||
->exampleHeader('zmm eff ovrall')
|
||||
->label('ZMM EFF OVERALL')
|
||||
->exampleHeader('ZMM EFF OVERALL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_bodymoc')
|
||||
->label('zmm bodymoc')
|
||||
->exampleHeader('zmm bodymoc')
|
||||
->label('ZMM BODYMOC')
|
||||
->exampleHeader('ZMM BODYMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_rotormoc')
|
||||
->label('zmm rotormoc')
|
||||
->exampleHeader('zmm rotormoc')
|
||||
->label('ZMM ROTORMOC')
|
||||
->exampleHeader('ZMM ROTORMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dlwl')
|
||||
->label('zmm dlwl')
|
||||
->exampleHeader('zmm dlwl')
|
||||
->label('ZMM DLWL')
|
||||
->exampleHeader('ZMM DLWL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inputpower')
|
||||
->label('zmm inputpower')
|
||||
->exampleHeader('zmm inputpower')
|
||||
->label('ZMM INPUTPOWER')
|
||||
->exampleHeader('ZMM INPUTPOWER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_imp_od')
|
||||
->label('zmm imp od')
|
||||
->exampleHeader('zmm imp od')
|
||||
->label('ZMM IMP OD')
|
||||
->exampleHeader('ZMM IMP OD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_ambtemp')
|
||||
->label('zmm ambtemp')
|
||||
->exampleHeader('zmm ambtemp')
|
||||
->label('ZMM AMBTEMP')
|
||||
->exampleHeader('ZMM AMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_de')
|
||||
->label('zmm de')
|
||||
->exampleHeader('zmm de')
|
||||
->label('ZMM DE')
|
||||
->exampleHeader('ZMM DE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dischargerange')
|
||||
->label('zmm dischargerange')
|
||||
->exampleHeader('zmm dischargerange')
|
||||
->label('ZMM DISCHARGERANGE')
|
||||
->exampleHeader('ZMM DISCHARGERANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_efficiency_class')
|
||||
->label('zmm efficiency class')
|
||||
->exampleHeader('zmm efficiency class')
|
||||
->example(''),
|
||||
->label('ZMM EFFICIENCY CLASS')
|
||||
->exampleHeader('ZMM EFFICIENCY CLASS')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_framesize')
|
||||
->label('zmm framesize')
|
||||
->exampleHeader('zmm framesize')
|
||||
->label('ZMM FRAMESIZE')
|
||||
->exampleHeader('ZMM FRAMESIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_impellerdiameter')
|
||||
->label('zmm impellerdiameter')
|
||||
->exampleHeader('zmm impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER')
|
||||
->exampleHeader('ZMM IMPELLERDIAMETER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_insulationclass')
|
||||
->label('zmm insulationclass')
|
||||
->exampleHeader('zmm insulationclass')
|
||||
->example(''),
|
||||
->label('ZMM INSULATIONCLASS')
|
||||
->exampleHeader('ZMM INSULATIONCLASS')
|
||||
->example('F'),
|
||||
ImportColumn::make('zmm_maxflow')
|
||||
->label('zmm maxflow')
|
||||
->exampleHeader('zmm maxflow')
|
||||
->label('ZMM MAXFLOW')
|
||||
->exampleHeader('ZMM MAXFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_minhead')
|
||||
->label('zmm minhead')
|
||||
->exampleHeader('zmm minhead')
|
||||
->label('ZMM MINHEAD')
|
||||
->exampleHeader('ZMM MINHEAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mtrlofconst')
|
||||
->label('zmm mtrlofconst')
|
||||
->exampleHeader('zmm mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST')
|
||||
->exampleHeader('ZMM MTRLOFCONST')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_nde')
|
||||
->label('zmm nde')
|
||||
->exampleHeader('zmm nde')
|
||||
->label('ZMM NDE')
|
||||
->exampleHeader('ZMM NDE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_powerfactor')
|
||||
->label('zmm powerfactor')
|
||||
->exampleHeader('zmm powerfactor')
|
||||
->label('ZMM POWERFACTOR')
|
||||
->exampleHeader('ZMM POWERFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_tagno')
|
||||
->label('zmm tagno')
|
||||
->exampleHeader('zmm tagno')
|
||||
->label('ZMM TAGNO')
|
||||
->exampleHeader('ZMM TAGNO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_year')
|
||||
->label('zmm year')
|
||||
->exampleHeader('zmm year')
|
||||
->label('ZMM YEAR')
|
||||
->exampleHeader('ZMM YEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_laser_name')
|
||||
->label('zmm laser name')
|
||||
->exampleHeader('zmm laser name')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenote')
|
||||
->label('zmm beenote')
|
||||
->exampleHeader('zmm beenote')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenumber')
|
||||
->label('zmm beenumber')
|
||||
->exampleHeader('zmm beenumber')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beestar')
|
||||
->label('zmm beenumber')
|
||||
->exampleHeader('zmm beenumber')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_codeclass')
|
||||
->label('zmm codeclass')
|
||||
->exampleHeader('zmm codeclass')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_colour')
|
||||
->label('zmm colour')
|
||||
->exampleHeader('zmm colour')
|
||||
->label('ZMM LASER NAME')
|
||||
->exampleHeader('ZMM LASER NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_cp')
|
||||
->label('zmm logo cp')
|
||||
->exampleHeader('zmm logo cp')
|
||||
->label('ZMM LOGO CP')
|
||||
->exampleHeader('ZMM LOGO CP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_ce')
|
||||
->label('zmm logo ce')
|
||||
->exampleHeader('zmm logo ce')
|
||||
->example(''),
|
||||
->label('ZMM LOGO CE')
|
||||
->exampleHeader('ZMM LOGO CE')
|
||||
->example('NO'),
|
||||
ImportColumn::make('zmm_logo_nsf')
|
||||
->label('zmm logo nsf')
|
||||
->exampleHeader('zmm logo nsf')
|
||||
->label('ZMM LOGO NSF')
|
||||
->exampleHeader('ZMM LOGO NSF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE')
|
||||
->exampleHeader('ZMM BEENOTE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER')
|
||||
->exampleHeader('ZMM BEENUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR')
|
||||
->exampleHeader('ZMM BEESTAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS')
|
||||
->exampleHeader('ZMM CODECLASS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR')
|
||||
->exampleHeader('ZMM COLOUR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grade')
|
||||
->label('zmm grade')
|
||||
->exampleHeader('zmm grade')
|
||||
->label('ZMM GRADE')
|
||||
->exampleHeader('ZMM GRADE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pset')
|
||||
->label('zmm grwt pset')
|
||||
->exampleHeader('zmm grwt pset')
|
||||
->label('ZMM GRWT PSET')
|
||||
->exampleHeader('ZMM GRWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_cable')
|
||||
->label('zmm grwt cable')
|
||||
->exampleHeader('zmm grwt cable')
|
||||
->label('ZMM GRWT CABLE')
|
||||
->exampleHeader('ZMM GRWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_motor')
|
||||
->label('zmm grwt motor')
|
||||
->exampleHeader('zmm grwt motor')
|
||||
->label('ZMM GRWT MOTOR')
|
||||
->exampleHeader('ZMM GRWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pf')
|
||||
->label('zmm grwt pf')
|
||||
->exampleHeader('zmm grwt pf')
|
||||
->label('ZMM GRWT PF')
|
||||
->exampleHeader('ZMM GRWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pump')
|
||||
->label('zmm grwt pump')
|
||||
->exampleHeader('zmm grwt pump')
|
||||
->label('ZMM GRWT PUMP')
|
||||
->exampleHeader('ZMM GRWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isivalve')
|
||||
->label('zmm isivalve')
|
||||
->exampleHeader('zmm isivalve')
|
||||
->label('ZMM ISIVALVE')
|
||||
->exampleHeader('ZMM ISIVALVE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi_wc')
|
||||
->label('zmm isi wc')
|
||||
->exampleHeader('zmm isi wc')
|
||||
->label('ZMM ISI WC')
|
||||
->exampleHeader('ZMM ISI WC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_labelperiod')
|
||||
->label('zmm labelperiod')
|
||||
->exampleHeader('zmm labelperiod')
|
||||
->label('ZMM LABELPERIOD')
|
||||
->exampleHeader('ZMM LABELPERIOD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_length')
|
||||
->label('zmm length')
|
||||
->exampleHeader('zmm length')
|
||||
->label('ZMM LENGTH')
|
||||
->exampleHeader('ZMM LENGTH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_license_cml_no')
|
||||
->label('zmm license cml no')
|
||||
->exampleHeader('zmm license cml no')
|
||||
->label('ZMM LICENSE CML NO')
|
||||
->exampleHeader('ZMM LICENSE CML NO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mfgmonyr')
|
||||
->label('zmm mfgmonyr')
|
||||
->exampleHeader('zmm mfgmonyr')
|
||||
->label('ZMM MFGMONYR')
|
||||
->exampleHeader('ZMM MFGMONYR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_modelyear')
|
||||
->label('zmm modelyear')
|
||||
->exampleHeader('zmm modelyear')
|
||||
->label('ZMM MODELYEAR')
|
||||
->exampleHeader('ZMM MODELYEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motoridentification')
|
||||
->label('zmm motoridentification')
|
||||
->exampleHeader('zmm motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION')
|
||||
->exampleHeader('ZMM MOTORIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pset')
|
||||
->label('zmm newt pset')
|
||||
->exampleHeader('zmm newt pset')
|
||||
->label('ZMM NEWT PSET')
|
||||
->exampleHeader('ZMM NEWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_cable')
|
||||
->label('zmm newt cable')
|
||||
->exampleHeader('zmm newt cable')
|
||||
->label('ZMM NEWT CABLE')
|
||||
->exampleHeader('ZMM NEWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_motor')
|
||||
->label('zmm newt motor')
|
||||
->exampleHeader('zmm newt motor')
|
||||
->label('ZMM NEWT MOTOR')
|
||||
->exampleHeader('ZMM NEWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pf')
|
||||
->label('zmm newt pf')
|
||||
->exampleHeader('zmm newt pf')
|
||||
->label('ZMM NEWT PF')
|
||||
->exampleHeader('ZMM NEWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pump')
|
||||
->label('zmm newt pump')
|
||||
->exampleHeader('zmm newt pump')
|
||||
->label('ZMM NEWT PUMP')
|
||||
->exampleHeader('ZMM NEWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_packtype')
|
||||
->label('zmm packtype')
|
||||
->exampleHeader('zmm packtype')
|
||||
->label('ZMM PACKTYPE')
|
||||
->exampleHeader('ZMM PACKTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_panel')
|
||||
->label('zmm panel')
|
||||
->exampleHeader('zmm panel')
|
||||
->label('ZMM PANEL')
|
||||
->exampleHeader('ZMM PANEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_performance_factor')
|
||||
->label('zmm performance factor')
|
||||
->exampleHeader('zmm performance factor')
|
||||
->label('ZMM PERFORMANCE FACTOR')
|
||||
->exampleHeader('ZMM PERFORMANCE FACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpidentification')
|
||||
->label('zmm pumpidentification')
|
||||
->exampleHeader('zmm pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION')
|
||||
->exampleHeader('ZMM PUMPIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_psettype')
|
||||
->label('zmm psettype')
|
||||
->exampleHeader('zmm psettype')
|
||||
->label('ZMM PSETTYPE')
|
||||
->exampleHeader('ZMM PSETTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_size')
|
||||
->label('zmm size')
|
||||
->exampleHeader('zmm size')
|
||||
->label('ZMM SIZE')
|
||||
->exampleHeader('ZMM SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ttl')
|
||||
->label('zmm eff ttl')
|
||||
->exampleHeader('zmm eff ttl')
|
||||
->label('ZMM EFF TTL')
|
||||
->exampleHeader('ZMM EFF TTL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_type')
|
||||
->label('zmm type')
|
||||
->exampleHeader('zmm type')
|
||||
->label('ZMM TYPE')
|
||||
->exampleHeader('ZMM TYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_usp')
|
||||
->label('zmm usp')
|
||||
->exampleHeader('zmm usp')
|
||||
->label('ZMM USP')
|
||||
->exampleHeader('ZMM USP')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
@@ -535,15 +542,23 @@ class ClassCharacteristicImporter extends Importer
|
||||
ImportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->exampleHeader('MARKED DATETIME')
|
||||
->example(''),
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->exampleHeader('MARKED EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->exampleHeader('MARKED BY')
|
||||
->example(''),
|
||||
->example('TEST001'),
|
||||
ImportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED STATUS')
|
||||
->label('MANUAL MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MANUAL MARKED STATUS')
|
||||
->example(''),
|
||||
->example('0'),
|
||||
ImportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME')
|
||||
->exampleHeader('MANUAL MARKED DATETIME')
|
||||
@@ -556,6 +571,14 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('MOTOR MARKED STATUS')
|
||||
->exampleHeader('MOTOR MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_marked_physical_count')
|
||||
->label('MOTOR MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MOTOR MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->exampleHeader('MOTOR EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->exampleHeader('MOTOR MARKED BY')
|
||||
@@ -564,14 +587,38 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('PUMP MARKED STATUS')
|
||||
->exampleHeader('PUMP MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_marked_physical_count')
|
||||
->label('PUMP MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('PUMP MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->exampleHeader('PUMP EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->exampleHeader('PUMP MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_marked_status')
|
||||
->label('NAME PLATE MARKED STATUS')
|
||||
->exampleHeader('NAME PLATE MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_expected_time')
|
||||
->label('NAME PLATE EXPECTED TIME')
|
||||
->exampleHeader('NAME PLATE EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY')
|
||||
->exampleHeader('NAME PLATE MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS')
|
||||
->exampleHeader('MOTOR PUMP PUMPSET STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->exampleHeader('MOTOR MACHINE NAME')
|
||||
@@ -580,6 +627,10 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('PUMP MACHINE NAME')
|
||||
->exampleHeader('PUMP MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_machine_name')
|
||||
->label('NAME PLATE MACHINE NAME')
|
||||
->exampleHeader('NAME PLATE MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pumpset_machine_name')
|
||||
->label('PUMPSET MACHINE NAME')
|
||||
->exampleHeader('PUMPSET MACHINE NAME')
|
||||
@@ -600,31 +651,26 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('PENDING RELEASED STATUS')
|
||||
->exampleHeader('PENDING RELEASED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->exampleHeader('MOTOR EXPECTED TIME')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->exampleHeader('PUMP EXPECTED TIME')
|
||||
->example(''),
|
||||
ImportColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID')
|
||||
->exampleHeader('HAS WORK FLOW ID')
|
||||
->example('0'),
|
||||
ImportColumn::make('created_at')
|
||||
->label('CREATED AT')
|
||||
->exampleHeader('CREATED AT')
|
||||
->example(''),
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234'),
|
||||
->example('TEST001'),
|
||||
ImportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example(''),
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example(''),
|
||||
// ImportColumn::make('updated_by'),
|
||||
->example('TEST001'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
496
app/Filament/Imports/InvoiceValidationImporter.php
Normal file
496
app/Filament/Imports/InvoiceValidationImporter.php
Normal file
@@ -0,0 +1,496 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class InvoiceValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_reference')// stickerMaster
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
// ->relationship()// resolveUsing: 'items.code'
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('INVOICE NUMBER')
|
||||
->example('RAW0009611')
|
||||
->label('INVOICE NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('12345678901234')
|
||||
->label('SERIAL NUMBER'),
|
||||
ImportColumn::make('motor_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MOTOR SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ImportColumn::make('pump_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PUMP SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ImportColumn::make('capacitor_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CAPACITOR SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ImportColumn::make('scanned_status_set')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PUMPSET SCANNED STATUS')
|
||||
->example('')
|
||||
->label('PUMPSET SCANNED STATUS'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SCANNED STATUS')
|
||||
->example('Scanned')
|
||||
->label('SCANNED STATUS'),
|
||||
ImportColumn::make('panel_box_code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX CODE')
|
||||
->example('PBOX0123')
|
||||
->label('PANEL BOX CODE'),
|
||||
ImportColumn::make('panel_box_supplier')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX SUPPLIER')
|
||||
->example('1900433')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ImportColumn::make('panel_box_serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX SERIAL NUMBER')
|
||||
->example('2512/101236')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ImportColumn::make('load_rate')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOAD RATE')
|
||||
->example('0')
|
||||
->label('LOAD RATE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPLOAD STATUS')
|
||||
->example('N')
|
||||
->label('UPLOAD STATUS')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('batch_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('BATCH NUMBER')
|
||||
->example('')
|
||||
->label('BATCH NUMBER'),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QUANTITY')
|
||||
->example('')
|
||||
->label('QUANTITY'),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OPERATOR ID')
|
||||
->example('USER1')
|
||||
->label('OPERATOR ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('')
|
||||
->label('CREATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('USER1')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('USER1')
|
||||
->label('UPDATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('')
|
||||
->label('UPDATED BY')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?InvoiceValidation
|
||||
{
|
||||
// return InvoiceValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$iCode = trim($this->data['item_reference']) ?? null;
|
||||
$invoiceNumber = trim($this->data['invoice_number']) ?? null;
|
||||
$serialNumber = trim($this->data['serial_number']) ?? null;
|
||||
$curMotorQr = trim($this->data['motor_scanned_status']) ?? null;
|
||||
$curPumpQr = trim($this->data['pump_scanned_status']) ?? null;
|
||||
$curPumpSetQr = trim($this->data['scanned_status_set']) ?? null;
|
||||
$curCapacitorQr = trim($this->data['capacitor_scanned_status']) ?? null;
|
||||
$curScanStatus = trim($this->data['scanned_status']) ?? null;
|
||||
$curPanelBoxCode = trim($this->data['panel_box_code']) ?? null;
|
||||
$curPanelBoxSupplier = trim($this->data['panel_box_supplier']) ?? null;
|
||||
$curPanelBoxSerialNumber = trim($this->data['panel_box_serial_number']) ?? null;
|
||||
$loadRate = trim($this->data['load_rate']) ?? 0;
|
||||
$uploadStatus = trim($this->data['upload_status']) ?? 'N';
|
||||
$batchNumber = null; // trim($this->data['batch_number']) ??
|
||||
$quantity = null; // trim($this->data['quantity']) ??
|
||||
$operatorId = trim($this->data['operator_id']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
$updatedBy = trim($this->data['updated_by']);
|
||||
$createdAt = $this->data['created_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
|
||||
$packCnt = 0;
|
||||
$scanCnt = 0;
|
||||
$hasMotorQr = null;
|
||||
$hasPumpQr = null;
|
||||
$hasPumpSetQr = null;
|
||||
$hasCapacitorQr = null;
|
||||
$hadMotorQr = null;
|
||||
$hadPumpQr = null;
|
||||
$hadPumpSetQr = null;
|
||||
$hadCapacitorQr = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif ($invoiceNumber == null || $invoiceNumber == '') {
|
||||
$warnMsg[] = "Invoice number can't be empty!";
|
||||
} elseif ($serialNumber == null || $serialNumber == '') {
|
||||
$warnMsg[] = "Serial number can't be empty!";
|
||||
} elseif ($curMotorQr != null && $curMotorQr != '' && $curMotorQr != '1' && $curMotorQr != 1) {
|
||||
$warnMsg[] = 'Motor scanned status is invalid!';
|
||||
} elseif ($curPumpQr != null && $curPumpQr != '' && $curPumpQr != '1' && $curPumpQr != 1) {
|
||||
$warnMsg[] = 'Pump scanned status is invalid!';
|
||||
} elseif ($curPumpSetQr != null && $curPumpSetQr != '' && $curPumpSetQr != '1' && $curPumpSetQr != 1) {
|
||||
$warnMsg[] = 'PumpSet scanned status is invalid!';
|
||||
} elseif ($curCapacitorQr != null && $curCapacitorQr != '' && $curCapacitorQr != '1' && $curCapacitorQr != 1) {
|
||||
$warnMsg[] = 'Capacitor scanned status is invalid!';
|
||||
} elseif ($curScanStatus != null && $curScanStatus != '' && $curScanStatus != 'Scanned') {
|
||||
$warnMsg[] = 'Scanned status is invalid!';
|
||||
} elseif ($loadRate == null || $loadRate == '' || ! is_numeric($loadRate)) {
|
||||
$warnMsg[] = 'Invalid load rate found!';
|
||||
} elseif ($uploadStatus != 'N' && $uploadStatus != 'Y') {
|
||||
$warnMsg[] = 'Invalid upload status found!';
|
||||
} elseif ($operatorId == null || $operatorId == '') {
|
||||
$warnMsg[] = "Operator ID can't be empty!";
|
||||
} elseif ($createdBy == null || $createdBy == '') {
|
||||
$warnMsg[] = "Created by user can't be empty!";
|
||||
} elseif ($updatedBy == null || $updatedBy == '') {
|
||||
$warnMsg[] = "Updated by user can't be empty!";
|
||||
}
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) > 0) {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master for the given plant!';
|
||||
} elseif ($itemCode->material_type != '' && $itemCode->material_type != null) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Material invoice item code found!';
|
||||
} else {
|
||||
$stickId = $itemCode->id;
|
||||
$invalidPackage = false;
|
||||
|
||||
$hasMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $itemCode->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasCapacitorQr = $itemCode->panel_box_code ?? null;
|
||||
|
||||
if (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr) {// && ! $hasCapacitorQr
|
||||
$hasMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
} else {
|
||||
if (! $hasPumpSetQr && ! $hasPumpQr) {
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
}
|
||||
|
||||
$hasTubeMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPackMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasTubePumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasPackPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
if ($hasTubeMotorQr != $hasPackMotorQr || $hasTubePumpSetQr != $hasPackPumpSetQr) {
|
||||
$invalidPackage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) || $invalidPackage) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = "Item code doesn't have valid package type to proceed!";
|
||||
} else {
|
||||
if ($hasMotorQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasPumpQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasPumpSetQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasCapacitorQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
// if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
// $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasCapacitorQr ? $packCnt + 1 : $packCnt;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
if (! $hasMotorQr) {
|
||||
$curMotorQr = null;
|
||||
}
|
||||
if (! $hasPumpQr) {
|
||||
$curPumpQr = null;
|
||||
}
|
||||
if (! $hasPumpSetQr) {
|
||||
$curPumpSetQr = null;
|
||||
}
|
||||
if (! $hasCapacitorQr) {
|
||||
$curCapacitorQr = null;
|
||||
$curPanelBoxCode = null;
|
||||
$curPanelBoxSupplier = null;
|
||||
$curPanelBoxSerialNumber = null;
|
||||
}
|
||||
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||
|
||||
if ($record && $record->sticker_master_id != $stickId) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Item code mismatch with existing record!';
|
||||
} elseif ($record) {
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)
|
||||
->whereHas('stickerMasterRelation.item', function ($query) use ($plantId, $iCode) {
|
||||
$query->where('plant_id', $plantId)->where('code', $iCode);
|
||||
})
|
||||
->first();
|
||||
|
||||
$invalidPackage = false;
|
||||
|
||||
if ($record) {
|
||||
|
||||
$hadMotorQr = $record->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $record->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||
$hadCapacitorQr = $record->capacitor_scanned_status ?? null;
|
||||
|
||||
if ($hadMotorQr && $hasMotorQr) {
|
||||
$curMotorQr = $hadMotorQr;
|
||||
}
|
||||
if ($hadPumpQr && $hasPumpQr) {
|
||||
$curPumpQr = $hadPumpQr;
|
||||
}
|
||||
if ($hadPumpSetQr && $hasPumpSetQr) {
|
||||
$curPumpSetQr = $hadPumpSetQr;
|
||||
}
|
||||
if ($hadCapacitorQr && $hasCapacitorQr) {
|
||||
$curCapacitorQr = $hadCapacitorQr;
|
||||
$curPanelBoxCode = $record->panel_box_code ?? null;
|
||||
$curPanelBoxSupplier = $record->panel_box_supplier ?? null;
|
||||
$curPanelBoxSerialNumber = $record->panel_box_serial_number ?? null;
|
||||
}
|
||||
|
||||
$warnMsg[] = 'Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||
if ($record->invoice_number != $invoiceNumber) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Invoice number mismatch with existing record!';
|
||||
// throw new RowImportFailedException('Invoice number mismatch with existing record!');
|
||||
} elseif ($record->scanned_status == 'Scanned') {
|
||||
$stickId = null;
|
||||
|
||||
return null;
|
||||
} else {
|
||||
// if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curCapacitorQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
$record->motor_scanned_status = $curMotorQr;
|
||||
$record->pump_scanned_status = $curPumpQr;
|
||||
$record->scanned_status_set = $curPumpSetQr;
|
||||
$record->capacitor_scanned_status = $curCapacitorQr;
|
||||
$record->panel_box_code = $curPanelBoxCode;
|
||||
$record->panel_box_supplier = $curPanelBoxSupplier;
|
||||
$record->panel_box_serial_number = $curPanelBoxSerialNumber;
|
||||
if ($packCnt == $scanCnt) {
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->updated_by = $updatedBy;
|
||||
$record->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
$cDateTime = null;
|
||||
$uDateTime = null;
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($cDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
if (! isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curCapacitorQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
if ($packCnt == $scanCnt) {
|
||||
$curScanStatus = 'Scanned';
|
||||
} else {
|
||||
$curScanStatus = null;
|
||||
}
|
||||
}
|
||||
// $curScanStatus
|
||||
|
||||
InvoiceValidation::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'serial_number' => $serialNumber,
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'motor_scanned_status' => $curMotorQr,
|
||||
'pump_scanned_status' => $curPumpQr,
|
||||
'scanned_status_set' => $curPumpSetQr,
|
||||
'capacitor_scanned_status' => $curCapacitorQr,
|
||||
'panel_box_code' => $curPanelBoxCode,
|
||||
'panel_box_supplier' => $curPanelBoxSupplier,
|
||||
'panel_box_serial_number' => $curPanelBoxSerialNumber,
|
||||
'scanned_status' => $curScanStatus,
|
||||
'load_rate' => $loadRate,
|
||||
'upload_status' => $uploadStatus,
|
||||
'batch_number' => null,
|
||||
'quantity' => null,
|
||||
'operator_id' => $operatorId,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
// return new InvoiceValidation;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your invoice validation import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
@@ -24,13 +25,13 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->example('1200')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(' Polywrapped line')
|
||||
->example('Poly Wrapped Wire SFG')
|
||||
->label('LINE NAME')
|
||||
->relationship(resolveUsing: 'name'),
|
||||
ImportColumn::make('item')
|
||||
@@ -43,54 +44,57 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('process_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PROCESS ORDER')
|
||||
->example('202500123456')
|
||||
->example('202601123456')
|
||||
->label('PROCESS ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
->example('01')
|
||||
->label('COIL NUMBER'),
|
||||
ImportColumn::make('order_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ORDER QUANTITY')
|
||||
->example('100')
|
||||
->example('1000')
|
||||
->label('ORDER QUANTITY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_order_quantity')
|
||||
->exampleHeader('UPDATED ORDER QUANTITY')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
// ->example('01')
|
||||
->label('COIL NUMBER'),
|
||||
ImportColumn::make('received_quantity')
|
||||
->exampleHeader('RECEIVED QUANTITY')
|
||||
->example('01')
|
||||
// ->example('01')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ImportColumn::make('sfg_number')
|
||||
->exampleHeader('SFG NUMBER')
|
||||
->example('200000220613-72')
|
||||
// ->example('200000220613-72')
|
||||
->label('SFG NUMBER'),
|
||||
ImportColumn::make('machine_name')
|
||||
->exampleHeader('MACHINE NAME')
|
||||
->example('WMIWRM13 - 2-L2')
|
||||
// ->example('WMIWRM13 - 2-L2')
|
||||
->label('MACHINE NAME'),
|
||||
ImportColumn::make('scrap_quantity')
|
||||
->exampleHeader('SCRAP QUANTITY')
|
||||
->example('0')
|
||||
// ->example('0')
|
||||
->label('SCRAP QUANTITY'),
|
||||
ImportColumn::make('rework_status')
|
||||
->exampleHeader('REWORK STATUS')
|
||||
->example('0')
|
||||
// ->example('0')
|
||||
->label('REWORK STATUS'),
|
||||
ImportColumn::make('created_at')
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('2026-02-20 13:00:00')
|
||||
// ->example('2026-02-20 13:00:00')
|
||||
->label('CREATED AT'),
|
||||
ImportColumn::make('updated_at')
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('2026-02-20 13:00:00')
|
||||
// ->example('2026-02-20 13:00:00')
|
||||
->label('UPDATED AT'),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234')
|
||||
// ->example('RAW01234')
|
||||
->label('CREATED BY'),
|
||||
ImportColumn::make('updated_by')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('RAW01234')
|
||||
// ->example('RAW01234')
|
||||
->label('UPDATED BY'),
|
||||
];
|
||||
}
|
||||
@@ -98,17 +102,19 @@ class ProcessOrderImporter extends Importer
|
||||
public function resolveRecord(): ?ProcessOrder
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$plantId = null;
|
||||
$iCode = trim($this->data['item']) ?? '';
|
||||
$itemId = null;
|
||||
$iCode = trim($this->data['item']);
|
||||
$lineName = trim($this->data['line']);
|
||||
$lineNam = trim($this->data['line']) ?? '';
|
||||
$lineId = null;
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$coilNo = trim($this->data['coil_number'] ?? '');
|
||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
|
||||
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
|
||||
$reworkStatus = trim($this->data['rework_status'] ?? '');
|
||||
$recQuan = trim($this->data['received_quantity'] ?? '');
|
||||
@@ -120,19 +126,39 @@ class ProcessOrderImporter extends Importer
|
||||
// $operatorName = $user->name;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = 'Plant code cannot be empty';
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = 'Item code cannot be empty';
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
}
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = 'Process order cannot be empty';
|
||||
$warnMsg[] = "Process order can't be empty!";
|
||||
} elseif ($processOrder && (Str::contains($processOrder, '.') || Str::contains($processOrder, 'E', ignoreCase: true))) {
|
||||
$warnMsg[] = 'Invalid process order found!';
|
||||
}
|
||||
if ($lineNam == null || $lineNam == '') {
|
||||
$warnMsg[] = "Line name can't be empty!";
|
||||
}
|
||||
if ($orderQuan == null || $orderQuan == '') {
|
||||
$warnMsg[] = 'Order quantity cannot be empty';
|
||||
$warnMsg[] = "Order quantity can't be empty!";
|
||||
} elseif ($orderQuan == 0 || $orderQuan == '0') {
|
||||
$warnMsg[] = 'Order quantity cannot be zero';
|
||||
$warnMsg[] = "Order quantity can't be zero!";
|
||||
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
|
||||
$warnMsg[] = 'Invalid order quantity found!';
|
||||
}
|
||||
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
|
||||
$updatedOrderQuan = $orderQuan;
|
||||
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
|
||||
$warnMsg[] = 'Invalid Updated order quantity found!';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$coilNo = '0';
|
||||
}
|
||||
@@ -147,70 +173,89 @@ class ProcessOrderImporter extends Importer
|
||||
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
||||
$reworkStatus = 1;
|
||||
} else {
|
||||
$warnMsg[] = 'Invalid rework status found';
|
||||
$warnMsg[] = 'Invalid rework status 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();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
|
||||
// TESTING PURPOSE ONLY - TO CHECK DUPLICATE PROCESS ORDER WITH SAME COIL NUMBER FOR THE SAME PLANT
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->first();
|
||||
// if ($existing) {
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->where('coil_number', $coilNo)->first();
|
||||
// if ($existing) {
|
||||
// $warnMsg[] = 'Process Order with coil number already exists!';
|
||||
// } else {
|
||||
// $warnMsg[] = 'Process order already exists!';
|
||||
// }
|
||||
// } else {
|
||||
// $warnMsg[] = 'New process order found!';
|
||||
// }
|
||||
// if (! empty($warnMsg)) {
|
||||
// throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
// }
|
||||
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($plant && $itemCode && $processOrder != '') {
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($plantId && $itemId && $lineId && $processOrder != '') {
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
|
||||
}
|
||||
}
|
||||
|
||||
if ($lineName != null && $lineName != '') {
|
||||
$lineExists = Line::where('name', $lineName)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lineId = null;
|
||||
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $masterExist) {
|
||||
// $warnMsg[] = 'Characteristics master not found for the given plant!';
|
||||
// } else {
|
||||
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $masterExist) {
|
||||
// $warnMsg[] = 'Characteristics master not found for the given line!';
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found';
|
||||
// $warnMsg[] = 'User not found!';
|
||||
// }
|
||||
|
||||
if (! $createdBy) {
|
||||
@@ -224,13 +269,57 @@ class ProcessOrderImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if ($lineName != null && $lineName != '') {
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
$receivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($existing) {
|
||||
$liveOrdQuan = (float) $existing->order_quantity;
|
||||
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
|
||||
|
||||
$allowedIncrease = $liveOrdQuan * 0.10;
|
||||
|
||||
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
|
||||
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
|
||||
|
||||
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existingCoil) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
@@ -240,6 +329,7 @@ class ProcessOrderImporter extends Importer
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -267,12 +357,18 @@ class ProcessOrderImporter extends Importer
|
||||
'updated_at' => $updatedAt,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$coilNo = '0';
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// // ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
} elseif ($lineName == null || $lineName == '') {
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||
ProcessOrder::create([
|
||||
@@ -282,6 +378,7 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => 0,
|
||||
'scrap_quantity' => 0,
|
||||
'created_by' => $createdBy,
|
||||
@@ -296,6 +393,7 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -308,23 +406,25 @@ class ProcessOrderImporter extends Importer
|
||||
]
|
||||
);
|
||||
} else {// $coilNo = '0'
|
||||
if ($existing->rework_status == 1 && $reworkStatus == 0) {
|
||||
if ($existing->process_order == $processOrder) {
|
||||
throw new RowImportFailedException('Process order already exist for the given plant!');
|
||||
} elseif ($existing->rework_status == 1 && $reworkStatus == 0) {
|
||||
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
|
||||
} else {
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
'updated_by' => $updatedBy,
|
||||
// 'updated_at' => $updatedAt,
|
||||
]);
|
||||
}
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
'updated_by' => $updatedBy,
|
||||
// 'updated_at' => $updatedAt,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,75 +24,77 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->label('PLANT CODE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example(['1000', '1000'])
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->label('ITEM CODE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example(['123456', '123456'])
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->label('LINE NAME')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->label('GROUP WORK CENTER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group Work Center')
|
||||
->example('RMGCGABC')
|
||||
->exampleHeader('GROUP WORK CENTER')
|
||||
->example(['RMGSTR01', 'RMGSTR01'])
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->label('WORK CENTER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center')
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example(['RMISTR01', 'RMISTR02'])
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristics_type')
|
||||
->exampleHeader('Characteristics Type')
|
||||
->example('Process or Product')
|
||||
->label('Characteristics Type')
|
||||
->label('CHARACTERISTICS TYPE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTICS TYPE')
|
||||
->example(['Product', 'Process'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->exampleHeader('Characteristics Name')
|
||||
->example('Body')
|
||||
->label('Characteristics Name')
|
||||
->label('CHARACTERISTICS NAME')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTICS NAME')
|
||||
->example(['TEST01', 'TEST02'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('inspection_type')
|
||||
->exampleHeader('Inspection Type')
|
||||
->example('Visual or Value')
|
||||
->label('Inspection Type')
|
||||
->label('INSPECTION TYPE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('INSPECTION TYPE')
|
||||
->example(['Value', 'Visual'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lower')
|
||||
->exampleHeader('Lower')
|
||||
->example('0')
|
||||
->label('Lower')
|
||||
->rules(['numeric']),
|
||||
->label('LOWER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOWER')
|
||||
->example(['5', '0'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('middle')
|
||||
->exampleHeader('Middle')
|
||||
->example('1')
|
||||
->label('Middle')
|
||||
->numeric()
|
||||
->rules(['numeric']),
|
||||
->label('MIDDLE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MIDDLE')
|
||||
->example(['10', '0'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upper')
|
||||
->exampleHeader('Upper')
|
||||
->example('2')
|
||||
->label('Upper')
|
||||
->rules(['numeric']),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By'),
|
||||
->label('UPPER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPPER')
|
||||
->example(['15', '0'])
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('created_by'),
|
||||
// ImportColumn::make('updated_by'),
|
||||
|
||||
];
|
||||
@@ -102,117 +104,174 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
|
||||
$lower = null;
|
||||
$middle = null;
|
||||
$upper = null;
|
||||
$plantId = null;
|
||||
$name = trim($this->data['name']);
|
||||
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();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
$itemExists = Item::where('code', $this->data['item'])->first();
|
||||
if (! $itemExists) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
}
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$itemCod = trim($this->data['item']) ?? null;
|
||||
$lineNam = trim($this->data['line']) ?? null;
|
||||
$groupWorkCenter = trim($this->data['work_group_master_id']) ?? null;
|
||||
$workCenter = trim($this->data['machine']) ?? null;
|
||||
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
||||
$charNam = trim($this->data['name']) ?? null;
|
||||
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
||||
$lower = trim($this->data['lower']) ?? null;
|
||||
$middle = trim($this->data['middle']) ?? null;
|
||||
$upper = trim($this->data['upper']) ?? null;
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = null;
|
||||
|
||||
$itemAgainstPlant = Item::where('code', $this->data['item'])
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$lineId = null;
|
||||
$workGroupMasterId = null;
|
||||
$machineId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
}
|
||||
if ($itemCod == null || $itemCod == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($lineNam == null || $lineNam == '') {
|
||||
$warnMsg[] = "Line name can't be empty!";
|
||||
}
|
||||
if ($groupWorkCenter == null || $groupWorkCenter == '') {
|
||||
$warnMsg[] = "Group work center can't be empty!";
|
||||
}
|
||||
if ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = "Work center can't be empty!";
|
||||
}
|
||||
if ($charTyp != 'Product' && $charTyp != 'Process') {
|
||||
$warnMsg[] = "Characteristics type must be either 'Product' or 'Process'!";
|
||||
}
|
||||
if ($charNam == null || $charNam == '') {
|
||||
$warnMsg[] = "Characteristics name can't be empty!";
|
||||
}
|
||||
if ($inspectTyp != 'Visual' && $inspectTyp != 'Value') {
|
||||
$warnMsg[] = "Inspection type must be either 'Visual' or 'Value'!";
|
||||
}
|
||||
if ($lower == null || $lower == '' || $middle == null || $middle == '' || $upper == null || $upper == '' || $upper == 0 || $upper == '0') {
|
||||
$lower = 0;
|
||||
$middle = 0;
|
||||
$upper = 0;
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
$itemExists = Item::where('code', $itemCod)->first();
|
||||
if (! $itemExists) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
$itemAgainstPlant = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $itemAgainstPlant) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $this->data['line'])->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
}
|
||||
|
||||
$lineAgainstPlant = Line::where('name', $this->data['line'])
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line not found for the given plant';
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$LineId = $lineAgainstPlant->id;
|
||||
}
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $this->data['work_group_master_id'])->where('plant_id', $plantId)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Work Group Master value not found';
|
||||
} else {
|
||||
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
|
||||
$existsInLine = Line::where('plant_id', $plantId)
|
||||
->where(function ($q) use ($workGroupMasterId) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
|
||||
}
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (! $existsInLine) {
|
||||
$warnMsg[] = "Work Group Master '{$WorkgroupMaster->name}' is not mapped to any line in this plant";
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $groupWorkCenter)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Group work center not found!';
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $groupWorkCenter)->where('plant_id', $plantId)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Group work center not found for the given plant!';
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
|
||||
$existsInLine = Line::where('plant_id', $plantId)->where('id', $lineId)
|
||||
->where(function ($q) use ($workGroupMasterId) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
|
||||
}
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (! $existsInLine) {
|
||||
$workGroupMasterId = null;
|
||||
$warnMsg[] = "Group work center '{$WorkgroupMaster->name}' is not mapped for the given line!";
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found!';
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found for the given plant!';
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given line!";
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given group work center!";
|
||||
} else {
|
||||
$machineId = $machine->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $this->data['machine'])->first();
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work Center not found';
|
||||
$user = User::where('name', $createdBy)->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'Created by user not found!';
|
||||
} else {
|
||||
$updatedBy = $createdBy;
|
||||
}
|
||||
|
||||
if ($inspectTyp == 'Value') {
|
||||
if (is_null($upper) || is_null($lower) || is_null($middle)) {
|
||||
$warnMsg[] = 'Upper, Lower, and Middle values are required.';
|
||||
} elseif (! is_numeric($upper) || ! is_numeric($lower) || ! is_numeric($middle)) {
|
||||
$warnMsg[] = 'Upper, Lower, and Middle values must be numeric.';
|
||||
} else {
|
||||
$machineId = $machine->id;
|
||||
}
|
||||
|
||||
$machineAgainstPlant = Machine::where('work_center', $this->data['machine'])
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (! $machineAgainstPlant) {
|
||||
$warnMsg[] = 'Work Center not found for the given plant';
|
||||
} else {
|
||||
$machineId = $machineAgainstPlant->id;
|
||||
}
|
||||
|
||||
if ($name == null || $name == '') {
|
||||
$warnMsg[] = "Name can't be empty";
|
||||
}
|
||||
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
}
|
||||
|
||||
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
|
||||
if (! $updatedBy) {
|
||||
$warnMsg[] = 'Invalid updated by user name found';
|
||||
}
|
||||
|
||||
if (($this->data['inspection_type'] ?? null) == 'Value') {
|
||||
$lower = $this->data['lower'] ?? null;
|
||||
$middle = $this->data['middle'] ?? null;
|
||||
$upper = $this->data['upper'] ?? null;
|
||||
|
||||
if (is_null($upper) || is_null($lower) || is_null($middle)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, Upper, Lower, and Middle values are required.";
|
||||
} elseif (! is_numeric($upper) || ! is_numeric($lower) || ! is_numeric($middle)) {
|
||||
$warnMsg[] = 'Upper, Lower, and Middle values must be numeric.';
|
||||
} elseif (! ($lower <= $middle && $middle <= $upper)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower ≤ Middle ≤ Upper.";
|
||||
$lower = (float) $lower;
|
||||
$middle = (float) $middle;
|
||||
$upper = (float) $upper;
|
||||
if ($lower == $upper) {
|
||||
if ($lower != $middle) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower = Middle = Upper.";
|
||||
}
|
||||
} elseif (! ($lower < $middle && $middle < $upper)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower < Middle < Upper.";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lower = 0;
|
||||
$middle = 0;
|
||||
$upper = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,49 +279,31 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
// $record = ProductCharacteristicsMaster::firstOrNew([
|
||||
// 'plant_id' => $plantId,
|
||||
// 'item_id' => $itemId,
|
||||
// 'line_id' => $LineId,
|
||||
// 'work_group_master_id' => $workGroupMasterId,
|
||||
// 'machine_id' => $machineId,
|
||||
// ]);
|
||||
// // If record is new, fill all fields
|
||||
// if (! $record->exists) {
|
||||
// $record->name = $name;
|
||||
// $record->characteristics_type = $this->data['characteristics_type'];
|
||||
// $record->inspection_type = $this->data['inspection_type'];
|
||||
// $record->lower = $this->data['lower'] ?? null;
|
||||
// $record->upper = $this->data['upper'] ?? null;
|
||||
// $record->middle = $this->data['middle'] ?? null;
|
||||
// $record->created_by = $this->data['created_by'] ?? null;
|
||||
// $record->updated_by = $updatedBy ?? null;
|
||||
// } else {
|
||||
// // Record exists → update only updated_by and updated_at
|
||||
// $record->updated_by = $updatedBy ?? null;
|
||||
// $record->touch();
|
||||
// }
|
||||
// $record->save();
|
||||
if ($machineId) {
|
||||
$record = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->where('machine_id', $machineId)->where('item_id', $itemId)->where('characteristics_type', $charTyp)->where('name', $charNam)->first();
|
||||
if ($record) {
|
||||
$createdBy = $record->created_by ?? $createdBy;
|
||||
}
|
||||
|
||||
ProductCharacteristicsMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $LineId,
|
||||
'work_group_master_id' => $workGroupMasterId,
|
||||
'machine_id' => $machineId,
|
||||
],
|
||||
[
|
||||
'name' => $name,
|
||||
'characteristics_type' => $this->data['characteristics_type'],
|
||||
'inspection_type' => $this->data['inspection_type'],
|
||||
'lower' => $lower,
|
||||
'middle' => $middle,
|
||||
'upper' => $upper,
|
||||
// 'created_by' => user ?? $this->data['created_by'],
|
||||
'created_by' => $this->data['created_by'] ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]);
|
||||
ProductCharacteristicsMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $lineId,
|
||||
'work_group_master_id' => $workGroupMasterId,
|
||||
'machine_id' => $machineId,
|
||||
'characteristics_type' => $charTyp,
|
||||
'name' => $charNam,
|
||||
],
|
||||
[
|
||||
'inspection_type' => $inspectTyp,
|
||||
'lower' => $lower,
|
||||
'middle' => $middle,
|
||||
'upper' => $upper,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
@@ -158,8 +158,20 @@ class ProductionPlanImporter extends Importer
|
||||
|
||||
if ($productionPlan) {
|
||||
|
||||
$recordDate = now();
|
||||
$month = $recordDate->month;
|
||||
$year = $recordDate->year;
|
||||
|
||||
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->first();
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
$productionPlan->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
$productionPlan->save();
|
||||
@@ -168,12 +180,24 @@ class ProductionPlanImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
$recordDate = now();
|
||||
$month = $recordDate->month;
|
||||
$year = $recordDate->year;
|
||||
|
||||
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->first();
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'item_id' => $itemAgaPlant->id,
|
||||
// 'shift_id' => $shift->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'created_at' =>now(),
|
||||
'updated_at' => now(),
|
||||
'operator_id' => $operatorName,
|
||||
|
||||
234
app/Filament/Imports/StockDataMasterImporter.php
Normal file
234
app/Filament/Imports/StockDataMasterImporter.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class StockDataMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StockDataMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->examples(['1000', '1000'])
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('TYPE')
|
||||
->examples(['FG', 'NON-FG'])
|
||||
->label('TYPE'),
|
||||
ImportColumn::make('location')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOCATION')
|
||||
->examples(['2001', '2002'])
|
||||
->label('LOCATION')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_reference')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->examples(['123456', '246118'])
|
||||
->label('ITEM CODE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->examples(['200235236622', '200235236623'])
|
||||
->label('SERIAL NUMBER'),
|
||||
ImportColumn::make('batch')
|
||||
->requiredMapping()
|
||||
->exampleHeader('BATCH')
|
||||
->examples(['20102', '20103'])
|
||||
->label('BATCH'),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QUANTITY')
|
||||
->examples(['1', '1'])
|
||||
->label('QUANTITY'),
|
||||
ImportColumn::make('doc_no')
|
||||
->requiredMapping()
|
||||
->exampleHeader('DOCUMENT NUMBER')
|
||||
->examples(['82128', '21222'])
|
||||
->label('DOCUMENT NUMBER'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StockDataMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$typeValue = $this->data['type'];
|
||||
$iCode = trim($this->data['item_reference']) ?? null;
|
||||
$location = trim($this->data['location']) ?? null;
|
||||
$serialNumber = trim($this->data['serial_number']) ?? null;
|
||||
$batch = trim($this->data['batch']) ?? null;
|
||||
$quantity = trim($this->data['quantity']) ?? null;
|
||||
$docNo = trim($this->data['doc_no']) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($typeValue == null || $typeValue == '') {
|
||||
$warnMsg[] = "Type can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif ($location == null || $location == '') {
|
||||
$warnMsg[] = "Location can't be empty!";
|
||||
} elseif ($serialNumber == null || $serialNumber == '') {
|
||||
$warnMsg[] = "Serial number can't be empty!";
|
||||
}
|
||||
// else if ($batch == null || $batch == '') {
|
||||
// $warnMsg[] = "Batch can't be empty!";
|
||||
// }
|
||||
elseif ($quantity == null || $quantity == '') {
|
||||
$warnMsg[] = "Quantity can't be empty!";
|
||||
}
|
||||
// else if ($docNo == null || $docNo == '') {
|
||||
// $warnMsg[] = "Doc No can't be empty!";
|
||||
// }
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) > 0) {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master for the given plant!';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$typeValue = strtoupper($typeValue);
|
||||
|
||||
if (! in_array($typeValue, ['FG', 'NON-FG'])) {
|
||||
$warnMsg[] = 'Invalid type found! It should be either FG or NON-FG.';
|
||||
} elseif (Str::length($location) < 4) {
|
||||
$warnMsg[] = 'Location should contain minimum 4 digits!';
|
||||
} elseif (! ctype_digit((string) $location)) {
|
||||
$warnMsg[] = 'Location must be an integer!';
|
||||
} elseif (Str::length($serialNumber) < 9) {
|
||||
$warnMsg[] = 'Serial number should contain minimum 9 digits!';
|
||||
} elseif (! ctype_alnum($serialNumber)) {
|
||||
$warnMsg[] = 'Serial number should contain alpha-numeric values!';
|
||||
} elseif (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
|
||||
$warnMsg[] = 'Quantity must be an integer and greater than 0!';
|
||||
}
|
||||
|
||||
if ($batch) {
|
||||
if (Str::length($batch) < 5) {
|
||||
$warnMsg[] = 'Batch should contain minimum 5 digits!';
|
||||
}
|
||||
}
|
||||
|
||||
if ($docNo) {
|
||||
if (Str::length($docNo) < 5) {
|
||||
$warnMsg[] = 'Document number contain minimum 5 digits!';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$type = match ($typeValue) {
|
||||
'FG' => '0',
|
||||
'NON-FG' => '1',
|
||||
default => null,
|
||||
};
|
||||
|
||||
$stickId = $itemCode->id;
|
||||
|
||||
$record = StockDataMaster::where([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'serial_number' => $serialNumber,
|
||||
])->first();
|
||||
|
||||
if ($record) {
|
||||
|
||||
$record->update([
|
||||
'type' => $type,
|
||||
'location' => $location ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'quantity' => $quantity ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
||||
StockDataMaster::create([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'type' => $type,
|
||||
'location' => $location ?? null,
|
||||
'serial_number' => $serialNumber ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'quantity' => $quantity ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your stock data master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
2231
app/Filament/Pages/CycleCount.php
Normal file
2231
app/Filament/Pages/CycleCount.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -9,64 +10,117 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null
|
||||
]);
|
||||
}
|
||||
protected static string $view = 'filament.pages.dashboard';
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Store form state in 'filters'
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]); // fixed typo
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
}),
|
||||
]);
|
||||
// public function mount(): void
|
||||
// {
|
||||
// session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
// $this->filtersForm->fill([
|
||||
// 'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// // 'success_status' => null
|
||||
// ]);
|
||||
// }
|
||||
|
||||
}
|
||||
// public function filtersForm(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->statePath('filters') // Store form state in 'filters'
|
||||
// ->schema([
|
||||
// Select::make('plant')
|
||||
// ->label('Select Plant')
|
||||
// ->reactive()
|
||||
// // ->options(Plant::pluck('name', 'id'))
|
||||
// ->options(function (callable $get) {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['selected_plant' => $state]); // fixed typo
|
||||
// //$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// // Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
// }),
|
||||
|
||||
// // Select::make('success_status')
|
||||
// // ->label('Select Status')
|
||||
// // ->options([
|
||||
// // 'Ok' => 'Ok',
|
||||
// // 'Not Ok' => 'Not Ok',
|
||||
// // ])
|
||||
// // ->reactive()
|
||||
// // ->afterStateUpdated(function ($state) {
|
||||
// // session(['success_status' => $state]);
|
||||
// // }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
// }
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (CumulativeChart::canView()) {
|
||||
$widgets[] = CumulativeChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
return 'Welcome';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -163,11 +163,15 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->default(function () {
|
||||
@@ -348,7 +352,8 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'id' => 'scan_locator_no',
|
||||
'id' => 'production_order',
|
||||
'wire:keydown.enter' => '$dispatch("focus-qr-input")',
|
||||
'class' => $get('productionError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
|
||||
@@ -419,13 +424,13 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
|
||||
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
|
||||
|
||||
if (!$machinenotAgaPlant) {
|
||||
if (! $machinenotAgaPlant) {
|
||||
Notification::make()
|
||||
->title('Unknown WorkCenter')
|
||||
->body("Work Center not found")
|
||||
->body('Work Center not found')
|
||||
->danger()
|
||||
->send();
|
||||
$this->form->fill([
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->pId,
|
||||
'machine_id' => $this->mNam,
|
||||
'block_name' => $this->bNam,
|
||||
@@ -440,9 +445,9 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// 'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!$machineAgaPlant) {
|
||||
} elseif (! $machineAgaPlant) {
|
||||
Notification::make()
|
||||
->title('Unknown WorkCenter')
|
||||
->body("Work Center not found against plant code $PlaCo")
|
||||
@@ -464,20 +469,20 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// 'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first();
|
||||
|
||||
if($rec)
|
||||
{
|
||||
if ($rec) {
|
||||
|
||||
$item = Item::where('id', $rec->item_id)->where('plant_id', $plantId)->first();
|
||||
|
||||
$itemCode = $item?->code ?? '';
|
||||
$serialNo = $rec->serial_number ?? '';
|
||||
|
||||
$this->recQr = $itemCode . ' | ' . $serialNo;
|
||||
$this->recQr = $itemCode.' | '.$serialNo;
|
||||
|
||||
}
|
||||
|
||||
@@ -504,12 +509,11 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// 'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
$this->dispatch('focus-production-order');
|
||||
$this->triggerChartUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// Method to process the value when Enter is pressed
|
||||
|
||||
#[On('handleQrScan')]
|
||||
public function handleQrScan($value)
|
||||
{
|
||||
@@ -567,7 +571,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->body('Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (! $this->pId) {
|
||||
@@ -1125,7 +1128,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
|
||||
if (! ctype_alnum($iCode)) {
|
||||
|
||||
$this->form->fill([
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift'; // 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
public function getHeading(): string
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static ?string $slug = 'production-line-count';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
return '';
|
||||
session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// 'success_status' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
}),
|
||||
|
||||
// Select::make('success_status')
|
||||
// ->label('Select Status')
|
||||
// ->options([
|
||||
// 'Ok' => 'Ok',
|
||||
// 'Not Ok' => 'Not Ok',
|
||||
// ])
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['success_status' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
// public static function canAccess(): bool
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view welcome page');
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ class WireMasterPrint extends Page
|
||||
|
||||
protected static string $view = 'filament.pages.wire-master-print';
|
||||
|
||||
use InteractsWithForms;
|
||||
protected static ?string $navigationGroup = 'Master Packing';
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId, $palletNo, $serialNo;
|
||||
public $snoCount = 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Machine;
|
||||
@@ -398,13 +399,13 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Characteristics Approver Master')
|
||||
// ->color('warning')
|
||||
// ->importer(CharacteristicApproverMasterImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import characteristic approver master');
|
||||
// }),
|
||||
ImportAction::make()
|
||||
->label('Import Characteristics Approver Master')
|
||||
->color('warning')
|
||||
->importer(CharacteristicApproverMasterImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import characteristic approver master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Characteristics Approver Master')
|
||||
->color('warning')
|
||||
|
||||
@@ -17,6 +17,7 @@ use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -41,20 +42,22 @@ class CharacteristicValueResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(CharacteristicValue::latest()->first())->plant_id;
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('line_id', null);
|
||||
@@ -76,8 +79,10 @@ class CharacteristicValueResource extends Resource
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
@@ -87,6 +92,7 @@ class CharacteristicValueResource extends Resource
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('item_id', null);
|
||||
@@ -101,11 +107,12 @@ class CharacteristicValueResource extends Resource
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id') || ! $get('line_id')) {
|
||||
return [];
|
||||
@@ -115,6 +122,7 @@ class CharacteristicValueResource extends Resource
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('machine_id', null);
|
||||
@@ -128,11 +136,12 @@ class CharacteristicValueResource extends Resource
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Machine')
|
||||
->label('Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('item_id')) {
|
||||
return [];
|
||||
@@ -143,6 +152,7 @@ class CharacteristicValueResource extends Resource
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('process_order', null);
|
||||
@@ -155,7 +165,6 @@ class CharacteristicValueResource extends Resource
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
@@ -325,12 +334,12 @@ class CharacteristicValueResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -340,12 +349,12 @@ class CharacteristicValueResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->label('Item Description')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Machine')
|
||||
->label('Work Center')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -427,39 +436,32 @@ class CharacteristicValueResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('characteristicValues', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Item Code')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
@@ -467,17 +469,44 @@ class CharacteristicValueResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
return Line::whereHas('characteristicValues', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('characteristicValues', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Select::make('Machine')
|
||||
->label('Select Machine')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
@@ -486,11 +515,13 @@ class CharacteristicValueResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
||||
|
||||
return Machine::whereHas('characteristicValues', function ($query) use ($plantId, $lineId) {
|
||||
if ($plantId && $lineId) {
|
||||
$query->where('plant_id', $plantId)->where('line_id', $lineId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
@@ -546,11 +577,11 @@ class CharacteristicValueResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['process_order'])) {
|
||||
$query->where('process_order', $data['process_order']);
|
||||
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['coil_number'])) {
|
||||
$query->where('coil_number', $data['coil_number']);
|
||||
$query->where('coil_number', 'like', '%'.$data['coil_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
@@ -571,7 +602,7 @@ class CharacteristicValueResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -581,15 +612,15 @@ class CharacteristicValueResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['Machine'])) {
|
||||
$indicators[] = 'Machine: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (! empty($data['process_order'])) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,8 @@ class CustomerPoMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Packing';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
|
||||
181
app/Filament/Resources/DuplicateStockResource.php
Normal file
181
app/Filament/Resources/DuplicateStockResource.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
use App\Models\DuplicateStock;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class DuplicateStockResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DuplicateStock::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Cycle Count Software';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('stock_data_master_id')
|
||||
->relationship('stockDataMaster', 'id')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.plant.name')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.stickerMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.location')
|
||||
->label('Location')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.bin')
|
||||
->label('Bin')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.batch')
|
||||
->label('Batch')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.quantity')
|
||||
->label('Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.doc_no')
|
||||
->label('Document Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.type')
|
||||
->label('Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.motor_scanned_status')
|
||||
->label('Motor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.pump_scanned_status')
|
||||
->label('Pump Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.scanned_status_set')
|
||||
->label('Scanned Status Set')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stockDataMaster.scanned_status')
|
||||
->label('Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDuplicateStocks::route('/'),
|
||||
'create' => Pages\CreateDuplicateStock::route('/create'),
|
||||
'view' => Pages\ViewDuplicateStock::route('/{record}'),
|
||||
'edit' => Pages\EditDuplicateStock::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDuplicateStock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DuplicateStockResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDuplicateStock extends EditRecord
|
||||
{
|
||||
protected static string $resource = DuplicateStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDuplicateStocks extends ListRecords
|
||||
{
|
||||
protected static string $resource = DuplicateStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewDuplicateStock extends ViewRecord
|
||||
{
|
||||
protected static string $resource = DuplicateStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@@ -45,6 +46,7 @@ class GrMasterResource extends Resource
|
||||
->reactive()
|
||||
->searchable()
|
||||
->relationship('plant', 'name')
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -56,6 +58,7 @@ class GrMasterResource extends Resource
|
||||
// ->relationship('item', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
|
||||
@@ -626,7 +626,6 @@ class InvoiceInTransitResource extends Resource
|
||||
->body('Invoice in transit upload failed!')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Resources;
|
||||
|
||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\InvoiceValidationExporter;
|
||||
use App\Filament\Imports\InvoiceValidationImporter;
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
use App\Mail\InvoiceNotification;
|
||||
use App\Models\InvoiceValidation;
|
||||
@@ -27,6 +28,7 @@ use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -1125,6 +1127,13 @@ class InvoiceValidationResource extends Resource
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import material invoice');
|
||||
}),
|
||||
ImportAction::make()
|
||||
->label('Import Invoices')
|
||||
->color('warning')
|
||||
->importer(InvoiceValidationImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import invoice');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoices')
|
||||
->color('warning')
|
||||
@@ -1189,17 +1198,23 @@ class InvoiceValidationResource extends Resource
|
||||
->inlineLabel(false)
|
||||
->inline(),
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('invoiceValidations', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('sticker_master_id', null);
|
||||
$set('operator_id', null);
|
||||
@@ -1213,6 +1228,8 @@ class InvoiceValidationResource extends Resource
|
||||
Select::make('sticker_master_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
@@ -1225,9 +1242,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
$query->whereHas('invoiceValidations');
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
}),
|
||||
Select::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->nullable()
|
||||
@@ -1347,7 +1362,7 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
@@ -48,10 +48,12 @@ class ItemResource extends Resource
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
// ->preload()
|
||||
// ->nullable(),
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
@@ -191,7 +193,7 @@ class ItemResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -230,8 +232,7 @@ class ItemResource extends Resource
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
@@ -246,13 +247,21 @@ class ItemResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('items', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('code', null);
|
||||
@@ -319,11 +328,23 @@ class ItemResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
if ($data['uom'] == 'empty') {
|
||||
$query->where(function ($q) {
|
||||
$q->where('uom', '')->orWhereNull('uom');
|
||||
});
|
||||
} else {
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
$query->where('category', '%'.$data['category'].'%');
|
||||
if ($data['category'] == 'empty') {
|
||||
$query->where(function ($q) {
|
||||
$q->where('category', '')->orWhereNull('category');
|
||||
});
|
||||
} else {
|
||||
$query->where('category', '%'.$data['category'].'%');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
@@ -356,11 +377,11 @@ class ItemResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$indicators[] = 'UOM: '.$data['uom'];
|
||||
$indicators[] = ($data['uom'] == 'empty') ? "UOM: ''" : 'UOM: '.$data['uom'];
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
$indicators[] = 'Category: '.$data['category'];
|
||||
$indicators[] = ($data['category'] == 'empty') ? "Category: ''" : 'Category: '.$data['category'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
|
||||
284
app/Filament/Resources/NotInStockResource.php
Normal file
284
app/Filament/Resources/NotInStockResource.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\NotInStockExporter;
|
||||
use App\Filament\Imports\NotInStockImporter;
|
||||
use App\Filament\Resources\NotInStockResource\Pages;
|
||||
use App\Models\NotInStock;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
|
||||
class NotInStockResource extends Resource
|
||||
{
|
||||
protected static ?string $model = NotInStock::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Cycle Count Software';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('sticker_master_id')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location'),
|
||||
Forms\Components\TextInput::make('bin')
|
||||
->label('Bin'),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number'),
|
||||
Forms\Components\TextInput::make('batch')
|
||||
->label('Batch'),
|
||||
Forms\Components\TextInput::make('quantity')
|
||||
->label('Quantity'),
|
||||
Forms\Components\TextInput::make('doc_no')
|
||||
->label('Doc No'),
|
||||
Forms\Components\Select::make('type')
|
||||
->label('Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
]),
|
||||
Forms\Components\TextInput::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status'),
|
||||
Forms\Components\TextInput::make('pump_scanned_status')
|
||||
->label('Pump Scanned Status'),
|
||||
Forms\Components\TextInput::make('capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status'),
|
||||
Forms\Components\TextInput::make('scanned_status_set')
|
||||
->label('Scanned Status Set'),
|
||||
Forms\Components\TextInput::make('panel_box_item_code')
|
||||
->label('Panel Box Item Code'),
|
||||
Forms\Components\TextInput::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier'),
|
||||
Forms\Components\TextInput::make('panel_box_sno')
|
||||
->label('Panel Box Sno'),
|
||||
Forms\Components\TextInput::make('scanned_status')
|
||||
->label('Scanned Status'),
|
||||
Forms\Components\TextInput::make('scanned_quantity')
|
||||
->label('Scanned Quantity'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stickerMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('location')
|
||||
->label('Location')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bin')
|
||||
->label('Bin')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('batch')
|
||||
->label('Batch')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('doc_no')
|
||||
->label('Document Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pump_scanned_status')
|
||||
->label('Pump Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_status_set')
|
||||
->label('Scanned Status Set')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('panel_box_item_code')
|
||||
->label('Panel Box Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('panel_box_sno')
|
||||
->label('Panel Box Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_quantity')
|
||||
->label('Scanned Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Not In Stock')
|
||||
->color('warning')
|
||||
->importer(NotInStockImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import not in stock');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Not In Stock')
|
||||
->color('warning')
|
||||
->exporter(NotInStockExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export not in stock');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListNotInStocks::route('/'),
|
||||
'create' => Pages\CreateNotInStock::route('/create'),
|
||||
'view' => Pages\ViewNotInStock::route('/{record}'),
|
||||
'edit' => Pages\EditNotInStock::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NotInStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateNotInStock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = NotInStockResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NotInStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditNotInStock extends EditRecord
|
||||
{
|
||||
protected static string $resource = NotInStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NotInStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListNotInStocks extends ListRecords
|
||||
{
|
||||
protected static string $resource = NotInStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotInStockResource\Pages;
|
||||
|
||||
use App\Filament\Resources\NotInStockResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewNotInStock extends ViewRecord
|
||||
{
|
||||
protected static string $resource = NotInStockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -50,14 +51,15 @@ class ProcessOrderResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->searchable()
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -73,6 +75,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -93,7 +96,8 @@ class ProcessOrderResource extends Resource
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -103,7 +107,7 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('item_id', null);
|
||||
$set('item_description', null);
|
||||
@@ -111,6 +115,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -123,21 +128,27 @@ class ProcessOrderResource extends Resource
|
||||
// ->relationship('item', 'id')
|
||||
// ->required(),
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
// $lineId = $get('line_id');
|
||||
if (empty($plantId)) {// || empty($lineId)
|
||||
return [];
|
||||
}
|
||||
|
||||
// $availItems = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('item_id', 'item_id')->toArray();
|
||||
|
||||
// return Item::where('plant_id', $plantId)->whereIn('id', $availItems)->pluck('code', 'id');
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -166,9 +177,8 @@ class ProcessOrderResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->label('Item Description')
|
||||
->readOnly()
|
||||
->required()
|
||||
->reactive()
|
||||
@@ -187,7 +197,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('item_uom')
|
||||
->label('UOM')
|
||||
->label('Item UOM')
|
||||
->readOnly()
|
||||
->required()
|
||||
->reactive()
|
||||
@@ -215,6 +225,7 @@ class ProcessOrderResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -262,12 +273,11 @@ class ProcessOrderResource extends Resource
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate Process Order!')
|
||||
->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
||||
->danger()
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title('Duplicate Process Order!')
|
||||
// ->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
|
||||
}
|
||||
};
|
||||
@@ -279,10 +289,10 @@ class ProcessOrderResource extends Resource
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
// $coilNo = $get('coil_number');
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
@@ -318,14 +328,29 @@ class ProcessOrderResource extends Resource
|
||||
function (callable $get) {
|
||||
return Rule::unique('process_orders', 'coil_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('process_order', $get('process_order'))
|
||||
->where('process_order', trim($get('process_order')))
|
||||
->ignore($get('id'));
|
||||
},
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$rework = $get('rework_status');
|
||||
if ($value && Str::contains($value, '.') && $rework == 0) {
|
||||
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if ($value && Str::contains($value, '.')) {
|
||||
if ($rework == 0) {
|
||||
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
|
||||
}
|
||||
} elseif ($value > 1) {
|
||||
$prevCoilNo = (string) ($value - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
$fail("Previous coil number '{$prevCoilNo}' not exist against plant and process order!");
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -333,7 +358,7 @@ class ProcessOrderResource extends Resource
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('process_orders', 'coil_number')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->where('process_order', $get('process_order'))
|
||||
// ->where('process_order', trim($get('process_order')))
|
||||
// ->ignore($get('id'));
|
||||
// })
|
||||
->extraAttributes(fn ($get) => [
|
||||
@@ -347,15 +372,17 @@ class ProcessOrderResource extends Resource
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$set('received_quantity', '0');
|
||||
// $set('updated_order_quantity', $state);
|
||||
$set('scrap_quantity', '0');
|
||||
if (! $plantId || ! $itemId || ! $processOrder) {
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
}
|
||||
|
||||
$query = ProcessOrder::where('plant_id', $plantId)
|
||||
@@ -371,13 +398,175 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->required()
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == '' || trim($get('order_quantity')) == '' || trim($get('order_quantity')) == null))
|
||||
->reactive()
|
||||
->rules([
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$receivedQty = $get('received_quantity');
|
||||
|
||||
$currentId = $get('id');
|
||||
|
||||
$orderQty = (float) $get('order_quantity');
|
||||
$updatedQty = (float) $value;
|
||||
|
||||
$allowedVariance = $orderQty * 0.10;
|
||||
|
||||
$maxAllowed = $orderQty + $allowedVariance;
|
||||
$minAllowed = $orderQty - $allowedVariance;
|
||||
|
||||
if ($updatedQty > $maxAllowed || $updatedQty < $minAllowed) {
|
||||
$fail('Quantity can vary by ±10% of the order quantity.');
|
||||
}
|
||||
|
||||
$otherReceivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->when($currentId, fn ($q) => $q->where('id', '!=', $currentId))
|
||||
->sum('received_quantity');
|
||||
|
||||
$currentReceivedQty = (float) $get('received_quantity');
|
||||
|
||||
$totalReceivedQty = $otherReceivedQty + $currentReceivedQty;
|
||||
|
||||
if ($updatedQty < $totalReceivedQty) {
|
||||
$fail("You cannot set quantity below received quantity ({$totalReceivedQty}).");
|
||||
}
|
||||
};
|
||||
},
|
||||
]),
|
||||
Forms\Components\TextInput::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->default('0.000')
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->maxValue(fn (Get $get) => $get('order_quantity') ?? PHP_INT_MAX)
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$rework = $get('rework_status');
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$coilNo = trim($get('coil_number'));
|
||||
|
||||
$orderExist = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
|
||||
if ($orderExist) {
|
||||
// $orderQty = $orderExist->order_quantity ?? 0;
|
||||
$orderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
$total = $alreadyReceived + $value;
|
||||
|
||||
if ($rework == 1) {
|
||||
if ($coilNo && Str::contains($coilNo, '.')) {
|
||||
$coilMain = explode('.', $coilNo)[0];
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilMain)
|
||||
->first();
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
|
||||
$fail('Rework received quantity should not exceed exist received quantity!');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($existingCoil && $existingCoil->rework_status == 1 && $total > $orderQty) {
|
||||
$fail("Rework received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
|
||||
}
|
||||
} else {
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if (! $existingCoil) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
|
||||
$fail('Rework received quantity should not exceed exist received quantity!');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($coilNo && Str::contains($coilNo, '.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
if ($existing) {
|
||||
if ($existing->received_quantity < $value) {
|
||||
$fail('Received quantity should not exceed exist received quantity!'); // Exist Received Qty = '{$existing->received_quantity}'.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $orderQty) {
|
||||
$fail("Received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('scrap_quantity', '0');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -386,7 +575,7 @@ class ProcessOrderResource extends Resource
|
||||
->label('Scrap Quantity')
|
||||
->default('0.000')
|
||||
->required()
|
||||
->readOnly(fn ($get) => ($get('rework_status') == 0 || $get('process_order') == null))
|
||||
->readOnly(fn ($get) => ($get('rework_status') == 0 || trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->reactive()
|
||||
->numeric()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
@@ -413,7 +602,7 @@ class ProcessOrderResource extends Resource
|
||||
Forms\Components\TextInput::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->reactive()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$sfgNo = $get('sfg_number');
|
||||
@@ -445,9 +634,10 @@ class ProcessOrderResource extends Resource
|
||||
->hint(fn ($get) => $get('sfgNumberError') ? $get('sfgNumberError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine ID')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->maxLength(18)
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -575,7 +765,7 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
|
||||
// Get the value of process_order field
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if ($batchId != $processOrder) {
|
||||
Notification::make()
|
||||
@@ -620,7 +810,7 @@ class ProcessOrderResource extends Resource
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->action(function ($get, callable $set) {
|
||||
$equipmentNumber = $get('process_order');
|
||||
$equipmentNumber = trim($get('process_order'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (! $equipmentNumber) {
|
||||
@@ -680,27 +870,27 @@ class ProcessOrderResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Uom')
|
||||
->label('Item UOM')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -719,6 +909,11 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->alignCenter()
|
||||
@@ -735,7 +930,7 @@ class ProcessOrderResource extends Resource
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine ID')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -778,16 +973,47 @@ class ProcessOrderResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant Name')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('processOrders', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
@@ -797,6 +1023,10 @@ class ProcessOrderResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
@@ -847,7 +1077,7 @@ class ProcessOrderResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && Str::length($data['coil_number']) <= 0 && empty($data['sfg_number']) && empty($data['machine_name']) && ($data['rework_status'] == null || $data['rework_status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['process_order']) && Str::length($data['coil_number']) <= 0 && empty($data['sfg_number']) && empty($data['machine_name']) && ($data['rework_status'] == null || $data['rework_status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -861,6 +1091,10 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
@@ -900,17 +1134,21 @@ class ProcessOrderResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.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.';
|
||||
return 'Plant Name: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['process_order'])) {
|
||||
@@ -1020,7 +1258,7 @@ class ProcessOrderResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if (empty($plantId) || empty($itemId) || empty($processOrder)) {
|
||||
return [];
|
||||
@@ -1037,7 +1275,7 @@ class ProcessOrderResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
|
||||
$set('received_quantity', null);
|
||||
|
||||
@@ -3,10 +3,28 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProcessOrder extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'];
|
||||
$processOrder = $this->data['process_order'];
|
||||
$updatedQty = (float) $this->data['updated_order_quantity'];
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $updatedQty,
|
||||
'updated_by' => Filament::auth()->user()->name,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,78 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProcessOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'] ?? null;
|
||||
$processOrder = $this->data['process_order'] ?? null;
|
||||
$extraQty = (float) ($this->data['updated_order_quantity'] ?? 0);
|
||||
$extraQtyRaw = $this->data['updated_order_quantity'] ?? '';
|
||||
|
||||
if (!preg_match('/^\d+(\.\d{1,3})?$/', $extraQtyRaw)) {
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Only positive numbers with up to 3 decimal places are allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stop save
|
||||
}
|
||||
|
||||
if ($extraQty < 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Negative values are not allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if ($extraQty > 0) {
|
||||
|
||||
$order = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($order) {
|
||||
|
||||
$baseQty = (float) $order->order_quantity;
|
||||
$maxAllowed = $baseQty * 0.10;
|
||||
|
||||
$maxFinalQty = $baseQty + $maxAllowed;
|
||||
|
||||
if ($extraQty > $maxFinalQty) {
|
||||
Notification::make()
|
||||
->title('Limit Exceeded')
|
||||
->body("You can only increase the order by 10% (Max allowed: {$maxFinalQty}).")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stops save
|
||||
}
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $extraQty,
|
||||
'updated_by' => Filament::auth()->user()?->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -27,6 +27,8 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class ProductCharacteristicsMasterResource extends Resource
|
||||
{
|
||||
@@ -41,7 +43,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
@@ -57,6 +59,10 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('item_id', null);
|
||||
$set('line_id', null);
|
||||
$set('work_group_master_id', null);
|
||||
$set('machine_id', null);
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
@@ -71,15 +77,38 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('line_id', null);
|
||||
$set('work_group_master_id', null);
|
||||
$set('machine_id', null);
|
||||
})
|
||||
->rules([
|
||||
function (callable $get) {
|
||||
return Rule::unique('product_characteristics_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->where('work_group_master_id', $get('work_group_master_id'))
|
||||
->where('machine_id', $get('machine_id'))
|
||||
->where('characteristics_type', $get('characteristics_type'))
|
||||
->where('name', $get('name'))
|
||||
->ignore($get('id'));
|
||||
},
|
||||
// function (callable $get): Closure {
|
||||
// return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
// $rework = $get('rework_status');
|
||||
// if ($value && Str::contains($value, '.') && $rework == 0) {
|
||||
// $fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
@@ -90,16 +119,14 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('machine_id', null);
|
||||
if (! $get('work_group_master_id')) {
|
||||
$set('machine_id', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('work_group_master_id', null);
|
||||
$set('machine_id', null);
|
||||
})
|
||||
// ->relationship('line', 'name'),
|
||||
->required(),
|
||||
// ->relationship('line', 'name'),
|
||||
Forms\Components\Select::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->required()
|
||||
@@ -121,13 +148,13 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $get('plant_id'))->whereIn('id', $workGroupIds)->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('machine_id', null);
|
||||
if (! $lineId) {
|
||||
$set('mGroupWorkError', 'Please select a line first.');
|
||||
$set('machine_id', null);
|
||||
|
||||
return;
|
||||
} else {
|
||||
@@ -139,13 +166,12 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
// return;
|
||||
// }
|
||||
$set('mGroupWorkError', null);
|
||||
$set('machine_id', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mGroupWorkError') ? 'border-red-500' : '',
|
||||
])
|
||||
// ->dehydrateStateUsing(fn ($state) => null)
|
||||
// ->dehydrateStateUsing(fn ($state) => null)
|
||||
->hint(fn ($get) => $get('mGroupWorkError') ? $get('mGroupWorkError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
@@ -167,7 +193,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->where('work_group_master_id', $workGroupId)
|
||||
->pluck('work_center', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
|
||||
$set('machine_id', null);
|
||||
@@ -190,7 +216,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->label('Characteristics Name')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -206,9 +232,15 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
// ->preload()
|
||||
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'Visual') {
|
||||
$set('lower', 0);
|
||||
$set('middle', 0);
|
||||
$set('upper', 0);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
|
||||
// Forms\Components\Select::make('result')
|
||||
// ->label('Visual Type')
|
||||
// ->reactive()
|
||||
@@ -226,6 +258,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
// session()->put('temp_result', $state);
|
||||
// })
|
||||
// ->hidden(fn (callable $get) => $get('inspection_type') != 'Visual'),
|
||||
|
||||
Forms\Components\TextInput::make('lower')
|
||||
->label('Lower')
|
||||
->numeric()
|
||||
@@ -238,7 +271,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
$set('middle', ($state + $get('upper')) / 2);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value')
|
||||
->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'),
|
||||
Forms\Components\TextInput::make('upper')
|
||||
->label('Upper')
|
||||
->numeric()
|
||||
@@ -251,7 +285,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
$set('middle', ($get('lower') + $state) / 2);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value')
|
||||
->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'),
|
||||
Forms\Components\TextInput::make('middle')
|
||||
->label('Middle')
|
||||
->readOnly()
|
||||
@@ -274,8 +309,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->dehydrateStateUsing(fn ($state, Get $get) => ($get('lower') + $get('upper')) / 2)
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
}),
|
||||
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
@@ -302,7 +337,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -311,13 +346,13 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -331,10 +366,16 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('machine.work_center')
|
||||
// ->label('Work Center')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Characteristics Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inspection_type')
|
||||
->label('Inspection Type')
|
||||
->alignCenter()
|
||||
@@ -390,20 +431,34 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('productCharacteristicsMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
$set('work_group_master', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
@@ -411,34 +466,42 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
return Line::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('work_group_master', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->reactive(),
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $set('process_order', null);
|
||||
// }),
|
||||
Select::make('work_group_master')
|
||||
->label('Select Work Group Master')
|
||||
->label('Search by Group Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
@@ -446,45 +509,65 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
return WorkGroupMaster::whereHas('productCharacteristicsMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Machine')
|
||||
->label('Select Machine')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
$workGroupMasterId = $get('work_group_master');
|
||||
|
||||
if (empty($plantId) || empty($lineId)) {
|
||||
if (empty($plantId) || empty($lineId) || empty($workGroupMasterId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
||||
|
||||
return Machine::whereHas('productCharacteristicsMasters', function ($query) use ($plantId, $lineId, $workGroupMasterId) {
|
||||
if ($plantId && $lineId && $workGroupMasterId) {
|
||||
$query->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
// return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive(),
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $set('process_order', null);
|
||||
// }),
|
||||
// TextInput::make('process_order')
|
||||
// ->label('Process Order')
|
||||
// ->placeholder('Enter Process Order'),
|
||||
// TextInput::make('coil_number')
|
||||
// ->label('Coil Number')
|
||||
// ->placeholder(placeholder: 'Enter Coil Number'),
|
||||
TextInput::make('name')
|
||||
->label('characteristics Name')
|
||||
->reactive()
|
||||
->placeholder(placeholder: 'Enter characteristics Name'),
|
||||
Select::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
->label('Search by Characteristics Type')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options([
|
||||
'Product' => 'Product',
|
||||
'Process' => 'Process',
|
||||
]),
|
||||
Select::make('inspection_type')
|
||||
->label('Search by Inspection Type')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options([
|
||||
'Visual' => 'Visual',
|
||||
'Value' => 'Value',
|
||||
]),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -498,7 +581,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['work_group_master']) && empty($data['Machine']) && empty($data['characteristics_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['work_group_master']) && empty($data['Machine']) && empty($data['name']) && empty($data['characteristics_type']) && empty($data['inspection_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -528,10 +611,18 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
$query->where('machine_id', $data['Machine']);
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$query->where('name', 'like', '%'.$data['name'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['characteristics_type'])) {
|
||||
$query->where('characteristics_type', $data['characteristics_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['inspection_type'])) {
|
||||
$query->where('inspection_type', $data['inspection_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -546,7 +637,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -556,25 +647,33 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
||||
$indicators[] = 'Item Name: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['work_group_master'])) {
|
||||
$indicators[] = 'Work Group Master: '.WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
||||
$indicators[] = 'Group Work Center: '.WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['Machine'])) {
|
||||
$indicators[] = 'Machine: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$indicators[] = 'Characteristics Name: '.$data['name'];
|
||||
}
|
||||
|
||||
if (! empty($data['characteristics_type'])) {
|
||||
$indicators[] = 'Characteristics Type: '.$data['characteristics_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['inspection_type'])) {
|
||||
$indicators[] = 'Inspection Type: '.$data['inspection_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class QualityValidationResource extends Resource
|
||||
->statePath('data')
|
||||
->schema(components: [
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
@@ -94,6 +95,7 @@ class QualityValidationResource extends Resource
|
||||
->default(fn () => session('last_selected_plant_id')),
|
||||
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->relationship('line', titleAttribute: 'name')
|
||||
->reactive()
|
||||
->required()
|
||||
@@ -104,7 +106,6 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->where('type', 'FG Line') // Filter by type
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
@@ -130,7 +131,7 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\Hidden::make('line')
|
||||
->default(fn () => session('last_selected_line')),
|
||||
Forms\Components\Hidden::make('sticker_master_id')
|
||||
// ->relationship('stickerMaster', 'id')
|
||||
// ->relationship('stickerMaster', 'id')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('uom')
|
||||
->required(),
|
||||
@@ -2347,6 +2348,7 @@ class QualityValidationResource extends Resource
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation1')
|
||||
->label('Part Validation 1')
|
||||
->hidden(fn (callable $get) => ! $get('part_validation1_visible'))
|
||||
->default('')
|
||||
->reactive()
|
||||
@@ -2444,6 +2446,7 @@ class QualityValidationResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->hidden(fn (callable $get) => ! $get('part_validation2_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
@@ -2538,6 +2541,7 @@ class QualityValidationResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->hidden(fn (callable $get) => ! $get('part_validation3_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
@@ -2631,6 +2635,7 @@ class QualityValidationResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->hidden(fn (callable $get) => ! $get('part_validation4_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
@@ -2715,6 +2720,7 @@ class QualityValidationResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->label('Part Validation 5')
|
||||
->hidden(fn (callable $get) => ! $get('part_validation5_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
@@ -2873,11 +2879,11 @@ class QualityValidationResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->label('Line Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -2893,6 +2899,10 @@ class QualityValidationResource extends Resource
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stickerMaster.item.description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('Unit of Measure')
|
||||
->alignCenter()
|
||||
@@ -2992,6 +3002,11 @@ class QualityValidationResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
@@ -3007,17 +3022,22 @@ class QualityValidationResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('qualityValidations', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('sticker_master_id', null);
|
||||
$set('sap_msg_status', null);
|
||||
@@ -3025,20 +3045,23 @@ class QualityValidationResource extends Resource
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->where('type', 'FG Line') // Filter by type
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
return Line::whereHas('qualityValidations', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
// return Line::where('plant_id', $plantId)->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('sticker_master_id', null);
|
||||
$set('sap_msg_status', null);
|
||||
@@ -3053,6 +3076,8 @@ class QualityValidationResource extends Resource
|
||||
Select::make('sticker_master_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
@@ -3062,12 +3087,12 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
$query->whereHas('qualityValidations');
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
}),
|
||||
Select::make('sap_msg_status')
|
||||
->label('Select SAP Message Status')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
@@ -3076,12 +3101,13 @@ class QualityValidationResource extends Resource
|
||||
} else {
|
||||
return QualityValidation::where('plant_id', $plantId)->whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status');
|
||||
}
|
||||
})
|
||||
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
|
||||
->reactive(),
|
||||
}),
|
||||
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
@@ -3092,9 +3118,7 @@ class QualityValidationResource extends Resource
|
||||
} else { // if ($plantId && $lineId)
|
||||
return QualityValidation::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
}),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -3127,11 +3151,11 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
$query->where('production_order', $data['production_order']);
|
||||
$query->where('production_order', 'like', '%'.$data['production_order'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$query->where('serial_number', $data['serial_number']);
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['sap_msg_status'])) {
|
||||
@@ -3166,7 +3190,7 @@ class QualityValidationResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -3176,7 +3200,7 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
@@ -3189,7 +3213,7 @@ class QualityValidationResource extends Resource
|
||||
|
||||
if (! empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Codes: '.$itemCode;
|
||||
$indicators[] = 'Item Code: '.$itemCode;
|
||||
}
|
||||
|
||||
if (! empty($data['sap_msg_status'])) {
|
||||
|
||||
@@ -49,7 +49,9 @@ class StickerMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
@@ -188,7 +190,7 @@ class StickerMasterResource extends Resource
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->label('Item Description')
|
||||
->required()
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
@@ -529,7 +531,7 @@ class StickerMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
@@ -537,6 +539,19 @@ class StickerMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_motor')
|
||||
->label('Serial Number Motor')
|
||||
->disabled(true)
|
||||
@@ -692,12 +707,19 @@ class StickerMasterResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('stickersMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
|
||||
600
app/Filament/Resources/StockDataMasterResource.php
Normal file
600
app/Filament/Resources/StockDataMasterResource.php
Normal file
@@ -0,0 +1,600 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\StockDataMasterExporter;
|
||||
use App\Filament\Imports\StockDataMasterImporter;
|
||||
use App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class StockDataMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StockDataMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Cycle Count Software';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('sticker_master_id')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location'),
|
||||
Forms\Components\TextInput::make('bin')
|
||||
->label('Bin'),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number'),
|
||||
Forms\Components\TextInput::make('batch')
|
||||
->label('Batch'),
|
||||
Forms\Components\TextInput::make('quantity')
|
||||
->label('Quantity'),
|
||||
Forms\Components\TextInput::make('doc_no')
|
||||
->label('Doc No'),
|
||||
Forms\Components\Select::make('type')
|
||||
->label('Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
]),
|
||||
Forms\Components\TextInput::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status'),
|
||||
Forms\Components\TextInput::make('pump_scanned_status')
|
||||
->label('Pump Scanned Status'),
|
||||
Forms\Components\TextInput::make('capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status'),
|
||||
Forms\Components\TextInput::make('scanned_status_set')
|
||||
->label('Scanned Status Set'),
|
||||
Forms\Components\TextInput::make('panel_box_item_code')
|
||||
->label('Panel Box Item Code'),
|
||||
Forms\Components\TextInput::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier'),
|
||||
Forms\Components\TextInput::make('panel_box_sno')
|
||||
->label('Panel Box Sno'),
|
||||
Forms\Components\TextInput::make('scanned_status')
|
||||
->label('Scanned Status'),
|
||||
Forms\Components\TextInput::make('scanned_quantity')
|
||||
->label('Scanned Quantity'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stickerMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('location')
|
||||
->label('Location')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bin')
|
||||
->label('Bin')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('batch')
|
||||
->label('Batch')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('doc_no')
|
||||
->label('Document Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('pump_scanned_status')
|
||||
->label('Pump Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('capacitor_scanned_status')
|
||||
->label('Capacitor Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('scanned_status_set')
|
||||
->label('Scanned Status Set')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('panel_box_item_code')
|
||||
->label('Panel Box Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('panel_box_sno')
|
||||
->label('Panel Box Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->visible(fn ($livewire) => ($livewire->tableFilters['advanced_filters']['type'] ?? null) != '1'),
|
||||
Tables\Columns\TextColumn::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_quantity')
|
||||
->label('Scanned Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('system_stock')
|
||||
->label('System Stock')
|
||||
->alignCenter()
|
||||
->getStateUsing(fn ($record) => $record->quantity),
|
||||
Tables\Columns\TextColumn::make('scanned_stock')
|
||||
->label('Scanned Stock')
|
||||
->alignCenter()
|
||||
->getStateUsing(fn ($record) => $record->scanned_quantity),
|
||||
Tables\Columns\TextColumn::make('duplicate_stock')
|
||||
->label('Duplicate Stock')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
return \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('not_in_stock')
|
||||
->label('Not In Stock')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
return \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('physical_stock')
|
||||
->label('Physical Stock')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = $record->scanned_quantity ?? 0;
|
||||
|
||||
return $scanned + $duplicate + $notInStock;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('stock_difference')
|
||||
->label('Stock Difference Count')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = (int) $record->scanned_quantity;
|
||||
|
||||
$physicalStock = $scanned + $duplicate + $notInStock;
|
||||
|
||||
$systemStock = (int) $record->quantity;
|
||||
|
||||
$difference = $physicalStock - $systemStock;
|
||||
|
||||
return max($difference, 0); // prevents negative values
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Radio::make('type')
|
||||
->label('Stock Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
])
|
||||
->inline()
|
||||
->default('0')
|
||||
->nullable(),
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('stockDataMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('sticker_master_id', null);
|
||||
$set('updated_by', null);
|
||||
}),
|
||||
TextInput::make('location')
|
||||
->label('Location')
|
||||
->placeholder(placeholder: 'Enter Location'),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->placeholder(placeholder: 'Enter Serial Number'),
|
||||
Select::make('sticker_master_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
if (empty($pId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('stickerMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
// $query->whereHas('stockDataMasters');
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->nullable()
|
||||
->options([
|
||||
'Scanned' => 'Scanned',
|
||||
'Pending' => 'Pending',
|
||||
])
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('updated_by')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return StockDataMaster::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
} else {
|
||||
return StockDataMaster::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (! isset($data['type']) && (empty($data['Plant']) && empty($data['location']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
|
||||
if (empty($data['type'])) {
|
||||
Notification::make()
|
||||
->title('Please, choose valid type to filter.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if ($data['type'] != '') {
|
||||
|
||||
if ($data['type'] == '0') {
|
||||
|
||||
$query->where('type', '0');
|
||||
|
||||
if (! empty($data['scanned_status'])) {
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('scanned_status')
|
||||
->where('scanned_status', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
|
||||
$query->where(function ($query) {
|
||||
$query->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
} elseif ($data['type'] == '1') {
|
||||
$query->where('type', '1')
|
||||
->whereNotNull('quantity');
|
||||
|
||||
if ($data['scanned_status']) {
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
|
||||
$query->whereNotNull('scanned_status')
|
||||
->where('scanned_status', '!=', '');
|
||||
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($data['scanned_status']) {
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
|
||||
$query->whereNotNull('scanned_status')
|
||||
->where('scanned_status', '!=', '');
|
||||
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['location'])) {
|
||||
$query->where('location', 'like', '%'.$data['location'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['sticker_master_id'])) {
|
||||
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (! empty($stickerMasterIds)) {
|
||||
$query->whereIn('sticker_master_id', $stickerMasterIds);
|
||||
}
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$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['location'])) {
|
||||
$indicators[] = 'Location: '.$data['location'];
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$indicators[] = 'Serial Number: '.$data['serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Code: '.$itemCode;
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['scanned_status'])) {
|
||||
$indicators[] = 'Scanned Status: '.$data['scanned_status'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Stock Data')
|
||||
->color('warning')
|
||||
->importer(StockDataMasterImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import stock data master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Stock Data')
|
||||
->color('warning')
|
||||
->exporter(StockDataMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export stock data master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListStockDataMasters::route('/'),
|
||||
'create' => Pages\CreateStockDataMaster::route('/create'),
|
||||
'view' => Pages\ViewStockDataMaster::route('/{record}'),
|
||||
'edit' => Pages\EditStockDataMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StockDataMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStockDataMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StockDataMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StockDataMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStockDataMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = StockDataMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StockDataMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStockDataMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = StockDataMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StockDataMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewStockDataMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = StockDataMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ class WireMasterPackingResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Packing';
|
||||
|
||||
public $importedPoList = [];
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,10 +13,7 @@ class ObdController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
public function index() {}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
@@ -24,36 +21,40 @@ class ObdController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// if("Bearer " . $expectedToken != $header_auth)
|
||||
// {
|
||||
// return response("ERROR: Unauthorized", 403)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
// }
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$data = $request->all();
|
||||
// Validate required fields
|
||||
$missing = [];
|
||||
if (empty($data['plant_name'])) $missing[] = 'plant_name';
|
||||
if (empty($data['obd_number'])) $missing[] = 'obd_number';
|
||||
if (empty($data['line_numbers'])) $missing[] = 'line_numbers';
|
||||
if (empty($data['plant_name'])) {
|
||||
$missing[] = 'plant_name';
|
||||
}
|
||||
if (empty($data['obd_number'])) {
|
||||
$missing[] = 'obd_number';
|
||||
}
|
||||
if (empty($data['line_numbers'])) {
|
||||
$missing[] = 'line_numbers';
|
||||
}
|
||||
|
||||
if (! empty($missing)) {
|
||||
$message = 'Missing required field(s): '.implode(', ', $missing);
|
||||
|
||||
if (!empty($missing))
|
||||
{
|
||||
$message = "Missing required field(s): " . implode(', ', $missing);
|
||||
// return response($message, 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -63,53 +64,49 @@ class ObdController extends Controller
|
||||
|
||||
// OBD Number validation
|
||||
$obdNumber = $data['obd_number'];
|
||||
if (Str::length($obdNumber) < 8 || !ctype_alnum($obdNumber))
|
||||
{
|
||||
if (Str::length($obdNumber) < 8 || ! ctype_alnum($obdNumber)) {
|
||||
// return response("ERROR: OBD Number should contain minimum 8 digits", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "OBD number should contain minimum 8 digit alpha-numeric values only!"
|
||||
'status_description' => 'OBD number should contain minimum 8 digit alpha-numeric values only!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Lookup plant_id by plant_name
|
||||
$plantId = Plant::where('name', $data['plant_name'])->value('id');
|
||||
if (!$plantId) {
|
||||
if (! $plantId) {
|
||||
// return response("ERROR: Plant '{$data['plant_name']}' not found", 404)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$data['plant_name']}' not found!"
|
||||
'status_description' => "Plant '{$data['plant_name']}' not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
//Check if OBD number exists for that plant
|
||||
// Check if OBD number exists for that plant
|
||||
$obdRecords = WeightValidation::where('plant_id', $plantId)
|
||||
->where('obd_number', $obdNumber)
|
||||
->exists();
|
||||
|
||||
if (!$obdRecords)
|
||||
{
|
||||
if (! $obdRecords) {
|
||||
// return response( "ERROR: OBD Number '$obdNumber' not found for plant '{$data['plant_name']}'",404)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "OBD Number '$obdNumber' not found for plant '{$data['plant_name']}'!"
|
||||
'status_description' => "OBD Number '$obdNumber' not found for plant '{$data['plant_name']}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$missingLines = [];
|
||||
$alreadyUpdatedLines = [];
|
||||
|
||||
foreach ($data['line_numbers'] as $line)
|
||||
{
|
||||
if ($line['line_number'] == '' || $line['line_number'] == null)
|
||||
{
|
||||
foreach ($data['line_numbers'] as $line) {
|
||||
if ($line['line_number'] == '' || $line['line_number'] == null) {
|
||||
// return response("ERROR: Line Number can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line Number can't be empty!"
|
||||
'status_description' => "Line Number can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -118,50 +115,46 @@ class ObdController extends Controller
|
||||
->where('line_number', $line['line_number'])
|
||||
->first();
|
||||
|
||||
if (!$record)
|
||||
{
|
||||
if (! $record) {
|
||||
$missingLines[] = $line['line_number'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$mandatoryFields = ['vehicle_number', 'bundle_number', 'heat_number', 'picked_weight', 'scanned_by'];
|
||||
$missingFields = [];
|
||||
|
||||
foreach ($mandatoryFields as $field)
|
||||
{
|
||||
if ($line[$field] == '' || $line[$field] == null)
|
||||
{
|
||||
foreach ($mandatoryFields as $field) {
|
||||
if ($line[$field] == '' || $line[$field] == null) {
|
||||
$missingFields[] = ucwords(str_replace('_', ' ', $field));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missingFields))
|
||||
{
|
||||
if (count($missingFields) == 1)
|
||||
{
|
||||
if (! empty($missingFields)) {
|
||||
if (count($missingFields) == 1) {
|
||||
$fieldsString = $missingFields[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$lastField = array_pop($missingFields);
|
||||
$fieldsString = implode(', ', $missingFields) . ' and ' . $lastField;
|
||||
$fieldsString = implode(', ', $missingFields).' and '.$lastField;
|
||||
}
|
||||
|
||||
$message = $fieldsString . " can't be empty for line_number {$line['line_number']}!";
|
||||
$message = $fieldsString." can't be empty for line_number {$line['line_number']}!";
|
||||
|
||||
// return response($message, 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => $message
|
||||
'status_description' => $message,
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missingLines)) {
|
||||
$message = "Line(s) " . implode(', ', $missingLines) . " not found for Plant '{$data['plant_name']}' and OBD Number: '{$data['obd_number']}'!";
|
||||
if (! empty($missingLines)) {
|
||||
$message = 'Line(s) '.implode(', ', $missingLines)." not found for Plant '{$data['plant_name']}' and OBD Number: '{$data['obd_number']}'!";
|
||||
|
||||
// return response($message, 404)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => $message
|
||||
'status_description' => $message,
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -169,11 +162,11 @@ class ObdController extends Controller
|
||||
$internalDuplicates = [];
|
||||
$bundleChecks = [];
|
||||
|
||||
//Check for duplicates within the request
|
||||
// Check for duplicates within the request
|
||||
foreach ($data['line_numbers'] as $line) {
|
||||
$lineNumber = $line['line_number'];
|
||||
$bundleNumber = trim((string)$line['bundle_number']);
|
||||
$pairKey = $lineNumber . '|' . $bundleNumber;
|
||||
$bundleNumber = trim((string) $line['bundle_number']);
|
||||
$pairKey = $lineNumber.'|'.$bundleNumber;
|
||||
|
||||
if (isset($seenPairs[$pairKey])) {
|
||||
$internalDuplicates[] = "Line Number {$lineNumber} with Bundle Number {$bundleNumber}";
|
||||
@@ -186,7 +179,7 @@ class ObdController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
//Check for duplicates in the database
|
||||
// Check for duplicates in the database
|
||||
|
||||
$bundleNumbers = array_column($bundleChecks, 'bundle_number');
|
||||
$lineNumbers = array_column($bundleChecks, 'line_number');
|
||||
@@ -202,10 +195,10 @@ class ObdController extends Controller
|
||||
$line = $row->line_number;
|
||||
$bundle = $row->bundle_number;
|
||||
|
||||
if (!isset($grouped[$line])) {
|
||||
if (! isset($grouped[$line])) {
|
||||
$grouped[$line] = [];
|
||||
}
|
||||
if ($bundle && !in_array($bundle, $grouped[$line])) {
|
||||
if ($bundle && ! in_array($bundle, $grouped[$line])) {
|
||||
$grouped[$line][] = $bundle;
|
||||
}
|
||||
}
|
||||
@@ -216,85 +209,80 @@ class ObdController extends Controller
|
||||
$dbDuplicates[] = "Line {$line}, has bundle numbers : {$bundlesStr}";
|
||||
}
|
||||
|
||||
//Return all errors if any duplicates found
|
||||
// Return all errors if any duplicates found
|
||||
$allDuplicates = [];
|
||||
if (!empty($internalDuplicates))
|
||||
{
|
||||
$allDuplicates[] = "Duplicate(s) " . implode(', ', $internalDuplicates);
|
||||
if (! empty($internalDuplicates)) {
|
||||
$allDuplicates[] = 'Duplicate(s) '.implode(', ', $internalDuplicates);
|
||||
}
|
||||
if (!empty($dbDuplicates))
|
||||
{
|
||||
$allDuplicates[] = "Already exists in database: " . implode('; ', $dbDuplicates);
|
||||
if (! empty($dbDuplicates)) {
|
||||
$allDuplicates[] = 'Already exists in database: '.implode('; ', $dbDuplicates);
|
||||
}
|
||||
|
||||
if (!empty($allDuplicates)) {
|
||||
if (! empty($allDuplicates)) {
|
||||
// return response(
|
||||
// "Error:" . implode("\n", $allDuplicates),
|
||||
// 400
|
||||
// )->header('Content-Type', 'text/plain');
|
||||
|
||||
$retRes = implode(", and ", $allDuplicates);
|
||||
$retRes = implode(', and ', $allDuplicates);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => $retRes
|
||||
'status_description' => $retRes,
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..
|
||||
// ..
|
||||
$updated = 0;
|
||||
$inserted = 0;
|
||||
$updatedLines = [];
|
||||
$insertedLines = [];
|
||||
$lineTracker = [];
|
||||
|
||||
foreach ($data['line_numbers'] as $line)
|
||||
{
|
||||
foreach ($data['line_numbers'] as $line) {
|
||||
$lineNumber = $line['line_number'];
|
||||
$existing = WeightValidation::where('plant_id', $plantId)
|
||||
->where('obd_number', $obdNumber)
|
||||
->where('line_number', $lineNumber)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('bundle_number')
|
||||
->orWhere('bundle_number', '');
|
||||
})
|
||||
->first();
|
||||
->where('obd_number', $obdNumber)
|
||||
->where('line_number', $lineNumber)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('bundle_number')
|
||||
->orWhere('bundle_number', '');
|
||||
})
|
||||
->first();
|
||||
|
||||
if($existing)
|
||||
{
|
||||
if ($existing) {
|
||||
$existing->update([
|
||||
'vehicle_number' => $line['vehicle_number'] ?? null,
|
||||
'vehicle_number' => $line['vehicle_number'] ?? null,
|
||||
'bundle_number' => $line['bundle_number'] ?? null,
|
||||
'heat_number' => $line['heat_number'] ?? null,
|
||||
'picked_weight' => $line['picked_weight'] ?? null,
|
||||
'scanned_by' => $line['scanned_by'] ?? null,
|
||||
'updated_at' => now(),
|
||||
'scanned_by' => $line['scanned_by'] ?? null,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$updated++;
|
||||
$updatedLines[] = $lineNumber;
|
||||
$lineTracker[$lineNumber] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$original = WeightValidation::where([
|
||||
'plant_id' => $plantId,
|
||||
'obd_number' => $obdNumber,
|
||||
'plant_id' => $plantId,
|
||||
'obd_number' => $obdNumber,
|
||||
'line_number' => $lineNumber,
|
||||
])->orderBy('id')->first();
|
||||
|
||||
WeightValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'obd_number' => $obdNumber,
|
||||
'line_number' => $lineNumber,
|
||||
'item_id' => $original->item_id ?? null,
|
||||
'plant_id' => $plantId,
|
||||
'obd_number' => $obdNumber,
|
||||
'line_number' => $lineNumber,
|
||||
'item_id' => $original->item_id ?? null,
|
||||
'vehicle_number' => $line['vehicle_number'] ?? null,
|
||||
'bundle_number' => $line['bundle_number'] ?? null,
|
||||
'picked_weight' => $line['picked_weight'] ?? null,
|
||||
'scanned_by' => $line['scanned_by'] ?? null,
|
||||
'batch_number' => $original->batch_number ?? null,
|
||||
'heat_number' => $line['heat_number'] ?? null,
|
||||
'obd_weight' => $original->obd_weight ?? null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
'bundle_number' => $line['bundle_number'] ?? null,
|
||||
'picked_weight' => $line['picked_weight'] ?? null,
|
||||
'scanned_by' => $line['scanned_by'] ?? null,
|
||||
'batch_number' => $original->batch_number ?? null,
|
||||
'heat_number' => $line['heat_number'] ?? null,
|
||||
'obd_weight' => $original->obd_weight ?? null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$inserted++;
|
||||
@@ -306,11 +294,11 @@ class ObdController extends Controller
|
||||
$responseMessage = "OBD Number '{$obdNumber}'";
|
||||
|
||||
if ($updated > 0) {
|
||||
$responseMessage .= " updated successfully. Line Numbers: {" . implode(', ', $updatedLines) . "}";
|
||||
$responseMessage .= ' updated successfully. Line Numbers: {'.implode(', ', $updatedLines).'}';
|
||||
}
|
||||
|
||||
if ($inserted > 0) {
|
||||
$responseMessage .= "Inserted successfully. Line Numbers: {" . implode(', ', $insertedLines) . "}";
|
||||
$responseMessage .= 'Inserted successfully. Line Numbers: {'.implode(', ', $insertedLines).'}';
|
||||
}
|
||||
|
||||
// return response($responseMessage, 200)
|
||||
@@ -320,31 +308,28 @@ class ObdController extends Controller
|
||||
'status_description' => $responseMessage,
|
||||
], 200);
|
||||
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
// response("ERROR: Server error", 500)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Store OBD data internal server error : '.$e?->getCode()
|
||||
'status_description' => 'Store OBD data internal server error : '.$e?->getCode(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
//Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
||||
// Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
||||
public function get_test(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
@@ -374,48 +359,41 @@ class ObdController extends Controller
|
||||
// ], 400);
|
||||
// }
|
||||
|
||||
|
||||
$productionOrder = $request->header('production-order');
|
||||
if (empty($productionOrder))
|
||||
{
|
||||
if (empty($productionOrder)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Production order can't be empty!"
|
||||
'status_description' => "Production order can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if(Str::length($productionOrder) < 7 || !is_numeric($productionOrder))
|
||||
{
|
||||
} elseif (Str::length($productionOrder) < 7 || ! is_numeric($productionOrder)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Production order should contain minimum 7 digits numeric values only!"
|
||||
'status_description' => 'Production order should contain minimum 7 digits numeric values only!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$prodOrderExist = ($productionOrder == '1234567' || $productionOrder == '7654321');
|
||||
|
||||
if (!$prodOrderExist)
|
||||
{
|
||||
if (! $prodOrderExist) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Production order not found!"
|
||||
'status_description' => 'Production order not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//return response("Successfully GET request Received", 200)->header('Content-Type', 'text/plain');
|
||||
try {
|
||||
// return response("Successfully GET request Received", 200)->header('Content-Type', 'text/plain');
|
||||
$itemCode = Item::where('code', '123456')->where('plant_id', 1)->first();
|
||||
|
||||
return response()->json([
|
||||
'item_code' => $itemCode->code,
|
||||
'item_description' => $itemCode->description
|
||||
'item_description' => $itemCode->description,
|
||||
], 200);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
//return response("ERROR: GET test data server error", 500)->header('Content-Type', 'text/plain');
|
||||
} catch (\Exception $e) {
|
||||
// return response("ERROR: GET test data server error", 500)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Get test data internal server error : '.$e?->getCode()
|
||||
'status_description' => 'Get test data internal server error : '.$e?->getCode(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
@@ -423,9 +401,9 @@ class ObdController extends Controller
|
||||
public function get_obd(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// if ("Bearer " . $expectedToken != $header_auth)
|
||||
// {
|
||||
@@ -433,88 +411,81 @@ class ObdController extends Controller
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
// }
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$obdNumber = $request->header('obd-number');
|
||||
|
||||
if (empty($plantName))
|
||||
{
|
||||
if (empty($plantName)) {
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Name can't be empty!"
|
||||
'status_description' => "Plant Name can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if(empty($obdNumber))
|
||||
{
|
||||
} elseif (empty($obdNumber)) {
|
||||
// return response("ERROR: OBD Number can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "OBD Number can't be empty!"
|
||||
'status_description' => "OBD Number can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if(Str::length($obdNumber) < 8 || !ctype_alnum($obdNumber))
|
||||
{
|
||||
} elseif (Str::length($obdNumber) < 8 || ! ctype_alnum($obdNumber)) {
|
||||
// return response("ERROR: OBD Number should contain minimum 8 digits: '$obdNumber'", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "OBD number should contain minimum 8 digit alpha-numeric values only!"
|
||||
'status_description' => 'OBD number should contain minimum 8 digit alpha-numeric values only!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Fetch the plant id by name
|
||||
$plantId = Plant::where('name', $plantName)->value('id');
|
||||
|
||||
if (!$plantId) {
|
||||
if (! $plantId) {
|
||||
// return response("ERROR: Plant not found", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant not found!"
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// $records = WeightValidation::where('plant_id', $plantId)
|
||||
// ->where('obd_number', $obdNumber)
|
||||
// ->get();
|
||||
// Fetch and filter records where vehicle_number is empty or null
|
||||
// Fetch and filter records where vehicle_number is empty or null
|
||||
|
||||
$exists = WeightValidation::where('plant_id', $plantId)
|
||||
->where('obd_number', $obdNumber)
|
||||
->exists();
|
||||
$exists = WeightValidation::where('plant_id', $plantId)
|
||||
->where('obd_number', $obdNumber)
|
||||
->exists();
|
||||
|
||||
if (!$exists)
|
||||
{
|
||||
if (! $exists) {
|
||||
// return response("ERROR: OBD number $obdNumber does not exist for plant '$plantName'", 404)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "OBD number $obdNumber does not exist for plant '$plantName'!"
|
||||
'status_description' => "OBD number $obdNumber does not exist for plant '$plantName'!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$records = WeightValidation::where('plant_id', $plantId)
|
||||
->where('obd_number', $obdNumber)
|
||||
->get()
|
||||
->filter(function ($record) {
|
||||
return $record->vehicle_number == '' || $record->vehicle_number == null;
|
||||
});
|
||||
->where('obd_number', $obdNumber)
|
||||
->get()
|
||||
->filter(function ($record) {
|
||||
return $record->vehicle_number == '' || $record->vehicle_number == null;
|
||||
});
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
// return response("SUCCESS: Already scanning process completed for the OBD Number", 200)->header('Content-Type', values: 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => "Already weight validation completed for the OBD Number!"
|
||||
'status_description' => 'Already weight validation completed for the OBD Number!',
|
||||
], 200);
|
||||
}
|
||||
|
||||
@@ -530,18 +501,20 @@ class ObdController extends Controller
|
||||
'OBD_Number' => $obdNumber,
|
||||
'Line_Numbers' => $records->map(function ($item) use ($itemCodes) {
|
||||
$itemInfo = $itemCodes[$item->item_id] ?? null;
|
||||
|
||||
return [
|
||||
'Line' => $item->line_number ?? "",
|
||||
'Material_Code' => $itemInfo->code ?? "",
|
||||
'Material_Description' => $itemInfo->description ?? "",
|
||||
'Batch_Number' => $item->batch_number ?? "",
|
||||
'Line' => $item->line_number ?? '',
|
||||
'Material_Code' => $itemInfo->code ?? '',
|
||||
'Material_Description' => $itemInfo->description ?? '',
|
||||
'Batch_Number' => $item->batch_number ?? '',
|
||||
// 'Heat_Number' => $item->heat_number ?? "",
|
||||
'Actual_Weight' => $item->obd_weight ?? "",
|
||||
'Actual_Weight' => $item->obd_weight ?? '',
|
||||
];
|
||||
})->values()->toArray()
|
||||
]
|
||||
]
|
||||
})->values()->toArray(),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return response()->json($ObdResponseStructure);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@ namespace App\Http\Controllers;
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Illuminate\Http\Request;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class PalletPrintController extends Controller
|
||||
{
|
||||
@@ -20,30 +19,168 @@ class PalletPrintController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function print(Request $request, $pallet, $plant)
|
||||
{
|
||||
|
||||
$customerId = $request->query('customer');
|
||||
|
||||
// $customerName = $request->query('customer_name');
|
||||
|
||||
// $items = WireMasterPacking::with('item')
|
||||
// ->where('plant_id', $plant)
|
||||
// ->where('wire_packing_number', $pallet)
|
||||
// ->get()
|
||||
// ->groupBy('item_id')
|
||||
// ->map(function ($rows) {
|
||||
// $first = $rows->first();
|
||||
|
||||
// return (object) [
|
||||
// 'code' => $first->item->code,
|
||||
// 'description' => $first->item->description,
|
||||
// 'box_count' => $rows->count(),
|
||||
// 'weight' => $rows->sum('weight'),
|
||||
// ];
|
||||
// })
|
||||
// ->values();
|
||||
|
||||
$items = WireMasterPacking::with('item')
|
||||
->where('plant_id', $plant)
|
||||
->where('wire_packing_number', $pallet)
|
||||
->get()
|
||||
->map(function ($row) {
|
||||
return (object) [
|
||||
'code' => $row->item->code,
|
||||
'description' => $row->item->description,
|
||||
'box_count' => 1, // each row = one box
|
||||
'weight' => $row->weight,
|
||||
];
|
||||
});
|
||||
|
||||
$masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('wire_packing_number', $pallet)
|
||||
->value('customer_po_master_id');
|
||||
|
||||
$customer = CustomerPoMaster::find($masterBox);
|
||||
|
||||
$customerCode = $customer->customer_po ?? '';
|
||||
$customerName = $customer->customer_name ?? '';
|
||||
|
||||
// $masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||
// ->where('wire_packing_number', $pallet)
|
||||
// ->distinct('customer_po')
|
||||
// ->count('customer_po');
|
||||
|
||||
// $pallets = WireMasterPacking::where('plant_id', $plant)
|
||||
// ->select('wire_packing_number', 'updated_at')
|
||||
// ->distinct('wire_packing_number')
|
||||
// ->orderBy('wire_packing_number')
|
||||
// ->orderBy('updated_at', 'asc')
|
||||
// ->get()
|
||||
// ->pluck('wire_packing_number')
|
||||
// ->values();
|
||||
|
||||
// $currentPalletNo = $pallets->search($pallet) + 1;
|
||||
|
||||
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||
// // ->where('wire_packing_number', $pallet)
|
||||
// ->distinct()
|
||||
// ->count('customer_po');
|
||||
|
||||
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
|
||||
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('customer_po_master_id', $customerId)
|
||||
->distinct('wire_packing_number')
|
||||
->count('wire_packing_number');
|
||||
|
||||
$completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('customer_po_master_id', $customerId)
|
||||
->select('wire_packing_number')
|
||||
->groupBy('wire_packing_number')
|
||||
->havingRaw(
|
||||
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||
['Completed']
|
||||
)
|
||||
->orderBy('wire_packing_number')
|
||||
->pluck('wire_packing_number')
|
||||
->values();
|
||||
|
||||
$index = $completedPallets->search($pallet);
|
||||
|
||||
$currentPalletNo = ($index != false) ? $index + 1 : 0;
|
||||
|
||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||
|
||||
// $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||
// ->select('wire_packing_number')
|
||||
// ->groupBy('wire_packing_number')
|
||||
// ->havingRaw('COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', ['Completed'])
|
||||
// ->orderBy('wire_packing_number')
|
||||
// ->pluck('wire_packing_number')
|
||||
// ->values();
|
||||
|
||||
// $currentPalletNo = $completedPallets->search($pallet) != false
|
||||
// ? $completedPallets->search($pallet) + 1
|
||||
// : 0;
|
||||
|
||||
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
|
||||
$grossWeight = $items->sum('weight');
|
||||
$widthPt = 85 * 2.83465; // 85mm → points
|
||||
$heightPt = 100 * 2.83465; // 100mm → points
|
||||
|
||||
$plantName = Plant::where('id', $plant)->value('name');
|
||||
|
||||
$plantAddress = Plant::where('id', $plant)->value('address');
|
||||
|
||||
$pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||
'product' => 'Submersible Winding Wire',
|
||||
'plantName' => $plantName,
|
||||
'plantAddress' => $plantAddress,
|
||||
'monthYear' => now()->format('M-y'),
|
||||
'branch' => '',
|
||||
'customerCode' => $customerCode,
|
||||
'customerName' => $customerName,
|
||||
'masterBox' => $boxLabel,
|
||||
'items' => $items,
|
||||
'grossWeight' => $grossWeight,
|
||||
'netWeight' => $grossWeight - 3.05,
|
||||
'pallet' => $pallet,
|
||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
|
||||
return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||
// $pdfPath = storage_path("app/public/Pallet-{$pallet}.pdf");
|
||||
// $pdf->save($pdfPath);
|
||||
|
||||
// $printerName = 'Tsc';
|
||||
// $output = [];
|
||||
// $returnVar = 0;
|
||||
|
||||
// exec("lp -d {$printerName} " . escapeshellarg($pdfPath), $output, $returnVar);
|
||||
|
||||
// if ($returnVar == 0) {
|
||||
// return response()->json([
|
||||
// 'status' => 'success',
|
||||
// 'message' => "PDF sent to printer $printerName successfully."
|
||||
// ]);
|
||||
// } else {
|
||||
// return response()->json([
|
||||
// 'status' => 'error',
|
||||
// 'message' => "Failed to send PDF to printer $printerName.",
|
||||
// 'output' => $output,
|
||||
// 'code' => $returnVar
|
||||
// ], 500);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
// public function print(Request $request, $pallet, $plant)
|
||||
// {
|
||||
|
||||
// $customerId = $request->query('customer');
|
||||
|
||||
// // $customerName = $request->query('customer_name');
|
||||
|
||||
// // $items = WireMasterPacking::with('item')
|
||||
// // ->where('plant_id', $plant)
|
||||
// // ->where('wire_packing_number', $pallet)
|
||||
// // ->get()
|
||||
// // ->groupBy('item_id')
|
||||
// // ->map(function ($rows) {
|
||||
// // $first = $rows->first();
|
||||
|
||||
// // return (object) [
|
||||
// // 'code' => $first->item->code,
|
||||
// // 'description' => $first->item->description,
|
||||
// // 'box_count' => $rows->count(),
|
||||
// // 'weight' => $rows->sum('weight'),
|
||||
// // ];
|
||||
// // })
|
||||
// // ->values();
|
||||
|
||||
// $items = WireMasterPacking::with('item')
|
||||
// ->where('plant_id', $plant)
|
||||
// ->where('wire_packing_number', $pallet)
|
||||
@@ -66,29 +203,6 @@ class PalletPrintController extends Controller
|
||||
// $customerCode = $customer->customer_po ?? '';
|
||||
// $customerName = $customer->customer_name ?? '';
|
||||
|
||||
// // $masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||
// // ->where('wire_packing_number', $pallet)
|
||||
// // ->distinct('customer_po')
|
||||
// // ->count('customer_po');
|
||||
|
||||
// // $pallets = WireMasterPacking::where('plant_id', $plant)
|
||||
// // ->select('wire_packing_number', 'updated_at')
|
||||
// // ->distinct('wire_packing_number')
|
||||
// // ->orderBy('wire_packing_number')
|
||||
// // ->orderBy('updated_at', 'asc')
|
||||
// // ->get()
|
||||
// // ->pluck('wire_packing_number')
|
||||
// // ->values();
|
||||
|
||||
// // $currentPalletNo = $pallets->search($pallet) + 1;
|
||||
|
||||
// // $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||
// // // ->where('wire_packing_number', $pallet)
|
||||
// // ->distinct()
|
||||
// // ->count('customer_po');
|
||||
|
||||
// // $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
|
||||
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||
// ->where('customer_po_master_id', $customerId)
|
||||
// ->distinct('wire_packing_number')
|
||||
@@ -106,7 +220,6 @@ class PalletPrintController extends Controller
|
||||
// ->pluck('wire_packing_number')
|
||||
// ->values();
|
||||
|
||||
|
||||
// $index = $completedPallets->search($pallet);
|
||||
|
||||
// $currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
@@ -135,140 +248,43 @@ class PalletPrintController extends Controller
|
||||
|
||||
// $plantAddress = Plant::where('id', $plant)->value('address');
|
||||
|
||||
// $pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||
// 'product' => 'Submersible Winding Wire',
|
||||
// 'plantName' => $plantName,
|
||||
// 'plantAddress' => $plantAddress,
|
||||
// 'monthYear' => now()->format('M-y'),
|
||||
// 'branch' => '',
|
||||
// 'customerCode' => $customerCode,
|
||||
// 'customerName' => $customerName,
|
||||
// 'masterBox' => $boxLabel,
|
||||
// 'items' => $items,
|
||||
// 'grossWeight' => $grossWeight,
|
||||
// 'netWeight' => $grossWeight - 3.05,
|
||||
// $qrBase64 = $this->generateQrDataUri($pallet);
|
||||
|
||||
// $mpdf = new Mpdf([
|
||||
// 'format' => [85, 100],
|
||||
// 'margin_left' => 0,
|
||||
// 'margin_right' => 0,
|
||||
// 'margin_top' => 0,
|
||||
// 'margin_bottom' => 0,
|
||||
// 'tempDir' => '/var/www/tmp/mpdf'
|
||||
// ]);
|
||||
|
||||
// $html = view('pdf.wire-pallet', [
|
||||
// 'product' => 'Submersible Winding Wire',
|
||||
// 'plantName' => $plantName,
|
||||
// 'plantAddress' => $plantAddress,
|
||||
// 'monthYear' => now()->format('M-y'),
|
||||
// 'customerCode' => $customerCode,
|
||||
// 'customerName' => $customerName,
|
||||
// 'masterBox' => $pallet,
|
||||
// 'items' => $items,
|
||||
// 'grossWeight' => $grossWeight,
|
||||
// 'netWeight' => $grossWeight - 3.05,
|
||||
// 'pallet' => $pallet,
|
||||
// 'qrHtml' => '<barcode code="' . $pallet . '" type="QRCODE,H" class="barcode" />'
|
||||
// ])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
// 'qrBase64' => $qrBase64,
|
||||
// ])->render();
|
||||
|
||||
// return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||
// // $pdfPath = storage_path("app/public/Pallet-{$pallet}.pdf");
|
||||
// // $pdf->save($pdfPath);
|
||||
|
||||
// // $printerName = 'Tsc';
|
||||
// // $output = [];
|
||||
// // $returnVar = 0;
|
||||
|
||||
// // exec("lp -d {$printerName} " . escapeshellarg($pdfPath), $output, $returnVar);
|
||||
|
||||
// // if ($returnVar == 0) {
|
||||
// // return response()->json([
|
||||
// // 'status' => 'success',
|
||||
// // 'message' => "PDF sent to printer $printerName successfully."
|
||||
// // ]);
|
||||
// // } else {
|
||||
// // return response()->json([
|
||||
// // 'status' => 'error',
|
||||
// // 'message' => "Failed to send PDF to printer $printerName.",
|
||||
// // 'output' => $output,
|
||||
// // 'code' => $returnVar
|
||||
// // ], 500);
|
||||
// // }
|
||||
// $mpdf->WriteHTML($html);
|
||||
// return $mpdf->Output("Pallet-{$pallet}.pdf", 'I'); // 'I' = inline view in browser
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
|
||||
public function print(Request $request, $pallet, $plant)
|
||||
{
|
||||
$customerId = $request->query('customer');
|
||||
|
||||
// Fetch items
|
||||
$items = WireMasterPacking::with('item')
|
||||
->where('plant_id', $plant)
|
||||
->where('wire_packing_number', $pallet)
|
||||
->get()
|
||||
->map(function ($row) {
|
||||
return (object) [
|
||||
'code' => $row->item->code,
|
||||
'description' => $row->item->description,
|
||||
'box_count' => 1,
|
||||
'weight' => $row->weight,
|
||||
];
|
||||
});
|
||||
|
||||
// Fetch master box & customer info
|
||||
$masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('wire_packing_number', $pallet)
|
||||
->value('customer_po_master_id');
|
||||
|
||||
$customer = CustomerPoMaster::find($masterBox);
|
||||
$customerCode = $customer->customer_po ?? '';
|
||||
$customerName = $customer->customer_name ?? '';
|
||||
|
||||
// Calculate total boxes & current pallet number
|
||||
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('customer_po_master_id', $customerId)
|
||||
->distinct('wire_packing_number')
|
||||
->count('wire_packing_number');
|
||||
|
||||
$completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||
->where('customer_po_master_id', $customerId)
|
||||
->select('wire_packing_number')
|
||||
->groupBy('wire_packing_number')
|
||||
->havingRaw(
|
||||
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||
['Completed']
|
||||
)
|
||||
->orderBy('wire_packing_number')
|
||||
->pluck('wire_packing_number')
|
||||
->values();
|
||||
|
||||
$index = $completedPallets->search($pallet);
|
||||
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
$boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||
|
||||
// Calculate gross weight
|
||||
$grossWeight = $items->sum('weight');
|
||||
|
||||
// Page dimensions in points for DomPDF
|
||||
$widthPt = 85 * 2.83465; // 85mm
|
||||
$heightPt = 100 * 2.83465; // 100mm
|
||||
|
||||
// Plant info
|
||||
$plantName = Plant::where('id', $plant)->value('name');
|
||||
$plantAddress = Plant::where('id', $plant)->value('address');
|
||||
|
||||
// Generate QR code using GD (no Imagick required)
|
||||
$qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||
QrCode::format('png')
|
||||
->size(120) // ~12mm
|
||||
->margin(0)
|
||||
->errorCorrection('H')
|
||||
->generate($pallet)
|
||||
);
|
||||
|
||||
// Load Blade view with data
|
||||
$pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||
'product' => 'Submersible Winding Wire',
|
||||
'plantName' => $plantName,
|
||||
'plantAddress' => $plantAddress,
|
||||
'monthYear' => now()->format('M-y'),
|
||||
'branch' => '',
|
||||
'customerCode' => $customerCode,
|
||||
'customerName' => $customerName,
|
||||
'masterBox' => $boxLabel,
|
||||
'items' => $items,
|
||||
'grossWeight' => $grossWeight,
|
||||
'netWeight' => $grossWeight - 3.05,
|
||||
'pallet' => $pallet,
|
||||
'qrBase64' => $qrBase64
|
||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
|
||||
return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||
}
|
||||
// private function generateQrDataUri(string $data): string
|
||||
// {
|
||||
// $qr = new \Mpdf\QrCode\QrCode($data, 'H');
|
||||
// $output = new \Mpdf\QrCode\Output\Png();
|
||||
// $pngData = $output->output($qr, 80, [255, 255, 255], [0, 0, 0]);
|
||||
// return 'data:image/png;base64,' . base64_encode($pngData);
|
||||
// }
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
@@ -627,7 +627,7 @@ class PdfController extends Controller
|
||||
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
||||
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
||||
'coil_number' => $currentCoil,
|
||||
'order_quantity' => (string) $lastRecord->order_quantity ?? '0.000',
|
||||
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
||||
'ok_quantity' => (string) $okQty ?? '0',
|
||||
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
||||
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
||||
@@ -686,7 +686,7 @@ class PdfController extends Controller
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$lineName = $data['line_name'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
$updatedOrderQty = $data['order_quantity'] ?? 0;
|
||||
$receivedQty = $data['received_quantity'] ?? 0;
|
||||
$scrapQty = $data['scrap_quantity'] ?? 0;
|
||||
$sfgNo = $data['sfg_number'] ?? '';
|
||||
@@ -728,6 +728,17 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($scrapQty == null || $scrapQty == '') {
|
||||
$scrapQty = 0;
|
||||
}
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
|
||||
if (! $line) {
|
||||
@@ -861,7 +872,8 @@ class PdfController extends Controller
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($orderQty == 0) {
|
||||
$orderQty = 0;
|
||||
if ($updatedOrderQty == 0) {
|
||||
$orderExist = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
@@ -869,6 +881,7 @@ class PdfController extends Controller
|
||||
|
||||
if ($orderExist) {
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$updatedOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -882,9 +895,11 @@ class PdfController extends Controller
|
||||
// ->value('order_quantity') ?? 0;
|
||||
|
||||
if ($orderExist) {
|
||||
$existOrderQty = $orderExist->order_quantity ?? 0;
|
||||
// $existOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$existUpdatedOrdQuan = $orderExist->updated_order_quantity ?? 0;
|
||||
|
||||
if ($existOrderQty != $orderQty) {
|
||||
if ($existUpdatedOrdQuan != $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'",
|
||||
@@ -895,20 +910,6 @@ class PdfController extends Controller
|
||||
|
||||
$total = $alreadyReceived + $receivedQty;
|
||||
|
||||
if ($total > $orderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($rework != 'Yes' && $rework != 'No') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -949,6 +950,13 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
@@ -964,6 +972,7 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -994,6 +1003,21 @@ class PdfController extends Controller
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
@@ -1007,6 +1031,19 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil->received_quantity < $receivedQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework received quantity should not exceed exist received quantity! Exist Received Qty = '{$existPrevCoil->received_quantity}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
@@ -1055,6 +1092,28 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
@@ -1063,6 +1122,7 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
|
||||
@@ -77,14 +77,6 @@ class ProductionStickerReprintController extends Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
// if ($item->category == 'Submersible Motor')
|
||||
// {
|
||||
// $copies = 1;
|
||||
// }
|
||||
// elseif ($item->category == 'Submersible Pump')
|
||||
// {
|
||||
// $copies = 1;
|
||||
// }
|
||||
$copies = 1;
|
||||
|
||||
if ($serialNumberRaw) {
|
||||
|
||||
@@ -9,14 +9,7 @@ use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TestingPanelReading;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use DB;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Mpdf;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\QRCode\Output\QROutputInterface;
|
||||
use Mpdf\QrCode\Output;
|
||||
use Mpdf\QrCode\QrCode;
|
||||
use Str;
|
||||
|
||||
class TestingPanelController extends Controller
|
||||
@@ -35,173 +28,151 @@ class TestingPanelController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '')
|
||||
{
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '') {
|
||||
// return response("ERROR: Please provide a valid plant code.", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['plant_code']) < 4 || !is_numeric($data['plant_code']) || !preg_match('/^[1-9]\d{3,}$/', $data['plant_code']))//!ctype_digit($data['plant_code'])
|
||||
{
|
||||
} elseif (Str::length($data['plant_code']) < 4 || ! is_numeric($data['plant_code']) || ! preg_match('/^[1-9]\d{3,}$/', $data['plant_code'])) {// !ctype_digit($data['plant_code'])
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (!$plant) {
|
||||
//return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!'
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
if ($data['line_name'] == null || $data['line_name'] == '')
|
||||
{
|
||||
if ($data['line_name'] == null || $data['line_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!"
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['line_name']) < 0)
|
||||
{
|
||||
} elseif (Str::length($data['line_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid group work center found!"
|
||||
'status_description' => 'Invalid group work center found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
if (! $gWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Group work center not found!'
|
||||
'status_description' => 'Group work center not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
//return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
if (! $gWorkCenter) {
|
||||
// return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!"
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '')
|
||||
{
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!"
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['machine_name']) < 0)
|
||||
{
|
||||
} elseif (Str::length($data['machine_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid work center found!"
|
||||
'status_description' => 'Invalid work center found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
if (!$machine)
|
||||
{
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Work center not found!'
|
||||
'status_description' => 'Work center not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
if (!$machine)
|
||||
{
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!"
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (!$machine)
|
||||
{
|
||||
if (! $machine) {
|
||||
// return response("Machine not found for the specified line : {$data['line_name']}", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!"
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!",
|
||||
], 400);
|
||||
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (!$machine) {
|
||||
if (! $machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!"
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$lineId = $machine->line_id;
|
||||
$machineId = $machine->id;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$insertedSerials = [];
|
||||
$missedItemCodes = [];
|
||||
$duplicateItemCodes = [];
|
||||
$existSnoCount = [];
|
||||
|
||||
if (!empty($data['item_codes']) && is_array($data['item_codes']))
|
||||
{
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
if (! empty($data['item_codes']) && is_array($data['item_codes'])) {
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
$code = $item['item_code'] ?? null;
|
||||
|
||||
// Check if item_code is present
|
||||
if ($code == '' || $code == null)
|
||||
{
|
||||
if ($code == '' || $code == null) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code can't be empty!"
|
||||
'status_description' => "Item code can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Collect duplicates
|
||||
if (isset($itemCodeCounts[$code]))
|
||||
{
|
||||
if (isset($itemCodeCounts[$code])) {
|
||||
$itemCodeCounts[$code]++;
|
||||
// Only add to duplicates array once
|
||||
if ($itemCodeCounts[$code] == 2) {
|
||||
$duplicateItemCodes[] = $code;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$itemCodeCounts[$code] = 1;
|
||||
}
|
||||
|
||||
@@ -209,43 +180,41 @@ class TestingPanelController extends Controller
|
||||
$query->where('code', $item['item_code']);
|
||||
})->where('plant_id', $plantId)->first();
|
||||
|
||||
if (!$motorTestingMaster) {
|
||||
if (! $motorTestingMaster) {
|
||||
$missedItemCodes[] = $item['item_code'];
|
||||
}
|
||||
|
||||
if (!empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
if (! empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
$existSnoCount[] = $serial['serial_number'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any duplicates found, return error
|
||||
if (!empty($duplicateItemCodes)) {
|
||||
if (! empty($duplicateItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Duplicate item codes found in request: ' . implode(', ', $duplicateItemCodes)
|
||||
'status_description' => 'Duplicate item codes found in request: '.implode(', ', $duplicateItemCodes),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$uniqueInvalidCodes = array_unique($missedItemCodes);
|
||||
|
||||
if (!empty($uniqueInvalidCodes)) {
|
||||
if (! empty($uniqueInvalidCodes)) {
|
||||
|
||||
// return response("Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in motor testing master for the specified plant {$plant->name}", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
// return response("Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in motor testing master for the specified plant {$plant->name}", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in master for the specified plant : '{$plant->name}'!"
|
||||
'status_description' => 'Item codes : '.implode(', ', $uniqueInvalidCodes)." not found in master for the specified plant : '{$plant->name}'!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$insertedSnoCount = [];
|
||||
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::whereHas('item', callback: function ($query) use ($item) {
|
||||
$query->where('code', $item['item_code']);
|
||||
@@ -253,18 +222,16 @@ class TestingPanelController extends Controller
|
||||
|
||||
$motorTestingMasterId = $motorTestingMaster->id;
|
||||
|
||||
if (!empty($item['serial_numbers']) && is_array($item['serial_numbers']))
|
||||
{
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
//For update_count calculation
|
||||
if (! empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
// For update_count calculation
|
||||
$updateCount = [
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id' => $motorTestingMasterId,
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id' => $motorTestingMasterId,
|
||||
'serial_number' => $serial['serial_number'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
];
|
||||
|
||||
// // Find the current max update_count for this composite key //updated_at
|
||||
@@ -277,64 +244,64 @@ class TestingPanelController extends Controller
|
||||
$maxLength = TestingPanelReading::where($updateCount)->selectRaw('MAX(LENGTH(update_count)) as max_length')->value('max_length');
|
||||
|
||||
// Then, get all records with that length
|
||||
$lastUpdateCount = TestingPanelReading::where($updateCount)->whereRaw('LENGTH(update_count) = ?', [$maxLength])->orderByDesc('update_count')->select('update_count')->first();//->get();
|
||||
$lastUpdateCount = TestingPanelReading::where($updateCount)->whereRaw('LENGTH(update_count) = ?', [$maxLength])->orderByDesc('update_count')->select('update_count')->first(); // ->get();
|
||||
|
||||
$newUpdateCount = ($lastUpdateCount == null || $lastUpdateCount == '') ? 0 : (int)$lastUpdateCount?->update_count + 1;//$maxUpdateCount?->update_count
|
||||
$newUpdateCount = ($lastUpdateCount == null || $lastUpdateCount == '') ? 0 : (int) $lastUpdateCount?->update_count + 1; // $maxUpdateCount?->update_count
|
||||
|
||||
$updateCountString = (string)$newUpdateCount;
|
||||
$updateCountString = (string) $newUpdateCount;
|
||||
|
||||
$row = [
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id'=> $motorTestingMasterId,
|
||||
'serial_number' => $serial['serial_number'] ?? null,
|
||||
'winded_serial_number' => $serial['winded_serial_number'] ?? null,
|
||||
'output' => $serial['output'] ?? null,
|
||||
'before_fr_volt' => $serial['before_fr_volt'] ?? null,
|
||||
'before_fr_cur' => $serial['before_fr_cur'] ?? null,
|
||||
'before_fr_pow' => $serial['before_fr_pow'] ?? null,
|
||||
'before_fr_res_ry' => $serial['before_fr_res_ry'] ?? null,
|
||||
'before_fr_res_yb' => $serial['before_fr_res_yb'] ?? null,
|
||||
'before_fr_res_br' => $serial['before_fr_res_br'] ?? null,
|
||||
'before_fr_ir' => $serial['before_fr_ir'] ?? null,
|
||||
'before_fr_ir_r' => $serial['before_fr_ir_r'] ?? null,
|
||||
'before_fr_ir_y' => $serial['before_fr_ir_y'] ?? null,
|
||||
'before_fr_ir_b' => $serial['before_fr_ir_b'] ?? null,
|
||||
'before_fr_freq' => $serial['before_fr_freq'] ?? null,
|
||||
'before_fr_speed' => $serial['before_fr_speed'] ?? null,
|
||||
'after_fr_vol' => $serial['after_fr_vol'] ?? null,
|
||||
'after_fr_cur' => $serial['after_fr_cur'] ?? null,
|
||||
'after_fr_pow' => $serial['after_fr_pow'] ?? null,
|
||||
'after_fr_ir_hot' => $serial['after_fr_ir_hot'] ?? null,
|
||||
'after_fr_ir_hot_r' => $serial['after_fr_ir_hot_r'] ?? null,
|
||||
'after_fr_ir_hot_y' => $serial['after_fr_ir_hot_y'] ?? null,
|
||||
'after_fr_ir_hot_b' => $serial['after_fr_ir_hot_b'] ?? null,
|
||||
'after_fr_ir_cool' => $serial['after_fr_ir_cool'] ?? null,
|
||||
'after_fr_ir_cool_r' => $serial['after_fr_ir_cool_r'] ?? null,
|
||||
'after_fr_ir_cool_y' => $serial['after_fr_ir_cool_y'] ?? null,
|
||||
'after_fr_ir_cool_b' => $serial['after_fr_ir_cool_b'] ?? null,
|
||||
'after_fr_freq' => $serial['after_fr_freq'] ?? null,
|
||||
'after_fr_speed' => $serial['after_fr_speed'] ?? null,
|
||||
'after_fr_leak_cur' => $serial['after_fr_leak_cur'] ?? null,
|
||||
'locked_rt_volt' => $serial['locked_rt_volt'] ?? null,
|
||||
'locked_rt_cur' => $serial['locked_rt_cur'] ?? null,
|
||||
'locked_rt_pow' => $serial['locked_rt_pow'] ?? null,
|
||||
'no_load_pickup_volt' => $serial['no_load_pickup_volt'] ?? null,
|
||||
'room_temperature' => $serial['room_temperature'] ?? null,
|
||||
'hv_test' => $serial['hv_test'] ?? null,
|
||||
'batch_number' => $serial['batch_number'] ?? null,
|
||||
'batch_count' => $serial['batch_count'] ?? 0,
|
||||
'result' => $serial['result'] ?? null,
|
||||
'remark' => $serial['remark'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'output_flag' => $serial['output_flag'] ?? 0,
|
||||
'tested_by' => $serial['tested_by'] ?? null,
|
||||
'updated_by' => $serial['updated_by'] ?? null,
|
||||
'created_at' => $serial['created_at'] ?? null,
|
||||
'updated_at' => $serial['updated_at'] ?? $serial['created_at'],
|
||||
'scanned_at' => $serial['scanned_at'] ?? null,
|
||||
'update_count' => $updateCountString,
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id' => $motorTestingMasterId,
|
||||
'serial_number' => $serial['serial_number'] ?? null,
|
||||
'winded_serial_number' => $serial['winded_serial_number'] ?? null,
|
||||
'output' => $serial['output'] ?? null,
|
||||
'before_fr_volt' => $serial['before_fr_volt'] ?? null,
|
||||
'before_fr_cur' => $serial['before_fr_cur'] ?? null,
|
||||
'before_fr_pow' => $serial['before_fr_pow'] ?? null,
|
||||
'before_fr_res_ry' => $serial['before_fr_res_ry'] ?? null,
|
||||
'before_fr_res_yb' => $serial['before_fr_res_yb'] ?? null,
|
||||
'before_fr_res_br' => $serial['before_fr_res_br'] ?? null,
|
||||
'before_fr_ir' => $serial['before_fr_ir'] ?? null,
|
||||
'before_fr_ir_r' => $serial['before_fr_ir_r'] ?? null,
|
||||
'before_fr_ir_y' => $serial['before_fr_ir_y'] ?? null,
|
||||
'before_fr_ir_b' => $serial['before_fr_ir_b'] ?? null,
|
||||
'before_fr_freq' => $serial['before_fr_freq'] ?? null,
|
||||
'before_fr_speed' => $serial['before_fr_speed'] ?? null,
|
||||
'after_fr_vol' => $serial['after_fr_vol'] ?? null,
|
||||
'after_fr_cur' => $serial['after_fr_cur'] ?? null,
|
||||
'after_fr_pow' => $serial['after_fr_pow'] ?? null,
|
||||
'after_fr_ir_hot' => $serial['after_fr_ir_hot'] ?? null,
|
||||
'after_fr_ir_hot_r' => $serial['after_fr_ir_hot_r'] ?? null,
|
||||
'after_fr_ir_hot_y' => $serial['after_fr_ir_hot_y'] ?? null,
|
||||
'after_fr_ir_hot_b' => $serial['after_fr_ir_hot_b'] ?? null,
|
||||
'after_fr_ir_cool' => $serial['after_fr_ir_cool'] ?? null,
|
||||
'after_fr_ir_cool_r' => $serial['after_fr_ir_cool_r'] ?? null,
|
||||
'after_fr_ir_cool_y' => $serial['after_fr_ir_cool_y'] ?? null,
|
||||
'after_fr_ir_cool_b' => $serial['after_fr_ir_cool_b'] ?? null,
|
||||
'after_fr_freq' => $serial['after_fr_freq'] ?? null,
|
||||
'after_fr_speed' => $serial['after_fr_speed'] ?? null,
|
||||
'after_fr_leak_cur' => $serial['after_fr_leak_cur'] ?? null,
|
||||
'locked_rt_volt' => $serial['locked_rt_volt'] ?? null,
|
||||
'locked_rt_cur' => $serial['locked_rt_cur'] ?? null,
|
||||
'locked_rt_pow' => $serial['locked_rt_pow'] ?? null,
|
||||
'no_load_pickup_volt' => $serial['no_load_pickup_volt'] ?? null,
|
||||
'room_temperature' => $serial['room_temperature'] ?? null,
|
||||
'hv_test' => $serial['hv_test'] ?? null,
|
||||
'batch_number' => $serial['batch_number'] ?? null,
|
||||
'batch_count' => $serial['batch_count'] ?? 0,
|
||||
'result' => $serial['result'] ?? null,
|
||||
'remark' => $serial['remark'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'output_flag' => $serial['output_flag'] ?? 0,
|
||||
'tested_by' => $serial['tested_by'] ?? null,
|
||||
'updated_by' => $serial['updated_by'] ?? null,
|
||||
'created_at' => $serial['created_at'] ?? null,
|
||||
'updated_at' => $serial['updated_at'] ?? $serial['created_at'],
|
||||
'scanned_at' => $serial['scanned_at'] ?? null,
|
||||
'update_count' => $updateCountString,
|
||||
];
|
||||
|
||||
// Insert the new record
|
||||
@@ -346,32 +313,27 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($insertedSerials))
|
||||
{
|
||||
if(count($existSnoCount) == count($insertedSnoCount))
|
||||
{
|
||||
if (! empty($insertedSerials)) {
|
||||
if (count($existSnoCount) == count($insertedSnoCount)) {
|
||||
// $messages[] = "Inserted serial numbers are: " . implode(', ', $insertedSerials);
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Inserted serial numbers are: ' . implode(', ', $insertedSerials)
|
||||
'status_description' => 'Inserted serial numbers are: '.implode(', ', $insertedSerials),
|
||||
], 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
$missingSno = array_diff($existSnoCount,$insertedSnoCount);
|
||||
} else {
|
||||
$missingSno = array_diff($existSnoCount, $insertedSnoCount);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Missed serial numbers are: " . implode(', ', $missingSno)
|
||||
'status_description' => 'Missed serial numbers are: '.implode(', ', $missingSno),
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
// return response($e->getMessage(), 500)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Store testing panel readings internal server error : '.$e?->getCode()
|
||||
'status_description' => 'Store testing panel readings internal server error : '.$e?->getCode(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
@@ -382,16 +344,15 @@ class TestingPanelController extends Controller
|
||||
public function get_motor_master(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
//$data = $request->all();
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
@@ -399,45 +360,46 @@ class TestingPanelController extends Controller
|
||||
$itemCode = $request->header('item-code');
|
||||
// $description = $item ? $item->description : '';
|
||||
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
|
||||
{
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
}
|
||||
else if($itemCode == null || $itemCode == '')
|
||||
{
|
||||
// return response("ERROR: OBD Number can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
} elseif ($itemCode == null || $itemCode == '' || ! $itemCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if(Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
|
||||
{
|
||||
'status_description' => "Item code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($itemCode) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid item code found!"
|
||||
], 400);
|
||||
'status_description' => "Item code '{$itemCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (!$plant) {
|
||||
if (! $plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant not found!"
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -445,72 +407,79 @@ class TestingPanelController extends Controller
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (!$item)
|
||||
{
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table!"
|
||||
'status_description' => 'Item code not found in item table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||
|
||||
if (!$item)
|
||||
{
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
|
||||
'status_description' => "Item code not found in item table for the plant : '$plant->name'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Get description or empty string if not found
|
||||
$itemId = $item->id;
|
||||
|
||||
$description = $item ? $item->description : '';
|
||||
|
||||
$category = $item ? $item->category : '';
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
$motorTestingMaster = MotorTestingMaster::where('item_id', $itemId)->first();
|
||||
|
||||
if (!$motorTestingMaster)
|
||||
{
|
||||
if (! $motorTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in motor testing master table for the plant : '$plant->name'!"
|
||||
'status_description' => 'Item code not found in motor testing master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $motorTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code not found in motor testing master table for the plant : '$plant->name'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$output = [
|
||||
"mot_subassembly_code" => $motorTestingMaster->subassembly_code ?? "",
|
||||
"mot_model_name" => $description,
|
||||
"mot_non_isi_model" => $motorTestingMaster->isi_model ? "0" :"1",
|
||||
"mot_phase" => $motorTestingMaster->phase ?? "",
|
||||
"mot_hp" => $motorTestingMaster->hp ?? "",
|
||||
"mot_kw" => $motorTestingMaster->kw ?? "",
|
||||
"mot_volt" => $motorTestingMaster->volt ?? "",
|
||||
"mot_cur" => $motorTestingMaster->current ?? "",
|
||||
"mot_rpm" => $motorTestingMaster->rpm ?? "",
|
||||
"mot_rate_torque_kg" => $motorTestingMaster->torque ?? "",
|
||||
"mot_freq" => $motorTestingMaster->frequency ?? "",
|
||||
"mot_conn" => $motorTestingMaster->connection ?? "",
|
||||
"mot_ins_res_limit" => $motorTestingMaster->ins_res_limit ?? "",
|
||||
"mot_ins_res_type" => $motorTestingMaster->ins_res_type ?? "",
|
||||
"mot_category" => $category,
|
||||
"mot_routine_test_time" => $motorTestingMaster->routine_test_time ?? "",
|
||||
"mot_res_ry_ll" => $motorTestingMaster->res_ry_ll ?? "",
|
||||
"mot_res_ry_ul" => $motorTestingMaster->res_ry_ul ?? "",
|
||||
"mot_res_yb_ll" => $motorTestingMaster->res_yb_ll ?? "",
|
||||
"mot_res_yb_ul" => $motorTestingMaster->res_yb_ul ?? "",
|
||||
"mot_res_br_ll" => $motorTestingMaster->res_br_ll ?? "",
|
||||
"mot_res_br_ul" => $motorTestingMaster->res_br_ul ?? "",
|
||||
"mot_lock_volt_limit" => $motorTestingMaster->lock_volt_limit ?? "",
|
||||
"mot_leak_cur_limit" => $motorTestingMaster->leak_cur_limit ?? "",
|
||||
"mot_lock_cur_ll" => $motorTestingMaster->lock_cur_ll ?? "",
|
||||
"mot_lock_cur_ul" => $motorTestingMaster->lock_cur_ul ?? "",
|
||||
"mot_noload_cur_ll" => $motorTestingMaster->noload_cur_ll ?? "",
|
||||
"mot_noload_cur_ul" => $motorTestingMaster->noload_cur_ul ?? "",
|
||||
"mot_noload_pow_ll" => $motorTestingMaster->noload_pow_ll ?? "",
|
||||
"mot_noload_pow_ul" => $motorTestingMaster->noload_pow_ul ?? "",
|
||||
"mot_noload_spd_ll" => $motorTestingMaster->noload_spd_ll ?? "",
|
||||
"mot_noload_spd_ul" => $motorTestingMaster->noload_spd_ul ?? ""
|
||||
'mot_subassembly_code' => $motorTestingMaster->subassembly_code ?? '',
|
||||
'mot_model_name' => ($itemCode == '123456') ? 'SAMPLE TYPE' : $description,
|
||||
'mot_non_isi_model' => $motorTestingMaster->isi_model ? '0' : '1',
|
||||
'mot_phase' => $motorTestingMaster->phase ?? '',
|
||||
'mot_hp' => $motorTestingMaster->hp ?? '',
|
||||
'mot_kw' => $motorTestingMaster->kw ?? '',
|
||||
'mot_volt' => $motorTestingMaster->volt ?? '',
|
||||
'mot_cur' => $motorTestingMaster->current ?? '',
|
||||
'mot_rpm' => $motorTestingMaster->rpm ?? '',
|
||||
'mot_rate_torque_kg' => $motorTestingMaster->torque ?? '',
|
||||
'mot_freq' => $motorTestingMaster->frequency ?? '',
|
||||
'mot_conn' => $motorTestingMaster->connection ?? '',
|
||||
'mot_ins_res_limit' => $motorTestingMaster->ins_res_limit ?? '',
|
||||
'mot_ins_res_type' => $motorTestingMaster->ins_res_type ?? '',
|
||||
'mot_category' => $category,
|
||||
'mot_routine_test_time' => $motorTestingMaster->routine_test_time ?? '',
|
||||
'mot_res_ry_ll' => $motorTestingMaster->res_ry_ll ?? '',
|
||||
'mot_res_ry_ul' => $motorTestingMaster->res_ry_ul ?? '',
|
||||
'mot_res_yb_ll' => $motorTestingMaster->res_yb_ll ?? '',
|
||||
'mot_res_yb_ul' => $motorTestingMaster->res_yb_ul ?? '',
|
||||
'mot_res_br_ll' => $motorTestingMaster->res_br_ll ?? '',
|
||||
'mot_res_br_ul' => $motorTestingMaster->res_br_ul ?? '',
|
||||
'mot_lock_volt_limit' => $motorTestingMaster->lock_volt_limit ?? '',
|
||||
'mot_leak_cur_limit' => $motorTestingMaster->leak_cur_limit ?? '',
|
||||
'mot_lock_cur_ll' => $motorTestingMaster->lock_cur_ll ?? '',
|
||||
'mot_lock_cur_ul' => $motorTestingMaster->lock_cur_ul ?? '',
|
||||
'mot_noload_cur_ll' => $motorTestingMaster->noload_cur_ll ?? '',
|
||||
'mot_noload_cur_ul' => $motorTestingMaster->noload_cur_ul ?? '',
|
||||
'mot_noload_pow_ll' => $motorTestingMaster->noload_pow_ll ?? '',
|
||||
'mot_noload_pow_ul' => $motorTestingMaster->noload_pow_ul ?? '',
|
||||
'mot_noload_spd_ll' => $motorTestingMaster->noload_spd_ll ?? '',
|
||||
'mot_noload_spd_ul' => $motorTestingMaster->noload_spd_ul ?? '',
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
|
||||
@@ -30,7 +30,7 @@ class UserController extends Controller
|
||||
* Display the specified resource.
|
||||
*/
|
||||
// show(string $id)
|
||||
public function get_testing_data(Request $request)
|
||||
public function get_user_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
@@ -209,8 +209,9 @@ class ProductionTargetPlan extends Component
|
||||
'items.code as item_code',
|
||||
'items.category as category',
|
||||
'items.description as item_description',
|
||||
'items.hourly_quantity as hourly_quantity',
|
||||
'lines.name as line_name',
|
||||
'lines.line_capacity as line_capacity',
|
||||
// 'lines.line_capacity as line_capacity',
|
||||
'plants.name as plant_name'
|
||||
)
|
||||
->get();
|
||||
@@ -257,10 +258,10 @@ class ProductionTargetPlan extends Component
|
||||
$remainingDays = (int) ($row['working_days'] ?? 0);
|
||||
|
||||
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||
$dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||
$dailyHourlyQuantity = (float) ($row['hourly_quantity'] ?? 0);
|
||||
|
||||
$row['category'] = $row['category'] ?? '-';
|
||||
$row['daily_line_capacity'] = [];
|
||||
$row['daily_hourly_quantity'] = [];
|
||||
$row['daily_target_dynamic'] = [];
|
||||
$row['produced_quantity'] = [];
|
||||
|
||||
@@ -270,7 +271,7 @@ class ProductionTargetPlan extends Component
|
||||
|
||||
// Skip leave dates fast
|
||||
if (isset($leaveDates) && in_array($date, $leaveDates)) {
|
||||
$row['daily_line_capacity'][$date] = '-';
|
||||
$row['daily_hourly_quantity'][$date] = '-';
|
||||
$row['daily_target_dynamic'][$date] = '-';
|
||||
$row['produced_quantity'][$date] = '-';
|
||||
continue;
|
||||
@@ -284,7 +285,7 @@ class ProductionTargetPlan extends Component
|
||||
|
||||
$row['daily_target_dynamic'][$date] = $todayTarget;
|
||||
$row['produced_quantity'][$date] = $producedQty;
|
||||
$row['daily_line_capacity'][$date] = $dailyLineCapacity;
|
||||
$row['daily_hourly_quantity'][$date] = $dailyHourlyQuantity * 22.5;
|
||||
|
||||
// Carry forward remaining qty
|
||||
$remainingQty = max(0, $remainingQty - $producedQty);
|
||||
|
||||
558
app/Livewire/StockDataTable.php
Normal file
558
app/Livewire/StockDataTable.php
Normal file
@@ -0,0 +1,558 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\DuplicateStock;
|
||||
use App\Models\Item;
|
||||
use App\Models\NotInStock;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class StockDataTable extends Component
|
||||
{
|
||||
public $invoiceData = [];
|
||||
|
||||
use WithPagination;
|
||||
|
||||
protected $paginationTheme = 'tailwind';
|
||||
|
||||
// public $invoiceRecords;
|
||||
|
||||
public $plantId = 0;
|
||||
|
||||
public $package = [];
|
||||
|
||||
public $scannedIds = [];
|
||||
|
||||
public $scannedRecords = [];
|
||||
|
||||
public $scannedSerials = [];
|
||||
|
||||
public $packageCount = 0;
|
||||
|
||||
public string $location = '';
|
||||
|
||||
public bool $completedInvoice = false;
|
||||
|
||||
public bool $isSerial = false;
|
||||
|
||||
public $isnonQuanSfg = false;
|
||||
|
||||
public bool $onCapFocus = false;
|
||||
|
||||
public bool $emptyInvoice = false;
|
||||
|
||||
public bool $hasSearched = false;
|
||||
|
||||
public bool $materialInvoice = false;
|
||||
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
public bool $isSfg = false;
|
||||
|
||||
public $itemCode, $serialNumber, $serial_number;
|
||||
|
||||
public $scannedSfgData = [];
|
||||
|
||||
// protected $listeners = ['refreshInvoiceData' => 'loadData',];
|
||||
|
||||
protected $listeners = [
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshSfgData' => 'loadSfgData',
|
||||
'refreshSfgNonData' => 'loadSfgNonQuanData',
|
||||
'confirmStockUpdate',
|
||||
'confirmSerialUpdate',
|
||||
'confirmSerialFGUpdate',
|
||||
'confirmDuplicateUpdate'
|
||||
];
|
||||
|
||||
public $capacitorInput = '';
|
||||
|
||||
public $panel_box_supplier;
|
||||
|
||||
public $panel_box_code;
|
||||
|
||||
public $panel_box_serial_number;
|
||||
|
||||
public string $currentItemCode = '';
|
||||
|
||||
public string $currentSerialNumber = '';
|
||||
|
||||
public $stickerMasterId;
|
||||
|
||||
public $sNo;
|
||||
|
||||
public function confirmStockUpdate($plantId, $location, $bin, $stickerMasterId, $batch, $docNo, $quantity)
|
||||
{
|
||||
|
||||
$record = NotInStock::where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('doc_no', $docNo)
|
||||
->where('bin', $bin)
|
||||
->first();
|
||||
|
||||
if (!$record) {
|
||||
|
||||
NotInStock::create([
|
||||
'plant_id' => $plantId,
|
||||
'location' => $location,
|
||||
'bin' => $bin,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
'type' => '1',
|
||||
'serial_number' => $this->serialNumber ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'scanned_quantity' => $quantity ?? '0',
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record inserted successfully in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
} else {
|
||||
|
||||
$record->update([
|
||||
'scanned_quantity' => $record->scanned_quantity + $quantity,
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record updated in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmSerialUpdate($plantId, $location, $bin, $serial_number, $stickerMasterId, $batch, $docNo, $quantity)
|
||||
{
|
||||
$sNo = $serial_number;
|
||||
$record = NotInStock::where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('serial_number', $sNo)
|
||||
->where('bin', $bin)
|
||||
->first();
|
||||
|
||||
if (!$record) {
|
||||
|
||||
NotInStock::create([
|
||||
'plant_id' => $plantId,
|
||||
'location' => $location,
|
||||
'bin' => $bin,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
'type' => '1',
|
||||
'serial_number' => $sNo ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'scanned_quantity' => $quantity ?? '1',
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record inserted successfully in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
} else {
|
||||
|
||||
$record->update([
|
||||
'batch' => $batch ?? null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record updated in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmDuplicateUpdate($plantId, $location, $bin, $serial_number, $stickerMasterId, $batch, $docNo, $quantity)
|
||||
{
|
||||
$sNo = $serial_number;
|
||||
$stockRecord = StockDataMaster::where('serial_number', $sNo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (!$stockRecord) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record = DuplicateStock::where('stock_data_master_id', $stockRecord->id)->first();
|
||||
|
||||
if (!$record) {
|
||||
|
||||
DuplicateStock::create([
|
||||
'stock_data_master_id' => $stockRecord->id,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record inserted successfully in duplicate stock table.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
} else {
|
||||
|
||||
DuplicateStock::create([
|
||||
'stock_data_master_id' => $stockRecord->id,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record inserted successfully in duplicate stock table.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmSerialFGUpdate($plantId, $location, $bin, $serial_number, $stickerMasterId)
|
||||
{
|
||||
$sNo = $serial_number;
|
||||
$record = NotInStock::where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('serial_number', $sNo)
|
||||
->where('bin', $bin)
|
||||
->first();
|
||||
|
||||
if (!$record) {
|
||||
|
||||
NotInStock::create([
|
||||
'plant_id' => $plantId,
|
||||
'location' => $location,
|
||||
'bin' => $bin,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
'type' => '0',
|
||||
'serial_number' => $sNo ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'scanned_quantity' => $quantity ?? '1',
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record inserted successfully in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
} else {
|
||||
|
||||
$record->update([
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Record updated in not in stock table.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadCompletedData($location, $plantId, $isSerial)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->location = $location;
|
||||
$this->completedInvoice = true;
|
||||
$this->isSerial = $isSerial;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->packageCount = 0;
|
||||
// $this->showCapacitorInput = false;
|
||||
$this->dispatch('focus-invoice-number');
|
||||
}
|
||||
|
||||
public function loadEmptyData($location, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->location = $location;
|
||||
$this->completedInvoice = false;
|
||||
$this->onCapFocus = false;
|
||||
$this->emptyInvoice = true;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->packageCount = 0;
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function loadSfgData($location, $plantId, $itemCode,$docNo)
|
||||
{
|
||||
$this->isSfg = true;
|
||||
$this->hasSearched = false;
|
||||
// $this->materialInvoice = false;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->emptyInvoice = false;
|
||||
|
||||
$item = Item::where('plant_id', $plantId)
|
||||
->where('code', $itemCode)
|
||||
->first();
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->first();
|
||||
|
||||
$stickerMasterId = $stickerMaster->id;
|
||||
|
||||
$record = StockDataMaster::with('stickerMaster.item')
|
||||
->where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('doc_no', $docNo)
|
||||
->where('type', '1')
|
||||
->first();
|
||||
|
||||
if ($record) {
|
||||
|
||||
$itemCode = optional($record->stickerMaster->item)->code;
|
||||
|
||||
$foundIndex = null;
|
||||
|
||||
foreach ($this->scannedSfgData as $index => $row) {
|
||||
|
||||
if (
|
||||
$row['location'] == $record->location &&
|
||||
$row['doc_no'] == $record->doc_no &&
|
||||
$row['item_code'] == $itemCode
|
||||
) {
|
||||
$foundIndex = $index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($foundIndex !== null) {
|
||||
|
||||
$this->scannedSfgData[$foundIndex]['scanned_quantity'] = $record->scanned_quantity;
|
||||
|
||||
} else {
|
||||
|
||||
if (count($this->scannedSfgData) >= 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->scannedSfgData[] = [
|
||||
'serial_number' => $record->serial_number,
|
||||
'bin' => $record->bin,
|
||||
'item_code' => $itemCode,
|
||||
'batch' => $record->batch,
|
||||
'doc_no' => $record->doc_no,
|
||||
'quantity' => $record->quantity,
|
||||
'scanned_quantity' => $record->scanned_quantity,
|
||||
'location' => $record->location,
|
||||
'updated_by' => $record->updated_by,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadSfgNonQuanData($location, $plantId, $serialNumber, $itemCode){
|
||||
|
||||
$this->isnonQuanSfg = true;
|
||||
|
||||
$record = StockDataMaster::with('stickerMaster.item')
|
||||
->where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('serial_number', $serialNumber)
|
||||
->whereHas('stickerMaster.item', function ($q) use ($itemCode) {
|
||||
$q->where('code', $itemCode);
|
||||
})
|
||||
->where('type', '1')
|
||||
->orderBy('updated_at', 'desc')
|
||||
->first();
|
||||
|
||||
if ($record) {
|
||||
|
||||
// foreach ($this->scannedSerials as $row) {
|
||||
// if ($row['serial_number'] == $serialNumber) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $this->scannedSerials[] = [
|
||||
array_unshift($this->scannedSerials, [
|
||||
'location' => $record->location,
|
||||
'bin' => $record->bin ?? '',
|
||||
'item_code' => $record->stickerMaster->item->code ?? '',
|
||||
'serial_number' => $serialNumber,
|
||||
'batch' => $record->batch ?? '',
|
||||
'doc_no' => $record->doc_no ?? '',
|
||||
'quantity' => $record->quantity ?? '',
|
||||
'scanned_quantity' => $record->scanned_quantity ?? '',
|
||||
'updated_by' => $record->updated_by ?? '',
|
||||
]);
|
||||
// ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function loadData($location, $plantId, $itemCode, $serialNumber)
|
||||
{
|
||||
$this->location = $location;
|
||||
$this->plantId = $plantId;
|
||||
$this->itemCode = $itemCode;
|
||||
$this->serialNumber = $serialNumber;
|
||||
|
||||
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
|
||||
$this->resetPage();
|
||||
$this->packageCount = 0;
|
||||
|
||||
$item = Item::where('plant_id', $plantId)
|
||||
->where('code', $this->itemCode)
|
||||
->first();
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->first();
|
||||
|
||||
$stickerMasterId = $stickerMaster->id;
|
||||
|
||||
$records = StockDataMaster::with('stickerMasterRelation')
|
||||
->where('location', $this->location)
|
||||
->where('type', '=', '0')
|
||||
->where('plant_id', $this->plantId)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('serial_number', $this->serialNumber)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
foreach ($records as $record) {
|
||||
|
||||
if ($record->scanned_status == 'Scanned') {
|
||||
|
||||
if (!in_array($record->id, $this->scannedIds)) {
|
||||
$this->scannedIds[] = $record->id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->scannedIds = array_slice(array_unique($this->scannedIds), 0, 100);
|
||||
|
||||
|
||||
$this->packageCount = $records->sum(function ($record) {
|
||||
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
if (! $sm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
|
||||
if ($sm->tube_sticker_motor == 1) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
$sm->tube_sticker_pump == 1 ||
|
||||
($sm->tube_sticker_pumpset != 1 &&
|
||||
$sm->tube_sticker_pump != 1 &&
|
||||
$sm->pack_slip_pump == 1)
|
||||
) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->tube_sticker_pumpset == 1) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
} elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pump == 1) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pumpset == 1) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return max($stickCount - $scannedCount, 0);
|
||||
});
|
||||
|
||||
// $this->dispatch(
|
||||
// $onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'
|
||||
// );
|
||||
}
|
||||
|
||||
// public function getInvoiceRecordsProperty()
|
||||
// {
|
||||
// return StockDataMaster::with('stickerMasterRelation.item')
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->where('location', $this->location)
|
||||
// ->where('type', '=', '0')
|
||||
// ->where('scanned_status', 'Scanned')
|
||||
// // ->where(function ($query) {
|
||||
// // $query->whereNull('scanned_status')
|
||||
// // ->orWhere('scanned_status', 'Scanned');
|
||||
// // })
|
||||
// // ->when($this->hasSearched, function ($query) {
|
||||
// // $query->where('invoice_number', $this->invoiceNumber)
|
||||
// // ->where('plant_id', $this->plantId)
|
||||
// // ->where('scanned_status', '=', '');
|
||||
// // })
|
||||
// ->orderBy('updated_at', 'desc')
|
||||
// ->paginate(6);
|
||||
// }
|
||||
|
||||
|
||||
public function getInvoiceRecordsProperty()
|
||||
{
|
||||
if (empty($this->scannedIds)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
return StockDataMaster::with('stickerMasterRelation.item')
|
||||
->whereIn('id', $this->scannedIds)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->paginate(6);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
// return view('livewire.stock-data-table');
|
||||
return view('livewire.stock-data-table', [
|
||||
'records' => $this->invoiceRecords,
|
||||
'scannedSfgData' => $this->scannedSfgData,
|
||||
'scannedSerials' => $this->scannedSerials
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ class ClassCharacteristic extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_id',
|
||||
'machine_id',
|
||||
'item_id',
|
||||
'aufnr',
|
||||
'class',
|
||||
'arbid',
|
||||
@@ -106,14 +106,14 @@ class ClassCharacteristic extends Model
|
||||
'zmm_tagno',
|
||||
'zmm_year',
|
||||
'zmm_laser_name',
|
||||
'zmm_logo_cp',
|
||||
'zmm_logo_ce',
|
||||
'zmm_logo_nsf',
|
||||
'zmm_beenote',
|
||||
'zmm_beenumber',
|
||||
'zmm_beestar',
|
||||
'zmm_codeclass',
|
||||
'zmm_colour',
|
||||
'zmm_logo_cp',
|
||||
'zmm_logo_ce',
|
||||
'zmm_logo_nsf',
|
||||
'zmm_grade',
|
||||
'zmm_grwt_pset',
|
||||
'zmm_grwt_cable',
|
||||
@@ -144,24 +144,34 @@ class ClassCharacteristic extends Model
|
||||
'zmm_usp',
|
||||
'mark_status',
|
||||
'marked_datetime',
|
||||
'marked_physical_count',
|
||||
'marked_expected_time',
|
||||
'marked_by',
|
||||
'man_marked_status',
|
||||
'man_marked_datetime',
|
||||
'man_marked_by',
|
||||
'motor_marked_status',
|
||||
'motor_marked_physical_count',
|
||||
'motor_expected_time',
|
||||
'motor_marked_by',
|
||||
'pump_marked_status',
|
||||
'pump_marked_physical_count',
|
||||
'pump_expected_time',
|
||||
'pump_marked_by',
|
||||
'name_plate_marked_status',
|
||||
'name_plate_expected_time',
|
||||
'name_plate_marked_by',
|
||||
'motor_pump_pumpset_status',
|
||||
'winded_serial_number',
|
||||
'motor_machine_name',
|
||||
'pump_machine_name',
|
||||
'name_plate_machine_name',
|
||||
'pumpset_machine_name',
|
||||
'part_validation_1',
|
||||
'part_validation_2',
|
||||
'samlight_logged_name',
|
||||
'pending_released_status',
|
||||
'motor_expected_time',
|
||||
'pump_expected_time',
|
||||
'has_work_flow_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
|
||||
25
app/Models/DuplicateStock.php
Normal file
25
app/Models/DuplicateStock.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DuplicateStock extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'stock_data_master_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function stockDataMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StockDataMaster::class);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ class InvoiceValidation extends Model
|
||||
'operator_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Item extends Model
|
||||
@@ -60,6 +59,16 @@ class Item extends Model
|
||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||
}
|
||||
|
||||
public function characteristicValues()
|
||||
{
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function weightValidations()
|
||||
{
|
||||
return $this->hasMany(WeightValidation::class);
|
||||
|
||||
@@ -41,6 +41,11 @@ class Line extends Model
|
||||
return $this->belongsTo(Block::class);
|
||||
}
|
||||
|
||||
public function qualityValidations()
|
||||
{
|
||||
return $this->hasMany(QualityValidation::class);
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
@@ -51,6 +56,21 @@ class Line extends Model
|
||||
return $this->belongsTo(WorkGroupMaster::class);
|
||||
}
|
||||
|
||||
public function processOrders()
|
||||
{
|
||||
return $this->hasMany(ProcessOrder::class);
|
||||
}
|
||||
|
||||
public function productCharacteristicsMasters()
|
||||
{
|
||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||
}
|
||||
|
||||
public function characteristicValues()
|
||||
{
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function workGroup1()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||
|
||||
@@ -12,9 +12,9 @@ class Machine extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'line_id',
|
||||
'work_group_master_id',
|
||||
'name',
|
||||
'name',
|
||||
'work_center',
|
||||
];
|
||||
|
||||
@@ -23,7 +23,7 @@ class Machine extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
@@ -33,6 +33,21 @@ class Machine extends Model
|
||||
return $this->belongsTo(WorkGroupMaster::class);
|
||||
}
|
||||
|
||||
public function productCharacteristicsMasters()
|
||||
{
|
||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||
}
|
||||
|
||||
public function characteristicValues()
|
||||
{
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
@@ -42,5 +57,4 @@ class Machine extends Model
|
||||
{
|
||||
return $this->hasMany(EquipmentMaster::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
53
app/Models/NotInStock.php
Normal file
53
app/Models/NotInStock.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class NotInStock extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'sticker_master_id',
|
||||
'location',
|
||||
'bin',
|
||||
'serial_number',
|
||||
'batch',
|
||||
'quantity',
|
||||
'doc_no',
|
||||
'type',
|
||||
'motor_scanned_status',
|
||||
'pump_scanned_status',
|
||||
'capacitor_scanned_status',
|
||||
'scanned_status_set',
|
||||
'panel_box_item_code',
|
||||
'panel_box_supplier',
|
||||
'panel_box_sno',
|
||||
'scanned_status',
|
||||
'scanned_quantity',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function stickerMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class);
|
||||
}
|
||||
|
||||
public function stickerMasterRelation()
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,12 +25,12 @@ class Plant extends Model
|
||||
|
||||
public function blocks(): HasMany
|
||||
{
|
||||
return $this->hasMany(Block::class);
|
||||
return $this->hasMany(Block::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function lines(): HasMany
|
||||
{
|
||||
return $this->hasMany(Line::class);
|
||||
return $this->hasMany(Line::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function getLineNames()
|
||||
@@ -40,27 +40,32 @@ class Plant extends Model
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
return $this->hasMany(Item::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function stickersMasters(): HasMany
|
||||
{
|
||||
return $this->hasMany(StickerMaster::class);
|
||||
return $this->hasMany(StickerMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function invoiceValidations()
|
||||
{
|
||||
return $this->hasMany(InvoiceValidation::class, 'sticker_master_id');
|
||||
return $this->hasMany(InvoiceValidation::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function stockDataMasters()
|
||||
{
|
||||
return $this->hasMany(StockDataMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function qualityValidations()
|
||||
{
|
||||
return $this->hasMany(QualityValidation::class, 'sticker_master_id');
|
||||
return $this->hasMany(QualityValidation::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
return $this->hasMany(TestingPanelReading::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function guardNames()
|
||||
@@ -88,11 +93,31 @@ class Plant extends Model
|
||||
return $this->hasMany(WorkGroupMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function processOrders()
|
||||
{
|
||||
return $this->hasMany(ProcessOrder::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function productCharacteristicsMasters()
|
||||
{
|
||||
return $this->hasMany(ProductCharacteristicsMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function characteristicValues()
|
||||
{
|
||||
return $this->hasMany(CharacteristicValue::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function equipmentMasters()
|
||||
{
|
||||
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
// public function rejectReasons()
|
||||
// {
|
||||
// return $this->hasMany(RejectReason::class, 'plant_id', 'id');
|
||||
|
||||
@@ -21,6 +21,7 @@ class ProcessOrder extends Model
|
||||
'coil_number',
|
||||
'order_quantity',
|
||||
'received_quantity',
|
||||
'updated_order_quantity',
|
||||
'sfg_number',
|
||||
'machine_name',
|
||||
'scrap_quantity',
|
||||
|
||||
53
app/Models/StockDataMaster.php
Normal file
53
app/Models/StockDataMaster.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class StockDataMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'sticker_master_id',
|
||||
'location',
|
||||
'bin',
|
||||
'serial_number',
|
||||
'batch',
|
||||
'quantity',
|
||||
'doc_no',
|
||||
'type',
|
||||
'motor_scanned_status',
|
||||
'pump_scanned_status',
|
||||
'capacitor_scanned_status',
|
||||
'scanned_status_set',
|
||||
'panel_box_item_code',
|
||||
'panel_box_supplier',
|
||||
'panel_box_sno',
|
||||
'scanned_status',
|
||||
'scanned_quantity',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function stickerMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class);
|
||||
}
|
||||
|
||||
public function stickerMasterRelation()
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class WorkGroupMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
@@ -25,6 +25,11 @@ class WorkGroupMaster extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function productCharacteristicsMasters()
|
||||
{
|
||||
return $this->hasMany(ProductCharacteristicsMaster::class);
|
||||
}
|
||||
|
||||
// public function rejectReasons()
|
||||
// {
|
||||
// return $this->hasMany(RejectReason::class, 'work_group_master_id', 'id');
|
||||
|
||||
106
app/Policies/DuplicateStockPolicy.php
Normal file
106
app/Policies/DuplicateStockPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\DuplicateStock;
|
||||
use App\Models\User;
|
||||
|
||||
class DuplicateStockPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, DuplicateStock $duplicatestock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete DuplicateStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any DuplicateStock');
|
||||
}
|
||||
}
|
||||
106
app/Policies/NotInStockPolicy.php
Normal file
106
app/Policies/NotInStockPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\NotInStock;
|
||||
use App\Models\User;
|
||||
|
||||
class NotInStockPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, NotInStock $notinstock): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete NotInStock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any NotInStock');
|
||||
}
|
||||
}
|
||||
106
app/Policies/StockDataMasterPolicy.php
Normal file
106
app/Policies/StockDataMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\StockDataMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class StockDataMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, StockDataMaster $stockdatamaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete StockDataMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any StockDataMaster');
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ return [
|
||||
|
||||
'user_model' => \App\Models\User::class,
|
||||
|
||||
// 'user_model_class' => \App\Models\User::class,
|
||||
'user_model_class' => \App\Models\User::class,
|
||||
|
||||
'policies_namespace' => 'App\Policies',
|
||||
],
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
@@ -11,7 +10,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE device_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
@@ -9,7 +8,6 @@ return new class extends Migration
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
@@ -22,10 +20,10 @@ return new class extends Migration
|
||||
machine_id BIGINT DEFAULT NULL,
|
||||
name TEXT DEFAULT NULL,
|
||||
inspection_type TEXT DEFAULT NULL,
|
||||
characteristics_type TEXT DEFAULT NULL
|
||||
characteristics_type TEXT DEFAULT NULL,
|
||||
upper DOUBLE PRECISION DEFAULT 0.0,
|
||||
lower DOUBLE PRECISION DEFAULT 0.0,
|
||||
middle DOUBLE PRECISION DEFAULT NULL,
|
||||
middle DOUBLE PRECISION DEFAULT 0.0,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
@@ -42,7 +40,6 @@ return new class extends Migration
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
|
||||
@@ -105,6 +105,9 @@ return new class extends Migration
|
||||
zmm_tagno TEXT DEFAULT NULL,
|
||||
zmm_year TEXT DEFAULT NULL,
|
||||
zmm_laser_name TEXT DEFAULT NULL,
|
||||
zmm_logo_cp TEXT DEFAULT NULL,
|
||||
zmm_logo_ce TEXT DEFAULT NULL,
|
||||
zmm_logo_nsf TEXT DEFAULT NULL,
|
||||
zmm_beenote TEXT DEFAULT NULL,
|
||||
zmm_beenumber TEXT DEFAULT NULL,
|
||||
zmm_beestar TEXT DEFAULT NULL,
|
||||
@@ -129,9 +132,6 @@ return new class extends Migration
|
||||
zmm_newt_motor TEXT DEFAULT NULL,
|
||||
zmm_newt_pf TEXT DEFAULT NULL,
|
||||
zmm_newt_pump TEXT DEFAULT NULL,
|
||||
zmm_logo_cp TEXT DEFAULT NULL,
|
||||
zmm_logo_ce TEXT DEFAULT NULL,
|
||||
zmm_logo_nsf TEXT DEFAULT NULL,
|
||||
zmm_packtype TEXT DEFAULT NULL,
|
||||
zmm_panel TEXT DEFAULT NULL,
|
||||
zmm_performance_factor TEXT DEFAULT NULL,
|
||||
@@ -142,25 +142,35 @@ return new class extends Migration
|
||||
zmm_type TEXT DEFAULT NULL,
|
||||
zmm_usp TEXT DEFAULT NULL,
|
||||
mark_status TEXT DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
marked_physical_count TEXT DEFAULT '0',
|
||||
marked_expected_time TEXT DEFAULT '0',
|
||||
marked_by TEXT DEFAULT NULL,
|
||||
man_marked_status TEXT DEFAULT '0',
|
||||
man_marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
man_marked_by TEXT DEFAULT NULL,
|
||||
motor_marked_status TEXT DEFAULT NULL,
|
||||
motor_marked_physical_count TEXT DEFAULT '0',
|
||||
motor_expected_time TEXT DEFAULT '0',
|
||||
motor_marked_by TEXT DEFAULT NULL,
|
||||
pump_marked_status TEXT DEFAULT NULL,
|
||||
pump_marked_physical_count TEXT DEFAULT '0',
|
||||
pump_expected_time TEXT DEFAULT '0',
|
||||
pump_marked_by TEXT DEFAULT NULL,
|
||||
name_plate_marked_status TEXT DEFAULT NULL,
|
||||
name_plate_expected_time TEXT DEFAULT '0',
|
||||
name_plate_marked_by TEXT DEFAULT NULL,
|
||||
motor_pump_pumpset_status TEXT DEFAULT NULL,
|
||||
winded_serial_number TEXT DEFAULT NULL,
|
||||
motor_machine_name TEXT DEFAULT NULL,
|
||||
pump_machine_name TEXT DEFAULT NULL,
|
||||
name_plate_machine_name TEXT DEFAULT NULL,
|
||||
pumpset_machine_name TEXT DEFAULT NULL,
|
||||
part_validation_1 TEXT DEFAULT NULL,
|
||||
part_validation_2 TEXT DEFAULT NULL,
|
||||
samlight_logged_name TEXT DEFAULT NULL,
|
||||
pending_released_status INTEGER DEFAULT 0,
|
||||
motor_expected_time TEXT DEFAULT '0',
|
||||
pump_expected_time TEXT DEFAULT '0',
|
||||
has_work_flow_id TEXT DEFAULT '0',
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
@@ -168,6 +178,7 @@ return new class extends Migration
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (gernr, plant_id),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items (id)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE stock_data_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
sticker_master_id BIGINT NOT NULL,
|
||||
location TEXT DEFAULT NULL,
|
||||
bin TEXT DEFAULT NULL,
|
||||
serial_number TEXT DEFAULT NULL,
|
||||
batch TEXT DEFAULT NULL,
|
||||
quantity TEXT DEFAULT NULL,
|
||||
doc_no TEXT DEFAULT NULL,
|
||||
type TEXT DEFAULT '0',
|
||||
motor_scanned_status TEXT DEFAULT NULL,
|
||||
pump_scanned_status TEXT DEFAULT NULL,
|
||||
capacitor_scanned_status TEXT DEFAULT NULL,
|
||||
scanned_status_set TEXT DEFAULT NULL,
|
||||
panel_box_item_code TEXT DEFAULT NULL,
|
||||
panel_box_supplier TEXT DEFAULT NULL,
|
||||
panel_box_sno TEXT DEFAULT NULL,
|
||||
scanned_status TEXT DEFAULT NULL,
|
||||
|
||||
scanned_quantity TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (plant_id, serial_number),
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||
FOREIGN KEY (sticker_master_id) REFERENCES sticker_masters (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('stock_data_masters');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE not_in_stocks (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
sticker_master_id BIGINT NOT NULL,
|
||||
location TEXT DEFAULT NULL,
|
||||
bin TEXT DEFAULT NULL,
|
||||
serial_number TEXT DEFAULT NULL,
|
||||
batch TEXT DEFAULT NULL,
|
||||
quantity TEXT DEFAULT NULL,
|
||||
doc_no TEXT DEFAULT NULL,
|
||||
type TEXT DEFAULT '0',
|
||||
motor_scanned_status TEXT DEFAULT NULL,
|
||||
pump_scanned_status TEXT DEFAULT NULL,
|
||||
capacitor_scanned_status TEXT DEFAULT NULL,
|
||||
scanned_status_set TEXT DEFAULT NULL,
|
||||
panel_box_item_code TEXT DEFAULT NULL,
|
||||
panel_box_supplier TEXT DEFAULT NULL,
|
||||
panel_box_sno TEXT DEFAULT NULL,
|
||||
scanned_status TEXT DEFAULT NULL,
|
||||
|
||||
scanned_quantity TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (plant_id, serial_number),
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||
FOREIGN KEY (sticker_master_id) REFERENCES sticker_masters (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('not_in_stocks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE duplicate_stocks (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
stock_data_master_id BIGINT NOT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (stock_data_master_id) REFERENCES stock_data_masters(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('duplicate_stocks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE process_orders
|
||||
ADD COLUMN updated_order_quantity NUMERIC(10,3) NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -90,6 +90,7 @@ class PermissionSeeder extends Seeder
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import serial invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view import material invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view import invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view export invoice']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import locator invoice validation']);
|
||||
@@ -192,5 +193,9 @@ class PermissionSeeder extends Seeder
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view production calender page']);
|
||||
Permission::updateOrCreate(['name' => 'view production target page']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view wire master print page']);
|
||||
Permission::updateOrCreate(['name' => 'view cycle count page']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
13
resources/views/filament/pages/cycle-count.blade.php
Normal file
13
resources/views/filament/pages/cycle-count.blade.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
<div class="bg-white shadow rounded-xl p-4 mt-6">
|
||||
<livewire:stock-data-table />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</x-filament-panels::page>
|
||||
126
resources/views/filament/pages/dashboard.blade.php
Normal file
126
resources/views/filament/pages/dashboard.blade.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-bold tracking-tight">
|
||||
CRI Digital Manufacturing IIoT Platform
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mt-2">
|
||||
Complete visibility, traceability, and control across your manufacturing operations.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- BANNER -->
|
||||
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-72 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- INTRO -->
|
||||
<div class="max-w-4xl mb-10">
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
CRI Digital Manufacturing IIoT is built to deliver
|
||||
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
|
||||
across plants, lines, and production processes.
|
||||
</p>
|
||||
|
||||
<p class="text-lg text-gray-700">
|
||||
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
|
||||
complete tracking of materials, production orders, and finished goods—helping teams
|
||||
make faster, data-driven decisions with confidence.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- KEY PILLARS -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
|
||||
<p class="text-gray-600">
|
||||
Track materials, batches, and serials from input to dispatch.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">✅ Quality Assurance</h3>
|
||||
<p class="text-gray-600">
|
||||
Validate process data and ensure first-time-right production.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">⏱ On-Time Delivery</h3>
|
||||
<p class="text-gray-600">
|
||||
Identify delays early and meet production commitments.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
|
||||
<p class="text-gray-600">
|
||||
Monitor performance and take quick corrective actions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SUPPORT -->
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
|
||||
<p class="text-gray-700 mb-2">
|
||||
Our dedicated IIoT support team is available round-the-clock to ensure
|
||||
uninterrupted operations and quick issue resolution.
|
||||
</p>
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
|
||||
</p>
|
||||
{{-- <p class="text-lg font-medium text-gray-900">
|
||||
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p> --}}
|
||||
</div>
|
||||
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
|
||||
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
Our support structure is designed to ensure quick resolution based on the type
|
||||
of issue — whether it is on-site, application-related, or infrastructure-related.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
🏭 <strong>Plant & On-Site Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For plant visits, industry-level issues, and on-ground validation
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">8925899458 / 8925899459</span>
|
||||
</p>
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
💻 <strong>Application & Logic Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For website errors, logic issues, and application-level problems
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<!-- TEAM -->
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
|
||||
<div class="flex items-center gap-2">👤 Jothikumar</div>
|
||||
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
|
||||
<div class="flex items-center gap-2">👤 Dhanabalan</div>
|
||||
<div class="flex items-center gap-2">👤 Ranjith</div>
|
||||
<div class="flex items-center gap-2">👤 Srimathy</div>
|
||||
<div class="flex items-center gap-2">👤 Gokul</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
</x-filament-panels::page>
|
||||
@@ -87,6 +87,15 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('focus-qr-input', () => {
|
||||
const input = document.getElementById('qr-scan-input');
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const scanInput = document.getElementById('qr-scan-input');
|
||||
if (!scanInput) return;
|
||||
@@ -97,10 +106,10 @@
|
||||
|
||||
const value = scanInput.value.trim();
|
||||
|
||||
if (value !== '') {
|
||||
// if (value != '') {
|
||||
Livewire.dispatch('handleQrScan', { value: value });
|
||||
scanInput.value = '';
|
||||
}
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -34,22 +34,33 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
|
||||
window.addEventListener('focus-qr-input', () => {
|
||||
const input = document.getElementById('qr-scan-input');
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const scanInput = document.getElementById('qr-scan-input');
|
||||
if (!scanInput) return;
|
||||
|
||||
scanInput.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
if (event.key == 'Enter') {
|
||||
event.preventDefault();
|
||||
|
||||
const value = scanInput.value.trim();
|
||||
|
||||
if (value !== '') {
|
||||
//if (value !== '') {
|
||||
Livewire.dispatch('handleQrScan', { value: value });
|
||||
scanInput.value = '';
|
||||
}
|
||||
//}
|
||||
}
|
||||
});
|
||||
window.addEventListener('open-pdf', event => {
|
||||
|
||||
@@ -1,126 +1,13 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-bold tracking-tight">
|
||||
CRI Digital Manufacturing IIoT Platform
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mt-2">
|
||||
Complete visibility, traceability, and control across your manufacturing operations
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- BANNER -->
|
||||
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-72 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- INTRO -->
|
||||
<div class="max-w-4xl mb-10">
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
CRI Digital Manufacturing IIoT is built to deliver
|
||||
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
|
||||
across plants, lines, and production processes.
|
||||
</p>
|
||||
|
||||
<p class="text-lg text-gray-700">
|
||||
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
|
||||
complete tracking of materials, production orders, and finished goods—helping teams
|
||||
make faster, data-driven decisions with confidence.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- KEY PILLARS -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
|
||||
<p class="text-gray-600">
|
||||
Track materials, batches, and serials from input to dispatch.
|
||||
</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-4 md:gap-4 p-2 md:p-4 items-start">
|
||||
{{-- Filters form --}}
|
||||
<div class="space-y-4 w-full max-w-full col-span-1">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">✅ Quality Assurance</h3>
|
||||
<p class="text-gray-600">
|
||||
Validate process data and ensure first-time-right production.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">⏱ On-Time Delivery</h3>
|
||||
<p class="text-gray-600">
|
||||
Identify delays early and meet production commitments.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
|
||||
<p class="text-gray-600">
|
||||
Monitor performance and take quick corrective actions.
|
||||
</p>
|
||||
{{-- Stat widget --}}
|
||||
<div class="w-full max-w-full col-span-1 sm:col-span-1 lg:col-span-2">
|
||||
@livewire(\App\Filament\Widgets\CumulativeChart::class)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SUPPORT -->
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
|
||||
<p class="text-gray-700 mb-2">
|
||||
Our dedicated IIoT support team is available round-the-clock to ensure
|
||||
uninterrupted operations and quick issue resolution.
|
||||
</p>
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
|
||||
</p>
|
||||
{{-- <p class="text-lg font-medium text-gray-900">
|
||||
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p> --}}
|
||||
</div>
|
||||
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
|
||||
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
Our support structure is designed to ensure quick resolution based on the type
|
||||
of issue — whether it is on-site, application-related, or infrastructure-related.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
🏭 <strong>Plant & On-Site Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For plant visits, industry-level issues, and on-ground validation
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">8925899458 / 8925899459</span>
|
||||
</p>
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
💻 <strong>Application & Logic Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For website errors, logic issues, and application-level problems
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<!-- TEAM -->
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
|
||||
<div class="flex items-center gap-2">👤 Jothikumar</div>
|
||||
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
|
||||
<div class="flex items-center gap-2">👤 Dhanabalan</div>
|
||||
<div class="flex items-center gap-2">👤 Ranjith</div>
|
||||
<div class="flex items-center gap-2">👤 Srimathy</div>
|
||||
<div class="flex items-center gap-2">👤 Gokul</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
</x-filament-panels::page>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach($dates as $date)
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Line Capacity</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Item Quantity</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Target Plan</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap border-r-4 border-gray-400">
|
||||
Produced Quantity
|
||||
@@ -61,7 +61,7 @@
|
||||
@else
|
||||
{{-- <td class="border px-4 py-2 whitespace-nowrap">{{ $record['daily_target'] ?? '-' }}</td> --}}
|
||||
<td class="border px-4 py-2 whitespace-nowrap">
|
||||
{{ $record['daily_line_capacity'][$date] ?? '-' }}
|
||||
{{ $record['daily_hourly_quantity'][$date] ?? '-' }}
|
||||
</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">
|
||||
{{ $record['daily_target_dynamic'][$date] ?? '-' }}
|
||||
|
||||
308
resources/views/livewire/stock-data-table.blade.php
Normal file
308
resources/views/livewire/stock-data-table.blade.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<div>
|
||||
<div class="mb-4">
|
||||
<h2 class="text-lg font-bold text-gray-800">
|
||||
@if ($hasSearched)
|
||||
FG STOCK DATA TABLE
|
||||
@elseif ($isSfg)
|
||||
SFG STOCK DATA TABLE
|
||||
@elseif ($isnonQuanSfg)
|
||||
SFG STOCK DATA TABLE
|
||||
@else
|
||||
STOCK DATA TABLE
|
||||
@endif
|
||||
</h2>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<hr class="border-t-2 border-gray-300">
|
||||
</div>
|
||||
|
||||
|
||||
@if ($hasSearched)
|
||||
<div class="overflow-x-auto" style="height: 385px;">
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Material Code</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Motor Scanned Status</th>
|
||||
<th class="border px-4 py-2">Pump Scanned Status</th>
|
||||
<th class="border px-4 py-2">Scanned Status Set</th>
|
||||
<th class="border px-4 py-2">Scanned Status</th>
|
||||
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@forelse ($records as $index => $record)
|
||||
<tr wire:key="inv-{{ $record->id }}" class="border-t">
|
||||
<td class="border px-2 py-2">{{ $records->firstItem() + $index }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->stickerMasterRelation?->item?->code ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->serial_number ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->motor_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->pump_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status_set ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status ?? '' }}</td>
|
||||
<td class="border px-2 py-2 whitespace-nowrap">{{ optional($record->created_at)->format('d-m-Y H:i:s') }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->updated_by ?? '' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="12" class="py-4 text-gray-500">
|
||||
No scanned data found for location <strong>{{ $location }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
{{-- <div class="mt-3 flex justify-center">
|
||||
{{ $records->onEachSide(3)->links() }}
|
||||
</div> --}}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($isSfg)
|
||||
|
||||
<div class="w-full overflow-x-auto" style="height:385px">
|
||||
|
||||
<table class="w-full text-sm text-center border border-gray-300">
|
||||
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Location</th>
|
||||
<th class="border px-4 py-2">Bin</th>
|
||||
<th class="border px-4 py-2">Item Code</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Batch</th>
|
||||
<th class="border px-4 py-2">Document Number</th>
|
||||
<th class="border px-4 py-2">Total Quantity</th>
|
||||
<th class="border px-4 py-2">Scanned Quantity</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
@forelse($scannedSfgData as $index => $row)
|
||||
|
||||
<tr>
|
||||
<td class="border px-3 py-2">{{ $index+1 }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['location'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['bin'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['item_code'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['serial_number'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['batch'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['doc_no'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['quantity'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['scanned_quantity'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['updated_by'] }}</td>
|
||||
</tr>
|
||||
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="py-4 text-gray-500">
|
||||
No scanned SFG data
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($isnonQuanSfg)
|
||||
|
||||
<div class="w-full overflow-x-auto" style="height:385px">
|
||||
|
||||
<table class="w-full text-sm text-center border border-gray-300">
|
||||
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Location</th>
|
||||
<th class="border px-4 py-2">Bin</th>
|
||||
<th class="border px-4 py-2">Item Code</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Batch</th>
|
||||
<th class="border px-4 py-2">Document Number</th>
|
||||
<th class="border px-4 py-2">Total Quantity</th>
|
||||
<th class="border px-4 py-2">Scanned Quantity</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
@forelse($scannedSerials as $index => $row)
|
||||
|
||||
<tr>
|
||||
<td class="border px-3 py-2">{{ $index+1 }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['location'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['bin'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['item_code'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['serial_number'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['batch'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['doc_no'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['quantity'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['scanned_quantity'] }}</td>
|
||||
<td class="border px-3 py-2">{{ $row['updated_by'] }}</td>
|
||||
</tr>
|
||||
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="py-4 text-gray-500">
|
||||
No scanned SFG data
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Modal for Capacitor Input --}}
|
||||
<div>
|
||||
<button wire:click="$set('showCapacitorInput', true)"></button>
|
||||
@if($showCapacitorInput)
|
||||
<div class="fixed inset-0 z-[9999] bg-black bg-opacity-50 flex items-center justify-center">
|
||||
<div style="background:white; border:4px solid orange;" class="p-6 rounded-xl shadow-2xl w-[450px]">
|
||||
<h3 class="text-xl font-semibold text-orange-700 mb-4">
|
||||
Scan the Panel Box Supplier/Item Code/Serial Number
|
||||
</h3>
|
||||
|
||||
<input
|
||||
type="text"
|
||||
id="capacitorInput"
|
||||
autocomplete="off"
|
||||
wire:model.defer="capacitorInput"
|
||||
wire:keydown.enter.prevent="processCapacitorInput"
|
||||
class="w-full border border-orange-300 rounded px-3 py-2 focus:outline-none focus:ring-0 focus:border-orange-300"
|
||||
placeholder="Scan the panel box QR code"
|
||||
{{-- autofocus --}}
|
||||
onload="this.focus(); this.select();"
|
||||
{{-- onfocus="this.select();" --}}
|
||||
/>
|
||||
|
||||
<div class="flex justify-end gap-2 mt-4">
|
||||
<button type="button" wire:click="cancelCapacitorInput"
|
||||
class="mt-6 ml-10 bg-gray-300 hover:bg-gray-400 px-4 py-2 rounded transition">
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Add this script to focus on the input --}}
|
||||
<script>
|
||||
document.getElementById('capacitorInput').focus();
|
||||
</script>
|
||||
{{-- <script>
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
@this.on('focus-capacitor-input', () => {
|
||||
setTimeout(() => {
|
||||
const el = document.getElementById('capacitorInput');
|
||||
if (el) el.focus();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
</script> --}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Modal for material invoice--}}
|
||||
@if($materialInvoice)
|
||||
{{-- <div class="flex justify-center overflow-x-auto overflow-y-visible" style="height: 385px;"> --}}
|
||||
<div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
|
||||
{{-- <table class="min-w-full text-sm text-center border border-gray-300"> --}}
|
||||
<table class="min-w-full mx-auto text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Material Code</th>
|
||||
<th class="border px-4 py-2">Material Type</th>
|
||||
<th class="border px-4 py-2">Material Quantity</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Batch Number</th>
|
||||
<th class="border px-4 py-2">TimeStamp</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($invoiceData as $index => $row)
|
||||
<tr class="border-t">
|
||||
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['code'] ?? 'N/A' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['material_type'] ?? 'N/A' }}</td>
|
||||
<td class="border px-4 py-2">
|
||||
@if(($row['material_type'] ?? '') === 'Individual' || ($row['material_type'] ?? '') === 'Bundle')
|
||||
{{ number_format((float)($row['quantity'] ?? 0), 0) }}
|
||||
@else
|
||||
{{ $row['quantity'] ?? 'N/A' }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['batch_number'] ?? 'N/A' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['created_at'] ?? 'N/A' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['operator_id'] ?? 'N/A' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="text-center py-4 text-gray-500">
|
||||
No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
{{-- <script>
|
||||
// Clear input and set focus on form load
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const input = document.getElementById('capacitorInput');
|
||||
input.value = ''; // Clear the input field
|
||||
input.focus(); // Set focus to the input field
|
||||
});
|
||||
</script> --}}
|
||||
<script>
|
||||
window.addEventListener('focus-capacitor-input', () => {
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('capacitorInput');
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
|
||||
window.addEventListener('focus-serial-number', () => {
|
||||
setTimeout(() => {
|
||||
const container = document.getElementById('serial_number_input');
|
||||
const input = container?.querySelector('input'); // gets the actual input inside
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
|
||||
window.addEventListener('focus-invoice-number', () => {
|
||||
setTimeout(() => {
|
||||
const container = document.getElementById('invoice_number_input');
|
||||
const input = container?.querySelector('input'); // gets the actual input inside
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -61,9 +61,11 @@
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">No</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Plant</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Line</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Target Quantity</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Line Type</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Capacity Quantity</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Target Quantity</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Production Quantity</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">OverAll Efficiency(%)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -72,9 +74,11 @@
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['no'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['plant'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['line'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['targetQuantity'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['type'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['capacityQuantity'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['targetQuantity'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['productionQuantity'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['efficiency'] }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
// Total fixed space
|
||||
$fixedSpace = $titleHeight +
|
||||
(5 * $headerRowHeight) + // 6 header rows
|
||||
(5 * $headerRowHeight) +
|
||||
$itemHeaderHeight +
|
||||
$grossWeightHeight +
|
||||
$netWeightHeight +
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
$itemRowHeight = floor(($spaceForItemsOnly / $numItems) * 10) / 10;
|
||||
|
||||
// $itemRowHeight -= 0.5;
|
||||
$itemRowHeight -= 0.5;
|
||||
if ($numItems == 1) {
|
||||
$itemRowHeight -= 0.5;
|
||||
}
|
||||
@@ -79,18 +79,19 @@
|
||||
$compensatedNetHeight = $netWeightHeight - 0.6;
|
||||
$compensatedLicenseHeight = $licenseHeight - 0.6;
|
||||
$compensatedCompanyHeight = $companyInfoHeight - 0.6;
|
||||
|
||||
$qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||
QrCode::format('png')
|
||||
->size(120) // 12mm ~ 120px
|
||||
->margin(0)
|
||||
->generate($pallet)
|
||||
// $qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||
// QrCode::format('png')
|
||||
// ->size(120) // 12mm ~ 120px
|
||||
// ->margin(0)
|
||||
// ->generate($pallet)
|
||||
// $qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||
// QrCode::format('png')
|
||||
// \SimpleSoftwareIO\QrCode\Facades\QrCode::format('png')
|
||||
// ->size(120)
|
||||
// ->margin(0)
|
||||
// ->errorCorrection('H')
|
||||
// ->generate($pallet)
|
||||
// );
|
||||
);
|
||||
@endphp
|
||||
|
||||
<style>
|
||||
|
||||
@@ -34,8 +34,9 @@ use App\Http\Controllers\StickerMasterController;
|
||||
use App\Http\Controllers\TestingPanelController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\VehicleController;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Http\Request;
|
||||
// use App\Http\Controllers\VehicleController;
|
||||
// use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
// use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
// Route::get('/user', function (Request $request) {
|
||||
@@ -135,9 +136,13 @@ Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 's
|
||||
|
||||
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
|
||||
|
||||
// User Controller
|
||||
|
||||
Route::get('user/get-data', [UserController::class, 'get_user_data']);
|
||||
|
||||
// Testing panel Controller
|
||||
|
||||
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']);
|
||||
Route::get('testing/user/get-data', [UserController::class, 'get_user_data']);
|
||||
|
||||
Route::get('testing/item/get-master-data', [TestingPanelController::class, 'get_motor_master']);
|
||||
|
||||
@@ -169,7 +174,7 @@ Route::get('laser/characteristics/check', [CharacteristicsController::class, 'ch
|
||||
|
||||
Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// ..serial (auto or manual)
|
||||
// ..Marked serial (auto or manual)
|
||||
|
||||
Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user