38 Commits

Author SHA1 Message Date
dhanabalan
063e50da66 Added export functionality via migration 2025-04-08 17:32:46 +05:30
dhanabalan
588299ee8b Commented export button label and format code 2025-04-08 17:31:37 +05:30
dhanabalan
8fe4352df5 Added export functionality 2025-04-08 17:30:43 +05:30
dhanabalan
92f9017b0e Added export functionality 2025-04-08 17:30:20 +05:30
dhanabalan
1ec38f827f Commented enter logic and added export functionality 2025-04-08 17:29:56 +05:30
dhanabalan
c03e55a1fb Commented enter logic 2025-04-08 17:27:59 +05:30
dhanabalan
20a7d06175 Added export column label 2025-04-08 17:26:55 +05:30
dhanabalan
3381cfca7c added migration, model, resource , grid table 2025-04-08 17:26:00 +05:30
dhanabalan
5fd16612fc added quality validation table 2025-04-08 17:22:12 +05:30
dhanabalan
177969399f removed old migration 2025-04-08 17:21:16 +05:30
dhanabalan
ac1dd2388d added bundle quantity and material type columns and import and export functionality 2025-04-08 17:20:12 +05:30
dhanabalan
4ad7a4e524 Added combined unique and default value 2025-04-08 09:19:53 +05:30
dhanabalan
f066794bca Added combined unique and default value 2025-04-08 09:13:14 +05:30
dhanabalan
4685b7fbb8 added columns 2025-04-07 08:43:35 +05:30
dhanabalan
1395b8d0a1 added two columns load rate and panelbox 2025-04-07 08:42:15 +05:30
dhanabalan
34e83282fa redirected to create page after scanning process completed 2025-04-07 08:38:18 +05:30
dhanabalan
e84a2e87b2 Unwanted comments removed 2025-04-06 17:53:56 +05:30
dhanabalan
7ada76a733 Added 'update_date' / 'created_at' column to update night shift plan, auto focus, production plan valid. and shift valid. 2025-04-06 17:52:14 +05:30
dhanabalan
6241aad068 Removed desc. and Added last scanned qr and production plan valid. and shift valid. and warn notification 2025-04-06 17:47:04 +05:30
dhanabalan
0118a19352 Added production quantity update func. in production plan on success production transaction 2025-04-06 17:38:19 +05:30
dhanabalan
448dc59535 Added fillable Panel box code and Load rate column 2025-04-06 17:35:08 +05:30
dhanabalan
ea90bd7f83 Added 'updated_at' column into productionQuantityImporter 2025-04-06 17:34:16 +05:30
dhanabalan
535a7f40ff Added StickerMasterImporter 2025-04-06 17:33:01 +05:30
dhanabalan
30ab500235 Added Panel box code and Load rate column and import function 2025-04-06 17:31:36 +05:30
dhanabalan
fe94a00854 Updated duration column type from decimal to numeric(4,2) 2025-04-06 17:29:13 +05:30
dhanabalan
5628824754 Added auto focus, option limit, loading msg, to datetime warnMsg and report filters 2025-04-06 17:27:26 +05:30
dhanabalan
7485a908b7 Added 'created_at' column to update night shift production plan 2025-04-06 17:23:54 +05:30
dhanabalan
dc8e46283b Redirect to create page after submit 2025-04-06 17:22:08 +05:30
dhanabalan
69ef321204 Added Auto focus and restrict duplicate shift name and invalid duration 2025-04-06 17:20:18 +05:30
dhanabalan
b67d8e4b0c Autot focus added 2025-04-06 17:17:34 +05:30
dhanabalan
490f109254 Redirect to create page after submit 2025-04-06 17:17:15 +05:30
dhanabalan
daf0a4559c Autot focus added 2025-04-06 17:16:12 +05:30
dhanabalan
40231259c5 Autot focus added 2025-04-06 17:15:52 +05:30
dhanabalan
e4019162fa Autot focus added 2025-04-06 17:15:40 +05:30
dhanabalan
588a53044d Autot focus added 2025-04-06 17:15:02 +05:30
dhanabalan
1584d96587 Updated relationship column 'name' 2025-04-06 17:14:46 +05:30
dhanabalan
7d928b8cd1 Autot focus added 2025-04-06 17:13:15 +05:30
dhanabalan
e3c22efd42 Added livewire and maatwebsite/excel packages 2025-04-06 17:11:53 +05:30
51 changed files with 2718 additions and 385 deletions

View File

