fix conflict issue in sticker pdf service #210

Merged
jothi merged 1 commits from ranjith-dev into master 2026-09-20 05:23:03 +00:00
42 changed files with 3844 additions and 1966 deletions

View File

@@ -34,6 +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 . ' - Target Plan';
$headings[] = $date . ' - Produced Quantity';
}
@@ -43,19 +44,17 @@ class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
public function map($row): array
{
$mapped = [
$mapped = [
$row['plant_name'] ?? '',
$row['line_name'] ?? '',
$row['item_code'] ?? '',
];
// Add daily target and produced quantity for each date
foreach ($this->dates as $date) {
// $mapped[] = $row['daily_target_dynamic'] ?? 0;
$mapped[] = $row['daily_line_capacity'][$date] ?? '-';
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
$mapped[] = $row['produced_quantity'][$date] ?? 0;
$mapped[] = $row['produced_quantity'][$date] ?? '-';
}
return $mapped;
}

View File

@@ -24,32 +24,41 @@ class ProcessOrderExporter extends Exporter
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('line.name')
->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')
->label('SFG NUMBER'),
ExportColumn::make('machine_name')
->label('MACHINE ID'),
->label('MACHINE NAME'),
ExportColumn::make('scrap_quantity')
->label('SCRAP QUANTITY'),
ExportColumn::make('rework_status')
->label('REWORK STATUS'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -3,13 +3,16 @@
namespace App\Filament\Imports;
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;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class ProcessOrderImporter extends Importer
@@ -22,10 +25,15 @@ 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('Poly Wrapped Wire SFG')
->label('LINE NAME')
->relationship(resolveUsing: 'name'),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('ITEM CODE')
@@ -34,68 +42,393 @@ class ProcessOrderImporter extends Importer
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('process_order')
->requiredMapping()
->exampleHeader('PROCESS ORDER')
->example('202500123456')
->example('202601123456')
->label('PROCESS ORDER')
->rules(['required']),
ImportColumn::make('order_quantity')
->requiredMapping()
->exampleHeader('ORDER QUANTITY')
->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')
->label('RECEIVED QUANTITY'),
ImportColumn::make('sfg_number')
->exampleHeader('SFG NUMBER')
// ->example('200000220613-72')
->label('SFG NUMBER'),
ImportColumn::make('machine_name')
->exampleHeader('MACHINE NAME')
// ->example('WMIWRM13 - 2-L2')
->label('MACHINE NAME'),
ImportColumn::make('scrap_quantity')
->exampleHeader('SCRAP QUANTITY')
// ->example('0')
->label('SCRAP QUANTITY'),
ImportColumn::make('rework_status')
->exampleHeader('REWORK STATUS')
// ->example('0')
->label('REWORK STATUS'),
ImportColumn::make('created_at')
->exampleHeader('CREATED AT')
// ->example('2026-02-20 13:00:00')
->label('CREATED AT'),
ImportColumn::make('updated_at')
->exampleHeader('UPDATED AT')
// ->example('2026-02-20 13:00:00')
->label('UPDATED AT'),
ImportColumn::make('created_by')
->exampleHeader('CREATED BY')
->example('RAW01234')
->label('CREATED BY')
->rules(['required']),
// ->example('RAW01234')
->label('CREATED BY'),
ImportColumn::make('updated_by')
->exampleHeader('UPDATED BY')
// ->example('RAW01234')
->label('UPDATED BY'),
];
}
public function resolveRecord(): ?ProcessOrder
{
$warnMsg = [];
$plant = Plant::where('code', $this->data['plant'])->first();
$itemCode = Item::where('code', $this->data['item'])->first();
$iCode = trim($this->data['item']);
if (! $plant) {
$warnMsg[] = 'Plant not found';
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
$warnMsg[] = 'Invalid item code found';
} elseif (! $itemCode) {
$warnMsg[] = 'Item Code not found';
}
$plant = null;
$plantCod = trim($this->data['plant']) ?? '';
$plantId = null;
$iCode = trim($this->data['item']) ?? '';
$itemId = null;
$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'] ?? '');
$createdAt = trim($this->data['created_at'] ?? '');
$createdBy = trim($this->data['created_by'] ?? '');
$updatedAt = trim($this->data['updated_at'] ?? '');
$updatedBy = trim($this->data['updated_by'] ?? '');
// $user = Filament::auth()->user();
// $operatorName = $user->name;
if ($processOrder == '') {
$warnMsg[] = 'Process Order cannot be empty';
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,6}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found';
}
if ($iCode == null || $iCode == '') {
$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 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 can't be empty!";
} elseif ($orderQuan == 0 || $orderQuan == '0') {
$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!';
}
$user = User::where('name', $this->data['created_by'])->first();
if (! $user) {
$warnMsg[] = 'User not found';
if ($coilNo == null || $coilNo == '') {
$coilNo = '0';
}
if ($plant && $processOrder != '') {
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
->where('process_order', $processOrder)
->first();
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
}
if ($scrapQuan == null || $scrapQuan == '') {
$scrapQuan = 0;
}
if ($recQuan == null || $recQuan == '') {
$recQuan = 0;
}
if ($reworkStatus == null || $reworkStatus = '' || $reworkStatus == 0 || $reworkStatus = '0') {
$reworkStatus = 0;
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
$reworkStatus = 1;
} else {
$warnMsg[] = 'Invalid rework status found!';
}
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return ProcessOrder::create([
'plant_id' => $plant->id,
'item_id' => $itemCode->id,
'process_order' => trim($this->data['process_order']),
'coil_number' => '0',
'order_quantity' => 0,
'received_quantity' => 0,
'created_by' => $user->name,
]);
$plant = Plant::where('code', $plantCod)->first();
if (! $plant) {
$warnMsg[] = 'Plant not found!';
} else {
$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;
}
}
}
$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!';
}
// $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!';
// }
if (! $createdBy) {
$createdBy = Filament::auth()->user()->name;
$updatedBy = Filament::auth()->user()->name;
} elseif (! $updatedBy) {
$updatedBy = Filament::auth()->user()->name;
}
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
$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(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'process_order' => $processOrder,
'item_id' => $itemId,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
'created_at' => $createdAt,
'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->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,
]);
}
} else {
$coilNo = '0';
// $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([
'plant_id' => $plantId,
'line_id' => $lineId,
'item_id' => $itemId,
'process_order' => $processOrder,
'coil_number' => '0',
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => 0,
'scrap_quantity' => 0,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]);
} elseif (! $existing) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'item_id' => $itemId,
'process_order' => $processOrder,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan ?? 0,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
// 'created_at' => $createdAt,
// 'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {// $coilNo = '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,
]);
}
}
}
return null;
// return new ProcessOrder();
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,7 @@ use Filament\Forms\Components\ViewField;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Hidden;
use Illuminate\Support\Facades\Auth;
class ProductionCalender extends Page
{
@@ -160,4 +161,9 @@ class ProductionCalender extends Page
}
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production calender page');
}
}

