1 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
59 changed files with 932 additions and 6864 deletions

View File

@@ -36,8 +36,8 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-npm-global- ${{ runner.os }}-npm-global-
# - name: Install Gemini CLI globally - name: Install Gemini CLI globally
# run: npm install -g --loglevel=http @google/gemini-cli run: npm install -g --loglevel=http @google/gemini-cli
- name: Generate git diff and review with Gemini - name: Generate git diff and review with Gemini
id: review id: review

View File

@@ -1,202 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\Schedule;
use App\Models\AlertMailRule;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
class Scheduler extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
// protected $signature = 'app:scheduler';
protected $signature = 'custom:scheduler';
/**
* The console command description.
*
* @var string
*/
// protected $description = 'Command description';
protected $description = 'Manually trigger scheduler logic';
/**
* Execute the console command.
*/
// public function handle()
// {
// //
// }
public function handle()
{
// --- Production Rules ---
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->select('plant', 'schedule_type')
->distinct()
->get();
foreach ($productionRules as $rule) {
switch ($rule->schedule_type) {
case 'Live':
// Run every minute
\Artisan::call('send:production-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
break;
case 'Hourly':
if (now()->minute == 0) {
\Artisan::call('send:production-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
case 'Daily':
if (now()->format('H:i') == '07:59') {
\Artisan::call('send:production-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
}
}
// --- Invoice Validation Rules ---
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
->where('rule_name', 'InvoiceMail')
->select('plant', 'schedule_type')
->distinct()
->get();
foreach ($invoiceRules as $rule) {
switch ($rule->schedule_type) {
case 'Live':
// Run every minute
\Artisan::call('send:invoice-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
break;
case 'Hourly':
if (now()->minute == 0) {
\Artisan::call('send:invoice-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
case 'Daily':
if (now()->format('H:i') == '07:59') {
\Artisan::call('send:invoice-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
}
}
// foreach ($invoiceRules as $rule) {
// switch ($rule->schedule_type) {
// case 'Live':
// try {
// Artisan::call('send:invoice-report', [
// 'schedule_type' => $rule->schedule_type,
// 'plant' => $rule->plant,
// ]);
// Log::info('Invoice report sent | Plant: '.$rule->plant);
// } catch (\Throwable $e) {
// Log::error("Invoice Live Failed ({$rule->plant}): ".$e->getMessage());
// }
// break;
// case 'Hourly':
// if (now()->minute == 0) {
// Artisan::call('send:invoice-report', [
// 'schedule_type' => $rule->schedule_type,
// 'plant' => $rule->plant,
// ]);
// }
// break;
// case 'Daily':
// if (now()->format('H:i') == '07:59') {
// Artisan::call('send:invoice-report', [
// 'schedule_type' => $rule->schedule_type,
// 'plant' => $rule->plant,
// ]);
// }
// break;
// }
// }
// --- Invoice Data Report Rules ---
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
->where('rule_name', 'InvoiceDataMail')
->select('plant', 'schedule_type')
->distinct()
->get();
foreach ($invoiceDataRules as $rule) {
switch ($rule->schedule_type) {
case 'Live':
// Run every minute
\Artisan::call('send:invoice-data-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
break;
case 'Hourly':
if (now()->minute == 0) {
\Artisan::call('send:invoice-data-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
case 'Daily':
if (now()->format('H:i') == '10:00') {
\Artisan::call('send:invoice-data-report', [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
}
break;
}
}
}
/**
* Helper to call Artisan commands with parameters.
*/
protected function callArtisanCommand($commandName, $rule)
{
\Artisan::call($commandName, [
'schedule_type' => $rule->schedule_type,
'plant' => $rule->plant,
]);
$this->info("Executed {$commandName} for plant: {$rule->plant}");
\Log::info("Executed {$commandName} for plant: {$rule->plant}");
}
}

View File

@@ -2,11 +2,11 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Mail\test;
use App\Models\InvoiceValidation; use App\Models\InvoiceValidation;
use App\Models\Plant; use App\Models\Plant;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use App\Mail\test;
class SendInvoiceReport extends Command class SendInvoiceReport extends Command
{ {
@@ -15,8 +15,9 @@ class SendInvoiceReport extends Command
* *
* @var string * @var string
*/ */
// protected $signature = 'app:send-invoice-report'; // protected $signature = 'app:send-invoice-report';
protected $signature = 'send:invoice-report {schedule_type} {plant}'; protected $signature = 'send:invoice-report{schedule_type} {plant}';
/** /**
* The console command description. * The console command description.
@@ -28,10 +29,12 @@ class SendInvoiceReport extends Command
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle() public function handle()
{ {
$schedule = $this->argument('schedule_type'); $schedule = $this->argument('schedule_type');
// $scheduleType = $this->argument('scheduleType'); //$scheduleType = $this->argument('scheduleType');
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants $plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name'); $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
@@ -49,14 +52,18 @@ class SendInvoiceReport extends Command
: [$plantIdArg]; : [$plantIdArg];
$no = 1; $no = 1;
if (strtolower($schedule) == 'daily') { if (strtolower($schedule) == 'daily')
{
$startDate = now()->subDay()->setTime(8, 0, 0); $startDate = now()->subDay()->setTime(8, 0, 0);
$endDate = now()->setTime(8, 0, 0); $endDate = now()->setTime(8, 0, 0);
} else { }
else
{
$startDate = now()->setTime(8, 0, 0); $startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0); $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
} }
foreach ($plantIds as $plantId) { foreach ($plantIds as $plantId)
{
$plant = Plant::find($plantId); $plant = Plant::find($plantId);
$plantName = $plant ? $plant->name : $plantId; $plantName = $plant ? $plant->name : $plantId;
@@ -82,7 +89,7 @@ class SendInvoiceReport extends Command
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId) $scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('scanned_status', 'Scanned') ->where('scanned_status', 'Scanned')
->where(function ($query) { ->where(function($query) {
$query->whereNull('quantity') $query->whereNull('quantity')
->orWhere('quantity', 0); ->orWhere('quantity', 0);
}) })
@@ -121,7 +128,7 @@ class SendInvoiceReport extends Command
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId) $scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1) ->where('quantity', 1)
->whereNotNull('serial_number') ->whereNotNull('serial_number')
->where('serial_number', '!=', '') ->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate]) ->whereBetween('updated_at', [$startDate, $endDate])
->count(); ->count();
@@ -157,7 +164,7 @@ class SendInvoiceReport extends Command
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId) $scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1) ->where('quantity', '>', 1)
->whereNotNull('serial_number') ->whereNotNull('serial_number')
->where('serial_number', '!=', '') ->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate]) ->whereBetween('updated_at', [$startDate, $endDate])
->count(); ->count();
@@ -186,6 +193,7 @@ class SendInvoiceReport extends Command
} }
} }
// Send to MaterialInvoiceMail recipients (material + bundle table) // Send to MaterialInvoiceMail recipients (material + bundle table)
if ($mailRules->has('MaterialInvoiceMail')) { if ($mailRules->has('MaterialInvoiceMail')) {
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray(); $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
@@ -204,14 +212,16 @@ class SendInvoiceReport extends Command
// Show preview in console // Show preview in console
$this->info('--- Serial Invoice Table ---'); $this->info('--- Serial Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData); $this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
$this->info('--- Material Invoice Table ---'); $this->info('--- Material Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData); $this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
$this->info('--- Bundle Invoice Table ---'); $this->info('--- Bundle Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData); $this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
$this->info($contentVars['wishes'] ?? ''); $this->info($contentVars['wishes'] ?? '');
} }
} }

View File

@@ -1,44 +0,0 @@
<?php
namespace App\Filament\Exports;
use App\Models\CharacteristicValue;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class CharacteristicValueExporter extends Exporter
{
protected static ?string $model = CharacteristicValue::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('plant.name'),
ExportColumn::make('line.name'),
ExportColumn::make('item.id'),
ExportColumn::make('machine.name'),
ExportColumn::make('process_order'),
ExportColumn::make('coil_number'),
ExportColumn::make('status'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('created_by'),
ExportColumn::make('updated_by'),
ExportColumn::make('deleted_at'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your characteristic value 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,70 +0,0 @@
<?php
namespace App\Filament\Exports;
use App\Models\ProductCharacteristicsMaster;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class ProductCharacteristicsMasterExporter extends Exporter
{
protected static ?string $model = ProductCharacteristicsMaster::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.name')
->label('PLANT'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('line.name')
->label('LINE NAME'), //machine.workGroupMaster.name
ExportColumn::make('machine.workGroupMaster.name')
->label('WORK GROUP MASTER'),
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('characteristics_type')
->label('CHARACTERISTICS TYPE'),
ExportColumn::make('name')
->label('NAME'),
ExportColumn::make('inspection_type')
->label('INSPECTION TYPE'),
ExportColumn::make('upper')
->label('UPPER'),
ExportColumn::make('lower')
->label('LOWER'),
ExportColumn::make('middle')
->label('MIDDLE'),
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 product characteristics 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

@@ -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,61 +0,0 @@
<?php
namespace App\Filament\Imports;
use App\Models\CharacteristicValue;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class CharacteristicValueImporter extends Importer
{
protected static ?string $model = CharacteristicValue::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('machine')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('process_order'),
ImportColumn::make('coil_number'),
ImportColumn::make('status'),
ImportColumn::make('created_by'),
ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?CharacteristicValue
{
// return CharacteristicValue::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new CharacteristicValue();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your characteristic value 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

@@ -1,282 +0,0 @@
<?php
namespace App\Filament\Imports;
use App\Models\Item;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\ProductCharacteristicsMaster;
use App\Models\User;
use App\Models\WorkGroupMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Illuminate\Support\Facades\Auth;
class ProductCharacteristicsMasterImporter extends Importer
{
protected static ?string $model = ProductCharacteristicsMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('Item Code')
->example('630214')
->label('Item Code')
->relationship(resolveUsing:'code')
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->exampleHeader('Line')
->example('4 inch pump line')
->label('Line')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('work_group_master_id')
->label('Group Work Center')
->requiredMapping()
->exampleHeader('Group Work Center')
->example('RMGCGABC')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('machine')
->requiredMapping()
->exampleHeader('Work Center')
->example('RMGCE001')
->label('Work Center')
->relationship(resolveUsing:'work_center')
->rules(['required']),
ImportColumn::make('characteristics_type')
->exampleHeader('Characteristics Type')
->example('Process or Product')
->label('Characteristics Type')
->rules(['required']),
ImportColumn::make('name')
->exampleHeader('Name')
->example('Body')
->label('Name')
->rules(['required']),
ImportColumn::make('inspection_type')
->exampleHeader('Inspection Type')
->example('Visual or Value')
->label('Inspection Type')
->rules(['required']),
ImportColumn::make('lower')
->exampleHeader('Lower')
->example('-0.2')
->label('Lower')
->rules(['numeric']),
ImportColumn::make('middle')
->exampleHeader('Middle')
->example('1')
->label('Middle')
->numeric()
->rules(['numeric']),
ImportColumn::make('upper')
->exampleHeader('Upper')
->example('0.2')
->label('Upper')
->rules(['numeric']),
ImportColumn::make('created_by')
->exampleHeader('Created By')
->example('Admin')
->label('Created By'),
//ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?ProductCharacteristicsMaster
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
$itemExists = Item::where('code', $this->data['item'])->first();
if (!$itemExists) {
$warnMsg[] = "Item not found";
}
$itemAgainstPlant = Item::where('code', $this->data['item'])
->where('plant_id', $plant->id)
->first();
if (!$itemAgainstPlant) {
$warnMsg[] = "Item code not found for the given plant";
}
else {
$itemId = $itemAgainstPlant->id;
}
$lineExists = Line::where('name', $this->data['line'])->first();
if (!$lineExists) {
$warnMsg[] = "Line not found";
}
$lineAgainstPlant = Line::where('name', $this->data['line'])
->where('plant_id', $plant->id)
->first();
if (!$lineAgainstPlant) {
$warnMsg[] = "Line not found for the given plant";
}
else
{
$LineId = $lineAgainstPlant->id;
}
$WorkgroupMaster = WorkGroupMaster::where('name', $this->data['work_group_master_id'])->where('plant_id', $plant->id)->first();
if (!$WorkgroupMaster) {
$warnMsg[] = "Work Group Master value not found";
}
else {
$workGroupMasterId = $WorkgroupMaster->id;
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
$existsInLine = Line::where('plant_id', $plant->id)
->where(function ($q) use ($workGroupMasterId) {
for ($i = 1; $i <= 10; $i++) {
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
}
})
->exists();
if (!$existsInLine) {
$warnMsg[] = "Work Group Master '{$WorkgroupMaster->name}' is not mapped to any line in this plant";
}
else {
$workGroupMasterId = $WorkgroupMaster->id;
}
}
$machine = Machine::where('work_center', $this->data['machine'])->first();
if (!$machine) {
$warnMsg[] = "Work Center not found";
}
else {
$machineId = $machine->id;
}
$machineAgainstPlant = Machine::where('work_center', $this->data['machine'])
->where('plant_id', $plant->id)
->first();
if (!$machineAgainstPlant) {
$warnMsg[] = "Work Center not found for the given plant";
}
else
{
$machineId = $machineAgainstPlant->id;
}
$user = User::where('name', $this->data['created_by'])->first();
if (!$user) {
$warnMsg[] = "Operator ID not found";
}
if (($this->data['inspection_type'] ?? null) == 'Value') {
$upper = $this->data['upper'] ?? null;
$lower = $this->data['lower'] ?? null;
$middle = $this->data['middle'] ?? null;
if (is_null($upper) || is_null($lower) || is_null($middle)) {
$warnMsg[] = "For 'Value' inspection type, Upper, Lower, and Middle values are required.";
} elseif (!is_numeric($upper) || !is_numeric($lower) || !is_numeric($middle)) {
$warnMsg[] = "Upper, Lower, and Middle values must be numeric.";
} elseif (!($lower <= $middle && $middle <= $upper)) {
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower ≤ Middle ≤ Upper.";
}
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
else
{
$record = ProductCharacteristicsMaster::firstOrNew([
'plant_id' => $plant->id,
'item_id' => $itemId,
'line_id' => $LineId,
'work_group_master_id' => $workGroupMasterId,
'machine_id' => $machineId,
]);
$currentUser = Auth::check() ? Auth::user()->name : ($this->data['created_by'] ?? 'System');
// If record is new, fill all fields
if (!$record->exists) {
$record->name = $this->data['name'];
$record->characteristics_type = $this->data['characteristics_type'];
$record->inspection_type = $this->data['inspection_type'];
$record->upper = $this->data['upper'] ?? null;
$record->lower = $this->data['lower'] ?? null;
$record->middle = $this->data['middle'] ?? null;
$record->created_by = $currentUser;
} else {
// Record exists → update only updated_by and updated_at
$record->updated_by = $currentUser;
$record->touch();
}
$record->save();
return null;
}
// else
// {
// ProductCharacteristicsMaster::updateOrCreate(
// [
// 'plant_id' => $plant->id,
// 'item_id' => $itemId,
// 'line_id' => $LineId,
// 'work_group_master_id' => $workGroupMasterId,
// 'machine_id'=> $machineId,
// ],
// [
// 'name' => $this->data['name'],
// 'characteristics_type' => $this->data['characteristics_type'],
// 'inspection_type' => $this->data['inspection_type'],
// 'upper' => $this->data['upper'] ?? null,
// 'lower' => $this->data['lower'] ?? null,
// 'middle' => $this->data['middle'] ?? null,
// //'created_by' => user ?? $this->data['created_by'],
// 'created_by' => Auth::check() ? Auth::user()->name :($this->data['created_by'] ?? null)
// ]
// );
// return null;
// }
//return new WorkGroupMaster();
// return new ProductCharacteristicsMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your product characteristics 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

@@ -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')
@@ -70,6 +70,7 @@ class AlertMailRuleResource extends Resource
->label('CC Emails'), ->label('CC Emails'),
Forms\Components\Select::make('schedule_type') Forms\Components\Select::make('schedule_type')
->label('Schedule Type') ->label('Schedule Type')
->required()
->options([ ->options([
'Live' => 'Live', 'Live' => 'Live',
'Hourly' => 'Hourly', 'Hourly' => 'Hourly',

View File

@@ -1,516 +0,0 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\CharacteristicValueExporter;
use App\Filament\Imports\CharacteristicValueImporter;
use App\Filament\Resources\CharacteristicValueResource\Pages;
use App\Filament\Resources\CharacteristicValueResource\RelationManagers;
use App\Models\CharacteristicValue;
use App\Models\Item;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Facades\Filament;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
class CharacteristicValueResource extends Resource
{
protected static ?string $model = CharacteristicValue::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Process Order';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->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();
})
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('item_id', null);
$set('line_id', null);
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->extraAttributes(fn ($get) => [
'class' => $get('poPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
->hintColor('danger')
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('item_id', null);
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required(),
Forms\Components\Select::make('item_id')
->label('Item')
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id')) {
return [];
}
return Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required()
->searchable(),
Forms\Components\Select::make('machine_id')
->label('Machine')
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id') || !$get('item_id')) {
return [];
}
return Machine::where('plant_id', $get('plant_id'))
->where('line_id', $get('line_id'))
->pluck('work_center', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('process_order', null);
$set('coil_number', null);
$set('status', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required(),
Forms\Components\TextInput::make('process_order')
->label('Process Order')
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('coil_number', null);
$set('status', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->required(),
Forms\Components\TextInput::make('coil_number')
->label('Coil Number')
// ->reactive()
// ->afterStateUpdated(function ($state, $set, callable $get) {
// $plantId = $get('plant_id');
// $set('status', null);
// if (! $plantId) {
// $set('poPlantError', 'Please select a plant first.');
// }
// })
// ->required(),
->label('Coil Number')
->default('0')
->reactive()
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$processOrder = $get('process_order');
$coilNo = $get('coil_number');
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
} elseif (! $processOrder) {
$set('coil_number', null);
$set('poPlantError', null);
} elseif ($coilNo || $coilNo == '0') {
$existing = CharacteristicValue::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
$set('poPlantError', null);
$set('coil_number', null);
$set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
} else {
$set('poPlantError', null);
$set('coilNumberError', null);
}
}
})
->extraAttributes(fn ($get) => [
'class' => $get('coilNumberError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('coilNumberError') ? $get('coilNumberError') : null)
->hintColor('danger')
->required(),
Forms\Components\Select::make('status')
->label('Status')
->options([
'Ok' => 'OK',
'NotOk' => 'Not Ok'
])
->reactive()
->required(),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Machine')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('process_order')
->label('Process Order')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('coil_number')
->label('Coil Number')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('status')
->label('Status')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
}),
Select::make('Line')
->label('Select Line')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if(empty($plantId)) {
return [];
}
return Line::where('plant_id', $plantId)->pluck('name', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
}),
Select::make('Item')
->label('Item Code')
->nullable()
->searchable()
->options(function (callable $get) {
$plantId = $get('Plant');
if(empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
Select::make('Machine')
->label('Select Machine')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
$lineId = $get('Line');
if(empty($plantId) || empty($lineId)) {
return [];
}
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
TextInput::make('process_order')
->label('Process Order')
->placeholder('Enter Process Order'),
TextInput::make('coil_number')
->label('Coil Number')
->placeholder(placeholder: 'Enter Coil Number'),
Select::make('status')
->label('Status')
->options([
'Ok' => 'OK',
'NotOk' => 'Not Ok'
]),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['Machine']) && empty($data['process_order']) && empty($data['coil_number']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['Line'])) {
$query->where('line_id', $data['Line']);
}
if (!empty($data['Item'])) {
$query->where('item_id', $data['Item']);
}
if (!empty($data['Machine'])) {
$query->where('machine_id', $data['Machine']);
}
if (!empty($data['process_order'])) {
$query->where('process_order', $data['process_order']);
}
if (!empty($data['coil_number'])) {
$query->where('coil_number', $data['coil_number']);
}
if (!empty($data['status'])) {
$query->where('status', $data['status']);
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
//$query->orderBy('created_at', 'asc');
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['Line'])) {
$indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name');
}
if (!empty($data['Item'])) {
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
}
if (!empty($data['Machine'])) {
$indicators[] = 'Machine: ' . Machine::where('id', $data['Machine'])->value('work_center');
}
if (!empty($data['process_order'])) {
$indicators[] = 'Process Order: ' . $data['process_order'];
}
if (!empty($data['coil_number'])) {
$indicators[] = 'Coil Number: ' . $data['coil_number'];
}
if (!empty($data['status'])) {
$indicators[] = 'Status: ' . $data['status'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'To: ' . $data['created_to'];
}
return $indicators;
})
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(CharacteristicValueImporter::class)
->label('Import Characteristic Value')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view import characteristic value');
}),
ExportAction::make()
->exporter(CharacteristicValueExporter::class)
->label('Export Characteristic Value')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view export characteristic value');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCharacteristicValues::route('/'),
'create' => Pages\CreateCharacteristicValue::route('/create'),
'view' => Pages\ViewCharacteristicValue::route('/{record}'),
'edit' => Pages\EditCharacteristicValue::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -1,12 +0,0 @@
<?php
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
use App\Filament\Resources\CharacteristicValueResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateCharacteristicValue extends CreateRecord
{
protected static string $resource = CharacteristicValueResource::class;
}

View File

@@ -1,22 +0,0 @@
<?php
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
use App\Filament\Resources\CharacteristicValueResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditCharacteristicValue extends EditRecord
{
protected static string $resource = CharacteristicValueResource::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\CharacteristicValueResource\Pages;
use App\Filament\Resources\CharacteristicValueResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListCharacteristicValues extends ListRecords
{
protected static string $resource = CharacteristicValueResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

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

View File

@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction; use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
use App\Filament\Exports\InvoiceValidationExporter; use App\Filament\Exports\InvoiceValidationExporter;
use App\Filament\Resources\InvoiceValidationResource\Pages; use App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Mail\InvoiceNotification;
use App\Models\InvoiceValidation; use App\Models\InvoiceValidation;
use App\Models\Item; use App\Models\Item;
use App\Models\Plant; use App\Models\Plant;
@@ -30,6 +29,7 @@ use Filament\Tables;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\View;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Tables\Actions\Action; use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ExportAction;
@@ -38,10 +38,6 @@ use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire; use Livewire\Livewire;
use Str; use Str;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Mail;
use Filament\Forms\Components\View;
class InvoiceValidationResource extends Resource class InvoiceValidationResource extends Resource
{ {
@@ -53,8 +49,6 @@ class InvoiceValidationResource extends Resource
public $invoiceNumber; public $invoiceNumber;
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form
@@ -125,9 +119,6 @@ class InvoiceValidationResource extends Resource
$invNo = $get('invoice_number'); $invNo = $get('invoice_number');
$set('serial_number', null); $set('serial_number', null);
$set('update_invoice', null); $set('update_invoice', null);
//Session::put('invoice_number', $state);
session(['invoice_number' => $state]);
// if (!$invNo) { return; } else { } // if (!$invNo) { return; } else { }
}), }),
@@ -135,32 +126,17 @@ class InvoiceValidationResource extends Resource
->label('Serial Number') ->label('Serial Number')
->reactive() ->reactive()
->readOnly(fn (callable $get) => empty($get('invoice_number'))) ->readOnly(fn (callable $get) => empty($get('invoice_number')))
->disabled(fn (Get $get) => empty($get('invoice_number'))) //->disabled(fn (Get $get) => empty($get('invoice_number')))
// ->extraAttributes([
// 'id' => 'serial_number_input',
// 'x-data' => '{ value: "" }',
// 'x-model' => 'value',
// 'wire:keydown.enter.prevent' => 'processSerial(value)', // Using wire:keydown
// ])
->dehydrated(false) // Do not trigger Livewire syncing
->extraAttributes([ ->extraAttributes([
'id' => 'serial_number_input', 'id' => 'serial_number_input',
'x-on:keydown.enter.prevent' => " 'x-data' => '{ value: "" }',
let serial = \$event.target.value; 'x-model' => 'value',
if (serial.trim() != '') { 'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
\$wire.dispatch('process-scan', serial);
\$event.target.value = '';
}
",
]) ])
->afterStateUpdated(function ($state, callable $set, callable $get, callable $livewire) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('update_invoice', 0); $set('update_invoice', 0);
// $this->dispatch('focus-serial-number'); // $this->dispatch('focus-serial-number');
// if (!$invNo) { return; } else { } // if (!$invNo) { return; } else { }
// if ($state) {
// $livewire('process-scan', $state);
// $set('serial_number', null);
// }
}) })
->columnSpan(1), ->columnSpan(1),
Forms\Components\TextInput::make('total_quantity') Forms\Components\TextInput::make('total_quantity')
@@ -1280,24 +1256,6 @@ class InvoiceValidationResource extends Resource
]; ];
} }
// public static function render(): View
// {
// if (session()->has('invoice_number')) {
// $invoiceNumber = session('invoice_number');
// // Debug: show the invoice number
// dd($invoiceNumber); // This will stop execution and show the value
// // Trigger email
// \Mail::to('jothikumar.padmanaban@cripumps.com')
// ->send(new InvoiceNotification($invoiceNumber));
// // Clear session so it doesn't resend on next refresh
// //session()->forget('invoice_number');
// }
// // return view('filament.resources.invoice-validation-resource.pages.list-invoice-validation');
// }
public static function getEloquentQuery(): Builder public static function getEloquentQuery(): Builder
{ {
return parent::getEloquentQuery() return parent::getEloquentQuery()

View File

@@ -19,7 +19,6 @@ use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Str; use Str;
use Livewire\Attributes\On;
class CreateInvoiceValidation extends CreateRecord class CreateInvoiceValidation extends CreateRecord
{ {
@@ -70,7 +69,7 @@ class CreateInvoiceValidation extends CreateRecord
$totQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count(); $totQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count(); $scanSQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
// $this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
if ($totQuan == $scanSQuan) { if ($totQuan == $scanSQuan) {
$this->form->fill([ $this->form->fill([
'plant_id' => $this->plantId, 'plant_id' => $this->plantId,
@@ -2261,7 +2260,7 @@ class CreateInvoiceValidation extends CreateRecord
]; ];
} }
public function processSer($serNo) public function processSerialNumber($serNo)
{ {
$serNo = trim($serNo); $serNo = trim($serNo);
$mSerNo = $serNo; $mSerNo = $serNo;
@@ -2371,18 +2370,18 @@ class CreateInvoiceValidation extends CreateRecord
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2405,19 +2404,19 @@ class CreateInvoiceValidation extends CreateRecord
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2440,19 +2439,19 @@ class CreateInvoiceValidation extends CreateRecord
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2482,18 +2481,18 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2514,18 +2513,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2556,18 +2555,18 @@ class CreateInvoiceValidation extends CreateRecord
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2589,18 +2588,18 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2631,18 +2630,18 @@ class CreateInvoiceValidation extends CreateRecord
// .Mail // .Mail
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2669,18 +2668,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2706,18 +2705,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2742,18 +2741,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotValidMaterialType') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotValidMaterialType')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2784,18 +2783,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotInvoice') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotInvoice')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -2825,18 +2824,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mInvoiceType = 'Material'; $mInvoiceType = 'Material';
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'Item') new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'Item')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -3099,6 +3098,22 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// ..Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, 'InvalidFormat')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3140,6 +3155,23 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('play-warn-sound'); $this->dispatch('play-warn-sound');
// ..Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFound')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
// ..
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3171,11 +3203,9 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (! empty($emails)) { if (! empty($emails)) {
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice') new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice')
); );
} else { } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
@@ -3210,6 +3240,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundItemS')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3222,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;
@@ -3233,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;
@@ -3262,6 +3302,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotValidPackage')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3300,6 +3353,18 @@ class CreateInvoiceValidation extends CreateRecord
->seconds(3) ->seconds(3)
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotMotorQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -3321,6 +3386,21 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// ..Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateMotorQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3381,18 +3461,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
// $mInvoiceType = 'Serial'; $mInvoiceType = 'Serial';
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// if (! empty($emails)) { if (! empty($emails)) {
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice') new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -3431,6 +3511,20 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotPumpQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3450,6 +3544,20 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3511,19 +3619,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
// $mInvoiceType = 'Serial'; $mInvoiceType = 'Serial';
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// if (! empty($emails)) { if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice') new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -3564,6 +3672,20 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'MissingPanelBox')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3584,21 +3706,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
// $mInvoiceType = 'Serial'; $mInvoiceType = 'Serial';
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name; if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// if (! empty($emails)) { Mail::to($emails)->send(
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateCapacitorQR')
// Mail::to($emails)->send( );
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'DuplicateCapacitorQR') } else {
// ); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } else { }
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -3642,6 +3762,20 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'UnknownPumpsetQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3662,6 +3796,20 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpsetQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, 'invoice_number' => $invoiceNumber,
@@ -3723,19 +3871,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
// $mInvoiceType = 'Serial'; $mInvoiceType = 'Serial';
// $mailData = $this->getMail(); $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// if (! empty($emails)) { if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv') new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
// ); );
// } else { } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// } }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -3769,12 +3917,6 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
#[On('process-scan')]
public function processSerial($serial)
{
$this->processSer($serial);
}
public function getHeading(): string public function getHeading(): string
{ {
return 'Scan Invoice Validation'; return 'Scan Invoice Validation';

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

@@ -24,12 +24,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile; use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Smalot\PdfParser\Parser; use Smalot\PdfParser\Parser;
use Storage; use Storage;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select;
use App\Models\Line;
use Filament\Forms\Components\TextInput;
use App\Models\Item;
class ProcessOrderResource extends Resource class ProcessOrderResource extends Resource
{ {
@@ -128,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()
@@ -144,34 +137,6 @@ class ProcessOrderResource extends Resource
$set('sfgNumberError', null); $set('sfgNumberError', null);
} }
}) })
->rule(function (callable $get) {
return function (string $attribute, $value, \Closure $fail) use ($get) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
$processOrder = $value;
//$currentId = $get('id'); // current editing record id
if (! $plantId || ! $processOrder) {
return;
}
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', '!=', $itemId)
->first();
if ($existing) {
Notification::make()
->title('Duplicate Process Order!')
->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
->danger()
->send();
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
}
};
})
->required(), ->required(),
Forms\Components\TextInput::make('coil_number') Forms\Components\TextInput::make('coil_number')
->label('Coil Number') ->label('Coil Number')
@@ -525,131 +490,9 @@ class ProcessOrderResource extends Resource
->sortable() ->sortable()
->toggleable(isToggledHiddenByDefault: true), ->toggleable(isToggledHiddenByDefault: true),
]) ])
// ->filters([ ->filters([
// Tables\Filters\TrashedFilter::make(), Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
}),
Select::make('Item')
->label('Item Code')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
TextInput::make('process_order')
->label('Process Order')
->placeholder('Enter Process Order'),
TextInput::make('sfg_number')
->label('Sfg Number')
->placeholder(placeholder: 'Enter Sfg Number'),
TextInput::make('machine_name')
->label('Machine Name')
->placeholder(placeholder: 'Enter Machine Name'),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['sfg_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['machine_name'])) {
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['Item'])) {
$query->where('item_id', $data['Item']);
}
if (!empty($data['process_order'])) {
$query->where('process_order', $data['process_order']);
}
if (!empty($data['sfg_number'])) {
$query->where('sfg_number', $data['sfg_number']);
}
if (!empty($data['machine_name'])) {
// $query->where('machine_name', $data['machine_name']);
$query->where('machine_name', 'like', '%' . $data['machine_name'] . '%');
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
//$query->orderBy('created_at', 'asc');
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['Item'])) {
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
}
if (!empty($data['process_order'])) {
$indicators[] = 'Process Order: ' . $data['process_order'];
}
if (!empty($data['sfg_number'])) {
$indicators[] = 'Sfg Number: ' . $data['sfg_number'];
}
if (!empty($data['machine_name'])) {
$indicators[] = 'Machine Name: ' . $data['machine_name'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'To: ' . $data['created_to'];
}
return $indicators;
})
]) ])
->filtersFormMaxHeight('280px')
->actions([ ->actions([
Tables\Actions\ViewAction::make(), Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(), Tables\Actions\EditAction::make(),

View File

@@ -1,366 +0,0 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\ProductCharacteristicsMasterExporter;
use App\Filament\Imports\ProductCharacteristicsMasterImporter;
use App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
use App\Filament\Resources\ProductCharacteristicsMasterResource\RelationManagers;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\ProductCharacteristicsMaster;
use App\Models\WorkGroupMaster;
use Filament\Facades\Filament;
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\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class ProductCharacteristicsMasterResource extends Resource
{
protected static ?string $model = ProductCharacteristicsMaster::class;
protected static ?string $navigationGroup = 'Process Order';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->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();
})
->reactive()
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'code')
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return Line::where('plant_id', $plantId)->pluck('name', 'id');
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('machine_id', null);
if (!$get('work_group_master_id')) {
$set('machine_id', null);
}
})
->required(),
// ->relationship('line', 'name'),
Forms\Components\Select::make('work_group_master_id')
->label('Group Work Center')
->required()
->reactive()
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id')) {
return [];
}
$line = Line::find($get('line_id'));
$workGroupIds = [];
for ($i = 1; $i <= $line->no_of_operation; $i++) {
$column = "work_group{$i}_id";
if (!empty($line->$column)) {
$workGroupIds[] = $line->$column;
}
}
return WorkGroupMaster::where('plant_id', $get('plant_id'))->whereIn('id', $workGroupIds)->pluck('name', 'id')->toArray();
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
if (!$lineId) {
$set('mGroupWorkError', 'Please select a line first.');
$set('machine_id', null);
return;
}
else
{
// $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// {
// $set('mGroupWorkError', 'Please select a group work center line.');
// $set('line_id', null);
// return;
// }
$set('mGroupWorkError', null);
$set('machine_id', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('mGroupWorkError') ? 'border-red-500' : '',
])
// ->dehydrateStateUsing(fn ($state) => null)
->hint(fn ($get) => $get('mGroupWorkError') ? $get('mGroupWorkError') : null)
->hintColor('danger'),
Forms\Components\Select::make('machine_id')
->label('Work Center')
//->relationship('machine', 'name'),
->searchable()
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
$workGroupId = $get('work_group_master_id');
if (empty($plantId) || empty($lineId) || empty($workGroupId)) {
return [];
}
return Machine::where('plant_id', $plantId)
->where('line_id', $lineId)
->where('work_group_master_id', $workGroupId)
->pluck('work_center', 'id');
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
if (!$get('plant_id') || !$get('line_id') || !$get('work_group_master_id')) {
$set('machine_id', null);
}
})
->required(),
Forms\Components\Select::make('characteristics_type')
->label('Characteristics Type')
->options([
'Product' => 'Product',
'Process' => 'Process',
])
->reactive()
->required(),
Forms\Components\TextInput::make('name')
->label('Name'),
Forms\Components\Select::make('inspection_type')
->label('Inspection Type')
->options([
'Visual' => 'Visual',
'Value' => 'Value',
])
->reactive()
->required(),
// Forms\Components\Select::make('result')
// ->label('Visual Type')
// ->reactive()
// ->options(function (callable $get) {
// if ($get('inspection_type') == 'Visual') {
// return [
// 'Ok' => 'OK',
// 'NotOk' => 'Not Ok',
// ];
// }
// return []; //empty options if type ≠ Visual
// })
// ->afterStateUpdated(function ($state, $set) {
// $set('result', $state); // store in form state only
// session()->put('temp_result', $state);
// })
// ->hidden(fn (callable $get) => $get('inspection_type') != 'Visual'),
Forms\Components\TextInput::make('upper')
->label('Upper')
->numeric()
->default(0.0)
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
Forms\Components\TextInput::make('lower')
->label('Lower')
->numeric()
->default(0.0)
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
Forms\Components\TextInput::make('middle')
->label('Middle')
->numeric()
->visible(fn (callable $get) => $get('inspection_type') == 'Value')
->rule(function (callable $get) {
return function (string $attribute, $value, \Closure $fail) use ($get) {
$lower = $get('lower');
$upper = $get('upper');
$middle = $value;
if (!is_null($lower) && !is_null($upper) && !is_null($middle)) {
if (!($lower <= $middle && $middle <= $upper)) {
$fail("Middle must be between Lower and Upper (Lower ≤ Middle ≤ Upper).");
}
}
};
}),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item Code')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('characteristics_type')
->label('Characteristics Type')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('workGroupMaster.name')
->label('Group Work Center')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('inspection_type')
->label('Inspection Type')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('upper')
->label('Upper')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('lower')
->label('Lower')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('middle')
->label('Middle')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->label('Import Product Characteristics Masters')
->color('warning')
->importer(ProductCharacteristicsMasterImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import product characteristics master');
}),
ExportAction::make()
->label('Export Product Characteristics Masters')
->color('warning')
->exporter(ProductCharacteristicsMasterExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export product characteristics master');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListProductCharacteristicsMasters::route('/'),
'create' => Pages\CreateProductCharacteristicsMaster::route('/create'),
'view' => Pages\ViewProductCharacteristicsMaster::route('/{record}'),
'edit' => Pages\EditProductCharacteristicsMaster::route('/{record}/edit'),
];
}
public static function getNavigationLabel(): string
{
return 'Characteristics';
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -1,23 +0,0 @@
<?php
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
use App\Filament\Resources\ProductCharacteristicsMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateProductCharacteristicsMaster extends CreateRecord
{
protected static string $resource = ProductCharacteristicsMasterResource::class;
public function getTitle(): string
{
return 'Create Characteristics'; // This will replace the "New product characteristics master"
}
// public function getHeading(): string
// {
// return 'Characteristics';
// }
}

View File

@@ -1,49 +0,0 @@
<?php
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
use App\Filament\Resources\ProductCharacteristicsMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditProductCharacteristicsMaster extends EditRecord
{
protected static string $resource = ProductCharacteristicsMasterResource::class;
public function getTitle(): string
{
return 'Edit Characteristics'; // This will replace the "New product characteristics master"
}
public function mount(int|string $record): void
{
parent::mount($record);
$model = $this->getRecord(); // actual model instance
// Step 1: Fill the actual saved fields first
$this->form->fill([
'plant_id' => $model->plant_id,
'line_id' => $model->line_id,
'item_id' => $model->item_id,
'machine_id' => $model->machine_id,
'name' => $model->name,
'type' => $model->type,
'upper' => $model->upper,
'lower' => $model->lower,
'middle' => $model->middle,
'work_group_master_id' => optional($model->machine)->work_group_master_id,
]);
}
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -1,24 +0,0 @@
<?php
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
use App\Filament\Resources\ProductCharacteristicsMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListProductCharacteristicsMasters extends ListRecords
{
protected static string $resource = ProductCharacteristicsMasterResource::class;
public function getTitle(): string
{
return 'Characteristics'; // This will replace the "New product characteristics master"
}
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -1,24 +0,0 @@
<?php
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
use App\Filament\Resources\ProductCharacteristicsMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewProductCharacteristicsMaster extends ViewRecord
{
protected static string $resource = ProductCharacteristicsMasterResource::class;
public function getTitle(): string
{
return 'View Characteristics';
}
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -6,7 +6,6 @@ use App\Filament\Exports\QualityValidationExporter;
use App\Filament\Imports\QualityValidationImporter; use App\Filament\Imports\QualityValidationImporter;
use App\Filament\Resources\QualityValidationResource\Pages; use App\Filament\Resources\QualityValidationResource\Pages;
use App\Filament\Resources\QualityValidationResource\RelationManagers; use App\Filament\Resources\QualityValidationResource\RelationManagers;
// use App\Jobs\SendInvalidQualityMailJob;
use App\Mail\InvalidQualityMail; use App\Mail\InvalidQualityMail;
use App\Models\AlertMailRule; use App\Models\AlertMailRule;
use App\Models\Item; use App\Models\Item;
@@ -14,8 +13,6 @@ use App\Models\Line;
use App\Models\Plant; use App\Models\Plant;
use App\Models\QualityValidation; use App\Models\QualityValidation;
use App\Models\StickerMaster; use App\Models\StickerMaster;
// use App\Models\User;
// use App\Notifications\StatusUpdated;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use Filament\Facades\Filament; use Filament\Facades\Filament;
@@ -48,7 +45,6 @@ class QualityValidationResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Display'; protected static ?string $navigationGroup = 'Display';
public $isSubmitted = false; public $isSubmitted = false;
public $data = []; public $data = [];
@@ -658,6 +654,7 @@ class QualityValidationResource extends Resource
->label('Select Validation') ->label('Select Validation')
->reactive() ->reactive()
->options(fn (callable $get) => $get('part_validation_type_options') ?? []) ->options(fn (callable $get) => $get('part_validation_type_options') ?? [])
->required()
->afterStateUpdated(function ($state, callable $set) { ->afterStateUpdated(function ($state, callable $set) {
// when user selects something new, hide the image // when user selects something new, hide the image
$set('show_validation_image', false); $set('show_validation_image', false);
@@ -710,6 +707,7 @@ class QualityValidationResource extends Resource
$fileName = "{$value}.png"; $fileName = "{$value}.png";
$imageUrl = route('part.validation.image', [ $imageUrl = route('part.validation.image', [
'plant' => $plantCode1,
'filename' => $fileName 'filename' => $fileName
]); ]);
@@ -1734,17 +1732,6 @@ class QualityValidationResource extends Resource
$set('tube_sticker_motor_error', null); $set('tube_sticker_motor_error', null);
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
//$plant = Plant::find($mPlantId);
// $plantCodePart4 = $plant?->code;
// $mlineId = $get('line_id');
// $mLine = Line::find($mlineId);
// $mLinePart = $mLine?->name;
if (empty($state)) { if (empty($state)) {
$set('tube_sticker_motor_error', null); $set('tube_sticker_motor_error', null);
return; return;
@@ -1846,24 +1833,6 @@ class QualityValidationResource extends Resource
if (!$isMatch) if (!$isMatch)
{ {
$set('tube_sticker_motor_error', 'Serial number does not match.'); $set('tube_sticker_motor_error', 'Serial number does not match.');
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerMotor')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
$set('tube_sticker_motor_qr', null); $set('tube_sticker_motor_qr', null);
return; return;
} }
@@ -1888,32 +1857,10 @@ class QualityValidationResource extends Resource
->default('') ->default('')
->required() ->required()
->reactive() ->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('tube_sticker_pump_error', null); $set('tube_sticker_pump_error', null);
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
// $plant = Plant::find($mPlantId);
// $mPlantName = $plant?->name;
// $mlineId = $get('line_id');
// $mLine = Line::find($mlineId);
// $mLinePart = $mLine?->name;
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
// $mlineId = $get('line_id');
// $mUserName = Filament::auth()->user()?->name ?? 'Unknown';
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
//$mUserName = Filament::auth()->user()->name;
if (empty($state)) { if (empty($state)) {
$set('tube_sticker_pump_error', null); $set('tube_sticker_pump_error', null);
return; return;
@@ -1995,14 +1942,14 @@ class QualityValidationResource extends Resource
// ]); // ]);
$visibleSerialNumber = $get('serial_number'); $visibleSerialNumber = $get('serial_number');
$expectedItemCode = trim((string) $get('item_id')); $expectedItemCode = trim((string) $get('item_id'));
if ($itemCode != $expectedItemCode) { if ($itemCode != $expectedItemCode) {
$set('tube_sticker_pump_error', 'Item code does not match.'); $set('tube_sticker_pump_error', 'Item code does not match.');
return; return;
} }
$set('tube_sticker_pump_error', $serialNumber); $set('tube_sticker_pump_error', $serialNumber);
// $isMatch = in_array($serialNumber, $visibleSerialNumbers, true); // $isMatch = in_array($serialNumber, $visibleSerialNumbers, true);
$isMatch = ($visibleSerialNumber == $serialNumber); $isMatch = ($visibleSerialNumber == $serialNumber);
@@ -2016,62 +1963,6 @@ class QualityValidationResource extends Resource
{ {
$set('tube_sticker_pump_error', 'Serial number does not match.'); $set('tube_sticker_pump_error', 'Serial number does not match.');
$set('tube_sticker_pump_qr', null); $set('tube_sticker_pump_qr', null);
// $user = User::where('name', $mUserName)->first();
// if ($user) {
// $user->notify(new StatusUpdated($state));
// }
// $currentUser = Filament::auth()->user();
// if ($currentUser) {
// $currentUser->notify(new StatusUpdated($state)); // standard Laravel DB notification
// // refresh Filament bell
// $livewire->dispatch('refreshFilamentNotifications');
// }
// Notification::make()
// ->title('Status Updated')
// ->body("Serial number scanned: $state")
// ->danger()
// ->sendToDatabase($currentUser);
//$user->notify(new StatusUpdated($state));
//Notification::send($user, new StatusUpdated($state));
//dd($user);
// $user->notify(new StatusUpdated($state));
// Inside a Filament page or resource
//$this->notify('success', "Serial number scanned: $state");
// dispatch(new SendInvalidQualityMailJob(
// $state, $mPorder, $mPlantId, $mlineId, $mUserName, 'InvalidTubeStickerPump'
// ))->afterResponse();
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->queue(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
return; return;
} }
else { else {
@@ -2099,17 +1990,6 @@ class QualityValidationResource extends Resource
$set('tube_sticker_pumpset_error', null); $set('tube_sticker_pumpset_error', null);
$mPorder = $get('production_order');
$mPlantId = $get('plant_id');
//$plant = Plant::find($mPlantId);
// $plantCodePart4 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (empty($state)) { if (empty($state)) {
$set('tube_sticker_pumpset_error', null); $set('tube_sticker_pumpset_error', null);
return; return;
@@ -2213,23 +2093,6 @@ class QualityValidationResource extends Resource
if (!$isMatch) if (!$isMatch)
{ {
$set('tube_sticker_pumpset_error', 'Serial number does not match.'); $set('tube_sticker_pumpset_error', 'Serial number does not match.');
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
$set('tube_sticker_pumpset_qr', null); $set('tube_sticker_pumpset_qr', null);
return; return;
} }
@@ -2387,15 +2250,9 @@ class QualityValidationResource extends Resource
$mPlantId = $get('plant_id'); $mPlantId = $get('plant_id');
$mlineId = $get('line_id');
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart1 = $plant?->code; $plantCodePart1 = $plant?->code;
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id'); $stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
@@ -2427,13 +2284,12 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber') new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber')
); );
} }
else else
@@ -2443,7 +2299,7 @@ class QualityValidationResource extends Resource
$set('part_validation1', null); $set('part_validation1', null);
$fileName = $expectedValue . ".png"; // or .jpg based on your file $fileName = $expectedValue . ".png"; // or .jpg based on your file
$fullPath = storage_path("app/private/uploads/PartValidation/{$fileName}"); $fullPath = storage_path("app/private/uploads/PartValidation/{$plantCodePart1}/{$fileName}");
// dd($fullPath); // dd($fullPath);
@@ -2454,7 +2310,7 @@ class QualityValidationResource extends Resource
// ]); // ]);
if (file_exists($fullPath)) { if (file_exists($fullPath)) {
$imageUrl = route('part.validation.image', [ $imageUrl = route('part.validation.image', [
// 'plant' => $plantCodePart1, 'plant' => $plantCodePart1,
'filename' => $fileName 'filename' => $fileName
]); ]);
} else { } else {
@@ -2492,11 +2348,6 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart2 = $plant?->code; $plantCodePart2 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id'); $stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
@@ -2525,13 +2376,12 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber2') new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber2')
); );
} }
else else
@@ -2591,12 +2441,6 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart3 = $plant?->code; $plantCodePart3 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
} }
@@ -2625,13 +2469,12 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber3') new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber3')
); );
} }
else else
@@ -2689,11 +2532,6 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart4 = $plant?->code; $plantCodePart4 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
} }
@@ -2722,13 +2560,12 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber4') new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber4')
); );
} }
else else
@@ -2745,7 +2582,7 @@ class QualityValidationResource extends Resource
'filename' => $fileName 'filename' => $fileName
]); ]);
$set('part_validation4_error_image', $imageUrl); $set('part_validation2_error_image', $imageUrl);
return; return;
} }
@@ -2842,22 +2679,22 @@ class QualityValidationResource extends Resource
else else
{ {
$set('part_validation5_error', "Invalid input for part validation 5."); $set('part_validation5_error', "Invalid input for part validation 5.");
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId); $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails']; $emails = $mailData['emails'];
// if (!empty($emails)) if (!empty($emails))
// { {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send( Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5') new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
// ); );
// } }
// else else
// { {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// } }
$set('part_validation5', null); $set('part_validation5', null);
return; return;
} }
@@ -2878,21 +2715,6 @@ class QualityValidationResource extends Resource
public static function getMailData($plantId) public static function getMailData($plantId)
{ {
$globalEmails = AlertMailRule::where('plant', 0)
->where('module', 'QualityValidation')
->where('rule_name', 'QualityMail')
->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', ''))
->pluck('email')
->toArray();
if (!empty($globalEmails)) {
return [
'plant_id' => 0,
'plant_name' => 'All Plants',
'emails' => $globalEmails,
];
}
$mPlantName = Plant::where('id', $plantId)->value('name'); $mPlantName = Plant::where('id', $plantId)->value('name');
$emails = AlertMailRule::where('plant', $plantId) $emails = AlertMailRule::where('plant', $plantId)
@@ -2909,6 +2731,34 @@ class QualityValidationResource extends Resource
]; ];
} }
// public function getMail(){
// //$plantId = $this->form->getState()['plant_id'];
// $plantId = $this->data['plant_id'] ?? null;
// //$this->plantId = $plantId;
// dd($plantId);
// $mInvoiceType = 'Serial';
// $mPlantName = Plant::where('id', $plantId)->value('name');
// $emails = AlertMailRule::where('plant', $plantId)
// //->where('plant', $plantName)
// ->where('module', 'InvoiceValidation')
// ->where('rule_name', 'InvoiceMail')
// ->where(function ($query) {
// $query->whereNull('schedule_type')
// ->orWhere('schedule_type', '');
// })
// ->pluck('email')
// ->toArray();
// return [
// 'plant_id' => $plantId,
// 'plant_name' => $mPlantName,
// 'invoice_type' => $mInvoiceType,
// 'emails' => $emails,
// ];
// }
public static function table(Table $table): Table public static function table(Table $table): Table
{ {
return $table return $table

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(),
@@ -844,56 +846,50 @@ class StickerMasterResource extends Resource
$plantCode = $plant->code; $plantCode = $plant->code;
// $sticker = StickerMaster::where('plant_id', $plantId) $sticker = StickerMaster::where('plant_id', $plantId)
// ->where('item_id', $itemId) ->where('item_id', $itemId)
// ->first(); ->first();
// if (! $sticker) { if (! $sticker) {
// Notification::make() Notification::make()
// ->title('Unknown Sticker Master') ->title('Unknown Sticker Master')
// ->body('Sticker Master data not found.') ->body('Sticker Master data not found.')
// ->danger() ->danger()
// ->seconds(2) ->seconds(2)
// ->send(); ->send();
// } }
// $value = $sticker->{$column}; $value = $sticker->{$column};
// if (empty($value)) { if (empty($value)) {
// Notification::make() Notification::make()
// ->title('Unknown Part validation') ->title('Unknown Part validation')
// ->body("Selected validation '$column' has no value.") ->body("Selected validation '$column' has no value.")
// ->danger() ->danger()
// ->seconds(2) ->seconds(2)
// ->send(); ->send();
// } }
// $newFileName = $value.'.png'; $newFileName = $value.'.png';
$originalName = $uploadedFile->getClientOriginalName(); $directory = "uploads/PartValidation/{$plantCode}";
$directory = 'uploads/PartValidation';
$disk = Storage::disk('local'); $disk = Storage::disk('local');
if (! $disk->exists($directory)) { if (! $disk->exists($directory)) {
$disk->makeDirectory($directory, 0755, true); $disk->makeDirectory($directory, 0755, true);
} }
// $fullPath = Storage::disk('local')->path($directory);
// $directory = "uploads/PartValidation/{$plantCode}";
// $disk = Storage::disk('local');
// if (! $disk->exists($directory)) {
// $disk->makeDirectory($directory, 0755, true);
// }
// $path = $uploadedFile->storeAs( // $path = $uploadedFile->storeAs(
// $directory, // $directory,
// $newFileName, // $newFileName,
// 'local' // 'local'
// ); // );
try { try {
$path = $disk->putFileAs($directory, $uploadedFile, $originalName); $path = $uploadedFile->storeAs(
$directory,
$newFileName,
'local'
);
} catch (\Exception $e) { } catch (\Exception $e) {
Notification::make() Notification::make()
->title('Upload Failed') ->title('Upload Failed')

View File

@@ -1,200 +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';
protected static ?string $navigationGroup = 'Sticker Reprint';
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

@@ -5,19 +5,21 @@ namespace App\Filament\Resources;
use App\Filament\Exports\WorkGroupMasterExporter; use App\Filament\Exports\WorkGroupMasterExporter;
use App\Filament\Imports\WorkGroupMasterImporter; use App\Filament\Imports\WorkGroupMasterImporter;
use App\Filament\Resources\WorkGroupMasterResource\Pages; use App\Filament\Resources\WorkGroupMasterResource\Pages;
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
use App\Models\Line;
use App\Models\Plant; use App\Models\Plant;
use App\Models\WorkGroupMaster; use App\Models\WorkGroupMaster;
use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Facades\Filament;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
class WorkGroupMasterResource extends Resource class WorkGroupMasterResource extends Resource
@@ -35,70 +37,68 @@ class WorkGroupMasterResource extends Resource
return $form return $form
->schema([ ->schema([
Section::make('') Section::make('')
->schema([ ->schema([
Forms\Components\Select::make('plant_id') Forms\Components\Select::make('plant_id')
->label('Plant') ->label('Plant')
->relationship('plant', 'name') ->relationship('plant', 'name')
->reactive() ->reactive()
->columnSpan(1) ->columnSpan(1)
->required() ->required()
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); if (!$plantId) {
}) $set('pqPlantError', 'Please select a plant first.');
->afterStateUpdated(function ($state, $set, callable $get) { $set('name', null);
$plantId = $get('plant_id'); $set('description', null);
$set('operation_number', null);
return;
}
if (! $plantId) { $set('validationError', null);
$set('pqPlantError', 'Please select a plant first.'); $set('pqPlantError', null);
$set('name', null); $set('name', null);
$set('description', null); $set('description', null);
$set('operation_number', null); $set('operation_number', null);
})
return; ->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
} ->hintColor('danger'),
Forms\Components\TextInput::make('name')
$set('validationError', null); ->label('Name')
$set('pqPlantError', null); ->required()
$set('name', null); ->minLength(6)
$set('description', null); ->columnSpan(1)
$set('operation_number', null); ->reactive()
}) ->rule(function (callable $get) {
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null) return Rule::unique('work_group_masters', 'name')
->hintColor('danger'), ->where('plant_id', $get('plant_id'))
Forms\Components\TextInput::make('name') ->ignore($get('id'));
->label('Name') }),
->required() Forms\Components\TextInput::make('operation_number')
->minLength(6) ->label('Operation Number')
->columnSpan(1) ->numeric()
->reactive() ->columnSpan(1)
->rule(function (callable $get) { ->reactive()
return Rule::unique('work_group_masters', 'name') ->required()
->where('plant_id', $get('plant_id')) ->rule(function (callable $get) {
->ignore($get('id')); return Rule::unique('work_group_masters', 'operation_number')
}), ->where('plant_id', $get('plant_id'))
Forms\Components\TextInput::make('operation_number') ->ignore($get('id'));
->label('Operation Number') }),
->numeric() Forms\Components\TextInput::make('description')
->columnSpan(1) ->label('Description')
->reactive() ->required()
->required(), ->minLength(5)
// ->rule(function (callable $get) { ->reactive()
// return Rule::unique('work_group_masters', 'operation_number') ->columnSpan(['default' => 1, 'sm' => 3]),
// ->where('plant_id', $get('plant_id')) Forms\Components\Hidden::make('created_by')
// ->ignore($get('id')); ->default(Filament::auth()->user()?->name),
// }), ])
Forms\Components\TextInput::make('description') ->columns(['default' => 1, 'sm' => 3]),
->label('Description')
->required()
->minLength(5)
->reactive()
->columnSpan(['default' => 1, 'sm' => 3]),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(['default' => 1, 'sm' => 3]),
]); ]);
} }
@@ -112,7 +112,6 @@ class WorkGroupMasterResource extends Resource
$paginator = $livewire->getTableRecords(); $paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration; return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}), }),
Tables\Columns\TextColumn::make('plant.name') Tables\Columns\TextColumn::make('plant.name')
@@ -178,14 +177,14 @@ class WorkGroupMasterResource extends Resource
->label('Import Work Group Masters') ->label('Import Work Group Masters')
->color('warning') ->color('warning')
->importer(WorkGroupMasterImporter::class) ->importer(WorkGroupMasterImporter::class)
->visible(function () { ->visible(function() {
return Filament::auth()->user()->can('view import work group master'); return Filament::auth()->user()->can('view import work group master');
}), }),
ExportAction::make() ExportAction::make()
->label('Export Work Group Masters') ->label('Export Work Group Masters')
->color('warning') ->color('warning')
->exporter(WorkGroupMasterExporter::class) ->exporter(WorkGroupMasterExporter::class)
->visible(function () { ->visible(function() {
return Filament::auth()->user()->can('view export work group master'); return Filament::auth()->user()->can('view export work group master');
}), }),
]); ]);

File diff suppressed because it is too large Load Diff

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

@@ -20,24 +20,17 @@ class InvalidQualityMail extends Mailable
public $invoiceNumber; public $invoiceNumber;
public $mplantName; public $mplantName;
public $mProdOrder; public $mProdOrder;
public $mUserName;
public $mPartNo; public $mPartNo;
public $mailType; public $mailType;
public $greeting; public $greeting;
public $subjectLine; public $subjectLine;
public $mLinePart;
public $itemCode; public $itemCode;
public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mailType = 'InvalidPartNumber') public function __construct($parNo, $mProdOrder, $mplantName, $mailType = 'InvalidPartNumber')
{ {
$this->mPartNo = $parNo; $this->mPartNo = $parNo;
$this->mProdOrder = $mProdOrder; $this->mProdOrder = $mProdOrder;
$this->mplantName = $mplantName; $this->mplantName = $mplantName;
$this->mLinePart = $mLinePart;
$this->mUserName = $mUserName;
$this->mailType = $mailType; $this->mailType = $mailType;
} }
@@ -46,20 +39,20 @@ class InvalidQualityMail extends Mailable
// dynamic subject based on mail type // dynamic subject based on mail type
switch ($this->mailType) { switch ($this->mailType) {
case 'InvalidPartNumber2': case 'InvalidPartNumber2':
$this->subjectLine = "Quality Part Validation ({$this->mplantName})"; $this->subjectLine = "Invalid Part Number 2 Scanned ({$this->mplantName})";
break; break;
case 'InvalidPartNumber3': case 'InvalidPartNumber3':
$this->subjectLine = "Quality Part Validation ({$this->mplantName})"; $this->subjectLine = "Invalid Part Number 3 Scanned ({$this->mplantName})";
break; break;
case 'InvalidPartNumber4': case 'InvalidPartNumber4':
$this->subjectLine = "Quality Part Validation ({$this->mplantName})"; $this->subjectLine = "Invalid Part Number 4 Scanned ({$this->mplantName})";
break; break;
case 'InvalidPartNumber5': case 'InvalidPartNumber5':
$this->subjectLine = "Quality Part Validation ({$this->mplantName})"; $this->subjectLine = "Invalid Part Number 5 Scanned ({$this->mplantName})";
break; break;
case 'InvalidPartNumber': case 'InvalidPartNumber':
default: default:
$this->subjectLine = "Quality Part Validation ({$this->mplantName})"; $this->subjectLine = "Invalid Part Number 1 Scanned ({$this->mplantName})";
break; break;
} }
@@ -77,10 +70,8 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 2:</b> {$this->mPartNo}<br> <b>Scanned Part Number 2:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber3': case 'InvalidPartNumber3':
@@ -88,10 +79,8 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 3:</b> {$this->mPartNo}<br> <b>Scanned Part Number 3:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber4': case 'InvalidPartNumber4':
@@ -99,10 +88,8 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 4:</b> {$this->mPartNo}<br> <b>Scanned Part Number 4:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber5': case 'InvalidPartNumber5':
@@ -110,10 +97,8 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 5:</b> {$this->mPartNo}<br> <b>Scanned Part Number 5:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber': case 'InvalidPartNumber':
@@ -122,10 +107,8 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 1:</b> {$this->mPartNo}<br> <b>Scanned Part Number 1:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
} }

View File

@@ -82,14 +82,12 @@ class InvalidSerialMail extends Mailable
public $greeting; public $greeting;
public $subjectLine; public $subjectLine;
public $mUserName;
public $itemCode; public $itemCode;
/** /**
* Create a new message instance. * Create a new message instance.
*/ */
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mUserName, $mailType = 'InvalidFormat') public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat')
{ {
$this->serial = $serial; $this->serial = $serial;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
@@ -97,7 +95,6 @@ class InvalidSerialMail extends Mailable
$this->mInvoiceType = $mInvoiceType; $this->mInvoiceType = $mInvoiceType;
$this->mailType = $mailType; $this->mailType = $mailType;
$this->itemCode = $itemCode; $this->itemCode = $itemCode;
$this->mUserName = $mUserName;
} }
/** /**
@@ -107,24 +104,58 @@ class InvalidSerialMail extends Mailable
{ {
// dynamic subject based on mail type // dynamic subject based on mail type
switch ($this->mailType) { switch ($this->mailType) {
case 'NotFound':
$this->subjectLine = "Serial Number Not Found ({$this->mplantName})";
break;
case 'NotFoundInvoice': case 'NotFoundInvoice':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})"; $this->subjectLine = "Serial Number Not Found in Invoice ({$this->mplantName})";
break;
case 'NotFoundItemS':
$this->subjectLine = "Item Code Not Found ({$this->mplantName})";
break;
case 'NotValidPackage':
$this->subjectLine = "Not Valid Package ({$this->mplantName})";
break;
case 'InvalidMaterialFormat':
$this->subjectLine = "Invalid Qr code format Found material ({$this->mplantName})";
break;
case 'DuplicateMotorQR':
$this->subjectLine = "Duplicate Serial Number ({$this->mplantName})";
break;
case 'NotMotorQR':
$this->subjectLine = "Item Code doesn't have Motor QR ({$this->mplantName})";
break;
case 'CompletedSerialInvoice':
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
break;
case 'NotPumpQR':
$this->subjectLine = "Item Code doesn't have Pump QR ({$this->mplantName})";
break;
case 'DuplicatePumpQR':
$this->subjectLine = "Duplicate Serial Number ({$this->mplantName})";
break;
case 'CSerialInvoice':
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
break;
case 'MissingPanelBox':
$this->subjectLine = "Missing Panel Box ({$this->mplantName})";
break; break;
case 'DuplicateCapacitorQR': case 'DuplicateCapacitorQR':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})"; $this->subjectLine = "Duplicate Capacitor QR ({$this->mplantName})";
break; break;
case 'InvalidPanelBox': case 'UnknownPumpsetQR':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})"; $this->subjectLine = "Unknown PumpSet QR ({$this->mplantName})";
break;
case 'DuplicatePumpsetQR':
$this->subjectLine = "Duplicate PumpSet QR ({$this->mplantName})";
break;
case 'ComSerInv':
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
break;
case 'InvalidFormat':
default:
$this->subjectLine = "Invalid Serial Format Found ({$this->mplantName})";
break; break;
// case 'CompletedSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'CSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'ComSerInv':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
} }
return new Envelope( return new Envelope(
@@ -139,28 +170,224 @@ class InvalidSerialMail extends Mailable
{ {
// dynamic greeting/message body // dynamic greeting/message body
switch ($this->mailType) { switch ($this->mailType) {
case 'NotFound':
$this->greeting = "
Dear Sir/Madam,<br><br>
The scanned Serial Number <b>{$this->serial}</b> was not found in the database
for the plant <b>{$this->mplantName}</b>.<br><br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
Please verify the serial number.
";
break;
case 'NotFoundInvoice': case 'NotFoundInvoice':
$this->greeting = " $this->greeting = "
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
The scanned serial number could not be found in the given invoice.<br><br> The scanned Serial Number <b>'{$this->serial}'</b> was not found in the Invoice Number <b>'{$this->invoiceNumber}'</b>
for the plant <b>{$this->mplantName}</b>.<br><br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
Please verify the serial number.
";
break;
case 'NotFoundItemS':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item Code <b>'{$this->itemCode}'</b> with Serial Number<b>'{$this->serial}'</b> not found in sticker master
for the plant <b>{$this->mplantName}</b>.<br><br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br><br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
Please verify the Item Code.
";
break;
case 'NotValidPackage':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned Item Code<b>'{$this->itemCode}'</b> doesn't have valid package type to proceed!
for the plant <b>{$this->mplantName}</b>.<br><br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br><br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
Please verify the Item Code.
";
break;
case 'InvalidMaterialFormat':
$this->greeting = "
Dear Sir/Madam,<br><br>
Please note that the scanned serial number format appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br> <b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br> <b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br> <b>Scanned QR Code:</b> {$this->serial}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
// case 'DuplicateCapacitorQR': case 'DuplicateMotorQR':
// $this->greeting = " $this->greeting = "
// Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
// The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br> Scanned 'Motor' serial number <b>{$this->serial}</b> already completed the scanning process.<br>
// <b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
// <b>Invoice Type:</b> {$this->mInvoiceType}<br> <b>Invoice Type:</b> {$this->mInvoiceType}
// <b>Invoice Number:</b> {$this->invoiceNumber}<br> <b>Invoice Number:</b> {$this->invoiceNumber}<br>
// <b>Scanned QR Code:</b> {$this->serial}<br> <b>Scanned QR Code:</b> {$this->serial}<br>
// <b>Employee Code:</b> {$this->mUserName}<br> ";
// "; break;
// break; case 'NotMotorQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned Item Code <b>{$this->itemCode}</b> doesn't have 'Motor' QR to proceed!<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'CompletedSerialInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'NotPumpQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Pump' QR to proceed!<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'DuplicatePumpQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned 'Pump' serial number already completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'CSerialInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'MissingPanelBox':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Panel Box Code' to proceed!<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'DuplicateCapacitorQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned 'Capacitor' serial number already completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'UnknownPumpsetQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Pump Set' QR to proceed!<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'DuplicatePumpsetQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
Scanned 'Pump Set' serial number already completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ComSerInv':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ItemNotFound':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item code <b>'{$this->itemCode}'</b> not found in database.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ItemNotFoundDB':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item code <b>'{$this->itemCode}'</b> not found in database for choosed plant.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ItemNotValidMaterialType':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item code <b>'{$this->itemCode}'</b> doesn't have a valid material type.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ItemNotInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item code <b>'{$this->itemCode}'</b> doesn't exist in invoice.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ItemNotInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Item code <b>'{$this->itemCode}'</b> doesn't exist in invoice.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'InvalidFormat':
default:
$this->greeting = "
Dear Sir/Madam,<br><br>
Please note that the scanned serial number format appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
} }
return new Content( return new Content(

View File

@@ -1,47 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class CharacteristicValue extends Model
{
use SoftDeletes;
protected $fillable = [
'plant_id',
'line_id',
'item_id',
'machine_id',
'process_order',
'coil_number',
'status',
'created_at',
'updated_at',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function line(): BelongsTo
{
return $this->belongsTo(Line::class);
}
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
}
}

View File

@@ -1,60 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class ProductCharacteristicsMaster extends Model
{
use SoftDeletes;
protected $fillable = [
'plant_id',
'line_id',
'item_id',
'work_group_master_id',
'machine_id',
'name',
'inspection_type',
'characteristics_type',
'upper',
'lower',
'middle',
'created_at',
'updated_at',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function line(): BelongsTo
{
return $this->belongsTo(Line::class);
}
public function workGroupMaster(): BelongsTo
{
return $this->belongsTo(WorkGroupMaster::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
}
// public function machine()
// {
// return $this->belongsTo(\App\Models\Machine::class, 'machine_id');
// }
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
}

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

View File

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

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,53 +0,0 @@
<?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 product_characteristics_masters(
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
item_id BIGINT NOT NULL,
line_id BIGINT DEFAULT NULL,
work_group_master_id BIGINT DEFAULT NULL,
machine_id BIGINT DEFAULT NULL,
name TEXT DEFAULT NULL,
inspection_type TEXT DEFAULT NULL,
characteristics_type TEXT DEFAULT NULL
upper DOUBLE PRECISION DEFAULT 0.0,
lower DOUBLE PRECISION DEFAULT 0.0,
middle DOUBLE PRECISION DEFAULT NULL,
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),
FOREIGN KEY (line_id) REFERENCES lines (id),
FOREIGN KEY (item_id) REFERENCES items(id),
FOREIGN KEY (work_group_master_id) REFERENCES work_group_masters(id),
FOREIGN KEY (machine_id) REFERENCES machines(id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('product_characteristics_masters');
}
};

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

@@ -1,32 +0,0 @@
<?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'
ALTER TABLE process_orders
ALTER COLUMN order_quantity TYPE NUMERIC
USING order_quantity::NUMERIC;
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -1,35 +0,0 @@
<?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
{
Schema::table('work_group_masters', function (Blueprint $table) {
$table->dropUnique('work_group_masters_plant_id_operation_number_key');
});
// $sql = <<<'SQL'
// ALTER TABLE work_group_masters
// DROP INDEX work_group_masters_plant_id_operation_number_key;
// SQL;
// DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('work_group_masters', function (Blueprint $table) {
//
});
}
};

View File

@@ -1,48 +0,0 @@
<?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 characteristic_values (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
line_id BIGINT NOT NULL,
item_id BIGINT NOT NULL,
machine_id BIGINT NOT NULL,
process_order TEXT DEFAULT NULL,
coil_number TEXT DEFAULT NULL,
status 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),
FOREIGN KEY (line_id) REFERENCES lines (id),
FOREIGN KEY (item_id) REFERENCES items (id),
FOREIGN KEY (machine_id) REFERENCES machines (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('characteristic_values');
}
};

View File

@@ -1,40 +0,0 @@
<?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
{
// received_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN received_quantity TYPE NUMERIC(10,6)
USING received_quantity::NUMERIC(10,6);
SQL);
// order_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN order_quantity TYPE NUMERIC(10,6)
USING order_quantity::NUMERIC(10,6);
SQL);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -1,38 +0,0 @@
<?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
{
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN received_quantity TYPE NUMERIC(10,3)
USING received_quantity::NUMERIC(10,3);
SQL);
// order_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN order_quantity TYPE NUMERIC(10,3)
USING order_quantity::NUMERIC(10,3);
SQL);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

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>

View File

@@ -1,6 +1,8 @@
<?php <?php
use App\Http\Controllers\CharacteristicsController; //use App\Http\Controllers\CharacteristicsController;
// use App\Http\Controllers\CharacteristicsController;
use App\Http\Controllers\EquipmentMasterController; use App\Http\Controllers\EquipmentMasterController;
use App\Http\Controllers\InvoiceValidationController; use App\Http\Controllers\InvoiceValidationController;
use App\Http\Controllers\MachineController; use App\Http\Controllers\MachineController;
@@ -43,6 +45,7 @@ use Illuminate\Support\Facades\Route;
// return $item; // return $item;
// }); // });
// Route::post('/user/update', function (Request $request) { // Route::post('/user/update', function (Request $request) {
// // Return the request data as JSON // // Return the request data as JSON
@@ -53,6 +56,7 @@ use Illuminate\Support\Facades\Route;
// ]); // ]);
// }); // });
// Route::middleware('auth.basic')->post('/user/update', function (Request $request) { // Route::middleware('auth.basic')->post('/user/update', function (Request $request) {
// return response()->json([ // return response()->json([
// 'message' => 'Authenticated via Basic Auth', // 'message' => 'Authenticated via Basic Auth',
@@ -61,6 +65,7 @@ use Illuminate\Support\Facades\Route;
// ]); // ]);
// }); // });
Route::post('obd/store-data', [ObdController::class, 'store']); Route::post('obd/store-data', [ObdController::class, 'store']);
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']); Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
@@ -75,11 +80,9 @@ Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrP
Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf'); Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf');
// Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf'); Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
// Production Dashboard Controller //Production Dashboard Controller
Route::get('get/module-name/data', [ModuleController::class, 'get_module']); Route::get('get/module-name/data', [ModuleController::class, 'get_module']);
@@ -101,7 +104,7 @@ Route::get('get/module-production-order/data', [ModuleProductionOrderDataControl
Route::get('get/module-production-linestop/data', [ModuleProductionLineStopController::class, 'get_moduleProductionLineStop']); Route::get('get/module-production-linestop/data', [ModuleProductionLineStopController::class, 'get_moduleProductionLineStop']);
// Invoice Dashboard Controller //Invoice Dashboard Controller
Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']); Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']);
@@ -111,7 +114,7 @@ Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class,
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']); Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
// Guard Dashboard Controller //Guard Dashboard Controller
Route::get('get/module-guard-day/data', [ModuleGuardDayCountController::class, 'get_guardDay_countData']); Route::get('get/module-guard-day/data', [ModuleGuardDayCountController::class, 'get_guardDay_countData']);
@@ -119,19 +122,19 @@ Route::get('get/module-guard-hourly/data', [ModuleGuardHourlyCountController::cl
Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get_guard_name_Data']); Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get_guard_name_Data']);
// Power house controller //Power house controller
Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']); Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']);
Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']); Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
// Invoice Validation Controller //Invoice Validation Controller
Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']); Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']);
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']); Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
// Testing panel Controller //Testing panel Controller
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']); Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']);
@@ -151,39 +154,28 @@ Route::get('process-order/details', [PdfController::class, 'getProcessOrderData'
Route::post('process-order', [PdfController::class, 'storeProcessOrderData']); Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
Route::get('sap/files', [SapFileController::class, 'readFiles']); Route::get('sap/files', [SapFileController::class, 'readFiles']);
// ..Laser Marking - Characteristics //..Laser Marking - Characteristics
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']); Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class) // Route::post('laser/route/data', [CharacteristicsController::class, 'test']);//->withoutMiddleware(VerifyCsrfToken::class)
// //..Part Validation - Characteristics // Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
// // Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']); // //..
// // //..Serial or job // Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
// // Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']); // Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
// // Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']); // Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
// // //..Job or Master - Characteristics // Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
// // Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']); //GR Master PDF and Serial Number
// // //..serial auto or manual
// // Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
// ..Product Characteristics
Route::get('characteristics/get/master', [CharacteristicsController::class, 'getCharMaster']);
Route::post('characteristics/values', [CharacteristicsController::class, 'storeCharValues']);
// GR Master PDF and Serial Number
Route::get('grNumber-pdf', [PdfController::class, 'getGRPdf']); Route::get('grNumber-pdf', [PdfController::class, 'getGRPdf']);
@@ -191,7 +183,7 @@ Route::get('grmaster-sno', [PdfController::class, 'getGRSerial']);
Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']); Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']);
Route::post('file/store', [SapFileController::class, 'store'])->name('file.store'); // Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']); // Route::post('send-telegram', [TelegramController::class, 'sendMessage']);

View File

@@ -2,6 +2,8 @@
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use App\Models\AlertMailRule;
use Illuminate\Console\Scheduling\Schedule;
@@ -9,93 +11,87 @@ Artisan::command('inspire', function () {
$this->comment(Inspiring::quote()); $this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote'); })->purpose('Display an inspiring quote');
Artisan::command('auto:scheduler', function () {
$this->call('custom:scheduler');
})->everyMinute();
// Schedule::command('send:invoice-report'); // Schedule::command('send:invoice-report');
// Schedule::command('send:production-report'); // Schedule::command('send:production-report');
// app()->booted(function () { app()->booted(function () {
// $schedule = app(Schedule::class); $schedule = app(Schedule::class);
// // $schedule->command('report:send-daily-production')->dailyAt('07:59'); // $schedule->command('report:send-daily-production')->dailyAt('07:59');
// // Production report scheduling // Production report scheduling
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities') $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail') ->where('rule_name', 'ProductionMail')
// ->select('plant', 'schedule_type') ->select('plant', 'schedule_type')
// ->distinct() ->distinct()
// ->get(); ->get();
// foreach ($productionRules as $rule) { foreach ($productionRules as $rule) {
// $type = $rule->schedule_type; $type = $rule->schedule_type;
// $plantId = $rule->plant; $plantId = $rule->plant;
// $command = $schedule->command('send:production-report', [$type, $plantId]); $command = $schedule->command('send:production-report', [$type, $plantId]);
// // ->appendOutputTo(storage_path('logs/scheduler.log')); // ->appendOutputTo(storage_path('logs/scheduler.log'));
// switch ($type) { switch ($type) {
// case 'Live': case 'Live':
// $command->everyMinute(); $command->everyMinute();
// break; break;
// case 'Hourly': case 'Hourly':
// $command->hourly(); $command->hourly();
// break; break;
// case 'Daily': case 'Daily':
// $command->dailyAt('07:59'); $command->dailyAt('07:59');
// break; break;
// } }
// } }
// // Invoice report scheduling // Invoice report scheduling
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation') $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
// ->select('plant', 'schedule_type') ->select('plant', 'schedule_type')
// ->distinct() ->distinct()
// ->get(); ->get();
// foreach ($invoiceRules as $rule) { foreach ($invoiceRules as $rule) {
// $type = $rule->schedule_type; $type = $rule->schedule_type;
// $plantId = $rule->plant; $plantId = $rule->plant;
// $command = $schedule->command('send:invoice-report', [$type, $plantId]); $command = $schedule->command('send:invoice-report', [$type, $plantId]);
// switch ($type) { switch ($type) {
// case 'Live': case 'Live':
// $command->everyMinute(); $command->everyMinute();
// break; break;
// case 'Hourly': case 'Hourly':
// $command->hourly(); $command->hourly();
// break; break;
// case 'Daily': case 'Daily':
// $command->dailyAt('07:59'); $command->dailyAt('07:59');
// break; break;
// } }
// } }
// // Invoice Data Report Scheduling // Invoice Data Report Scheduling
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport') $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
// ->select('plant', 'schedule_type') ->select('plant', 'schedule_type')
// ->distinct() ->distinct()
// ->get(); ->get();
// foreach ($invoiceDataRules as $rule) { foreach ($invoiceDataRules as $rule) {
// $type = $rule->schedule_type; $type = $rule->schedule_type;
// $plantId = $rule->plant; $plantId = $rule->plant;
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]); $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
// switch ($type) { switch ($type) {
// case 'Live': case 'Live':
// $command->everyMinute(); $command->everyMinute();
// break; break;
// case 'Hourly': case 'Hourly':
// $command->hourly(); $command->hourly();
// break; break;
// case 'Daily': case 'Daily':
// $command->dailyAt('10:00'); $command->dailyAt('10:00');
// break; break;
// } }
// } }
// }); });

View File

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use thiagoalessio\TesseractOCR\TesseractOCR; use thiagoalessio\TesseractOCR\TesseractOCR;
use App\Filament\Pages\CustomLogin;
Route::get('/', function () { Route::get('/', function () {
return redirect('/admin'); return redirect('/admin');
@@ -25,8 +25,8 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
]); ]);
}); });
Route::get('/part-validation-image/{filename}', function ($filename) { Route::get('/part-validation-image/{plant}/{filename}', function ($plant, $filename) {
$path = storage_path("app/private/uploads/PartValidation/{$filename}"); $path = storage_path("app/private/uploads/PartValidation/{$plant}/{$filename}");
if (!file_exists($path)) { if (!file_exists($path)) {
abort(404, 'Image not found'); abort(404, 'Image not found');