22 Commits

Author SHA1 Message Date
9e5efe4eac Update dependency filament/filament to v4
Some checks failed
renovate/artifacts Artifact file update failure
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 34s
Laravel Larastan / larastan (pull_request) Failing after 2m20s
Laravel Pint / pint (pull_request) Failing after 2m18s
2025-11-30 00:00:54 +00:00
e20915ca82 Merge pull request 'Refactor content method in InvoiceDataMail to use null-safe operator for document_date check' (#29) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #29
2025-11-29 12:58:25 +00:00
58e6cbfac0 Merge pull request 'Added proper imports for mail' (#28) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #28
2025-11-29 12:57:53 +00:00
1ace049687 Merge pull request 'Uncommented the mail schedule logic' (#27) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Reviewed-on: #27
2025-11-29 12:33:52 +00:00
e5e85a8eea Merge pull request 'ranjith-dev' (#26) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Reviewed-on: #26
2025-11-29 12:28:01 +00:00
555802ab35 Merge pull request 'Updated warning message against tube_sticker and pack_slip master data' (#25) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Reviewed-on: #25
2025-11-29 11:53:18 +00:00
587b743f12 Merge pull request 'Clear process_order if plant not selected' (#24) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Reviewed-on: #24
2025-11-29 10:47:24 +00:00
42555d4a81 Merge pull request 'Added reactive validation for plant selection and duplicate checks for coil and SFG numbers in ProcessOrder form' (#23) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Reviewed-on: #23
2025-11-29 10:43:17 +00:00
fd1e554076 Merge pull request 'commented out machine ID validation logic in storeProcessOrderData method' (#22) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #22
2025-11-29 10:07:18 +00:00
022654f192 Merge pull request 'Updated get hasPumpQr status from pack_slip_pump if it does not exist in tube_sticker_pump' (#21) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #21
2025-11-29 09:00:31 +00:00
55f1088fda Merge pull request 'Updated sfg_number validations as optional and check duplcate only if it exist' (#20) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #20
2025-11-29 06:52:08 +00:00
f9233f44d8 Merge pull request 'commented alert mail rules logic from boot method' (#19) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Reviewed-on: #19
2025-11-29 06:19:01 +00:00
e0fec6b07c Merge pull request 'Added schedule method logic in app service provider' (#18) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #18
2025-11-29 05:35:04 +00:00
6bda9c1459 Merge pull request 'Added LogClear command and Updated log message' (#17) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #17
2025-11-27 06:34:58 +00:00
39bdd3df57 Merge pull request 'Updated report view logic' (#16) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #16
2025-11-27 05:41:34 +00:00
5bcf0703d9 Merge pull request 'Refactor: Clean up imports and enhance form/table structure in InvoiceDataValidation and InvoiceOutValidation resources' (#15) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #15
2025-11-27 05:29:19 +00:00
80e522b7e6 Merge pull request 'feat: Add validation rules for Machine and Work Center names; enhance ProcessOrder table sorting; refactor StickerMasterResource for improved readability and functionality' (#14) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #14
2025-11-27 04:50:10 +00:00
ee101f80ea Merge pull request 'Updated error response codes in updateGR and related methods to return 404 for various validation errors and Added sfg_number duplicate warning' (#13) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #13
2025-11-27 03:08:14 +00:00
37a99d03c1 Merge pull request 'Enhanced storeProcessOrderData method with improved validation and error handling for plant code, item code, coil number, order quantity, received quantity, SFG number, machine ID, and created by' (#12) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #12
2025-11-26 14:21:05 +00:00
5fdced003a Merge pull request 'ranjith-dev' (#11) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #11
2025-11-26 14:17:41 +00:00
0b0bb90efb Merge pull request 'Added POST API logs to view the structure in command prompt' (#10) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Reviewed-on: #10
2025-11-26 11:43:09 +00:00
32ce6da2c1 Merge pull request 'Add Larastan configuration and dependencies for static analysis' (#9) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Reviewed-on: #9
2025-11-26 09:11:36 +00:00
23 changed files with 34 additions and 1148 deletions

View File

@@ -1,54 +0,0 @@
<?php
namespace App\Filament\Exports;
use App\Models\StickerPrinting;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class StickerPrintingExporter extends Exporter
{
protected static ?string $model = StickerPrinting::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('reference_number')
->label('REFERENCE NUMBER'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your sticker printing 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

@@ -1,106 +0,0 @@
<?php
namespace App\Filament\Imports;
use App\Models\StickerPrinting;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use App\Models\Plant;
use App\Models\User;
use Str;
use Filament\Facades\Filament;
class StickerPrintingImporter extends Importer
{
protected static ?string $model = StickerPrinting::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('PLANT CODE')
->example('1000')
->label('PLANT CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('reference_number')
->exampleHeader('REFERENCE NUMBER')
->example('REF123456')
->label('REFERENCE NUMBER'),
ImportColumn::make('serial_number')
->exampleHeader('SERIAL NUMBER')
->example('135245325212')
->label('SERIAL NUMBER'),
// ImportColumn::make('created_by')
// ->exampleHeader('CREATED BY')
// ->example('RAW01234')
// ->label('CREATED BY'),
];
}
public function resolveRecord(): ?StickerPrinting
{
// return StickerPrinting::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
$warnMsg = [];
$plant = Plant::where('code', $this->data['plant'])->first();
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
$warnMsg[] = "Invalid serial number found";
}
$existing = StickerPrinting::where('plant_id', $plant->id)
->where('serial_number', $this->data['serial_number'])
->first();
if ($existing) {
$warnMsg[] = "Serial number already exists for this plant!";//throw new RowImportFailedException("Serial number already exists for this plant!");
}
$serial = $this->data['serial_number'];
// --- Check duplicate in DB ---
$existsInDB = StickerPrinting::where('plant_id', $plant->id)
->where('serial_number', $serial)
->first();
if ($existsInDB) {
//throw new RowImportFailedException("Serial number '{$serial}' already exists in DB for this plant!");
$warnMsg[] = "Serial number '{$serial}' already exists in DB for this plant!";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
StickerPrinting::Create([
'plant_id' => $plant->id,
'reference_number' => $this->data['reference_number'],
'serial_number' => $this->data['serial_number'],
'created_at' => now(),
'updated_at' =>now(),
'created_by' => Filament::auth()->user()?->name,
]);
return null;
//return new StickerPrinting();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your sticker printing 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

@@ -50,7 +50,7 @@ class AlertMailRuleResource extends Resource
'InvoiceValidation' => 'InvoiceValidation', 'InvoiceValidation' => 'InvoiceValidation',
'InvoiceDataReport' => 'InvoiceDataReport', 'InvoiceDataReport' => 'InvoiceDataReport',
'ProductionQuantities' => 'ProductionQuantities', 'ProductionQuantities' => 'ProductionQuantities',
'QualityValidation' => 'QualityValidation', //'Calibration' => 'Calibration',
]), ]),
Forms\Components\Select::make('rule_name') Forms\Components\Select::make('rule_name')
->label('Rule Name') ->label('Rule Name')
@@ -60,7 +60,7 @@ class AlertMailRuleResource extends Resource
'MaterialInvoiceMail' => 'Material Invoice Mail', 'MaterialInvoiceMail' => 'Material Invoice Mail',
'ProductionMail' => 'Production Mail', 'ProductionMail' => 'Production Mail',
'InvoiceDataMail' => 'Invoice Data Mail', 'InvoiceDataMail' => 'Invoice Data Mail',
'QualityMail' => 'Quality Mail', //'CalibrationMail' => 'Calibration Mail',
]) ])
->required(), ->required(),
Forms\Components\TextInput::make('email') Forms\Components\TextInput::make('email')

View File

@@ -3265,8 +3265,6 @@ class CreateInvoiceValidation extends CreateRecord
return; return;
} }
$invalidPackage = false;
$hasMotorQr = $record->stickerMasterRelation->tube_sticker_motor ?? null; $hasMotorQr = $record->stickerMasterRelation->tube_sticker_motor ?? null;
$hasPumpQr = $record->stickerMasterRelation->tube_sticker_pump ?? null; $hasPumpQr = $record->stickerMasterRelation->tube_sticker_pump ?? null;
$hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null; $hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null;
@@ -3276,18 +3274,17 @@ class CreateInvoiceValidation extends CreateRecord
$hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null; $hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
$hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null; $hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
} else { } elseif (! $hasPumpSetQr && ! $hasPumpQr) {
if (! $hasPumpSetQr && ! $hasPumpQr) { $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; }
}
$hasTubeMotorQr = $record->stickerMasterRelation->tube_sticker_motor ?? null; $invalidPackage = false;
$hasPackMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null; $hasTubeMotorQr = $record->stickerMasterRelation->tube_sticker_motor ?? null;
$hasTubePumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null; $hasPackMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
$hasPackPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null; $hasTubePumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null;
if ($hasTubeMotorQr != $hasPackMotorQr || $hasTubePumpSetQr != $hasPackPumpSetQr) { $hasPackPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
$invalidPackage = true; if ($hasTubeMotorQr != $hasPackMotorQr || $hasTubePumpSetQr != $hasPackPumpSetQr) {
} $invalidPackage = true;
} }
$hadMotorQr = $record->motor_scanned_status ?? null; $hadMotorQr = $record->motor_scanned_status ?? null;

View File

@@ -237,6 +237,9 @@ class ItemResource extends Resource
->sortable() ->sortable()
->toggleable(isToggledHiddenByDefault: true), ->toggleable(isToggledHiddenByDefault: true),
]) ])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([ ->filters([
Tables\Filters\TrashedFilter::make(), Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters') Filter::make('advanced_filters')
@@ -248,11 +251,11 @@ class ItemResource extends Resource
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}) })
->reactive() ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('code', null); $set('item_id', null);
$set('operator_id', null); $set('operator_id', null);
}), }),
Select::make('code') Select::make('code')
@@ -267,7 +270,9 @@ class ItemResource extends Resource
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : []; return $plantId
? Item::where('plant_id', $plantId)->pluck('code', 'id')
: [];
}) })
->searchable() ->searchable()
->reactive(), ->reactive(),
@@ -295,7 +300,7 @@ class ItemResource extends Resource
// Hide all records initially if no filters are applied // Hide all records initially if no filters are applied
if ( if (
empty($data['Plant']) && empty($data['Plant']) &&
empty($data['code']) && empty($data['item_id']) &&
empty($data['description']) && empty($data['description']) &&
empty($data['uom']) && empty($data['uom']) &&
empty($data['category']) && empty($data['category']) &&
@@ -309,8 +314,8 @@ class ItemResource extends Resource
$query->where('plant_id', $data['Plant']); $query->where('plant_id', $data['Plant']);
} }
if (! empty($data['code'])) { if (! empty($data['item_id'])) {
$query->where('id', $data['code']); $query->where('item_id', $data['item_id']);
} }
if (! empty($data['description'])) { if (! empty($data['description'])) {
@@ -332,6 +337,7 @@ class ItemResource extends Resource
if (! empty($data['created_to'])) { if (! empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']); $query->where('created_at', '<=', $data['created_to']);
} }
}) })
->indicateUsing(function (array $data) { ->indicateUsing(function (array $data) {
$indicators = []; $indicators = [];
@@ -340,8 +346,8 @@ class ItemResource extends Resource
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name'); $indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
} }
if (! empty($data['code'])) { if (! empty($data['item_id'])) {
$indicators[] = 'Item Code: '.Item::where('id', $data['code'])->value('code'); $indicators[] = 'Item Code: '.$data['item_id'];
} }
if (! empty($data['description'])) { if (! empty($data['description'])) {
@@ -615,10 +621,10 @@ class ItemResource extends Resource
}), }),
// ->maxRows(100000), // ->maxRows(100000),
ExportAction::make() ExportAction::make()
// ->columnMapping(true) // ->columnMapping(true)
->label('Export Items') ->label('Export Items')
->color('warning') ->color('warning')
// ->fileName("Items Report " . date('Y-m-d H:i:s')) // ->fileName("Items Report " . date('Y-m-d H:i:s'))
->exporter(ItemExporter::class) ->exporter(ItemExporter::class)
->visible(function () { ->visible(function () {
return Filament::auth()->user()->can('view export item'); return Filament::auth()->user()->can('view export item');

View File

@@ -109,7 +109,6 @@ class ProcessOrderResource extends Resource
->afterStateHydrated(function ($component, $state, Get $get, Set $set) { ->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
$itemId = $get('item_id'); $itemId = $get('item_id');
if ($get('id')) { if ($get('id')) {
$item = \App\Models\Item::where('id', $itemId)->first()?->description; $item = \App\Models\Item::where('id', $itemId)->first()?->description;
if ($item) { if ($item) {
$set('item_description', $item); $set('item_description', $item);
@@ -123,7 +122,6 @@ class ProcessOrderResource extends Resource
->hidden() ->hidden()
->readOnly(), ->readOnly(),
// ->readOnly(true), // ->readOnly(true),
Forms\Components\TextInput::make('process_order') Forms\Components\TextInput::make('process_order')
->label('Process Order') ->label('Process Order')
->reactive() ->reactive()

View File

@@ -601,7 +601,7 @@ class StickerMasterResource extends Resource
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}) })
->reactive() ->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
@@ -620,7 +620,9 @@ class StickerMasterResource extends Resource
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : []; return $plantId
? Item::where('plant_id', $plantId)->pluck('code', 'id')
: Item::pluck('code', 'id');
}) })
->searchable() ->searchable()
->reactive(), ->reactive(),

View File

@@ -1,199 +0,0 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\StickerPrintingResource\Pages;
use App\Models\Plant;
use App\Models\StickerPrinting;
use Filament\Facades\Filament;
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\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use App\Filament\Exports\StickerPrintingExporter;
use App\Filament\Imports\StickerPrintingImporter;
use Filament\Forms\Components\Actions\Action;
class StickerPrintingResource extends Resource
{
protected static ?string $model = StickerPrinting::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->required()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('reference_number', null);
$set('serial_number', null);
$set('ivPlantError', 'Please select a plant first.');
} else {
$set('ivPlantError', null);
$set('reference_number', null);
$set('serial_number', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('ivPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('ivPlantError') ? $get('ivPlantError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('reference_number')
->label('Reference Number')
->reactive()
->readOnly(fn (callable $get) => !empty($get('serial_number')))
->extraAttributes([
'id' => 'invoice_number_input',
'x-data' => '{ value: "" }',
'x-model' => 'value',
'wire:keydown.enter.prevent' => 'processRef(value)',
])
->required(),
Forms\Components\TextInput::make('serial_number')
->label('Serial Number')
->reactive()
// ->required()
->readOnly(fn (callable $get) => empty($get('reference_number')))
->extraAttributes([
'id' => 'serial_number_input',
'x-data' => '{ value: "" }',
'x-model' => 'value',
'wire:keydown.enter.prevent' => 'processSno(value)',
//'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
]),
//->required(),
Forms\Components\View::make('forms.components.print-button'),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
])
->columns(4),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('reference_number')
->label('Reference Number')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('serial_number')
->label('Serial Number')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(StickerPrintingImporter::class)
->label('Import Sticker Printing')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view import sticker printing');
}),
ExportAction::make()
->exporter(StickerPrintingExporter::class)
->label('Export Sticker Printing')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view export sticker printing');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListStickerPrintings::route('/'),
'create' => Pages\CreateStickerPrinting::route('/create'),
'view' => Pages\ViewStickerPrinting::route('/{record}'),
'edit' => Pages\EditStickerPrinting::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -1,244 +0,0 @@
<?php
namespace App\Filament\Resources\StickerPrintingResource\Pages;
use App\Filament\Resources\StickerPrintingResource;
use Filament\Resources\Pages\CreateRecord;
use PDF;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Filament\Facades\Filament;
use App\Models\StickerPrinting;
use Filament\Notifications\Notification;
use Str;
class CreateStickerPrinting extends CreateRecord
{
protected static string $resource = StickerPrintingResource::class;
protected static string $view = 'filament.resources.sticker-printing-resource.pages.create-sticker-printing';
public $plantId;
public $ref_number;
public $ref;
public $serial_number;
public function getFormActions(): array
{
return [
$this->getCancelFormAction(),
];
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function loadRecords()
{
$this->records = StickerPrinting::where('reference_number', $this->refNumber)
->where('plant_id', $this->plantId)
->latest()
->get();
}
public function processRef($value)
{
//$this->ref_number = $value;
$ref = $this->form->getState()['reference_number'] ?? null;
$user = Filament::auth()->user();
$operatorName = $user->name;
$plantId = $this->form->getState()['plant_id'];
$this->plantId = $plantId;
$this->dispatch('refreshEmptySticker', $plantId, $ref);
$this->dispatch('focus-serial-number');
}
public function processSno($value)
{
$this->serial_number = $value;
$plant = $this->form->getState()['plant_id'] ?? null;
$ref = $this->form->getState()['reference_number'] ?? null;
$sNumber = $this->form->getState()['serial_number'] ?? null;
$pattern1 = '/^(?<item_code>[^|]+)\|(?<serial_number>[^|]+)\|?$/i';
$pattern2 = '/^(?<item_code>[^|]+)\|(?<serial_number>[^|]+)\|(?<batch_number>.+)$/i';
$pattern3 = '/^(?<serial_number>[^|]+)$/i';
if (preg_match($pattern1, $sNumber, $matches) || preg_match($pattern2, $sNumber, $matches) || preg_match($pattern3, $sNumber, $matches)) {
$serial = $matches['serial_number'];
if (Str::length($serial) < 9) {
Notification::make()
->title('Invalid Serial Number')
->body("Serial number should conatin minimum 9 digits '$serial'.")
->warning()
->send();
$this->form->fill([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => '',
]);
return;
}
else if(!ctype_alnum($serial)) {
Notification::make()
->title('Invalid Serial Number')
->body("Serial number should be alphanumeric '$serial'.")
->warning()
->send();
$this->form->fill([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => '',
]);
return;
}
$extractedSerialNumber = $matches['serial_number'];
$sNumber = $extractedSerialNumber;
}
else
{
Notification::make()
->title('Invalid Format')
->body("Serial number must be in the format 'itemcode|serialnumber' or 'itemcode|serialnumber|batchnumber'. or just 'serialnumber'.")
->warning()
->send();
// Reset only serial number field
$this->form->fill([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => '',
]);
return;
}
if ($plant == null || trim($plant) == '' || $ref == null || trim($ref) == '' || $sNumber == null || trim($sNumber) == '')
{
Notification::make()
->title('Unknown: Incomplete Data!')
->body("Please ensure Plant, Reference Number, and Serial Number are provided.")
->danger()
->seconds(3)
->send();
return;
}
$exists = StickerPrinting::where('plant_id', $plant)
->where('serial_number', $sNumber)
->first();
if ($exists) {
Notification::make()
->title('Duplicate Serial Number!')
->body("Serial Number {$sNumber} already exists for this plant.")
->danger()
->seconds(3)
->send();
// Reset only serial number field
$this->form->fill([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => '',
]);
return;
}
StickerPrinting::create([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => $sNumber,
'created_by' => Filament::auth()->user()->name,
]);
$this->dispatch('addStickerToList', $plant, $ref, $sNumber);
$this->form->fill([
'plant_id' => $plant,
'reference_number' => $ref,
'serial_number' => '',
]);
}
public function printSticker() {
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
$refNumber = trim($this->form->getState()['reference_number'])?? null;
$refNumber = trim($refNumber) ?? null;
$serialNumber = trim($this->form->getState()['serial_number'])?? null;
$serialNumber = trim($serialNumber) ?? null;
// dd($plantId, $refNumber, $serialNumber);
$serialNumbers = StickerPrinting::where('plant_id', $plantId)
->where('reference_number', $refNumber)
->pluck('serial_number')
->toArray();
if (empty($serialNumbers))
{
Notification::make()
->title('No Serial Numbers found!')
->body('Please check the selected Plant & Reference Number.')
->danger()
->send();
return;
}
// Encode as JSON string in QR Code
// $qrData = json_encode([
// 'serial_numbers' => $serialNumbers,
// ]);
//$qrData = implode(',', $serialNumbers);
$qrData = implode("\n", $serialNumbers);
$qrCode = base64_encode(
QrCode::format('png')
->size(1200) // smaller, still high res
->margin(6) // white border
->errorCorrection('Q')// medium-high correction
->generate($qrData)
);
// Send data to Pdf view
$pdf = PDF::loadView('pdf.qrcode', [
'qrCode' => $qrCode,
'referenceNumber' => $refNumber,
]);
return response()->streamDownload(function () use ($pdf) {
echo $pdf->output();
}, "qr-sticker.pdf");
}
}

View File

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

View File

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

View File

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

View File

@@ -1,55 +0,0 @@
<?php
namespace App\Livewire;
use Livewire\Component;
use App\Models\StickerPrinting;
class StickerPrintData extends Component
{
public $plantId;
public $refNumber;
public $serialNumber;
public bool $materialInvoice = false;
public $records = [];
protected $listeners = [
'refreshEmptySticker' => 'loadStickerData',
'addStickerToList' => 'loadSticker'
];
public function loadStickerData($plantId, $refNumber)
{
$this->plantId = $plantId;
$this->refNumber = $refNumber;
$this->materialInvoice = true;
$this->records = StickerPrinting::where('plant_id', $plantId)
->where('reference_number', $refNumber)
->orderBy('created_at', 'asc')
->get(['serial_number', 'created_by']);
}
public function loadSticker($plantId, $refNumber, $serialNumber)
{
$this->plantId = $plantId;
$this->refNumber = $refNumber;
$this->materialInvoice = true;
$this->records = StickerPrinting::where('plant_id', $plantId)
->where('reference_number', $refNumber)
->orderBy('created_at', 'asc')
->get(['serial_number', 'created_by']);
}
public function render()
{
return view('livewire.sticker-print-data');
}
}

View File

@@ -1,29 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class StickerPrinting extends Model
{
//
use SoftDeletes;
protected $fillable = [
'plant_id',
'reference_number',
'serial_number',
'created_at',
'updated_at',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
}

View File

@@ -1,107 +0,0 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\StickerPrinting;
use App\Models\User;
class StickerPrintingPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any StickerPrinting');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('view StickerPrinting');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create StickerPrinting');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('update StickerPrinting');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('delete StickerPrinting');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any StickerPrinting');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('restore StickerPrinting');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any StickerPrinting');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('replicate StickerPrinting');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder StickerPrinting');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, StickerPrinting $stickerprinting): bool
{
return $user->checkPermissionTo('force-delete StickerPrinting');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any StickerPrinting');
}
}