View File

@@ -403,6 +403,9 @@ class ProductionQuantityPage extends Page implements HasForms
public function processMachine($value)
{
$plantId = $this->pId;
$plantCode = Plant::find($plantId);
$PlaCo = $plantCode->code;
$this->mNam = $value;
$now = Carbon::now()->format('H:i:s');
@@ -412,6 +415,72 @@ class ProductionQuantityPage extends Page implements HasForms
$machine = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->with('line.block')->first();
$machinenotAgaPlant = Machine::where('work_center', $this->mNam)->first();
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
if (!$machinenotAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found")
->danger()
->send();
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
'shift_id' => $this->sNam,
'line_id' => $this->lNam,
'item_id' => null,
'serial_number' => null,
'success_msg' => null,
'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
else if (!$machineAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found against plant code $PlaCo")
->danger()
->send();
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
'shift_id' => $this->sNam,
'line_id' => $this->lNam,
'item_id' => null,
'serial_number' => null,
'success_msg' => null,
'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
$rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first();
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;
}
if ($machine) {
$this->lNam = Line::where('id', $machine->line_id)->value('name');
$this->bNam = $machine->line->block->name ?? null;
@@ -436,15 +505,6 @@ class ProductionQuantityPage extends Page implements HasForms
'recent_qr' => $this->recQr,
]);
$this->triggerChartUpdate();
} else {
Notification::make()
->title('Unknown WorkCenter')
->body('Work Center not found')
->danger()
->send();
return;
}
}
@@ -1065,46 +1125,6 @@ class ProductionQuantityPage extends Page implements HasForms
$iCode = trim($splits[0]);
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
// $machine = Machine::where('work_center', $this->mNam)->where('plant_id', $this->pId)->first();
// $this->mId = $machine->id;
// $lineId = $machine->line_id;
// $this->lId = $lineId;
// $line = Line::find($lineId);
// if (! $line) {
// Notification::make()
// ->title('Invalid Line')
// ->body('Line associated with the machine not found.')
// ->danger()
// ->send();
// return;
// }
// $blockId = $line->block_id;
// $this->bId = $blockId;
// $shift = Shift::where('block_id', $blockId)->first();
// if (! $shift) {
// Notification::make()
// ->title('No Shift Found')
// ->body('No shift associated with this block.')
// ->danger()
// ->send();
// return;
// }
// $shiftId = $shift->id;
// $this->sId = $shiftId;
// $line = Line::with('block')->find($lineId);
// $lineName = $line?->name;
// $blockName = $line?->block?->name;
// $shiftName = $shift?->name;
if (! ctype_alnum($iCode)) {
@@ -1121,7 +1141,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1145,7 +1165,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1169,7 +1189,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1194,7 +1214,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1221,7 +1241,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1376,13 +1396,10 @@ class ProductionQuantityPage extends Page implements HasForms
->title('Invalid QR Found') // {$operatorName}
->body('Please, scan the valid QR code.')
->danger()
// ->persistent()
->send();
return;
} else {
// // Perform any additional processing or database operations
// $this->saveFormData($formValues);
$parts = explode('|', $this->qrData);
$itemCode = trim($parts[0]);
@@ -1467,7 +1484,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
return;
@@ -1489,7 +1506,6 @@ class ProductionQuantityPage extends Page implements HasForms
// $this->recent_qr = $itemCode.' | '.$this->sNoId;
// after success insertion
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
@@ -1502,7 +1518,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $itemCode.' | '.$this->sNoId,
]);
Notification::make()

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@ use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
class ProductionTarget extends Page
{
@@ -30,13 +31,16 @@ class ProductionTarget extends Page
->schema([
Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
// ->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::pluck('name', 'id')->toArray();
})
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
// dd($state);
$set('line_id', null);
$set('year', null);
$set('month', null);
@@ -45,6 +49,8 @@ class ProductionTarget extends Page
Select::make('line_id')
->label('Line')
->required()
->relationship('line', 'name')
// ->searchable()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
@@ -58,6 +64,8 @@ class ProductionTarget extends Page
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$plantId, $state, '', '');
@@ -65,7 +73,9 @@ class ProductionTarget extends Page
Select::make('year')
->label('Year')
->reactive()
// ->searchable()
->options([
'2025' => '2025',
'2026' => '2026',
'2027' => '2027',
'2028' => '2028',
@@ -93,6 +103,7 @@ class ProductionTarget extends Page
Select::make('month')
->label('Month')
->reactive()
// ->searchable()
->options([
'01' => 'January',
'02' => 'February',
@@ -170,4 +181,9 @@ class ProductionTarget extends Page
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production target page');
}
}

View File

@@ -61,14 +61,55 @@ class RfqDashboard extends Page
// session()->forget('rfq_number');
// }),
// Select::make('rfq_number')
// ->label('Select RFQ Number')
// ->reactive()
// ->options(function (callable $get) {
// return RequestQuotation::orderBy('rfq_number')
// ->pluck('rfq_number', 'id')
// ->toArray();
// })
// ->afterStateUpdated(function ($state, callable $set) {
// session(['rfq_id' => $state]);
// $set('transport_name', null);
// session()->forget('transport_name');
// }),
Select::make('rfq_number')
->label('Select RFQ Number')
->reactive()
->options(function (callable $get) {
->options(function () {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
$user = Filament::auth()->user();
if ($user?->hasAnyRole(['Super Admin', 'RFQ Supervisor'])) {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
}
$userName = $user?->name;
$masterIds = \App\Models\SpotRateTransportMaster::whereRaw(
"user_name::jsonb @> ?",
[json_encode([$userName])]
)
->pluck('id')
->unique()
->toArray();
if (empty($masterIds)) {
return [];
}
return RequestQuotation::whereIn(
'spot_rate_transport_master_id',
$masterIds
)
->orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
session(['rfq_id' => $state]);

View File

@@ -10,6 +10,8 @@ class Welcome extends Page
protected static string $view = 'filament.pages.welcome';
protected static ?string $navigationGroup = 'IIOT';
public function getHeading(): string
{
return '';

View File

@@ -139,7 +139,7 @@ class CreateInvoiceValidation extends CreateRecord
$user1 = Filament::auth()->user();
$user1->notify(new PushAlertNotification());
// $user1->notify(new PushAlertNotification());
$this->form->fill([
'plant_id' => $plantId,

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Resources;
use App\Filament\Exports\ItemCharacteristicExporter;
use App\Filament\Imports\ItemCharacteristicImporter;
use App\Filament\Resources\ItemCharacteristicResource\Pages;
use App\Filament\Resources\ItemCharacteristicResource\RelationManagers;
use App\Models\Item;
@@ -15,6 +17,8 @@ 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 ItemCharacteristicResource extends Resource
{
@@ -924,6 +928,22 @@ class ItemCharacteristicResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->label('Import Item Characteristics')
->color('warning')
->importer(ItemCharacteristicImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import item characteristics');
}),
ExportAction::make()
->label('Export Item Characteristics')
->color('warning')
->exporter(ItemCharacteristicExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export item characteristics');
}),
]);
}

View File

@@ -82,9 +82,6 @@ class ItemResource extends Resource
Forms\Components\TextInput::make('category')
->label('Category')
->placeholder('Scan the Category'),
Forms\Components\TextInput::make('category')
->label('Category')
->placeholder('Scan the Category'),
Forms\Components\TextInput::make('code')
->required()
->placeholder('Scan the valid code')

View File

@@ -216,7 +216,10 @@ class LineResource extends Resource
])
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('line_capacity')
->label('Line Capacity')
->required()
->reactive(),
Forms\Components\TextInput::make('no_of_operation')
->label('No of Operation')
->required()
@@ -1061,6 +1064,11 @@ class LineResource extends Resource
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('line_capacity')
->label('Line Capacity')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('no_of_operation')
->label('No of Operation')
->alignCenter()

View File

@@ -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,
]);
}
}