@@ -16,21 +16,30 @@ class ItemExporter extends Exporter
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('code'),
ExportColumn::make('description'),
ExportColumn::make('hourly_quantity'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('deleted_at'),
ExportColumn::make('code')
->label('CODE'),
ExportColumn::make('description')
->label('DESCRIPTION'),
ExportColumn::make('hourly_quantity')
->label('HOURLY QUANTITY'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
// ->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your item export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
$body = 'Your item 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.';
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Filament\Exports;
use App\Models\ProductionLineStop;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class ProductionLineStopExporter extends Exporter
{
protected static ?string $model = ProductionLineStop::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('linestop.code')
->label('CODE'),
ExportColumn::make('linestop.reason')
->label('REASON'),
ExportColumn::make('from_datetime')
->label('FROM DATETIME'),
ExportColumn::make('to_datetime')
->label('TO DATETIME'),
ExportColumn::make('stop_hour')
->label('STOP HOUR'),
ExportColumn::make('stop_min')
->label('STOP MINUTE'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your production line stop 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;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Filament\Exports;
use App\Models\ProductionPlan;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class ProductionPlanExporter extends Exporter
{
protected static ?string $model = ProductionPlan::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('plan_quantity')
->label('PLAN QUANTITY'),
ExportColumn::make('production_quantity')
->label('PRODUCTION QUANTITY'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your production plan 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;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Filament\Exports;
use App\Models\ProductionQuantity;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class ProductionQuantityExporter extends Exporter
{
protected static ?string $model = ProductionQuantity::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('item.code')
->label('CODE'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your production quantity 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;
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Filament\Exports;
use App\Models\StickerMaster;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class StickerMasterExporter extends Exporter
{
protected static ?string $model = StickerMaster::class;
public static function getColumns(): array
{
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('item.code'),
ExportColumn::make('plant.name'),
ExportColumn::make('serial_number_motor'),
ExportColumn::make('serial_number_pump'),
ExportColumn::make('serial_number_pumpset'),
ExportColumn::make('pack_slip_motor'),
ExportColumn::make('pack_slip_pump'),
ExportColumn::make('pack_slip_pumpset'),
ExportColumn::make('name_plate_motor'),
ExportColumn::make('name_plate_pump'),
ExportColumn::make('name_plate_pumpset'),
ExportColumn::make('tube_sticker_motor'),
ExportColumn::make('tube_sticker_pump'),
ExportColumn::make('tube_sticker_pumpset'),
ExportColumn::make('warranty_card'),
ExportColumn::make('part_validation1'),
ExportColumn::make('part_validation2'),
ExportColumn::make('part_validation3'),
ExportColumn::make('part_validation4'),
ExportColumn::make('part_validation5'),
ExportColumn::make('panel_box_code'),
ExportColumn::make('load_rate'),
ExportColumn::make('bundle_quantity'),
ExportColumn::make('material_type'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('deleted_at'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your sticker 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;
}
}

View File

@@ -23,7 +23,7 @@ class BlockImporter extends Importer
->requiredMapping()
->exampleHeader('Plant Name')
->label('Plant Name')
->relationship(resolveUsing:'Name')
->relationship(resolveUsing:'name')
->rules(['required']),
];
}

View File

@@ -54,6 +54,11 @@ class ProductionQuantityImporter extends Importer
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('updated_at')
->requiredMapping()
->exampleHeader('Updated DateTime')
->label('Updated DateTime')
->rules(['required']),
];
}

View File

@@ -0,0 +1,162 @@
<?php
namespace App\Filament\Imports;
use App\Models\StickerMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class StickerMasterImporter extends Importer
{
protected static ?string $model = StickerMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('item')
->requiredMapping()
->label('Item Code')
->relationship(resolveUsing: 'code')
->exampleHeader('Item Code')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->label('Plant Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('serial_number_motor')
// ->requiredMapping()
->exampleHeader('Serial Number Motor'),
ImportColumn::make('serial_number_pump')
//->requiredMapping()
->exampleHeader('Serial Number Pump'),
ImportColumn::make('serial_number_pumpset')
//->requiredMapping()
->exampleHeader('Serial Number PumpSet'),
ImportColumn::make('pack_slip_motor')
//->requiredMapping()
->exampleHeader('Pack Slip Motor'),
ImportColumn::make('pack_slip_pump')
//->requiredMapping()
->exampleHeader('Pack Slip Pump'),
ImportColumn::make('pack_slip_pumpset')
//->requiredMapping()
->exampleHeader('Pack Slip PumpSet'),
ImportColumn::make('name_plate_motor')
// ->requiredMapping()
->exampleHeader('Name Plate Motor'),
ImportColumn::make('name_plate_pump')
// ->requiredMapping()
->exampleHeader('Name Plate Pump'),
ImportColumn::make('name_plate_pumpset')
// ->requiredMapping()
->exampleHeader('Name Plate PumpSet'),
ImportColumn::make('tube_sticker_motor')
// ->requiredMapping()
->exampleHeader('Tube Sticker Motor'),
ImportColumn::make('tube_sticker_pump')
// ->requiredMapping()
->exampleHeader('Tube Sticker Pump'),
ImportColumn::make('tube_sticker_pumpset')
// ->requiredMapping()
->exampleHeader('Tube Sticker PumpSet'),
ImportColumn::make('warranty_card')
// ->requiredMapping()
->exampleHeader('Warranty Card'),
ImportColumn::make('part_validation1')
// ->requiredMapping()
->label('Part Validation 1')
->exampleHeader('Part Validation 1'),
ImportColumn::make('part_validation2')
// ->requiredMapping()
->label('Part Validation 2')
->exampleHeader('Part Validation 2'),
ImportColumn::make('part_validation3')
// ->requiredMapping()
->label('Part Validation 3')
->exampleHeader('Part Validation 3'),
ImportColumn::make('part_validation4')
// ->requiredMapping()
->label('Part Validation 4')
->exampleHeader('Part Validation 4'),
ImportColumn::make('part_validation5')
// ->requiredMapping()
->label('Part Validation 5')
->exampleHeader('Part Validation 5'),
ImportColumn::make('panel_box_code')
//->requiredMapping()
->label('Panel Box Code')
->exampleHeader('Panel Box Code'),
ImportColumn::make('load_rate')
// ->requiredMapping()
->label('Load Rate')
->integer()
->exampleHeader('Load Rate'),
ImportColumn::make('bundle_quantity')
// ->requiredMapping()
->label('Bundle Quantity')
->integer()
->exampleHeader('Bundle Quantity'),
ImportColumn::make('material_type')
// ->requiredMapping()
->label('Material Type')
->integer()
->exampleHeader('Material Type'),
];
}
public function resolveRecord(): ?StickerMaster
{
// return StickerMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new StickerMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your sticker 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;
}
}

View File

@@ -15,6 +15,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Illuminate\Validation\Rule;
class BlockResource extends Resource
{
@@ -34,8 +35,9 @@ class BlockResource extends Resource
->schema([
Forms\Components\TextInput::make('name')
->required()
->unique(ignoreRecord: true)
// ->unique(ignoreRecord: true)
->placeholder('Scan the valid name')
->autofocus(true)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('name');
@@ -53,12 +55,20 @@ class BlockResource extends Resource
'class' => $get('bNameError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('bNameError') ? $get('bNameError') : null)
->hintColor('danger'),
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('blocks', 'name')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
// ->unique(ignoreRecord: true)
->required()
->reactive()
->default(function () {
return optional(Block::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('plant_id');

View File

@@ -37,6 +37,7 @@ class CompanyResource extends Resource
->required()
//->citext('name')
->placeholder('Scan the valid name')
->autofocus(true)
->unique(ignoreRecord: true)
->columnSpanFull()
->reactive()

View File

@@ -0,0 +1,155 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Models\InvoiceValidation;
use Filament\Forms;
use Filament\Forms\Components\Section;
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\Forms\Components\View;
class InvoiceValidationResource extends Resource
{
protected static ?string $model = InvoiceValidation::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Invoice';
public $enter_pressed = false;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Hidden::make('sticker_master_id')
//->relationship('stickerMaster', 'id')
->required(),
Section::make('')
->schema([
// FileUpload::make('excel_file')
// ->label('Choose Excel File')
// ->disk('local')
// ->columnSpan(1),
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->required(),
Forms\Components\TextInput::make('invoice_number')
->required()
->label('Invoice Number')
->columnSpan(1)
->extraAttributes([
'x-data' => '{ value: "" }',
'x-model' => 'value',
'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
]),
Forms\Components\TextInput::make('serial_number')
//->required()
->reactive()
->columnSpan(1),
Forms\Components\TextInput::make('total_quantity')
->label('Total Quantity')
->columnSpan(1),
Forms\Components\TextInput::make('scanned_quantity')
->label('Scanned Quantity')
->columnSpan(1),
])
->columns(5),
// View::make('livewire.invoice-data-table')
// ->label('Invoice Details')
// ->viewData([
// 'invoiceData' => fn ($get) => $get('invoice_data') ?? [], // Changed from invoiceData to invoice_data
// ])
// ->columnSpan('full'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('stickerMaster.id')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('load_rate')
->numeric()
->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\ListInvoiceValidations::route('/'),
'create' => Pages\CreateInvoiceValidation::route('/create'),
'view' => Pages\ViewInvoiceValidation::route('/{record}'),
'edit' => Pages\EditInvoiceValidation::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,131 @@
<?php
namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource;
use Illuminate\Contracts\View\View;
use Filament\Resources\Pages\CreateRecord;
use Filament\Notifications\Notification;
class CreateInvoiceValidation extends CreateRecord
{
protected static string $resource = InvoiceValidationResource::class;
protected static string $view = 'filament.resources.invoice-validation-resource.pages.create-invoice-validation';
public $invoice_number;
public $invoice_data;
public $scanned_quantity;
public $total_quantity;
public $excel_file;
public function processInvoice($invoiceNumber)
{
$this->invoice_number = $invoiceNumber;
// Check if the file is uploaded
if (!$this->excel_file) {
Notification::make()
->title('No File Uploaded')
->body("Please upload an Excel file to proceed with invoice: {$invoiceNumber}.")
->danger()
->persistent()
->send();
return;
}
$localPath = $this->excel_file->getPath();
// Check if file exists
if (!file_exists($localPath)) {
Notification::make()
->title('File Not Found')
->body("No Excel file found for invoice: {$invoiceNumber}. Please ensure the file exists in your Downloads folder.")
->danger()
->persistent()
->send();
return;
}
try {
$rows = \Maatwebsite\Excel\Facades\Excel::toArray([], $localPath)[0] ?? [];
array_shift($rows);
if (empty($rows)) {
Notification::make()
->title('Empty File')
->body('The Excel file contains no data rows')
->danger()
->send();
return;
}
$validRecords = [];
$invalidMaterials = [];
foreach ($rows as $row) {
$materialCode = $row[0] ?? null;
$serialNumber = $row[1] ?? null;
if (!\App\Models\StickerMaster::where('item_id', $materialCode)->exists()) {
$invalidMaterials[] = $materialCode;
continue;
}
$validRecords[] = [
'material_code' => $materialCode,
'serial_number' => $serialNumber,
'invoice_number' => $invoiceNumber,
'created_at' => now(),
'updated_at' => now(),
];
}
if (!empty($invalidMaterials)) {
Notification::make()
->title('Invalid Materials')
->body('These codes not found: ' . implode(', ', array_unique($invalidMaterials)))
->danger()
->send();
return;
}
\DB::table('invoice_validations')->insert($validRecords);
$this->invoice_data = $validRecords;
$this->scanned_quantity = count($validRecords);
$this->total_quantity = count($validRecords);
Notification::make()
->title('Success')
->body(count($validRecords) . ' records inserted successfully')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Error')
->body($e->getMessage())
->danger()
->send();
}
}
public function getHeading(): string
{
return 'Scan Invoice Validation';
}
// public function render(): View
// {
// return view('filament.resources.invoice-validation-resource.pages.create-invoice-validation');
// }
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditInvoiceValidation extends EditRecord
{
protected static string $resource = InvoiceValidationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListInvoiceValidations extends ListRecords
{
protected static string $resource = InvoiceValidationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewInvoiceValidation extends ViewRecord
{
protected static string $resource = InvoiceValidationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -6,7 +6,9 @@ use App\Filament\Exports\ItemExporter;
use App\Filament\Imports\ItemImporter;
use App\Filament\Resources\ItemResource\Pages;
use App\Models\Item;
use Filament\Actions\Exports\Enums\ExportFormat;
use Filament\Forms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
@@ -17,6 +19,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Illuminate\Validation\Rule;
class ItemResource extends Resource
{
@@ -37,8 +40,12 @@ class ItemResource extends Resource
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->required()
// ->preload()
// ->nullable(),
->reactive()
->default(function () {
return optional(Item::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -61,7 +68,8 @@ class ItemResource extends Resource
Forms\Components\TextInput::make('code')
->required()
->placeholder('Scan the valid code')
->unique(ignoreRecord: true)
->autofocus(true)
// ->unique(ignoreRecord: true)
->alphaNum()
->minLength(6)
// ->autocapitalize('characters')
@@ -92,7 +100,12 @@ class ItemResource extends Resource
'class' => $get('iCodeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
->hintColor('danger'),
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('items', 'code')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TextInput::make('hourly_quantity')
->required()
->label('Hourly Quantity')
@@ -180,9 +193,17 @@ class ItemResource extends Resource
])
->headerActions([
ImportAction::make()
->importer(ItemImporter::class),
->importer(ItemImporter::class)
->maxRows(100000),
ExportAction::make()
// ->columnMapping(true)
//->label('Export')
// ->fileName("items" . date('Y-m-d') . ".xlsx")
->exporter(ItemExporter::class),
// ->formats([
// ExportFormat::Xlsx,
// ExportFormat::Csv,
// ]),
]);
}

View File

@@ -16,6 +16,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Unique;
class LineResource extends Resource
@@ -38,6 +39,9 @@ class LineResource extends Resource
->required()
// ->nullable(),
->reactive()
->default(function () {
return optional(Line::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -60,6 +64,7 @@ class LineResource extends Resource
Forms\Components\TextInput::make('name')
->required()
->placeholder('Scan the valid name')
->autofocus(true)
// ->unique(
// ignoreRecord: true,
// modifyRuleUsing: function (Unique $rule) {
@@ -87,16 +92,16 @@ class LineResource extends Resource
}
else
{
$exists = Line::where('name', $lineNam)
->where('plant_id', $get('plant_id'))
->exists();
// $exists = Line::where('name', $lineNam)
// ->where('plant_id', $get('plant_id'))
// ->exists();
if ($exists) {
$set('name', null);
$set('lNameError', 'The name has already been taken.');
// $set('lNameError', 'The combination of name and plant ID must be unique.');
return;
}
// if ($exists) {
// $set('name', null);
// $set('lNameError', 'The name has already been taken.');
// // $set('lNameError', 'The combination of name and plant ID must be unique.');
// return;
// }
$set('lNameError', null);
}
})
@@ -104,7 +109,12 @@ class LineResource extends Resource
'class' => $get('lNameError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('lNameError') ? $get('lNameError') : null)
->hintColor('danger'),
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('lines', 'name')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TextInput::make('type')
->required()
->placeholder('Scan the valid type')

View File

@@ -39,6 +39,7 @@ class LineStopResource extends Resource
->unique(ignoreRecord: true)
->minLength(3)
->placeholder('Scan the valid code')
->autofocus(true)
->autocapitalize(autocapitalize: 'characters')
->columnSpan(1)
->reactive()

View File

@@ -38,6 +38,7 @@ class PlantResource extends Resource
->integer()
->reactive()
->placeholder('Scan the valid code')
->autofocus(true)
->minValue(1000)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$codeId = $get('code');
@@ -70,6 +71,9 @@ class PlantResource extends Resource
->relationship('company', 'name')
->required()
->reactive()
->default(function () {
return optional(Plant::latest()->first())->company_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$companyId = $get('company_id');

View File

@@ -2,10 +2,15 @@
namespace App\Filament\Resources;
use App\Filament\Exports\ProductionLineStopExporter;
use App\Filament\Imports\ProductionLineStopImporter;
use App\Filament\Resources\ProductionLineStopResource\Pages;
use App\Filament\Resources\ProductionLineStopResource\RelationManagers;
use App\Models\Block;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProductionLineStop;
use App\Models\Shift;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
@@ -16,7 +21,12 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Carbon\Carbon;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Filters\Filter;
class ProductionLineStopResource extends Resource
{
@@ -40,6 +50,9 @@ class ProductionLineStopResource extends Resource
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(ProductionLineStop::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -68,26 +81,23 @@ class ProductionLineStopResource extends Resource
return [];
}
return \App\Models\Block::where('plant_id', $get('plant_id'))
// return \App\Models\Block::where('plant_id', $get('plant_id'))
return Block::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
// ->default(function (callable $get, callable $set) {
// if ($get('id')) {
// $getShift = ProductionLineStop::where('id', $get('id'))->first();
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
// // dd($getBlock->block_id);
// $set('block_name', $getBlock->block_id);
// }
// // return null; // Return null if no default value should be set
// })
->default(function () {
$latestShiftId = optional(ProductionLineStop::latest()->first())->shift_id;
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
})
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
$getShift = ProductionLineStop::where('id', $get('id'))->first();
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
$getBlock = Shift::where('id', $getShift->shift_id)->first();
if($getBlock->block_id)
{
$set('block_name', $getBlock->block_id);
@@ -116,33 +126,20 @@ class ProductionLineStopResource extends Resource
->relationship('shift', 'name')
->required()
// ->nullable()
// ->options(fn (callable $get) =>
// \App\Models\Shift::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
// ->toArray() // Convert collection to array
// )
->options(function (callable $get) {
if (!$get('plant_id') || !$get('block_name')) {
return [];
}
// // Get the block ID based on plant_id and block_name
// $block = \App\Models\Block::where('plant_id', $get('plant_id'))
// ->where('name', $get('block_name'))
// ->first();
// if (!$block) {
// return [];
// }
// return \App\Models\Shift::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
// ->toArray();
return \App\Models\Shift::where('plant_id', $get('plant_id'))
->where('block_id', $get('block_name'))
return Shift::where('plant_id', $get('plant_id'))
->where('block_id', $get('block_name'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
return optional(ProductionLineStop::latest()->first())->shift_id;
})
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
@@ -176,21 +173,20 @@ class ProductionLineStopResource extends Resource
->relationship('line', 'name')
->required()
// ->nullable()
// ->options(fn (callable $get) =>
// \App\Models\Line::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
// ->toArray() // Convert collection to array
// )
->options(function (callable $get) {
if (!$get('plant_id') || !$get('block_name') || !$get('shift_id')) {
return [];
}
return \App\Models\Line::where('plant_id', $get('plant_id'))
// return \App\Models\Line::where('plant_id', $get('plant_id'))
return Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
return optional(ProductionLineStop::latest()->first())->line_id;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
@@ -203,6 +199,8 @@ class ProductionLineStopResource extends Resource
}
$lineId = $get('line_id');
$set('linestop_id', null);
$set('lineStop_reason', null);
if (!$lineId) {
$set('plsLineError', 'Please select a line first.');
@@ -232,11 +230,14 @@ class ProductionLineStopResource extends Resource
// ->pluck('code', 'id')
// )
->placeholder('Scan the valid code')
->autofocus(true)
->options(fn () => \App\Models\LineStop::pluck('code', 'id'))
->required()
// ->nullable()
// ->reactive()
->optionsLimit(5)
->searchable()
->loadingMessage('Loading line stop codes...')
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineStopId = $get('linestop_id'); // Get entered linestop_id
@@ -264,6 +265,7 @@ class ProductionLineStopResource extends Resource
->label('From DateTime')
->required()
->reactive()
// ->closeOnDateSelection()
->afterStateUpdated(fn ($state, callable $set, callable $get) =>
self::updateStopDuration($get, $set)
),
@@ -274,7 +276,12 @@ class ProductionLineStopResource extends Resource
->reactive()
->afterStateUpdated(fn ($state, callable $set, callable $get) =>
self::updateStopDuration($get, $set) //self means it calling the function within the class
),
)
->extraAttributes(fn ($get) => [
'class' => $get('plsToDateError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('plsToDateError') ? $get('plsToDateError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('stop_hour')
->required()
->label( 'Stop Hour')
@@ -314,15 +321,18 @@ class ProductionLineStopResource extends Resource
{
$set('stop_hour', null);
$set('stop_min', null);
$set('plsToDateError', 'Time difference must be atlease a minute.');
}
else
{
$set('stop_hour', floor($diffInMinutes / 60));
$set('stop_min', $diffInMinutes % 60);
$set('plsToDateError', null);
}
} else {
$set('stop_hour', null);
$set('stop_min', null);
$set('plsToDateError', 'To DateTime must be greater.');
}
}
}
@@ -336,43 +346,134 @@ class ProductionLineStopResource extends Resource
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('linestop.code')
->label('Code')
->sortable(),
Tables\Columns\TextColumn::make('linestop.reason')
->label('Reason')
->sortable(),
Tables\Columns\TextColumn::make('from_datetime')
->label('From DateTime')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('to_datetime')
->label('To DateTime')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('stop_hour')
->label('Stop Hour')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('stop_min')
->label('Stop Minute')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->sortable(),
Tables\Columns\TextColumn::make('shift.name')
->label('Shift')
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->options(function () {
return Plant::pluck('name', 'id'); // Assuming 'name' is the column you want to display
}),
//block
Select::make('Block')
->label('Select Block')
->options(fn (callable $get) =>
$get('Plant')
? Block::where('plant_id', $get('Plant'))->pluck('name', 'id')
: []
)
->reactive(),
//shift
Select::make('Shift')
->label('Select Shift')
->options(function (callable $get) {
$plantId = $get('Plant');
$blockId = $get('Block');
if (!$plantId || !$blockId) {
return []; // Return empty if plant or block is not selected
}
return Shift::where('plant_id', $plantId)
->where('block_id', $blockId)
->pluck('name', 'id');
})
->reactive(),
//line
Select::make('line')
->label('Select line')
->options(function (callable $get) {
$plantId = $get('Plant');
if (!$plantId ) {
return [];
}
return Line::where('plant_id', $plantId)
->pluck('name', 'id');
})
->reactive(),
TextInput::make('Line Stop Code'),
Select::make('reason')
->label('Filter by Stop Reason')
->options(function () {
return \App\Models\Item::whereHas('stickerMasters', function ($query) {
$query->whereHas('qualityValidations');
})->pluck('code', 'id');
})
->searchable(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->reactive()
->native(false),
]),
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
@@ -386,7 +487,10 @@ class ProductionLineStopResource extends Resource
])
->headerActions([
ImportAction::make()
->importer(ProductionLineStopImporter::class),
->importer(ProductionLineStopImporter::class)
->maxRows(100000),
ExportAction::make()
->exporter(ProductionLineStopExporter::class),
]);
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateProductionLineStop extends CreateRecord
{
protected static string $resource = ProductionLineStopResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
}
}

View File

@@ -2,10 +2,13 @@
namespace App\Filament\Resources;
use App\Filament\Exports\ProductionPlanExporter;
use App\Filament\Imports\ProductionPlanImporter;
use App\Filament\Resources\ProductionPlanResource\Pages;
use App\Filament\Resources\ProductionPlanResource\RelationManagers;
use App\Models\ProductionPlan;
use App\Models\Shift;
use Carbon\Carbon;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
@@ -16,6 +19,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Support\Facades\Request;
class ProductionPlanResource extends Resource
@@ -39,6 +43,9 @@ class ProductionPlanResource extends Resource
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(ProductionPlan::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -72,12 +79,16 @@ class ProductionPlanResource extends Resource
->toArray();
})
->reactive()
->default(function () {
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
})
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
$getShift = ProductionPlan::where('id', $get('id'))->first();
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
$getBlock = Shift::where('id', $getShift->shift_id)->first();
if($getBlock->block_id)
{
$set('block_name', $getBlock->block_id);
@@ -106,17 +117,21 @@ class ProductionPlanResource extends Resource
->relationship('shift', 'name')
->required()
// ->nullable()
->autofocus(true)
->options(function (callable $get) {
if (!$get('plant_id') || !$get('block_name')) {
return [];
}
return \App\Models\Shift::where('plant_id', $get('plant_id'))
return Shift::where('plant_id', $get('plant_id'))
->where('block_id', $get('block_name'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
return optional(ProductionPlan::latest()->first())->shift_id;
})
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
@@ -129,10 +144,10 @@ class ProductionPlanResource extends Resource
}
}
$shiftId = $get('shift_id');
$curShiftId = $get('shift_id');
$set('line_id', null);
if (!$shiftId) {
if (!$curShiftId) {
$set('ppShiftError', 'Please select a shift first.');
return;
}
@@ -165,6 +180,9 @@ class ProductionPlanResource extends Resource
->toArray();
})
->reactive()
// ->default(function () {
// return optional(ProductionPlan::latest()->first())->line_id;
// })
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
@@ -175,8 +193,15 @@ class ProductionPlanResource extends Resource
$set('ppLineError', null);
}
}
else
{
$currentDT = Carbon::now()->toDateTimeString();
$set('created_at', $currentDT);
$set('update_date', null);
}
$lineId = $get('line_id');
// $set('plan_quantity', null);
if (!$lineId) {
$set('ppLineError', 'Please select a line first.');
@@ -184,13 +209,6 @@ class ProductionPlanResource extends Resource
}
else
{
//SELECT COUNT(*) FROM plant_quantity_details WHERE DATE(created_at) = '{DateTime.Now.ToString("yyyy-MM-dd")}' AND shift_id = '{userShiftId}' AND plant_id = '{userPlantId}' AND line_id = '{userLineId}'
//Day shift 'Plant Production Quantity' already updated into database
// $currentPath = url()->current();
// $currentPath = $_SERVER['REQUEST_URI'];
// dd($currentPath);
$isUpdate = !empty($get('id'));
if (!$isUpdate)
{
@@ -198,6 +216,7 @@ class ProductionPlanResource extends Resource
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', today())
->latest()
->exists();
if ($exists)
@@ -208,35 +227,194 @@ class ProductionPlanResource extends Resource
}
else
{
$currentDate = date('Y-m-d');
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
$existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', Carbon::yesterday())
->latest()
->exists();
if ($existShifts) //if ($existShifts->count() > 0)
{
//$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
$miNs = (int) $miNs;
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Production plan already updated.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
//echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Choosed a invalid shift.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('ppLineError', null);
return;
} else {
// 'Invalid (From: '.$from_dt.', To: '.$to_dt.')'
$set('ppLineError', 'Choosed a invalid shift...');
}
else
{
//$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
// here i'm updating created as yesterday
$set('created_at', $from_dt);
$set('update_date', '1');
$set('ppLineError', null);
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
//echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Choosed a invalid shift.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
$set('ppLineError', null);
return;
}
// if($shiftId->start_time > $shiftId->end_time)
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
// //->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// ->whereDate('created_at', today())
// ->latest() // Orders by created_at DESC
// ->first();
// if ($exists)
// {
// $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
// //->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// // ->whereDate('created_at', today())
// ->whereDate('created_at', today())
// ->get();
// foreach ($existingShifts as $shift) {
// $curShiftId = $shift->shift_id;
// $currentDate = date('Y-m-d');
// $shiftId = \App\Models\Shift::where('id', $curShiftId)
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// //echo "Choosed a valid shift...";
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// $set('line_id', null);
// $set('ppLineError', 'Production plan already updated.');
// return;
// }
// // else {
// // $set('ppLineError', 'Choosed a invalid shift...');
// // return;
// // }
// }
// $set('ppLineError', null);
// return;
// }
}
}
$set('ppLineError', null);
@@ -256,6 +434,16 @@ class ProductionPlanResource extends Resource
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$planQuan = $get('plan_quantity');
if(!$get('update_date') )
{
if(!$get('id'))
{
$currentDT = Carbon::now()->toDateTimeString();
$set('created_at', $currentDT);
}
}
if (!$planQuan) {
$set('ppPlanQuanError', 'Scan the valid plan quantity.');
return;
@@ -279,11 +467,38 @@ class ProductionPlanResource extends Resource
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
Forms\Components\TextInput::make('update_date')
->hidden()
->reactive()
->readOnly(),
Forms\Components\DateTimePicker::make('created_at')
->label('Created DateTime')
->hidden()
->reactive()
->required()
->readOnly(),
])
->columns(2),
]);
}
// public function submitForm(array $data)
// {
// if (empty($data['update_date'])) {
// $data['created_at'] = now(); // Set current datetime if 'update_date' is empty
// }
// // Save or process form data
// ProductionPlan::create($data);
// }
// protected function afterSave(array $data)
// {
// if ($this->model instanceof ProductionPlan && empty($data['update_date'])) {
// $this->model->created_at = now(); // Set current datetime if 'update_date' is empty
// $this->model->save();
// }
// }
public static function table(Table $table): Table
{
return $table
@@ -333,7 +548,10 @@ class ProductionPlanResource extends Resource
])
->headerActions([
ImportAction::make()
->importer(ProductionPlanImporter::class),
->importer(ProductionPlanImporter::class)
->maxRows(100000),
ExportAction::make()
->exporter(ProductionPlanExporter::class),
]);
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateProductionPlan extends CreateRecord
{
protected static string $resource = ProductionPlanResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
}
}

View File

@@ -2,10 +2,14 @@
namespace App\Filament\Resources;
use App\Filament\Exports\ProductionQuantityExporter;
use App\Filament\Imports\ProductionQuantityImporter;
use App\Filament\Resources\ProductionQuantityResource\Pages;
use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
use App\Models\Item;
use App\Models\ProductionQuantity;
use App\Models\Shift;
use Carbon\Carbon;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
@@ -16,6 +20,8 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\ExportAction;
class ProductionQuantityResource extends Resource
{
@@ -38,6 +44,9 @@ class ProductionQuantityResource extends Resource
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(ProductionQuantity::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -71,12 +80,16 @@ class ProductionQuantityResource extends Resource
->toArray();
})
->reactive()
->default(function () {
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
})
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
$getShift = ProductionQuantity::where('id', $get('id'))->first();
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
$getBlock = Shift::where('id', $getShift->shift_id)->first();
if($getBlock->block_id)
{
$set('block_name', $getBlock->block_id);
@@ -111,13 +124,16 @@ class ProductionQuantityResource extends Resource
return [];
}
return \App\Models\Shift::where('plant_id', $get('plant_id'))
return Shift::where('plant_id', $get('plant_id'))
->where('block_id', $get('block_name'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->afterStateUpdated(fn ($set) => $set('line_id', null))
->default(function () {
return optional(ProductionQuantity::latest()->first())->shift_id;
})
//->afterStateUpdated(fn ($set) => $set('line_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
@@ -129,10 +145,10 @@ class ProductionQuantityResource extends Resource
}
}
$shiftId = $get('shift_id');
$curShiftId = $get('shift_id');
$set('line_id', null);
if (!$shiftId) {
if (!$curShiftId) {
$set('pqShiftError', 'Please select a shift first.');
return;
}
@@ -166,6 +182,9 @@ class ProductionQuantityResource extends Resource
->toArray();
})
->reactive()
->default(function () {
return optional(ProductionQuantity::latest()->first())->line_id;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
if($get('id'))
{
@@ -189,8 +208,24 @@ class ProductionQuantityResource extends Resource
$set('validationError', null);
$set('pqLineError', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$exists = ProductionQuantity::where('plant_id', $get('plant_id'))
//->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->latest() // Orders by created_at DESC
->first();
// if($exists)
// {
// $existCode = Item::where('id', $exists->item_id)->first();
// $set('recent_qr', $existCode->code.'|'.$exists->serial_number);
// }
// else
// {
// $set('recent_qr', null);
// }
}
})
->extraAttributes(fn ($get) => [
@@ -211,11 +246,14 @@ class ProductionQuantityResource extends Resource
->label('Item Code')
// ->required()
->reactive()
->autofocus(true)
->debounce(1000)
// ->submitOnEnter()
->afterStateUpdated(function ($state, callable $get, callable $set) {
// **Check if input is empty before processing**
if (empty($state)) {
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
return;
@@ -225,52 +263,305 @@ class ProductionQuantityResource extends Resource
if (!$get('plant_id')) {
$set('item_code', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a plant first.');
Notification::make()
->title('Choose Plant')
->body("Please select a plant first.")
->danger()
->send();
return;
}
else if (!$get('block_name')) {
$set('item_code', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a block first.');
Notification::make()
->title('Choose Block')
->body("Please select a block first.")
->danger()
->send();
return;
}
else if (!$get('shift_id')) {
$set('item_code', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a shift first.');
Notification::make()
->title('Choose Shift')
->body("Please select a shift first.")
->danger()
->send();
return;
}
else if (!$get('line_id')) {
$set('item_code', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a line first.');
Notification::make()
->title('Choose Line')
->body("Please select a line first.")
->danger()
->send();
return;
}
// ********************************
$exists = \App\Models\ProductionPlan::where('plant_id', $get('plant_id'))
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', today())
->latest()
->exists();
if (!$exists)
if ($exists)
{
$set('item_code', null);
$set('item_id', null);
$set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please set production plan first.');
return;
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a valid shift.');
Notification::make()
->title('Invalid Shift')
->body("Please select a valid shift.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
}
}
else
{
$existShifts = \App\Models\ProductionPlan::where('plant_id', $get('plant_id'))
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', Carbon::yesterday())
->latest()
->exists();
if ($existShifts) //if ($existShifts->count() > 0)
{ // record exist on yesterday
//$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
}
else
{
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please set production plan first.');
Notification::make()
->title('Plan Not Found')
->body("Please set production plan first.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a valid shift.');
Notification::make()
->title('Invalid Shift')
->body("Please select a valid shift.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
}
else
{ // record not exist on yesterday
//$currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please set production plan first.');
Notification::make()
->title('Plan Not Found')
->body("Please set production plan first.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate . ' ' . $shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please set production plan first.');
Notification::make()
->title('Plan Not Found')
->body("Please set production plan first.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
else
{
//echo "Choosed a valid shift...";
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', 'Please select a valid shift.');
Notification::make()
->title('Invalid Shift')
->body("Please select a valid shift.")
->danger()
->send();
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
}
}
// ********************************
$set('item_id', null);
$set('serial_number', null);
$set('validationError', null);
}
@@ -278,8 +569,14 @@ class ProductionQuantityResource extends Resource
if (strpos($state, '|') === false) {
$set('validationError', 'Scan valid QR code. (Ex: Item_Code|Serial_Number )');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid QR')
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
->danger()
->send();
return;
}
else
@@ -291,44 +588,70 @@ class ProductionQuantityResource extends Resource
if (!ctype_alnum($iCode)) {
$set('validationError', 'Item code must contain alpha-numeric values.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid Item Code')
->body("Item code must contain alpha-numeric values only.")
->danger()
->send();
return;
}
else if (strlen($iCode) < 6) {
$set('validationError', 'Item code must be at least 6 digits.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid Item Code')
->body("Item code must be at least 6 digits.")
->danger()
->send();
return;
}
else if (!ctype_alnum($sNumber)) {
$set('validationError', 'Serial Number must contain alpha-numeric values.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid Serial Number')
->body("Serial Number must contain alpha-numeric values only.")
->danger()
->send();
return;
}
else if (strlen($sNumber) < 9) {
$set('validationError', 'Serial Number must be at least 9 digits.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid Serial Number')
->body("Serial Number must be at least 9 digits.")
->danger()
->send();
return;
}
}
$set('validationError', 'Scan valid QR code. (Ex: Item_Code|Serial_Number )');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Invalid QR')
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
->danger()
->send();
return;
}
else
{
$set('validationError', null);
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
}
@@ -337,68 +660,34 @@ class ProductionQuantityResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
// if (strlen($itemCode) < 6) {
// $set('validationError', 'Item code must be at least 6 digits.');
// $set('item_id', null);
// $set('item_description', null);
// $set('serial_number', null);
// return;
// }
// else if (!ctype_alnum($itemCode)) {
// $set('validationError', 'Item code must contain alpha-numeric values.');
// $set('item_id', null);
// $set('item_description', null);
// $set('serial_number', null);
// return;
// }
// else if ($serialNumber === '') {
// $set('validationError', 'Waiting for full QR scan...');
// $set('item_id', null);
// $set('item_description', null);
// $set('serial_number', null);
// return; // Do not clear item_id, just wait for full input
// }
// else if (strlen($serialNumber) < 9) {
// $set('validationError', 'Serial Number must be at least 9 digits.');
// $set('item_description', null);
// $set('serial_number', null);
// return;
// }
// else if (!ctype_alnum($serialNumber)) {
// $set('validationError', 'Serial Number must contain alpha-numeric values.');
// $set('item_id', null);
// $set('item_description', null);
// $set('serial_number', null);
// return;
// }
// else
// {
// $set('validationError', null);
// }
// Fetch item using item code and plant_id
$item = \App\Models\Item::where('code', $itemCode)
$item = Item::where('code', $itemCode)
->where('plant_id', $get('plant_id'))
->first();
if ($item)
{
$sNo = ProductionQuantity::where('serial_number', $serialNumber)
// ->where('plant_id', $get('plant_id'))
// ->where('plant_id', $get('plant_id'))
->exists();
if (!$sNo)
{
$set('serial_number', $serialNumber);
$set('item_id', $item->id);
$set('item_code', $itemCode);
$set('item_description', $item->description);
// $set('item_description', $item->description);
}
else
{
$set('validationError', 'Serial number already exist in database.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Duplicate Serial Number')
->body("Serial number already exist in database.")
->danger()
->send();
return;
}
}
@@ -406,8 +695,14 @@ class ProductionQuantityResource extends Resource
{
$set('validationError', 'Item code does not exist in master data.');
$set('item_id', null);
$set('item_description', null);
// $set('item_description', null);
$set('serial_number', null);
Notification::make()
->title('Unknown Item Code')
->body("Item code does not exist in master data.")
->danger()
->send();
return;
}
})
@@ -416,23 +711,39 @@ class ProductionQuantityResource extends Resource
])
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
->hintColor('danger'),
// ->extraAttributes([
// 'x-data' => '{ value: "" }',
// 'x-model' => 'value',
// 'x-on:keydown.enter.prevent' => '$wire.processQr(value)',
// ]),
Forms\Components\Hidden::make('item_id')
->required(),
Forms\Components\TextInput::make('item_description')
->label('Description')
->reactive()
->readOnly(true)
->required(),
// Forms\Components\Select::make('item_id')
// ->label('Description')
// ->relationship('item', 'description')
// ->required(),
Forms\Components\TextInput::make('serial_number')
->required()
->unique(ignoreRecord: true)
->readOnly(true)
->autocapitalize('serial_number'),
->autocapitalize('characters'),
//->columnSpanFull(),
Forms\Components\TextInput::make('recent_qr') //item_description
->label('Last scanned QR')
->reactive()
->default(function () {
// Get the latest 'item_id' foreign key from 'production_quantities' table
$latestProductionQuantity = ProductionQuantity::latest()->first();
if (!$latestProductionQuantity) {
return null; // Return null if no production quantities exist
}
// Get the corresponding 'code' from 'items' table where 'id' matches 'item_id'
$itemCode = optional(Item::find($latestProductionQuantity->item_id))->code;
// Get the latest 'serial_number' from 'production_quantities' table
$serialNumber = $latestProductionQuantity->serial_number;
// Combine 'code' and 'serial_number' into the desired format
return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
})
->readOnly(true),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
@@ -488,7 +799,10 @@ class ProductionQuantityResource extends Resource
])
->headerActions([
ImportAction::make()
->importer(ProductionQuantityImporter::class),
->importer(ProductionQuantityImporter::class)
->maxRows(100000),
ExportAction::make()
->exporter(ProductionQuantityExporter::class),
]);
}
@@ -516,4 +830,22 @@ class ProductionQuantityResource extends Resource
SoftDeletingScope::class,
]);
}
// public function mount(): void
// {
// // Fetch the value from the database based on your conditions
// $recentScanned = ProductionQuantity::where('plant_id', $this->plant_id)
// // ->where('shift_id', $this->shift_id)
// // ->where('line_id', $this->line_id)
// // ->whereDate('created_at', today())
// ->latest()
// ->first();
// // Set the default value for 'plan_quantity' if a record exists
// if ($recentScanned) {
// $this->form()->fill([
// 'recent_qr' => $recentScanned->plan_quantity,
// ]);
// }
// }
}

View File

@@ -4,9 +4,41 @@ namespace App\Filament\Resources\ProductionQuantityResource\Pages;
use App\Filament\Resources\ProductionQuantityResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
class CreateProductionQuantity extends CreateRecord
{
protected static string $resource = ProductionQuantityResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
}
// public $qr_data;
// public function processQr($itemCode)
// {
// $this->qr_data = $itemCode;
// // Check if the file is uploaded
// if (!$this->qr_data) {
// Notification::make()
// ->title('No QR Found')
// ->body("Please, scan the QR code.")
// ->danger()
// // ->persistent()
// ->send();
// return;
// }
// else {
// Notification::make()
// ->title('QR Found')
// ->body("Valid QR code scanned: {$this->qr_data}.")
// ->success()
// // ->persistent()
// ->send();
// }
// }
}

View File

@@ -51,14 +51,13 @@ class QualityValidationResource extends Resource
->required(),
Forms\Components\TextInput::make('production_order')
->required(),
// ->unique('quality_validations', 'production_order'), // Ensures unique values,
//..
Forms\Components\TextInput::make('item_id')
->label('Item Code')
->placeholder('Scan the valid QR code')
->reactive()
->required()
->autofocus()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$serialFields = [
@@ -158,7 +157,7 @@ class QualityValidationResource extends Resource
}
else if ($serialNumber === '') {
$set('validationError', 'Waiting for full QR scan...');
return; // Do not clear item_id, just wait for full input
return;
}
else if (strlen($serialNumber) < 9) {
$set('validationError', 'Serial Number must be at least 9 digits.');
@@ -259,6 +258,7 @@ class QualityValidationResource extends Resource
foreach ($serialnumber as $field) {
if ($get("{$field}_visible")) {
$set($field, $serialNumber);
break;
}
}
@@ -297,8 +297,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
//if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('pack_slip_motor_error', 'Scan valid QR code.');
return;
}
@@ -339,7 +341,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -396,8 +398,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('pack_slip_pump_error', 'Scan valid QR code.');
return;
}
@@ -438,7 +442,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -493,8 +497,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('pack_slip_pumpset_error', 'Scan valid QR code.');
return;
}
@@ -535,7 +541,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -591,8 +597,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('name_plate_motor_error', 'Scan valid QR code.');
return;
}
@@ -633,7 +641,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -689,8 +697,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('name_plate_pump_error', 'Scan valid QR code.');
return;
}
@@ -731,7 +741,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -787,8 +797,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('name_plate_pumpset_error', 'Scan valid QR code.');
return;
}
@@ -829,7 +841,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -885,8 +897,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('tube_sticker_motor_error', 'Scan valid QR code.');
return;
}
@@ -927,7 +941,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -983,8 +997,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('tube_sticker_pump_error', 'Scan valid QR code.');
return;
}
@@ -1025,7 +1041,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -1081,7 +1097,7 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('tube_sticker_pumpset_error', 'Scan valid QR code.');
return;
@@ -1123,7 +1139,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -1179,8 +1195,10 @@ class QualityValidationResource extends Resource
return;
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPp]\|?$/', $state)) {
if (strpos($state, '|') === false) {
// if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[MmPpCc]\|?$/', $state)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $state)) {
if (strpos($state, '|') === false) {
$set('warranty_card_error', 'Scan valid QR code.');
return;
}
@@ -1221,7 +1239,7 @@ class QualityValidationResource extends Resource
$itemCode = trim($parts[0]);
$serialNumber = trim($parts[1]);
$serialNumber = preg_replace('/\/[MmPp]$/', '', $serialNumber); // Remove
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber); // Remove
// Retrieve visible serial numbers
$visibleSerialNumbers = array_filter([
@@ -1441,7 +1459,7 @@ class QualityValidationResource extends Resource
return;
}
$expectedValue = $stickerMaster->part_validation4;
$expectedValue = $stickerMaster->part_validation5;
// If input is empty, reset the error
if ($state === null || trim($state) === '') {
@@ -1538,7 +1556,7 @@ class QualityValidationResource extends Resource
->filters([
Tables\Filters\TrashedFilter::make(),
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
@@ -1552,12 +1570,14 @@ class QualityValidationResource extends Resource
})->pluck('code', 'id');
})
->searchable(),
DateTimePicker::make('created_from')
DateTimePicker::make(name: 'created_from')
->label('Created From')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->reactive()
->native(false),
])
->query(function ($query, array $data) {

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Resources\QualityValidationResource\Pages;
use App\Filament\Resources\QualityValidationResource;
use Filament\Actions;
use Filament\Forms\Components\Component;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Validation\ValidationException;
@@ -11,6 +12,7 @@ class CreateQualityValidation extends CreateRecord
{
protected static string $resource = QualityValidationResource::class;
protected function beforeCreate(): void
{
$errors = [];
@@ -91,4 +93,10 @@ class CreateQualityValidation extends CreateRecord
throw ValidationException::withMessages($errors);
}
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Resources;
use App\Filament\Imports\ShiftImporter;
use App\Filament\Resources\ShiftResource\Pages;
use App\Models\Plant;
use App\Models\Shift;
use Carbon\Carbon;
use Filament\Forms;
@@ -16,6 +17,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Illuminate\Validation\Rule;
class ShiftResource extends Resource
{
@@ -38,6 +40,9 @@ class ShiftResource extends Resource
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(Shift::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -62,6 +67,9 @@ class ShiftResource extends Resource
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(Shift::latest()->first())->block_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
// ->options(fn (callable $get) =>
// \App\Models\Block::where('plant_id', $get('plant_id'))
@@ -97,6 +105,7 @@ class ShiftResource extends Resource
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->placeholder('Scan the valid name')
->autofocus(true)
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -108,6 +117,17 @@ class ShiftResource extends Resource
}
else
{
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $nameId)
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sNameError', null);
}
})
@@ -115,7 +135,13 @@ class ShiftResource extends Resource
'class' => $get('sNameError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sNameError') ? $get('sNameError') : null)
->hintColor('danger'),
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('shifts', 'name')
->where('plant_id', $get('plant_id'))
->where('block_id', $get('block_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TimePicker::make('start_time')
->required()
->label('Start Time')
@@ -125,15 +151,27 @@ class ShiftResource extends Resource
// )
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('start_time');
// $set('duration', null);
$startTime = $get('start_time');
$set('duration', null);
$set('end_time', self::calculateEndTime($state, $get('duration')));
if (!$nameId) {
if (!$startTime) {
$set('sStartTimeError', 'Choose the valid start time.');
return;
}
else
{
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $get('name'))
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sStartTimeError', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sStartTimeError', null);
}
})
@@ -167,6 +205,15 @@ class ShiftResource extends Resource
$hRs = (int) $hRs;
$miNs = (int) $miNs;
$set('duration', $hRs.'.'.$miNs);
if ($miNs > 60) {
$set('sDurationError', 'Minutes exceeds 1 hour.');
$set('duration', null);
$set('end_time', null);
return;
}
$totalMinutes = $hRs * 60 + $miNs;
if ($totalMinutes > 1440) {
@@ -212,8 +259,6 @@ class ShiftResource extends Resource
])
->columns(2),
]);
}
public static function table(Table $table): Table