View File

@@ -10,7 +10,7 @@
"alperenersoy/filament-export": "^3.0", "alperenersoy/filament-export": "^3.0",
"althinect/filament-spatie-roles-permissions": "^2.3", "althinect/filament-spatie-roles-permissions": "^2.3",
"erag/laravel-pwa": "^1.9", "erag/laravel-pwa": "^1.9",
"filament/filament": "^3.3", "filament/filament": "^4.0",
"intervention/image": "^3.11", "intervention/image": "^3.11",
"irazasyed/telegram-bot-sdk": "^3.15", "irazasyed/telegram-bot-sdk": "^3.15",
"laravel/framework": "^11.31", "laravel/framework": "^11.31",

View File

@@ -213,8 +213,6 @@ return [
'user_model' => \App\Models\User::class, 'user_model' => \App\Models\User::class,
// 'user_model_class' => \App\Models\User::class,
'policies_namespace' => 'App\Policies', 'policies_namespace' => 'App\Policies',
], ],
]; ];

View File

@@ -1,40 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
CREATE TABLE sticker_printings (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
reference_number TEXT DEFAULT NULL,
serial_number TEXT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by TEXT DEFAULT NULL,
updated_by TEXT DEFAULT NULL,
deleted_at TIMESTAMP,
FOREIGN KEY (plant_id) REFERENCES plants (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sticker_printings');
}
};