View File

@@ -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 [

View File

@@ -437,7 +437,7 @@ class ProductionPlanResource extends Resource
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('line.name')
->label('Plant')
->label('Line')
->alignCenter()
->sortable()
->searchable(),
@@ -476,7 +476,6 @@ class ProductionPlanResource extends Resource
// ->label('Shift')
// ->alignCenter()
// ->sortable(), // ->searchable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()

View File

@@ -158,9 +158,6 @@ class EditRfqTransporterBid extends EditRecord
$body
));
}
}
protected function getHeaderActions(): array

View File

@@ -15,6 +15,9 @@ use Storage;
use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire;
use Str;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
class CreateSerialValidation extends CreateRecord
{
@@ -67,6 +70,8 @@ class CreateSerialValidation extends CreateRecord
$invoiceNumber = trim($invoiceNumber);
$parts = explode('.', $invoiceNumber);
$this->showCapacitorInput = false;
$user = Filament::auth()->user();
@@ -90,9 +95,60 @@ class CreateSerialValidation extends CreateRecord
//..GET SERIAL INVOICE API
// $decodedJwt = JWT::decode($invoiceNumber, new Key('dummy_key', 'HS256')); // replace 'dummy_key' with actual key if needed
// if (!$decodedJwt || !isset($decodedJwt->data)) {
// Notification::make()
// ->title("Invalid e-Invoice QR data or format received...")
// ->info()
// ->seconds(1)
// ->send();
// return;
// }
// $documentData = $decodedJwt->data; // This should be JSON string containing DocNo
// // Extract DocNo using regex
// preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
// if (isset($matches[1])) {
// $this->invoiceNumber = $matches[1];
// } else {
// Notification::make()
// ->title("DocNo not found in QR data...")
// ->info()
// ->seconds(1)
// ->send();
// return;
// }
//..
// Decode JWT payload
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
$payload = json_decode($payloadJson, true);
if (!isset($payload['data'])) {
throw new \Exception('Invalid payload');
}
$documentData = $payload['data'];
// Extract DocNo
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
if (!isset($matches[1])) {
// throw new \Exception('DocNo not found');
}
if (isset($matches[1])) {
$invoiceNumber = $matches[1];
//dd($invoiceNumber);
}
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;

View File

@@ -124,36 +124,57 @@ class StickerStructureDetailResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
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.code')
->label('Plant Code')
->alignCenter(),
Tables\Columns\TextColumn::make('itemCharacteristic.item.code')
->label('Item')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_id')
->label('Sticker ID'),
->label('Sticker ID')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_width')
->label('Sticker Width'),
->label('Sticker Width')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_height')
->label('Sticker Height'),
->label('Sticker Height')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_lmargin')
->label('Sticker Left Margin'),
->label('Sticker Left Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_rmargin')
->label('Sticker Right Margin'),
->label('Sticker Right Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_tmargin')
->label('Sticker Top Margin'),
->label('Sticker Top Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_bmargin')
->label('Sticker Bottom Margin'),
->label('Sticker Bottom Margin')
->alignCenter(),
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),

View File