View File

@@ -2,19 +2,22 @@
namespace App\Filament\Resources;
use App\Filament\Exports\StickerMasterExporter;
use App\Filament\Imports\ShiftImporter;
use App\Filament\Imports\StickerMasterImporter;
use App\Filament\Resources\StickerMasterResource\Pages;
use App\Filament\Resources\StickerMasterResource\RelationManagers;
use App\Models\StickerMaster;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Notifications\Notification;
use Filament\Forms\Get;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
class StickerMasterResource extends Resource
{
@@ -34,6 +37,9 @@ class StickerMasterResource extends Resource
->relationship('plant', 'name')
->reactive()
->nullable()
->default(function () {
return optional(StickerMaster::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & //when plant changed remove all the data which is in text input box
@@ -152,6 +158,30 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation5')
->nullable(),
Forms\Components\TextInput::make('panel_box_code')
->label('Panel Box Code')
->nullable(),
Forms\Components\TextInput::make('load_rate')
->label('Load Rate')
->default(0)
->integer()
->nullable(),
Forms\Components\Select::make('material_type')
->label('Material Type')
->options([
'individual' => '1',
'bundle' => '2',
]),
Forms\Components\TextInput::make('bundle_quantity')
->label('Bundle Quantity')
->integer()
->nullable(),
Forms\Components\Checkbox::make('serial_number_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
@@ -214,92 +244,107 @@ class StickerMasterResource extends Resource
public static function table(Table $table): Table
{
return $table
->searchable()
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('warranty_card')
->disabled(true)
->sortable(),
Tables\Columns\TextColumn::make('part_validation1')
->sortable(),
Tables\Columns\TextColumn::make('part_validation2')
->sortable(),
Tables\Columns\TextColumn::make('part_validation3')
->sortable(),
Tables\Columns\TextColumn::make('part_validation4')
->sortable(),
Tables\Columns\TextColumn::make('part_validation5')
->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(),
]),
]);
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_motor')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pump')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pumpset')
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('warranty_card')
->disabled(true)
->sortable(),
Tables\Columns\TextColumn::make('part_validation1')
->sortable(),
Tables\Columns\TextColumn::make('part_validation2')
->sortable(),
Tables\Columns\TextColumn::make('part_validation3')
->sortable(),
Tables\Columns\TextColumn::make('part_validation4')
->sortable(),
Tables\Columns\TextColumn::make('part_validation5')
->sortable(),
Tables\Columns\TextColumn::make('panel_box_code')
->sortable(),
Tables\Columns\TextColumn::make('load_rate')
->sortable(),
Tables\Columns\TextColumn::make('bundle_quantity')
->sortable(),
Tables\Columns\TextColumn::make('material_type')
->label('Material Type')
->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(),
]),
])
->headerActions([
ImportAction::make()
->importer(StickerMasterImporter::class),
ExportAction::make()
->exporter(StickerMasterExporter::class),
]);
}
public static function getRelations(): array

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Livewire;
use App\Models\InvoiceValidation;
use Livewire\Component;
class InvoiceDataTable extends Component
{
public $invoiceData = [];
protected $listeners = ['refreshInvoiceData' => 'loadData'];
public function mount()
{
$this->loadData();
}
public function loadData()
{
$this->invoiceData = InvoiceValidation::all()->toArray();
}
public function render()
{
// Always fetch fresh data when Livewire re-renders (like via polling)
$invoiceData = InvoiceValidation::latest()->get();
return view('livewire.invoice-data-table', [
'invoiceData' => $invoiceData,
]);
// return view('livewire.invoice-data-table', [
// 'invoiceData' => $this->invoiceData, // <--- this is important
// ]);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceValidation extends Model
{
use SoftDeletes;
protected $fillable = [
'sticker_master_id',
'plant_id',
'invoice_number',
'serial_number',
'motor_scanned_status',
'pump_scanned_status',
'capacitor_scanned_status',
'scanned_status_set',
'scanned_status',
'panel_box_supplier',
'panel_box_serial_number',
'load_rate',
'upload_status',
'batch_number',
'quantity',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function stickerMaster(): BelongsTo
{
return $this->belongsTo(StickerMaster::class);
}
}

View File

@@ -13,6 +13,7 @@ class ProductionPlan extends Model
protected $fillable = [
"plant_id",
"shift_id",
"created_at",
"line_id",
"plan_quantity",
"production_quantity",

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -44,10 +45,22 @@ class ProductionQuantity extends Model
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
->where('shift_id', $productionQuantity->shift_id)
->where('line_id', $productionQuantity->line_id)
->whereDate('created_at',today())
->whereDate('created_at', today())
// ->where('plan_quantity', $productionQuantity->plan_quantity)
->latest()
->first();
if (!$productionPlan)
{
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
->where('shift_id', $productionQuantity->shift_id)
->where('line_id', $productionQuantity->line_id)
->whereDate('created_at', Carbon::yesterday())
// ->where('plan_quantity', $productionQuantity->plan_quantity)
->latest()
->first();
}
if ($productionPlan) {
$productionPlan->update([
'production_quantity' => $productionPlan->production_quantity + 1,

View File

@@ -13,6 +13,7 @@ class StickerMaster extends Model
protected $fillable = [
'item_id',
'plant_id',
'panel_box_code',
'serial_number_motor',
'serial_number_pump',
'serial_number_pumpset',
@@ -31,6 +32,9 @@ class StickerMaster extends Model
'part_validation3',
'part_validation4',
'part_validation5',
'load_rate',
'bundle_quantity',
'material_type',
];
public function item()
@@ -47,4 +51,9 @@ class StickerMaster extends Model
{
return $this->hasMany(QualityValidation::class, 'sticker_master_id');
}
public function invoiceValidations()
{
return $this->hasMany(InvoiceValidation::class);
}
}

View File

@@ -11,6 +11,8 @@
"filament/filament": "^3.3",
"laravel/framework": "^11.31",
"laravel/tinker": "^2.9",
"livewire/livewire": "^3.6",
"maatwebsite/excel": "^3.1",
"tpetry/laravel-postgresql-enhanced": "^2.3"
},
"require-dev": {

674
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7b2a34f16f1fa4714c137023cb652961",
"content-hash": "ac6e7ab9568c0715b7379e52b53f4456",
"packages": [
{
"name": "althinect/filament-spatie-roles-permissions",
@@ -414,6 +414,166 @@
],
"time": "2024-02-09T16:56:22+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "composer/semver",
"version": "3.4.3",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
"reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"symfony/phpunit-bridge": "^3 || ^7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.4.3"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-09-19T14:15:21+00:00"
},
{
"name": "danharrin/date-format-converter",
"version": "v0.3.1",
@@ -1045,6 +1205,67 @@
],
"time": "2025-03-06T22:45:56+00:00"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.18.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "cb56001e54359df7ae76dc522d08845dc741621b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/cb56001e54359df7ae76dc522d08845dc741621b",
"reference": "cb56001e54359df7ae76dc522d08845dc741621b",
"shasum": ""
},
"require": {
"php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
},
"require-dev": {
"cerdic/css-tidy": "^1.7 || ^2.0",
"simpletest/simpletest": "dev-master"
},
"suggest": {
"cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
"ext-bcmath": "Used for unit conversion and imagecrash protection",
"ext-iconv": "Converts text to and from non-UTF-8 encodings",
"ext-tidy": "Used for pretty-printing HTML"
},
"type": "library",
"autoload": {
"files": [
"library/HTMLPurifier.composer.php"
],
"psr-0": {
"HTMLPurifier": "library/"
},
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"support": {
"issues": "https://github.com/ezyang/htmlpurifier/issues",
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.18.0"
},
"time": "2024-11-01T03:51:45+00:00"
},
{
"name": "filament/actions",
"version": "v3.3.5",
@@ -3203,6 +3424,272 @@
],
"time": "2025-03-12T20:24:15+00:00"
},
{
"name": "maatwebsite/excel",
"version": "3.1.64",
"source": {
"type": "git",
"url": "https://github.com/SpartnerNL/Laravel-Excel.git",
"reference": "e25d44a2d91da9179cd2d7fec952313548597a79"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/e25d44a2d91da9179cd2d7fec952313548597a79",
"reference": "e25d44a2d91da9179cd2d7fec952313548597a79",
"shasum": ""
},
"require": {
"composer/semver": "^3.3",
"ext-json": "*",
"illuminate/support": "5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0||^12.0",
"php": "^7.0||^8.0",
"phpoffice/phpspreadsheet": "^1.29.9",
"psr/simple-cache": "^1.0||^2.0||^3.0"
},
"require-dev": {
"laravel/scout": "^7.0||^8.0||^9.0||^10.0",
"orchestra/testbench": "^6.0||^7.0||^8.0||^9.0||^10.0",
"predis/predis": "^1.1"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
},
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Maatwebsite\\Excel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Patrick Brouwers",
"email": "patrick@spartner.nl"
}
],
"description": "Supercharged Excel exports and imports in Laravel",
"keywords": [
"PHPExcel",
"batch",
"csv",
"excel",
"export",
"import",
"laravel",
"php",
"phpspreadsheet"
],
"support": {
"issues": "https://github.com/SpartnerNL/Laravel-Excel/issues",
"source": "https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.64"
},
"funding": [
{
"url": "https://laravel-excel.com/commercial-support",
"type": "custom"
},
{
"url": "https://github.com/patrickbrouwers",
"type": "github"
}
],
"time": "2025-02-24T11:12:50+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.2"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^11.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"time": "2025-01-27T12:07:53+00:00"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"time": "2022-12-02T22:17:43+00:00"
},
{
"name": "masterminds/html5",
"version": "2.9.0",
@@ -3865,6 +4352,112 @@
],
"time": "2025-03-11T14:40:46+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.29.10",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "c80041b1628c4f18030407134fe88303661d4e4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e",
"reference": "c80041b1628c4f18030407134fe88303661d4e4e",
"shasum": ""
},
"require": {
"composer/pcre": "^1||^2||^3",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"ezyang/htmlpurifier": "^4.15",
"maennchen/zipstream-php": "^2.1 || ^3.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^7.4 || ^8.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
"dompdf/dompdf": "^1.0 || ^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.3",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.0",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10"
},
"time": "2025-02-08T02:56:14+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.3",
@@ -7957,85 +8550,6 @@
],
"time": "2025-03-24T13:50:44+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.24.1",