View File

@@ -169,7 +169,6 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view import process order']); Permission::updateOrCreate(['name' => 'view import process order']);
Permission::updateOrCreate(['name' => 'view export process order']); Permission::updateOrCreate(['name' => 'view export process order']);
Permission::updateOrCreate(['name' => 'view import sticker printing']);
Permission::updateOrCreate(['name' => 'view export sticker printing']);
} }
} }

View File

@@ -1,24 +0,0 @@
<x-filament::page>
<form wire:submit.prevent="create" class="space-y-6">
{{-- Form Section --}}
<div class="filament-form space-y-6">
{{ $this->form }}
</div>
{{-- <livewire:notification-sound /> --}}
{{-- Livewire Component (Invoice Table) --}}
<div class="bg-white shadow rounded-xl p-4">
<livewire:sticker-print-data :ref-data="$ref_number" />
</div>
{{-- Actions --}}
<div class="filament-actions mt-6">
<x-filament::actions>
@foreach ($this->getFormActions() as $action)
{{ $action }}
@endforeach
</x-filament::actions>
</div>
</form>
</x-filament::page>

View File

@@ -1,23 +0,0 @@
{{-- <div class="flex flex-col items-start space-y-2">
<button
type="button"
wire:click="printSticker"
class="mt-15 px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Print
</button>
</div> --}}
<div class="flex flex-col items-start space-y-2">
<button
type="button"
wire:click="printSticker"
class="px-2 py-1 border border-primary-500 text-primary-600 bg-white rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
style="margin-top: 10mm;"
>
Print
</button>
</div>