@@ -387,20 +387,179 @@ class CreateStickerValidation extends CreateRecord
// ]);
}
// foreach ($stickers as $sticker) {
// // $printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
// \Log::info("Looking up printer for IP: " . $sticker['print_ip']);
// $printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
// \Log::info("Found printer: " . ($printerName ?? 'NULL'));
// if (! $printerName) {
// Notification::make()
// ->danger()
// ->title('Printer Not Found')
// ->body("No CUPS printer configured for IP: {$sticker['print_ip']}")
// ->send();
// return;
// }
// $structure = StickerStructureDetail::findOrFail($sticker['sticker_id']);
// $itemCharacteristic = ItemCharacteristic::where('plant_id', $this->plantId)
// ->where('id', $sticker['item_characteristic'])
// ->firstOrFail();
// $dynamicElements = StickerDetail::where(
// 'sticker_structure_detail_id',
// $structure->id
// )->where('element_type', 'Dynamic')->get();
// /** STEP 3: Stream PDF to CUPS (STDIN) */
// $process = proc_open(
// 'lp -d ' . escapeshellarg($printerName) . ' -o fit-to-page -',
// [
// ['pipe', 'r'], // STDIN
// ['pipe', 'w'], // STDOUT
// ['pipe', 'w'], // STDERR
// ],
// $pipes
// );
// if (! is_resource($process)) {
// Notification::make()
// ->danger()
// ->title('Print Failed')
// ->body('Unable to start CUPS print process.')
// ->send();
// return;
// // continue;
// }
// $pdfContent = (new StickerPdfService())->generatePdf1(
// $structure->sticker_id,
// $dynamicElements,
// $itemCharacteristic,
// $serialNumber,
// $serNo
// );
// fwrite($pipes[0], $pdfContent);
// fclose($pipes[0]);
// $stderr = stream_get_contents($pipes[2]);
// fclose($pipes[1]);
// fclose($pipes[2]);
// $status = proc_close($process);
// if ($status != 0) {
// Notification::make()
// ->danger()
// ->title('Print Failed')
// ->body("CUPS error: {$stderr}")
// ->send();
// return;
// }
// }
foreach ($stickers as $sticker)
{
\Log::info("Looking up printer for IP: " . $sticker['print_ip']);
$printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
\Log::info("Found printer: " . ($printerName ?? 'NULL'));
if (! $printerName) {
Notification::make()
->danger()
->title('Printer Not Found')
->body("No CUPS printer configured for IP: {$sticker['print_ip']}")
->send();
return;
}
$structure = StickerStructureDetail::findOrFail($sticker['sticker_id']);
$itemCharacteristic = ItemCharacteristic::where('plant_id', $this->plantId)
->where('id', $sticker['item_characteristic'])
->firstOrFail();
$dynamicElements = StickerDetail::where(
'sticker_structure_detail_id',
$structure->id
)->where('element_type', 'Dynamic')->get();
$pdfContent = (new StickerPdfService())->generatePdf1(
$structure->sticker_id,
$dynamicElements,
$itemCharacteristic,
$serialNumber,
$serNo
);
$tempPdfPath = storage_path('app/temp_sticker_' . uniqid() . '.pdf');
file_put_contents($tempPdfPath, $pdfContent);
exec(
"lp -d " . escapeshellarg($printerName) . " " . escapeshellarg($tempPdfPath),
$output,
$status
);
\Log::info("LP Output:", $output);
\Log::info("LP Status: " . $status);
if ($status != 0) {
Notification::make()
->danger()
->title('Print Failed')
->body("CUPS error while printing.")
->send();
if (file_exists($tempPdfPath)) {
unlink($tempPdfPath);
}
return;
}
if (file_exists($tempPdfPath)) {
unlink($tempPdfPath);
}
}
Notification::make()
->success()
->title('Sticker Printed')
->body("Sticker for Serial Number: $serialNumber printed successfully!")
->seconds(3)
->send();
// [$itemCode, $serialNumber] = explode('|', $serNo);
// $this->dispatch('open-sticker-pdf', [
// 'url' => url("/sticker/pdf/{$itemCode}/{$serialNumber}/$this->plantId/$this->ref_number")
// ]);
}
protected function getCupsPrinterNameByIp(string $ip): ?string
{
// exec('lpstat -v 2>&1', $output, $status);
exec('lpstat -h cups:631 -v 2>&1', $output, $status);
if ($status != 0 || empty($output)) {
return null;
}
foreach ($output as $line){
foreach ($output as $line) {
$parts = explode(':', $line, 2);
if (count($parts) < 2) continue;
@@ -411,6 +570,7 @@ class CreateStickerValidation extends CreateRecord
return $printerName;
}
}
return null;
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\ItemCharacteristic;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
@@ -33,29 +34,28 @@ class MachineController extends Controller
public function get_all_data(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)
{
if ('Bearer '.$expectedToken != $header_auth) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!'
'status_description' => 'Invalid authorization token!',
], 403);
}
$machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
$machinesData = $machines->map(function($machine) {
$machines = ItemCharacteristic::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
$machinesData = $machines->map(function ($machine) {
return [
'plant_code' => $machine->plant ? (String)$machine->plant->code : "",
'group_work_center' => $machine->workGroupMaster ? (String)$machine->workGroupMaster->name : "",
'work_center' => $machine->work_center ?? "",
'plant_code' => $machine->plant ? (string) $machine->plant->code : '',
'group_work_center' => $machine->workGroupMaster ? (string) $machine->workGroupMaster->name : '',
'work_center' => $machine->work_center ?? '',
];
});
return response()->json([
'machines' => $machinesData
'machines' => $machinesData,
]);
}
@@ -65,80 +65,70 @@ class MachineController extends Controller
public function get_data(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)
{
if ('Bearer '.$expectedToken != $header_auth) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!'
'status_description' => 'Invalid authorization token!',
], 403);
}
$plantCode = $request->header('plant-code');
$lineName = $request->header('line-name');
if ($plantCode == null || $plantCode == '')
{
if ($plantCode == null || $plantCode == '') {
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 ($lineName == null || $lineName == '' || Str::length($lineName) <= 0)
{
} elseif ($lineName == null || $lineName == '' || Str::length($lineName) <= 0) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line name can't be empty!"
'status_description' => "Line name can't be empty!",
], 400);
}
$plant = Plant::where('code', $plantCode)->first();
if (!$plant)
{
if (! $plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant Code '{$plantCode}' not found!"
'status_description' => "Plant Code '{$plantCode}' not found!",
], 400);
}
$plantId = $plant->id;
$line = Line::where('name', $lineName)->first();
if (!$line)
{
if (! $line) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line Name '{$lineName}' not found!"
'status_description' => "Line Name '{$lineName}' not found!",
], 400);
}
$line = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
if (!$line)
{
if (! $line) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line Name '{$lineName}' not found for the plant!"
'status_description' => "Line Name '{$lineName}' not found for the plant!",
], 400);
}
$lineId = $line->id;//no_of_operation
$lineId = $line->id; // no_of_operation
$lineWorkGroup1Id = $line->work_group1_id;
$lineWorkGroup2Id = $line->work_group2_id;
if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || !is_numeric($line->no_of_operation))
{
if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || ! is_numeric($line->no_of_operation)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Group work center not found for the plant & line!"
'status_description' => 'Group work center not found for the plant & line!',
], 400);
}
@@ -146,26 +136,22 @@ class MachineController extends Controller
$lineWorkGroupIds = [];
for ($i = 1; $i <= $line->no_of_operation; $i++) {
$curWorkGroupId = $line->{"work_group{$i}_id"};
if (in_array($curWorkGroupId, $lineWorkGroupIds))
{
if (in_array($curWorkGroupId, $lineWorkGroupIds)) {
continue;
}
else
{
} else {
$lineWorkGroupIds[] = $curWorkGroupId;
}
$test[] = [
'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? "",
'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? "",
'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? '',
'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? '',
'work_centers' => Machine::where('plant_id', $plantId)->where('work_group_master_id', $curWorkGroupId)->orderBy('work_center')->pluck('work_center')->toArray() ?? [],
];
}
if($lineWorkGroupIds)
{
if ($lineWorkGroupIds) {
return response()->json([
'machines' => $test
'machines' => $test,
]);
}
// $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
@@ -203,7 +189,7 @@ class MachineController extends Controller
/**
* Update the specified resource in storage.
*/
*/
public function update(Request $request, string $id)
{
//

View File

@@ -1034,12 +1034,24 @@ class PdfController extends Controller
->where('id', $itemCharacteristicId)
->first();
return (new StickerPdfService())->generatePdf1(
// return (new StickerPdfService())->generatePdf1(
// $structure->sticker_id,
// $dynamicElements,
// $itemCharacteristic,
// $serialNumber
// );
$pdfBytes = (new StickerPdfService())->generatePdf1(
$structure->sticker_id,
$dynamicElements,
$itemCharacteristic,
$serialNumber
);
// Return as downloadable/streamed PDF
return response($pdfBytes, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="sticker.pdf"');
}
return abort(404);

View File

@@ -44,8 +44,139 @@ class ProductionTargetPlan extends Component
return $dates;
}
public function loadProductionData($plantId, $lineId, $month, $year){
// public function loadProductionData($plantId, $lineId, $month, $year){
// if (!$plantId || !$lineId || !$month || !$year) {
// $this->records = [];
// $this->dates = [];
// $this->leaveDates = [];
// return;
// }
// $this->dates = $this->getMonthDates($month, $year);
// $data = ProductionPlan::query()
// ->join('items', 'items.id', '=', 'production_plans.item_id')
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
// ->where('production_plans.plant_id', $plantId)
// ->where('production_plans.line_id', $lineId)
// ->whereMonth('production_plans.created_at', $month)
// ->whereYear('production_plans.created_at', $year)
// ->select(
// 'production_plans.created_at',
// 'production_plans.operator_id',
// 'plants.name as plant',
// 'items.code as item_code',
// 'items.description as item_description',
// 'lines.name as line_name',
// 'production_plans.leave_dates'
// )
// ->first();
// if ($data && $data->leave_dates) {
// $this->leaveDates = array_map('trim', explode(',', $data->leave_dates));
// }
// $producedData = ProductionQuantity::selectRaw("
// plant_id,
// line_id,
// item_id,
// DATE(created_at) as prod_date,
// COUNT(*) as total_qty
// ")
// ->where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereMonth('created_at', $month)
// ->whereYear('created_at', $year)
// ->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
// ->get()
// ->groupBy(function ($row) {
// return $row->plant_id . '_' . $row->line_id . '_' . $row->item_id;
// })
// ->map(function ($group) {
// return $group->keyBy('prod_date');
// });
// $this->records = ProductionPlan::query()
// ->join('items', 'items.id', '=', 'production_plans.item_id')
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
// ->where('production_plans.plant_id', $plantId)
// ->where('production_plans.line_id', $lineId)
// ->whereMonth('production_plans.created_at', $month)
// ->whereYear('production_plans.created_at', $year)
// ->select(
// 'production_plans.item_id',
// 'production_plans.plant_id',
// 'production_plans.line_id',
// 'production_plans.plan_quantity',
// 'production_plans.working_days',
// 'items.code as item_code',
// 'items.description as item_description',
// 'lines.name as line_name',
// 'plants.name as plant_name'
// )
// ->get()
// ->map(function ($row) use ($producedData) {
// $row = $row->toArray();
// $remainingQty = $row['plan_quantity'];
// // $remainingDays = $row['working_days'];
// $remainingDays = (int) ($row['working_days'] ?? 0);
// $row['daily_target_dynamic'] = [];
// $row['produced_quantity'] = [];
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
// foreach ($this->dates as $date) {
// // Skip leave dates
// if (in_array($date, $this->leaveDates)) {
// $row['daily_target_dynamic'][$date] = '-';
// $row['produced_quantity'][$date] = '-';
// continue;
// }
// $todayTarget = $remainingDays > 0
// ? round($remainingQty / $remainingDays, 2)
// : 0;
// //$todayTarget = $remainingDays > 0
// // ? $remainingQty / $remainingDays
// // : 0;
// $producedQty = isset($producedData[$key][$date])
// ? $producedData[$key][$date]->total_qty
// : 0;
// $row['daily_target_dynamic'][$date] = $todayTarget;
// $row['produced_quantity'][$date] = $producedQty;
// // Carry forward pending
// $remainingQty -= $producedQty;
// if ($remainingQty < 0) {
// $remainingQty = 0;
// }
// if ($remainingDays > 0) {
// $remainingDays--;
// }
// // $remainingDays--;
// }
// return $row;
// })
// ->toArray();
// }
public function loadProductionData($plantId, $lineId, $month, $year)
{
if (!$plantId || !$lineId || !$month || !$year) {
$this->records = [];
$this->dates = [];
@@ -53,52 +184,10 @@ class ProductionTargetPlan extends Component
return;
}
$this->dates = $this->getMonthDates($month, $year);
$dates = $this->getMonthDates($month, $year);
$this->dates = $dates;
$data = ProductionPlan::query()
->join('items', 'items.id', '=', 'production_plans.item_id')
->join('lines', 'lines.id', '=', 'production_plans.line_id')
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
->where('production_plans.plant_id', $plantId)
->where('production_plans.line_id', $lineId)
->whereMonth('production_plans.created_at', $month)
->whereYear('production_plans.created_at', $year)
->select(
'production_plans.created_at',
'production_plans.operator_id',
'plants.name as plant',
'items.code as item_code',
'items.description as item_description',
'lines.name as line_name',
'production_plans.leave_dates'
)
->first();
if ($data && $data->leave_dates) {
$this->leaveDates = array_map('trim', explode(',', $data->leave_dates));
}
$producedData = ProductionQuantity::selectRaw("
plant_id,
line_id,
item_id,
DATE(created_at) as prod_date,
COUNT(*) as total_qty
")
->where('plant_id', $plantId)
->where('line_id', $lineId)
->whereMonth('created_at', $month)
->whereYear('created_at', $year)
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
->get()
->groupBy(function ($row) {
return $row->plant_id . '_' . $row->line_id . '_' . $row->item_id;
})
->map(function ($group) {
return $group->keyBy('prod_date');
});
$this->records = ProductionPlan::query()
$plans = ProductionPlan::query()
->join('items', 'items.id', '=', 'production_plans.item_id')
->join('lines', 'lines.id', '=', 'production_plans.line_id')
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
@@ -112,111 +201,96 @@ class ProductionTargetPlan extends Component
'production_plans.line_id',
'production_plans.plan_quantity',
'production_plans.working_days',
'production_plans.leave_dates',
'items.code as item_code',
'items.description as item_description',
'lines.name as line_name',
'lines.line_capacity as line_capacity',
'plants.name as plant_name'
)
->get();
$leaveDates = [];
if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
$leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
}
$this->leaveDates = $leaveDates;
$producedData = ProductionQuantity::selectRaw("
plant_id,
line_id,
item_id,
DATE(created_at) as prod_date,
COUNT(*) as total_qty
")
->where('plant_id', $plantId)
->where('line_id', $lineId)
->whereMonth('created_at', $month)
->whereYear('created_at', $year)
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
->get()
// ->map(function ($row) use ($producedData) {
// $row = $row->toArray();
->groupBy(fn($row) =>
$row->plant_id . '_' . $row->line_id . '_' . $row->item_id
)
->map(fn($group) => $group->keyBy('prod_date'));
// $row['daily_target'] = ($row['working_days'] > 0)
// ? round($row['plan_quantity'] / $row['working_days'], 2)
// : 0;
// // $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
$records = [];
// // foreach ($this->dates as $date) {
// // $found = $producedData[$key][$date] ?? null;
// // $row['produced_quantity'][$date] = $found->total_qty ?? 0;
// // }
foreach ($plans as $plan) {
// $remainingDays = $row['working_days'];
// $pendingQty = 0;
$row = $plan->toArray();
// $row['daily_target_dynamic'] = [];
// $row['produced_quantity'] = [];
$remainingQty = (float) $row['plan_quantity'];
$remainingDays = (int) ($row['working_days'] ?? 0);
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
$dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
// foreach ($this->dates as $date) {
// $found = $producedData[$key][$date] ?? null;
// $producedQty = $found->total_qty ?? 0;
$row['daily_line_capacity'] = [];
$row['daily_target_dynamic'] = [];
$row['produced_quantity'] = [];
// // today's adjusted target
// $todayTarget = $baseDailyTarget;
$key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
// if ($remainingDays > 1 && $pendingQty > 0) {
// $todayTarget += $pendingQty / $remainingDays;
// }
foreach ($dates as $date) {
// $row['daily_target_dynamic'][$date] = round($todayTarget, 2);
// $row['produced_quantity'][$date] = $producedQty;
// // calculate today's shortfall
// $pendingQty += ($todayTarget - $producedQty);
// if ($pendingQty < 0) {
// $pendingQty = 0;
// }
// $remainingDays--;
// }
// return $row;
// })
->map(function ($row) use ($producedData) {
$row = $row->toArray();
$remainingQty = $row['plan_quantity'];
$remainingDays = $row['working_days'];
$row['daily_target_dynamic'] = [];
$row['produced_quantity'] = [];
$key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
foreach ($this->dates as $date) {
// Skip leave dates
if (in_array($date, $this->leaveDates)) {
$row['daily_target_dynamic'][$date] = '-';
$row['produced_quantity'][$date] = '-';
continue;
}
$todayTarget = $remainingDays > 0
? round($remainingQty / $remainingDays, 2)
: 0;
//$todayTarget = $remainingDays > 0
// ? $remainingQty / $remainingDays
// : 0;
$producedQty = isset($producedData[$key][$date])
? $producedData[$key][$date]->total_qty
: 0;
$row['daily_target_dynamic'][$date] = $todayTarget;
$row['produced_quantity'][$date] = $producedQty;
// Carry forward pending
$remainingQty -= $producedQty;
if ($remainingQty < 0) {
$remainingQty = 0;
}
$remainingDays--;
// Skip leave dates fast
if (isset($leaveDates) && in_array($date, $leaveDates)) {
$row['daily_line_capacity'][$date] = '-';
$row['daily_target_dynamic'][$date] = '-';
$row['produced_quantity'][$date] = '-';
continue;
}
return $row;
})
->toArray();
$todayTarget = $remainingDays > 0
? round($remainingQty / $remainingDays, 2)
: 0;
$producedQty = $producedData[$key][$date]->total_qty ?? 0;
$row['daily_target_dynamic'][$date] = $todayTarget;
$row['produced_quantity'][$date] = $producedQty;
$row['daily_line_capacity'][$date] = $dailyLineCapacity;
// Carry forward remaining qty
$remainingQty = max(0, $remainingQty - $producedQty);
if ($remainingDays > 0) {
$remainingDays--;
}
}
$records[] = $row;
}
$this->records = $records;
}
public function exportProductionData()
{
return Excel::download(

View File

@@ -16,6 +16,7 @@ class Line extends Model
"block_id",
"name",
"type",
"line_capacity",
"group_work_center",
"no_of_operation",
"work_group1_id",

View File

@@ -23,7 +23,8 @@ class ProductionQuantity extends Model
"serial_number",
"production_order",
"operator_id",
// "success_status",
"success_status",
"reject_reason",
// "no_of_employee",
// "list_of_employee",
"created_at",

View File

@@ -37,4 +37,9 @@ class StickerStructureDetail extends Model
return $this->belongsTo(ItemCharacteristic::class, 'item_characteristic_id');
}
public function item(): BelongsTo
{
return $this->belongsTo(Item::class, 'item_id');
}
}

View File

@@ -2,10 +2,13 @@
namespace App\Providers;
use App\Filament\Pages\NotificationSettings;
use App\Models\AlertMailRule;
use App\Models\User;
use App\Policies\PermissionPolicy;
use App\Policies\RolePolicy;
use DB;
use Filament\Facades\Filament;
use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Console\Scheduling\Schedule;
@@ -40,6 +43,16 @@ class AppServiceProvider extends ServiceProvider
// $view->with('forgotPasswordUrl', route('password.request'));
// });
DB::listen(function ($query) {
if ($query->time > 1000) { // > 1 sec
logger()->warning('Slow query', [
'sql' => $query->sql,
'time' => $query->time
]);
}
});
Gate::before(function (User $user, string $ability) {
return $user->isSuperAdmin() ? true : null;
});

View File

@@ -895,7 +895,8 @@ class StickerPdfService
if (
($row->element_type) == 'Dynamic'
) {
$qrContent = $serNo ?? '';
$qrContent = $itemCode . '|' . ($serNo ?? '');
$pdf->write2DBarcode(
$qrContent,
'QRCODE,H',
@@ -1018,22 +1019,9 @@ class StickerPdfService
}
}
// $pdfContent = $pdf->Output('', 'S'); // 'S' returns string
// // Encode as base64
// return base64_encode($pdfContent);
// $pdfContent = $pdf->Output('', 'S');
// return response($pdfContent)
// ->header('Content-Type', 'application/pdf')
// ->header('Content-Disposition', 'inline; filename="sticker.pdf"');
$pdfContent = $pdf->Output('', 'S'); // 'S' returns the PDF as a string
// Return the PDF as a response
try {
$pdfContent = $pdf->Output('', 'S'); // 'S' returns the PDF as a string
$pdfContent = $pdf->Output('', 'S');
return response($pdfContent)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="sticker.pdf"');

View File

@@ -19,7 +19,7 @@ return new class extends Migration
production_order TEXT DEFAULT NULL,
serial_number TEXT DEFAULT NULL,
status TEXT DEFAULT NULL,
sticker_id TEXT DEFAULT NULL
sticker_id TEXT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),

View File

@@ -171,5 +171,17 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view import sticker printing']);
Permission::updateOrCreate(['name' => 'view export sticker printing']);
Permission::updateOrCreate(['name' => 'view import request quotation']);
Permission::updateOrCreate(['name' => 'view export request quotation']);
Permission::updateOrCreate(['name' => 'view rfq dashboard']);
Permission::updateOrCreate(['name' => 'view rfq overview dashboard']);
Permission::updateOrCreate(['name' => 'view production calender page']);
Permission::updateOrCreate(['name' => 'view production target page']);
}
}

915
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@
"dev": "vite"
},
"devDependencies": {
"@vitejs/plugin-react": "^5.1.2",
"autoprefixer": "^10.4.20",
"axios": "^1.7.4",
"chartjs-plugin-datalabels": "^2.2.0",
@@ -14,5 +15,9 @@
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
"vite": "^6.0.11"
},
"dependencies": {
"react": "^19.2.3",
"react-dom": "^19.2.3"
}
}

View File

@@ -115,3 +115,5 @@ $sticker_id = $attributes->get('sticker_id');

View File

@@ -1,19 +1,96 @@
<x-filament-panels::page>
<h1 class="text-3xl font-bold mb-6">Welcome to CRI Digital Manufacturing IIOT</h1>
<!-- 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>
<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-64 object-cover"
>
</div>
<!-- BANNER -->
<div class="w-full overflow-hidden rounded-2xl shadow mb-10">
<img
src="{{ asset('images/iiot-banner.jpg') }}"
alt="CRI Digital Manufacturing IIoT"
class="w-full h-72 object-cover"
>
</div>
<p class="text-lg text-gray-600 mb-6">
This dashboard provides real-time visibility into your manufacturing operations,
enabling you to monitor production, track performance, and make data-driven decisions
across plants and lines—all from one centralized platform.
</p>
<!-- 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 Contact: <span class="font-semibold">+91 8925899458 / +91 8925899459</span>
</p>
{{-- <p class="text-lg font-medium text-gray-900">
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
</p> --}}
</div>
<!-- TEAM -->
<div class="bg-white rounded-xl border p-6 shadow-sm">
<h2 class="text-2xl font-semibold mb-4">Our Team</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">👤 Dhanabalan</div>
<div class="flex items-center gap-2">👤 Shibu</div>
<div class="flex items-center gap-2">👤 Ranjith</div>
<div class="flex items-center gap-2">👤 Srimathi</div>
<div class="flex items-center gap-2">👤 Gokul</div>
</div>
</div>
</x-filament-panels::page>

View File

@@ -67,3 +67,29 @@ window.addEventListener('open-stickers-sequence', async (event) => {
});
</script>
<script>
window.addEventListener('open-sticker-pdf', event => {
console.log('PDF event:', event.detail);
let url = null;
// Livewire v3 wraps payload in array
if (Array.isArray(event.detail)) {
url = event.detail[0]?.url;
}
// fallback (if direct object comes)
else if (event.detail?.url) {
url = event.detail.url;
}
if (url) {
window.open(url, '_blank');
} else {
console.error('PDF URL missing', event.detail);
}
});
</script>

View File

@@ -64,88 +64,58 @@ document.addEventListener('DOMContentLoaded', function () {
});
// var calendar = new FullCalendar.Calendar(calendarEl, {
// initialView: 'dayGridMonth',
// height: 600,
// showNonCurrentDates: true,
// function updateWorkingDays(date) {
// let totalDays = new Date(
// date.getFullYear(),
// date.getMonth()+1,
// 0
// ).getDate();
// dateClick: function(info) {
// let workingDays = totalDays - selectedDates.length;
// // document.querySelector('input[name="working_days"]').value = workingDays;
// let viewMonth = calendar.view.currentStart.getMonth();
// let clickedMonth = info.date.getMonth();
// const input = document.querySelector('#working_days');
// // let month = info.date.getMonth() + 1; // JS month: 0-11 → 1-12
// // let year = info.date.getFullYear();
// input.value = workingDays;
// if (viewMonth != clickedMonth) {
// return; // Ignore next/prev month dates
// }
// input.dispatchEvent(new Event('input'));
// let dateStr = info.dateStr;
// const monthInput = document.querySelector('#month');
// monthInput.value = date.getMonth() + 1; // 112 month number
// monthInput.dispatchEvent(new Event('input'));
// if (selectedDates.includes(dateStr)) {
// selectedDates = selectedDates.filter(d => d !== dateStr);
// const yearInput = document.querySelector('#year');
// yearInput.value = date.getFullYear();
// yearInput.dispatchEvent(new Event('input'));
// calendar.getEvents().forEach(event => {
// if (event.startStr == dateStr) {
// event.remove();
// }
// });
// const selectedDatesInput = document.querySelector('#selected_dates');
// selectedDatesInput.value = selectedDates.join(',');
// selectedDatesInput.dispatchEvent(new Event('input'));
// } else {
// selectedDates.push(dateStr);
// calendar.addEvent({
// start: dateStr,
// display: 'background',
// color: '#f03f17'
// });
// }
// updateWorkingDays(info.date);
// }
// });
// yearSelect.addEventListener('change', function () {
// let year = this.value;
// if (!year) return;
// let currentDate = calendar.getDate();
// let newDate = new Date(year, currentDate.getMonth(), 1);
// calendar.gotoDate(newDate);
// });
// }
function updateWorkingDays(date) {
let totalDays = new Date(
date.getFullYear(),
date.getMonth()+1,
date.getMonth() + 1,
0
).getDate();
let workingDays = totalDays - selectedDates.length;
// document.querySelector('input[name="working_days"]').value = workingDays;
const input = document.querySelector('#working_days');
input.value = workingDays;
input.dispatchEvent(new Event('input'));
const monthInput = document.querySelector('#month');
monthInput.value = date.getMonth() + 1; // 112 month number
monthInput.dispatchEvent(new Event('input'));
const yearInput = document.querySelector('#year');
yearInput.value = date.getFullYear();
yearInput.dispatchEvent(new Event('input'));
const selectedDatesInput = document.querySelector('#selected_dates');
selectedDatesInput.value = selectedDates.join(',');
selectedDatesInput.dispatchEvent(new Event('input'));
// Set values only
document.querySelector('#working_days').value = workingDays;
document.querySelector('#month').value = date.getMonth() + 1;
document.querySelector('#year').value = date.getFullYear();
document.querySelector('#selected_dates').value = selectedDates.join(',');
// Trigger only ONE update (important)
document
.querySelector('#selected_dates')
.dispatchEvent(new Event('input'));
}
calendar.render();
});
</script>