View File

@@ -19,7 +19,7 @@ return new class extends Migration
name TEXT NOT NULL,
start_time TIME NOT NULL,
duration DECIMAL NOT NULL,
duration NUMERIC(4, 2) NOT NULL,
end_time TIME NOT NULL, --GENERATED ALWAYS AS (start_time + (duration * INTERVAL '1 hour')) STORED,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),

View File

@@ -17,6 +17,7 @@ return new class extends Migration
item_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,
serial_number_motor TEXT DEFAULT NULL,
serial_number_pump TEXT DEFAULT NULL,
serial_number_pumpset TEXT DEFAULT NULL,
@@ -40,6 +41,12 @@ return new class extends Migration
part_validation4 TEXT DEFAULT NULL,
part_validation5 TEXT DEFAULT NULL,
panel_box_code TEXT DEFAULT NULL,
load_rate INT NOT NULL DEFAULT (0),
bundle_quantity INT DEFAULT NULL,
material_type INT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
@@ -49,7 +56,7 @@ return new class extends Migration
);
SQL;
DB::statement($sql);
DB::statement($sql);
}
/**

View File

@@ -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 invoice_validations (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
sticker_master_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,
invoice_number TEXT NOT NULL,
serial_number TEXT UNIQUE,
motor_scanned_status TEXT DEFAULT NULL,
pump_scanned_status TEXT DEFAULT NULL,
capacitor_scanned_status TEXT DEFAULT NULL,
scanned_status_set TEXT DEFAULT NULL,
scanned_status TEXT DEFAULT NULL,
panel_box_supplier TEXT DEFAULT NULL,
panel_box_serial_number TEXT DEFAULT NULL,
load_rate INT NOT NULL DEFAULT (0),
upload_status TEXT NOT NULL DEFAULT 'N',
batch_number TEXT DEFAULT NULL,
quantity INT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
FOREIGN KEY (sticker_master_id) REFERENCES sticker_masters (id),
FOREIGN KEY (plant_id) REFERENCES plants (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('invoice_validations');
}
};

View File

@@ -0,0 +1,7 @@
<x-filament::page>
{{ $this->form }}
{{-- @livewire('invoice-data-table') --}}
<livewire:invoice-data-table :invoice-data="$invoice_data" />
</x-filament::page>

View File

@@ -0,0 +1,45 @@
<div wire:poll.5s>
<div class="mb-4">
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2>
<div class="mt-2">
<hr class="border-t-2 border-gray-300">
</div>
</div>
<table class="min-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 min-w-[100px]">No</th>
<th class="border px-4 py-2 min-w-[200px]">Material Code</th>
<th class="border px-4 py-2 min-w-[250px]">Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Motor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Pump Scanned Status</th>
<th class="border px-4 py-2 min-w-[250px]">Capacitor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status Set</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Supplier</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status</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['material_code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['motor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['pump_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['capacitor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status_set'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? 'N/A' }}</td>
</tr>
@empty
<tr>
<td colspan="10" class="text-center py-4 text-gray-500">No data available.</td>
</tr>
@endforelse
</tbody>
</table>
</div>

0
storage/app/.gitignore vendored Normal file → Executable file
View File

0
storage/app/private/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/cache/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/cache/data/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/sessions/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/testing/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/views/.gitignore vendored Normal file → Executable file
View File

0
storage/logs/.gitignore vendored Normal file → Executable file
View File