View File

@@ -1,81 +0,0 @@
{{-- <div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
<table class="table-auto w-full border-collapse border">
<thead class="bg-gray-100">
<tr>
<th class="border p-2">No</th>
<th class="border p-2">Reference No</th>
<th class="border p-2">Serial Number</th>
<th class="border p-2">Created By</th>
</tr>
</thead>
<tbody>
@forelse($records as $index => $record)
<tr>
<td class="border p-2 text-center">{{ $index + 1 }}</td>
<td class="border p-2 text-center">{{ $refNumber }}</td>
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
<td class="border p-2 text-center">{{ $record->created_by }}</td>
</tr>
@empty
<tr>
<td class="border p-2 text-center" colspan="4">No serial numbers found.</td>
</tr>
@endforelse
</tbody>
</table>
</div> --}}
<div>
<h3 class="text-lg font-semibold mb-2">Sticker Printing Table</h3>
<div
wire:loading.remove
@if(!$materialInvoice) style="display:none" @endif
class="overflow-x-auto overflow-y-visible"
style="height: 385px;"
>
<table class="table-auto w-full border-collapse border">
{{-- <thead class="bg-gray-100"> --}}
<thead class="bg-gray-100 text-xs">
<tr>
<th class="border p-2">No</th>
<th class="border p-2">Reference No</th>
<th class="border p-2">Serial Number</th>
<th class="border p-2">Created By</th>
</tr>
</thead>
{{-- <tbody> --}}
<tbody class="text-xs">
@forelse($records as $index => $record)
<tr>
<td class="border p-2 text-center">{{ $index + 1 }}</td>
<td class="border p-2 text-center">{{ $refNumber }}</td>
<td class="border p-2 text-center">{{ $record['serial_number'] }}</td>
<td class="border p-2 text-center">{{ $record->created_by }}</td>
</tr>
@empty
<tr>
<td class="border p-2 text-center" colspan="4">No serial numbers found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<script>
window.addEventListener('focus-serial-number', () => {
setTimeout(() => {
const container = document.getElementById('serial_number_input');
const input = container?.querySelector('input'); // gets the actual input inside
if (input) {
input.focus();
input.select();
}
}, 50);
});
</script>