View File

@@ -4,17 +4,6 @@
</h2>
<div class="overflow-x-auto rounded-lg shadow">
<table class="w-full divide-y divide-gray-200 text-sm text-center">
{{-- <thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
<tr>
<th class="border px-4 py-2">No</th>
<th class="border px-4 py-2">Created Datetime</th>
<th class="border px-4 py-2 whitespace-nowrap">Created By</th>
<th class="border px-4 py-2 whitespace-nowrap">Plant</th>
<th class="border px-4 py-2">Line</th>
<th class="border px-4 py-2 whitespace-nowrap">Item Code</th>
<th class="border px-4 py-2">Production Plan Dates</th>
</tr>
</thead> --}}
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
<tr>
<th class="border px-4 py-2" rowspan="3">No</th>
@@ -22,21 +11,29 @@
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Line</th>
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Item Code</th>
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 2 }}" class="text-center">
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 3 }}" class="text-center">
Production Plan Dates
</th>
</tr>
<tr>
@foreach($dates as $date)
<th colspan="2" class="text-center">
{{-- <th colspan="3" class="text-center">
{{ $date }}
</th> --}}
<th colspan="3" class="text-center border-r-4 border-gray-400">
{{ $date }}
</th>
@endforeach
</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">Target Plan</th>
<th class="border px-4 py-2 whitespace-nowrap">Produced Quantity</th>
<th class="border px-4 py-2 whitespace-nowrap border-r-4 border-gray-400">
Produced Quantity
</th>
{{-- <th class="border px-4 py-2 whitespace-nowrap">Produced Quantity</th> --}}
@endforeach
</tr>
</thead>
@@ -58,8 +55,12 @@
@if(in_array($date, $leaveDates))
<td class="border px-4 py-2 whitespace-nowrap">-</td>
<td class="border px-4 py-2 whitespace-nowrap">-</td>
<td class="border px-4 py-2 whitespace-nowrap">-</td>
@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] ?? '-' }}
</td>
<td class="border px-4 py-2 whitespace-nowrap">
{{ $record['daily_target_dynamic'][$date] ?? '-' }}
</td>
@@ -72,7 +73,7 @@
</tr>
@empty
<tr>
<td colspan="9" class="px-4 py-4 text-center text-gray-500">
<td colspan="10" class="px-4 py-4 text-center text-gray-500">
No production plan data found.
</td>
</tr>