View File

@@ -1,92 +0,0 @@
{{-- <!DOCTYPE html>
<html>
<head>
<style>
body { text-align: center; font-family: Arial, sans-serif; }
.qr-container { margin-top: 30px; }
</style>
</head>
<body>
<div class="qr-container">
<img src="data:image/png;base64,{{ $qrCode }}" width="250" height="250">
</div>
</body>
</html> --}}
{{-- <!DOCTYPE html>
<html>
<head>
<style>
@page {
margin: 0;
size: 100mm 100mm;
}
body {
margin: 0;
padding: 0;
width: 100mm;
height: 100mm;
display: flex;
justify-content: center;
align-items: center;
}
img {
width: 100mm;
height: 100mm;
}
</style>
</head>
<body>
<img src="data:image/png;base64,{{ $qrCode }}" />
</body>
</html> --}}
<!DOCTYPE html>
<html>
<head>
<style>
@page {
margin: 0;
size: 100mm 100mm;
}
body {
margin: 0;
padding: 0;
width: 100mm;
height: 100mm;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
font-size: 12px;
font-family: Arial, sans-serif;
}
img {
width: 90mm; /* QR CODE REDUCED TO FIT TEXT */
height: 90mm;
}
.ref-text {
margin-top: 3mm;
font-size: 16px; /* Increased Font Size */
font-weight: bold;
}
</style>
</head>
<body>
<div class="ref-text">
{{ $referenceNumber }}
</div>
<img src="data:image/png;base64,{{ $qrCode }}" />
</body>
</html>