View File

@@ -12,7 +12,7 @@
<thead class="bg-gray-100 text-xs">
<tr>
<th class="border p-2">No</th>
<th class="border p-2">Sticker ID</th>
{{-- <th class="border p-2">Sticker ID</th> --}}
<th class="border p-2">Production Order</th>
<th class="border p-2">Serial Number</th>
<th class="border p-2">Status</th>
@@ -24,7 +24,7 @@
@forelse($records as $index => $record)
<tr>
<td class="border p-2 text-center">{{ $index + 1 }}</td>
<td class="border p-2 text-center">{{ $record->sticker_id }}</td>
{{-- <td class="border p-2 text-center">{{ $record->sticker_id }}</td> --}}
<td class="border p-2 text-center">{{ $refNumber }}</td>
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
<td class="border p-2 text-center">{{ $record->status }}</td>
@@ -32,7 +32,7 @@
</tr>
@empty
<tr>
<td class="border p-2 text-center" colspan="6">No serial numbers found.</td>
<td class="border p-2 text-center" colspan="5">No serial numbers found.</td>
</tr>
@endforelse
</tbody>

View File

@@ -192,42 +192,4 @@ Route::post('file/store', [SapFileController::class, 'store'])->name('file.store
Route::post('/print-pdf', [PrintController::class, 'print']);
Route::post('/push/subscribe', function (Request $request) {
$user = Filament::auth()->user();
abort_if(!$user, 401);
$request->validate([
'endpoint' => 'required|string',
'keys.p256dh' => 'required|string',
'keys.auth' => 'required|string',
]);
// WebPushSubscription::updateOrCreate(
// ['endpoint' => $request->endpoint],
// [
// 'subscribable_type' => get_class($user),
// 'subscribable_id' => $user->id,
// 'public_key' => $request->keys['p256dh'],
// 'auth_token' => $request->keys['auth'],
// 'content_encoding' => $request->contentEncoding ?? 'aesgcm',
// ]
// );
WebPushSubscription::updateOrCreate(
[
'endpoint' => $request->endpoint,
'subscribable_type' => get_class($user),
'subscribable_id' => $user->id,
],
[
'public_key' => $request->keys['p256dh'],
'auth_token' => $request->keys['auth'],
'content_encoding' => $request->contentEncoding ?? 'aesgcm',
]
);
return response()->json(['success' => true]);
});
Route::get('/sticker/preview/{serial}', [PrintController::class, 'preview']);

View File

@@ -12,7 +12,7 @@ Artisan::command('inspire', function () {
Artisan::command('auto:scheduler', function () {
$this->call('custom:scheduler');
})->everyMinute();
})->everyMinute()->withoutOverlapping();
// Schedule::command('send:invoice-report');

View File

@@ -1,12 +1,32 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/js/filament-chart-js-plugins.js', 'resources/css/filament/admin/theme.css',],
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/js/filament-chart-js-plugins.js', 'resources/css/filament/admin/theme.css'],
// input: ['resources/css/app.css', 'resources/js/app.js',],
refresh: true,
}),
],
});
// export default defineConfig({
// server: {
// host: '127.0.0.1',
// port: 5173,
// },
// plugins: [
// laravel({
// input: [
// 'resources/css/app.css',
// 'resources/js/app.jsx',
// 'resources/js/filament-chart-js-plugins.js',
// 'resources/css/filament/admin/theme.css',
// ],
// refresh: true,
// }),
// react(),
// ],
// })