Compare commits
172 Commits
ee101f80ea
...
renovate/v
| Author | SHA1 | Date | |
|---|---|---|---|
| 63e7f1a344 | |||
| f0ef2dda8e | |||
|
|
c43bc208b8 | ||
| 968d67d808 | |||
|
|
a1974ce78c | ||
| 2342c6003d | |||
|
|
151c563c4b | ||
| 290d218a0d | |||
|
|
e4223e28be | ||
| c455c76715 | |||
|
|
030013f914 | ||
| a1abe537c3 | |||
|
|
750f8520f5 | ||
| c65265e68e | |||
|
|
3b0eeda209 | ||
| 3da016ae49 | |||
|
|
1bc14aac38 | ||
| ea17636670 | |||
|
|
19b44a6705 | ||
| 31b56ae9b2 | |||
|
|
364fa1958e | ||
| 9517b38f9b | |||
|
|
587d91d790 | ||
| 2c1caa40a3 | |||
|
|
00b566a4ca | ||
| c3fef2f3a0 | |||
|
|
a0d715c975 | ||
| 904e18e63a | |||
|
|
6c68f2baab | ||
| 27dc2690ca | |||
|
|
27a6b2b5e3 | ||
| 8e1c4f46e8 | |||
|
|
35d9419198 | ||
| d699c043d4 | |||
|
|
63d18fd785 | ||
| 1806f32a7b | |||
|
|
84b6c45706 | ||
| eb2ae19641 | |||
|
|
84799678eb | ||
| 2dbcc8b859 | |||
|
|
db6af9863f | ||
| 79e3427cdb | |||
|
|
cdd746d5da | ||
| 81a5fa16c4 | |||
|
|
385103323a | ||
| 6520c3ca87 | |||
|
|
6ead4bce3d | ||
|
|
5917ae4717 | ||
| 2e167c75b0 | |||
|
|
dbdb11b9cf | ||
| aca5d6c957 | |||
|
|
764a14990b | ||
| 9edbaf3d43 | |||
|
|
1905359179 | ||
| a46aaa72a2 | |||
|
|
67961ff0f9 | ||
| d917aa530d | |||
|
|
34412da102 | ||
| 45944c5c25 | |||
|
|
ad55d30d78 | ||
| fda672948b | |||
|
|
04eb933997 | ||
| f15e6451ca | |||
|
|
95ed717020 | ||
| c8aac9116d | |||
|
|
e2b58a496c | ||
| bcd107a8bc | |||
|
|
d9d0930e70 | ||
| 458e143b9a | |||
|
|
1f9bfdd6fe | ||
| de2dda0dc5 | |||
|
|
2b2b0d8803 | ||
| 7543f8a416 | |||
|
|
91d8a3441b | ||
| f76316ec91 | |||
|
|
d719769fdd | ||
| acea7b14a6 | |||
|
|
154b689daf | ||
| 87f49e8491 | |||
|
|
eb7910c119 | ||
| f612551288 | |||
|
|
8d1e616777 | ||
| 4f84735eaf | |||
|
|
534ac222fa | ||
| 45b8c1fbb4 | |||
|
|
005ea2cf87 | ||
| 6015968043 | |||
| 2bc8584e7a | |||
| d126e931c8 | |||
|
|
e525e3c526 | ||
| 62bf68ad2e | |||
|
|
caf2f3c1e7 | ||
| c6c63dcb35 | |||
|
|
2ceb76f008 | ||
| d1663ae58a | |||
|
|
988d109acc | ||
| deb46cdda2 | |||
|
|
bc8163a535 | ||
| 002bdc597d | |||
|
|
6834e37429 | ||
| a406d1b58a | |||
|
|
a9012ffc05 | ||
| 58d0b9f0ae | |||
|
|
c67bbc02b6 | ||
| c0d8ca7b1e | |||
|
|
d71837f314 | ||
| f31ab62ec0 | |||
|
|
36a50815f9 | ||
| 4285a31f94 | |||
|
|
11678dd846 | ||
| 0c9228bfec | |||
|
|
035e6cd560 | ||
| 58b45c849d | |||
|
|
91deb448ef | ||
| 61a2e7ffad | |||
|
|
c05b536253 | ||
| 3779cf3e3b | |||
|
|
10071413a1 | ||
| acf955dd94 | |||
|
|
624e18e18d | ||
| 0de49f14ce | |||
|
|
11bbad0cf8 | ||
| 0473ca33cf | |||
|
|
6ac3c664dd | ||
| 8a01033459 | |||
|
|
10f2909b0e | ||
| 0555f9faff | |||
|
|
e8ed47a110 | ||
| 8cbbaa4845 | |||
|
|
055d7707f4 | ||
| cb6b201648 | |||
|
|
55cf2f6924 | ||
| c3089a147c | |||
|
|
d389136223 | ||
| 45f0e39f73 | |||
|
|
173638cd19 | ||
| fe1e1b9918 | |||
|
|
c8c38a05f4 | ||
| e20915ca82 | |||
|
|
5f4494f5aa | ||
| 58e6cbfac0 | |||
|
|
9fa73b2ecc | ||
| 1ace049687 | |||
|
|
d75d435456 | ||
| e5e85a8eea | |||
|
|
ff8aa8b536 | ||
|
|
53f0a7bfdf | ||
| 555802ab35 | |||
|
|
1aa1937b39 | ||
| 587b743f12 | |||
|
|
0812484926 | ||
| 42555d4a81 | |||
|
|
2d4700c9b2 | ||
| fd1e554076 | |||
|
|
eb38f4ddcf | ||
| 022654f192 | |||
|
|
faaaa88e8f | ||
| 55f1088fda | |||
|
|
d6c7e43715 | ||
| f9233f44d8 | |||
|
|
f45bb7b74b | ||
| e0fec6b07c | |||
|
|
80806d0f17 | ||
| 6bda9c1459 | |||
|
|
2b3db1cde1 | ||
|
|
bf1ae76334 | ||
| 39bdd3df57 | |||
|
|
01783c4fc7 | ||
| 5bcf0703d9 | |||
|
|
95c909b6ac | ||
| 80e522b7e6 | |||
|
|
c16c967757 |
4
.github/workflows/gemini-pr-review.yaml
vendored
4
.github/workflows/gemini-pr-review.yaml
vendored
@@ -36,8 +36,8 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-npm-global-
|
||||
|
||||
- name: Install Gemini CLI globally
|
||||
run: npm install -g --loglevel=http @google/gemini-cli
|
||||
# - name: Install Gemini CLI globally
|
||||
# run: npm install -g --loglevel=http @google/gemini-cli
|
||||
|
||||
- name: Generate git diff and review with Gemini
|
||||
id: review
|
||||
|
||||
31
app/Console/Commands/LogClear.php
Normal file
31
app/Console/Commands/LogClear.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class LogClear extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:log-clear';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
file_put_contents(storage_path('logs/laravel.log'), '');
|
||||
$this->info('Laravel log cleared!');
|
||||
}
|
||||
}
|
||||
202
app/Console/Commands/Scheduler.php
Normal file
202
app/Console/Commands/Scheduler.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?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}");
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\test;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\test;
|
||||
|
||||
class SendInvoiceReport extends Command
|
||||
{
|
||||
@@ -15,9 +15,8 @@ class SendInvoiceReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -29,12 +28,10 @@ class SendInvoiceReport extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
//$scheduleType = $this->argument('scheduleType');
|
||||
// $scheduleType = $this->argument('scheduleType');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
@@ -52,18 +49,14 @@ class SendInvoiceReport extends Command
|
||||
: [$plantIdArg];
|
||||
|
||||
$no = 1;
|
||||
if (strtolower($schedule) == 'daily')
|
||||
{
|
||||
if (strtolower($schedule) == 'daily') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
foreach ($plantIds as $plantId)
|
||||
{
|
||||
foreach ($plantIds as $plantId) {
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
@@ -89,7 +82,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('scanned_status', 'Scanned')
|
||||
->where(function($query) {
|
||||
->where(function ($query) {
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
@@ -128,7 +121,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -164,7 +157,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -193,7 +186,6 @@ class SendInvoiceReport extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
@@ -212,16 +204,14 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Show preview in console
|
||||
$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->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->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'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
44
app/Filament/Exports/CharacteristicValueExporter.php
Normal file
44
app/Filament/Exports/CharacteristicValueExporter.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ class ItemExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('code')
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
54
app/Filament/Exports/StickerPrintingExporter.php
Normal file
54
app/Filament/Exports/StickerPrintingExporter.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
61
app/Filament/Imports/CharacteristicValueImporter.php
Normal file
61
app/Filament/Imports/CharacteristicValueImporter.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ItemImporter extends Importer
|
||||
{
|
||||
@@ -48,10 +49,10 @@ class ItemImporter extends Importer
|
||||
->label('Unit of Measure'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code') // Lookup Plant by code column
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -59,36 +60,46 @@ class ItemImporter extends Importer
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
Log::info('ResolveRecord triggered', $this->data);
|
||||
$iCode = trim($this->data['code']);
|
||||
$description = trim($this->data['description']);
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found'; // '" . $plantCod . "'
|
||||
}
|
||||
}
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
}
|
||||
// if (Str::length($this->data['uom']) <= 0) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
if (Str::length($description) < 5) {
|
||||
$warnMsg[] = "Invalid description found";
|
||||
$warnMsg[] = 'Invalid description found';
|
||||
}
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
$warnMsg[] = "Invalid hourly quantity found";
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || ! is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
$warnMsg[] = 'Invalid hourly quantity found';
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return Item::updateOrCreate([
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id,
|
||||
],
|
||||
[
|
||||
'category' => trim($this->data['category']),
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => trim($this->data['uom'])
|
||||
'uom' => trim($this->data['uom']),
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
|
||||
282
app/Filament/Imports/ProductCharacteristicsMasterImporter.php
Normal file
282
app/Filament/Imports/ProductCharacteristicsMasterImporter.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
106
app/Filament/Imports/StickerPrintingImporter.php
Normal file
106
app/Filament/Imports/StickerPrintingImporter.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -976,7 +976,9 @@ class StickerReprint extends Page implements HasForms
|
||||
]);
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
|
||||
// if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData))
|
||||
// {
|
||||
if (!preg_match('/^[A-Za-z0-9]{6,}\|[1-9][A-Za-z0-9]{7,}(\/[A-Za-z0-9]*)?(\|)?$/', $formQRData)) {
|
||||
if (strpos($formQRData, '|') === false) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1004,7 +1006,14 @@ class StickerReprint extends Page implements HasForms
|
||||
{
|
||||
$splits = explode('|', $formQRData);
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
$sNumberRaw = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if ($sNumberRaw !== null) {
|
||||
$sNumber = preg_replace('/\/.*/', '', $sNumberRaw);
|
||||
$sNumber = trim($sNumber);
|
||||
} else {
|
||||
$sNumber = null;
|
||||
}
|
||||
|
||||
if (!ctype_alnum($iCode)) {
|
||||
$this->form->fill([
|
||||
@@ -1052,6 +1061,7 @@ class StickerReprint extends Page implements HasForms
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!ctype_alnum($sNumber)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1145,9 +1155,18 @@ class StickerReprint extends Page implements HasForms
|
||||
// Only search when all parent IDs are selected
|
||||
$parts = explode('|', $formQRData);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// Remove slash and everything after it
|
||||
if ($serialNumberRaw != null) {
|
||||
$serialNumber = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$serialNumber = trim($serialNumber);
|
||||
} else {
|
||||
$serialNumber = null;
|
||||
}
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
|
||||
if (!$item) {
|
||||
// Handle unknown item code
|
||||
$this->form->fill([
|
||||
@@ -1364,6 +1383,15 @@ class StickerReprint extends Page implements HasForms
|
||||
$itemCode = trim($parts[0]);
|
||||
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
if ($this->sNoId != null) {
|
||||
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$this->sNoId = trim($this->sNoId);
|
||||
} else {
|
||||
$this->sNoId = null;
|
||||
}
|
||||
|
||||
$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||
|
||||
ProductionQuantity::create([
|
||||
'plant_id'=> $this->pId,
|
||||
'shift_id'=> $this->sId,
|
||||
@@ -1418,11 +1446,16 @@ class StickerReprint extends Page implements HasForms
|
||||
// Save the form data to the database or perform other operations
|
||||
// For example:
|
||||
$model = ProductionQuantity::create($formValues);
|
||||
// $formValues['serial_number'] = $this->serialNumber;
|
||||
|
||||
// ProductionQuantity::create($formValues);
|
||||
|
||||
// dd('Production Updated Event Dispatched');
|
||||
|
||||
$this->dispatch('productionUpdated');
|
||||
|
||||
|
||||
|
||||
// // Optionally, you can emit an event or perform a redirect after saving
|
||||
// $this->emit('formSaved', $model->id);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceValidation' => 'InvoiceValidation',
|
||||
'InvoiceDataReport' => 'InvoiceDataReport',
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
//'Calibration' => 'Calibration',
|
||||
'QualityValidation' => 'QualityValidation',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -60,7 +60,7 @@ class AlertMailRuleResource extends Resource
|
||||
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
||||
'ProductionMail' => 'Production Mail',
|
||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
||||
//'CalibrationMail' => 'Calibration Mail',
|
||||
'QualityMail' => 'Quality Mail',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
@@ -70,7 +70,6 @@ class AlertMailRuleResource extends Resource
|
||||
->label('CC Emails'),
|
||||
Forms\Components\Select::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->required()
|
||||
->options([
|
||||
'Live' => 'Live',
|
||||
'Hourly' => 'Hourly',
|
||||
|
||||
516
app/Filament/Resources/CharacteristicValueResource.php
Normal file
516
app/Filament/Resources/CharacteristicValueResource.php
Normal file
@@ -0,0 +1,516 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,27 +4,23 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\InvoiceDataValidationExporter;
|
||||
use App\Filament\Resources\InvoiceDataValidationResource\Pages;
|
||||
use App\Filament\Resources\InvoiceDataValidationResource\RelationManagers;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\Plant;
|
||||
use DB;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Get;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\User;
|
||||
use DB;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class InvoiceDataValidationResource extends Resource
|
||||
{
|
||||
@@ -67,6 +63,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
@@ -77,10 +74,12 @@ class InvoiceDataValidationResource extends Resource
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.code')
|
||||
@@ -100,8 +99,8 @@ class InvoiceDataValidationResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('document_number')
|
||||
->label('Document Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('document_date')
|
||||
->label('Document Date')
|
||||
@@ -127,15 +126,28 @@ class InvoiceDataValidationResource extends Resource
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
// ->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
@@ -169,7 +181,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
->reactive()
|
||||
->required()
|
||||
->disk('local')
|
||||
//->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
// ->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
@@ -191,12 +203,10 @@ class InvoiceDataValidationResource extends Resource
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
if ($fullPath && file_exists($fullPath)) {
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0)
|
||||
{
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Invoice Data' file to proceed..!")
|
||||
@@ -206,6 +216,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,43 +234,40 @@ class InvoiceDataValidationResource extends Resource
|
||||
$invalidLocation = [];
|
||||
|
||||
$seenPlantDoc = [];
|
||||
//$duplicateEntries = [];
|
||||
// $duplicateEntries = [];
|
||||
$duplicateEntriesExcel = [];
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
} // Skip header
|
||||
|
||||
$DisChaDesc = trim($row[3]);
|
||||
$plantCode = trim($row[4]);
|
||||
$CustomerCode = trim($row[5]);
|
||||
$DocNo = trim($row[6]);
|
||||
$DocDate = trim($row[7]);
|
||||
$CusTradeName = trim($row[9]);
|
||||
$CusLocation = trim($row[10]);
|
||||
$Location = trim($row[36]);
|
||||
$DisChaDesc = trim($row[3]);
|
||||
$plantCode = trim($row[4]);
|
||||
$CustomerCode = trim($row[5]);
|
||||
$DocNo = trim($row[6]);
|
||||
$DocDate = trim($row[7]);
|
||||
$CusTradeName = trim($row[9]);
|
||||
$CusLocation = trim($row[10]);
|
||||
$Location = trim($row[36]);
|
||||
|
||||
// if (empty($plantCode)) $invalidPlantCode[] = "Row {$index}";
|
||||
if (empty($DisChaDesc)){
|
||||
if (empty($DisChaDesc)) {
|
||||
$invalidDisChaDesc[] = "Row {$index}";
|
||||
}
|
||||
if (empty($CustomerCode)){
|
||||
if (empty($CustomerCode)) {
|
||||
$invalidCustomerCode[] = "Row {$index}";
|
||||
}
|
||||
if (empty($DocNo))
|
||||
{
|
||||
if (empty($DocNo)) {
|
||||
$invalidDocNo[] = "Row {$index}";
|
||||
}
|
||||
if (empty($CusTradeName))
|
||||
{
|
||||
if (empty($CusTradeName)) {
|
||||
$invalidCusTradeName[] = "Row {$index}";
|
||||
}
|
||||
if (empty($CusLocation))
|
||||
{
|
||||
if (empty($CusLocation)) {
|
||||
$invalidCusLocation[] = "Row {$index}";
|
||||
}
|
||||
if (empty($Location))
|
||||
{
|
||||
if (empty($Location)) {
|
||||
$invalidLocation[] = "Row {$index}";
|
||||
}
|
||||
// if (empty($createdBy)) $invalidUser[] = "Row {$index}";
|
||||
@@ -267,11 +275,9 @@ class InvoiceDataValidationResource extends Resource
|
||||
if (strlen($plantCode) < 4) {
|
||||
$invalidPlantCode[] = $plantCode;
|
||||
}
|
||||
if (!is_numeric($plantCode)) {
|
||||
if (! is_numeric($plantCode)) {
|
||||
$invalidPlantType[] = $plantCode;
|
||||
}
|
||||
else if (!Plant::where('code', $plantCode)->first())
|
||||
{
|
||||
} elseif (! Plant::where('code', $plantCode)->first()) {
|
||||
$invalidPlaCoFound[] = $plantCode;
|
||||
}
|
||||
|
||||
@@ -288,25 +294,36 @@ class InvoiceDataValidationResource extends Resource
|
||||
// $duplicateEntries[] = "Duplicate record: Document Number '{$DocNo}' already exists for Plant '{$plant->name}'";
|
||||
// }
|
||||
|
||||
//Also check duplicates within the same file ---
|
||||
$uniqueKey = $plantCode . '_' . $DocNo;
|
||||
// Also check duplicates within the same file ---
|
||||
$uniqueKey = $plantCode.'_'.$DocNo;
|
||||
if (in_array($uniqueKey, $seenPlantDoc)) {
|
||||
$duplicateEntriesExcel[] = "Duplicate in file at Row {$index}: Document Number '{$DocNo}' already exists for Plant '{$plant->name}'";
|
||||
}
|
||||
$seenPlantDoc[] = $uniqueKey;
|
||||
}
|
||||
|
||||
if (!empty($invalidCustomerCode) || !empty($invalidDocNo) || !empty($invalidDocDate) || !empty($invalidCusTradeName) || !empty($invalidCusLocation))
|
||||
{
|
||||
if (! empty($invalidCustomerCode) || ! empty($invalidDocNo) || ! empty($invalidDocDate) || ! empty($invalidCusTradeName) || ! empty($invalidCusLocation)) {
|
||||
$errorMsg = '';
|
||||
|
||||
//if (!empty($invalidDisChaDesc)) $errorMsg .= 'Missing Distribution Channel Description in rows: ' . implode(', ', $invalidDisChaDesc) . '<br>';
|
||||
if (!empty($invalidCustomerCode)) $errorMsg .= 'Missing Customer Code in rows: ' . implode(', ', $invalidCustomerCode) . '<br>';
|
||||
if (!empty($invalidDocNo)) $errorMsg .= 'Missing Document Number in rows: ' . implode(', ', $invalidDocNo) . '<br>';
|
||||
if (!empty($invalidDocDate)) $errorMsg .= 'Missing Document Date in rows: ' . implode(', ', $invalidDocDate) . '<br>';
|
||||
if (!empty($invalidCusTradeName)) $errorMsg .= 'Missing Customer Trade Name in rows: ' . implode(', ', $invalidCusTradeName) . '<br>';
|
||||
if (!empty($invalidCusLocation)) $errorMsg .= 'Missing Customer Location in rows: ' . implode(', ', $invalidCusLocation) . '<br>';
|
||||
if (!empty($invalidLocation)) $errorMsg .= 'Missing Location in rows: ' . implode(', ', $invalidLocation) . '<br>';
|
||||
// if (!empty($invalidDisChaDesc)) $errorMsg .= 'Missing Distribution Channel Description in rows: ' . implode(', ', $invalidDisChaDesc) . '<br>';
|
||||
if (! empty($invalidCustomerCode)) {
|
||||
$errorMsg .= 'Missing Customer Code in rows: '.implode(', ', $invalidCustomerCode).'<br>';
|
||||
}
|
||||
if (! empty($invalidDocNo)) {
|
||||
$errorMsg .= 'Missing Document Number in rows: '.implode(', ', $invalidDocNo).'<br>';
|
||||
}
|
||||
if (! empty($invalidDocDate)) {
|
||||
$errorMsg .= 'Missing Document Date in rows: '.implode(', ', $invalidDocDate).'<br>';
|
||||
}
|
||||
if (! empty($invalidCusTradeName)) {
|
||||
$errorMsg .= 'Missing Customer Trade Name in rows: '.implode(', ', $invalidCusTradeName).'<br>';
|
||||
}
|
||||
if (! empty($invalidCusLocation)) {
|
||||
$errorMsg .= 'Missing Customer Location in rows: '.implode(', ', $invalidCusLocation).'<br>';
|
||||
}
|
||||
if (! empty($invalidLocation)) {
|
||||
$errorMsg .= 'Missing Location in rows: '.implode(', ', $invalidLocation).'<br>';
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Missing Mandatory Fields')
|
||||
@@ -317,45 +334,43 @@ class InvoiceDataValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($invalidPlantCode))
|
||||
{
|
||||
} elseif (! empty($invalidPlantCode)) {
|
||||
$invalidPlantCode = array_unique($invalidPlantCode);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes should contain minimum 4 digits:<br>' . implode(', ', $invalidPlantCode))
|
||||
->body('The following plant codes should contain minimum 4 digits:<br>'.implode(', ', $invalidPlantCode))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($invalidPlantType))
|
||||
{
|
||||
} elseif (! empty($invalidPlantType)) {
|
||||
$invalidPlantType = array_unique($invalidPlantType);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes should contain numeric values:<br>' . implode(', ', $invalidPlantType))
|
||||
->body('The following plant codes should contain numeric values:<br>'.implode(', ', $invalidPlantType))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($invalidPlaCoFound))
|
||||
{
|
||||
} elseif (! empty($invalidPlaCoFound)) {
|
||||
$invalidPlaCoFound = array_unique($invalidPlaCoFound);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes not found in plants:<br>' . implode(', ', $invalidPlaCoFound))
|
||||
->body('The following plant codes not found in plants:<br>'.implode(', ', $invalidPlaCoFound))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -401,11 +416,10 @@ class InvoiceDataValidationResource extends Resource
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!empty($duplicateEntriesExcel))
|
||||
{
|
||||
if (! empty($duplicateEntriesExcel)) {
|
||||
$duplicateGroupedByPlantExcel = [];
|
||||
|
||||
foreach ($duplicateEntriesExcel as $message) {//"/Document Number '([^']+)' already exist(?:s)?(?: for Plant (.+))?/"
|
||||
foreach ($duplicateEntriesExcel as $message) {// "/Document Number '([^']+)' already exist(?:s)?(?: for Plant (.+))?/"
|
||||
if (preg_match("/Document Number '([^']+)' already exists for Plant '([^']+)'/", $message, $matches)) {
|
||||
$docNo = $matches[1];
|
||||
$plantName = $matches[2] ?? 'Unknown';
|
||||
@@ -415,8 +429,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
|
||||
$errorMsg = 'Duplicate Document Number found in Uploaded File :<br>';
|
||||
|
||||
foreach ($duplicateGroupedByPlantExcel as $plant => $docNumbers)
|
||||
{
|
||||
foreach ($duplicateGroupedByPlantExcel as $plant => $docNumbers) {
|
||||
// Remove duplicate document numbers for each plant
|
||||
$uniqueDocNumbers = array_unique($docNumbers);
|
||||
$count = count($uniqueDocNumbers);
|
||||
@@ -425,13 +438,13 @@ class InvoiceDataValidationResource extends Resource
|
||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plant}</b> : {$count} Document Numbers already exist in uploaded file<br>";
|
||||
} else {
|
||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plant}</b> : '"
|
||||
. implode(', ', $uniqueDocNumbers)
|
||||
. "' already exist in uploaded file<br>";
|
||||
.implode(', ', $uniqueDocNumbers)
|
||||
."' already exist in uploaded file<br>";
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
//->title('Duplicate Document Number in Uploaded File')
|
||||
// ->title('Duplicate Document Number in Uploaded File')
|
||||
->body($errorMsg)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -439,6 +452,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -455,33 +469,34 @@ class InvoiceDataValidationResource extends Resource
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) continue;
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
try {
|
||||
$DisChaDesc = trim($row[3]);
|
||||
$plantCode = trim($row[4]);
|
||||
$DisChaDesc = trim($row[3]);
|
||||
$plantCode = trim($row[4]);
|
||||
$CustomerCode = trim($row[5]);
|
||||
$DocNo = trim($row[6]);
|
||||
$DocDate = trim($row[7]);
|
||||
$DocNo = trim($row[6]);
|
||||
$DocDate = trim($row[7]);
|
||||
$CusTradeName = trim($row[9]);
|
||||
$CusLocation = trim($row[10]);
|
||||
$Location = trim($row[36]);
|
||||
$CusLocation = trim($row[10]);
|
||||
$Location = trim($row[36]);
|
||||
|
||||
if (empty($DocNo)) {
|
||||
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (!$plant) {
|
||||
if (! $plant) {
|
||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||
}
|
||||
|
||||
if (!empty($DocDate)) {
|
||||
if (! empty($DocDate)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $DocDate)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $DocDate);
|
||||
$formattedDate = "{$year}-{$month}-{$day}";
|
||||
@@ -503,26 +518,26 @@ class InvoiceDataValidationResource extends Resource
|
||||
if ($record) {
|
||||
$record->update([
|
||||
'distribution_channel_desc' => $DisChaDesc,
|
||||
'customer_code' => $CustomerCode,
|
||||
'document_date' => $formattedDate,
|
||||
'customer_trade_name' => $CusTradeName,
|
||||
'customer_location' => $CusLocation,
|
||||
'location' => $Location,
|
||||
'updated_by' => $operatorName
|
||||
'customer_code' => $CustomerCode,
|
||||
'document_date' => $formattedDate,
|
||||
'customer_trade_name' => $CusTradeName,
|
||||
'customer_location' => $CusLocation,
|
||||
'location' => $Location,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted = $record;
|
||||
} else {
|
||||
// Record does not exist, create with 'created_by'
|
||||
$inserted = InvoiceDataValidation::create([
|
||||
'plant_id' => $plant->id,
|
||||
'document_number' => $DocNo,
|
||||
'plant_id' => $plant->id,
|
||||
'document_number' => $DocNo,
|
||||
'distribution_channel_desc' => $DisChaDesc,
|
||||
'customer_code' => $CustomerCode,
|
||||
'document_date' => $formattedDate,
|
||||
'customer_trade_name' => $CusTradeName,
|
||||
'customer_location' => $CusLocation,
|
||||
'location' => $Location,
|
||||
'created_by' => $operatorName
|
||||
'customer_code' => $CustomerCode,
|
||||
'document_date' => $formattedDate,
|
||||
'customer_trade_name' => $CusTradeName,
|
||||
'customer_location' => $CusLocation,
|
||||
'location' => $Location,
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
// $inserted = InvoiceDataValidation::create([
|
||||
@@ -536,7 +551,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
// 'created_by' => $operatorName
|
||||
// ]);
|
||||
|
||||
if (!$inserted) {
|
||||
if (! $inserted) {
|
||||
throw new \Exception("{$curStat} failed for Document Number : {$DocNo}");
|
||||
}
|
||||
|
||||
@@ -545,7 +560,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
$failedRecords[] = [
|
||||
'row' => $rowNumber,
|
||||
'document_number' => $DocNo ?? null,
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -554,13 +569,13 @@ class InvoiceDataValidationResource extends Resource
|
||||
|
||||
if (count($failedRecords) > 0) {
|
||||
$failedSummary = collect($failedRecords)
|
||||
->map(fn($f) => "Row {$f['row']} ({$f['document_number']}) : {$f['error']}")
|
||||
->map(fn ($f) => "Row {$f['row']} ({$f['document_number']}) : {$f['error']}")
|
||||
->take(5) // limit preview to first 5 errors
|
||||
->implode("\n");
|
||||
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body("'{$successCount}' records inserted. " . count($failedRecords) . " failed.\n\n{$failedSummary}")
|
||||
->body("'{$successCount}' records inserted. ".count($failedRecords)." failed.\n\n{$failedSummary}")
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
@@ -570,9 +585,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Notification::make()
|
||||
->title('Import Failed')
|
||||
@@ -582,14 +595,14 @@ class InvoiceDataValidationResource extends Resource
|
||||
}
|
||||
}
|
||||
})
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import invoice data validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoice Data')
|
||||
->color('warning')
|
||||
->exporter(InvoiceDataValidationExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export invoice data validation');
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -4,27 +4,25 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\InvoiceOutValidationExporter;
|
||||
use App\Filament\Resources\InvoiceOutValidationResource\Pages;
|
||||
use App\Filament\Resources\InvoiceOutValidationResource\RelationManagers;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Notifications\Notification;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Storage;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
|
||||
use Storage;
|
||||
|
||||
class InvoiceOutValidationResource extends Resource
|
||||
{
|
||||
@@ -39,24 +37,25 @@ class InvoiceOutValidationResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('qr_code')
|
||||
->label('QR Code'),
|
||||
Forms\Components\DateTimePicker::make('scanned_at')
|
||||
->label('Scanned At'),
|
||||
Forms\Components\TextInput::make('scanned_by')
|
||||
->label('Scanned By'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(4),
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('qr_code')
|
||||
->label('QR Code'),
|
||||
Forms\Components\DateTimePicker::make('scanned_at')
|
||||
->label('Scanned At'),
|
||||
Forms\Components\TextInput::make('scanned_by')
|
||||
->label('Scanned By'),
|
||||
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),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -66,15 +65,18 @@ class InvoiceOutValidationResource extends Resource
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.code')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('qr_code')
|
||||
->label('QR Code')
|
||||
@@ -93,27 +95,33 @@ class InvoiceOutValidationResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->searchable()
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
//->toggleable(isToggledHiddenByDefault: true),
|
||||
// ->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
// ->toggleable(isToggledHiddenByDefault: true),
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -143,7 +151,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
->reactive()
|
||||
->required()
|
||||
->disk('local')
|
||||
//->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
// ->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
@@ -165,12 +173,10 @@ class InvoiceOutValidationResource extends Resource
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
if ($fullPath && file_exists($fullPath)) {
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0)
|
||||
{
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Invoice Data' file to proceed..!")
|
||||
@@ -180,6 +186,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,27 +199,34 @@ class InvoiceOutValidationResource extends Resource
|
||||
$userNotFound = [];
|
||||
$seenPlantQr = [];
|
||||
$duplicateQrExcel = [];
|
||||
//$duplicateQrDb = [];
|
||||
// $duplicateQrDb = [];
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue;
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$qrCode = trim($row[1]);
|
||||
$plantCode = trim($row[2]);
|
||||
$scannedAt = trim($row[3]);
|
||||
$scannedby = trim($row[4]);
|
||||
$qrCode = trim($row[1]);
|
||||
$plantCode = trim($row[2]);
|
||||
$scannedAt = trim($row[3]);
|
||||
$scannedby = trim($row[4]);
|
||||
|
||||
if (empty($plantCode)) $invalidPlantCode[] = "Row {$index}";
|
||||
if (empty($qrCode)) $invalidqrCode[] = "Row {$index}";
|
||||
if (empty($scannedAt)) $invalidScannedAt[] = "Row {$index}";
|
||||
if (empty($scannedby)) $invalidScannedBy[] = "Row {$index}";
|
||||
if (empty($plantCode)) {
|
||||
$invalidPlantCode[] = "Row {$index}";
|
||||
}
|
||||
if (empty($qrCode)) {
|
||||
$invalidqrCode[] = "Row {$index}";
|
||||
}
|
||||
if (empty($scannedAt)) {
|
||||
$invalidScannedAt[] = "Row {$index}";
|
||||
}
|
||||
if (empty($scannedby)) {
|
||||
$invalidScannedBy[] = "Row {$index}";
|
||||
}
|
||||
|
||||
if (strlen($plantCode) < 4) {
|
||||
$invalidPlantCode[] = $plantCode;
|
||||
}
|
||||
else if(!Plant::where('code', $plantCode)->first())
|
||||
{
|
||||
} elseif (! Plant::where('code', $plantCode)->first()) {
|
||||
$invalidPlaCoFound[] = $plantCode;
|
||||
}
|
||||
|
||||
@@ -220,7 +234,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$uniqueKey = $plantCode . '_' . $qrCode;
|
||||
$uniqueKey = $plantCode.'_'.$qrCode;
|
||||
|
||||
if (in_array($uniqueKey, $seenPlantQr)) {
|
||||
$duplicateQrExcel[] = "Duplicate in file at Row {$index}: Document Number '{$qrCode}' already exists for Plant '{$plant->name}'";
|
||||
@@ -237,13 +251,18 @@ class InvoiceOutValidationResource extends Resource
|
||||
// }
|
||||
}
|
||||
|
||||
if (!empty($invalidqrCode) || !empty($invalidScannedAt) || !empty($invalidScannedBy) || !empty($invalidUser))
|
||||
{
|
||||
if (! empty($invalidqrCode) || ! empty($invalidScannedAt) || ! empty($invalidScannedBy) || ! empty($invalidUser)) {
|
||||
$errorMsg = '';
|
||||
|
||||
if (!empty($invalidqrCode)) $errorMsg .= 'Missing Qr code in rows: '.implode(', ', $invalidqrCode) . '<br>';
|
||||
if (!empty($invalidScannedAt)) $errorMsg .= 'Missing Scanned At in rows: '.implode(', ', $invalidScannedAt) . '<br>';
|
||||
if (!empty($invalidScannedBy)) $errorMsg .= 'Missing Scanned By in rows: '.implode(', ', $invalidScannedBy) . '<br>';
|
||||
if (! empty($invalidqrCode)) {
|
||||
$errorMsg .= 'Missing Qr code in rows: '.implode(', ', $invalidqrCode).'<br>';
|
||||
}
|
||||
if (! empty($invalidScannedAt)) {
|
||||
$errorMsg .= 'Missing Scanned At in rows: '.implode(', ', $invalidScannedAt).'<br>';
|
||||
}
|
||||
if (! empty($invalidScannedBy)) {
|
||||
$errorMsg .= 'Missing Scanned By in rows: '.implode(', ', $invalidScannedBy).'<br>';
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Missing Mandatory Fields')
|
||||
@@ -254,53 +273,56 @@ class InvoiceOutValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($invalidPlantCode)) {
|
||||
if (! empty($invalidPlantCode)) {
|
||||
$invalidPlantCode = array_unique($invalidPlantCode);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes should contain minimum 4 digits:<br>' . implode(', ', $invalidPlantCode))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes should contain minimum 4 digits:<br>'.implode(', ', $invalidPlantCode))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($invalidPlaCoFound)) {
|
||||
if (! empty($invalidPlaCoFound)) {
|
||||
$invalidPlaCoFound = array_unique($invalidPlaCoFound);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes not found in plants:<br>' . implode(', ', $invalidPlaCoFound))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes not found in plants:<br>'.implode(', ', $invalidPlaCoFound))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($userNotFound)) {
|
||||
if (! empty($userNotFound)) {
|
||||
$userNotFound = array_unique($userNotFound);
|
||||
Notification::make()
|
||||
->title('Invalid User')
|
||||
->body('The following user not found:<br>' . implode(', ', $userNotFound))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid User')
|
||||
->body('The following user not found:<br>'.implode(', ', $userNotFound))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($duplicateQrExcel))
|
||||
{
|
||||
if (! empty($duplicateQrExcel)) {
|
||||
$duplicateGroupedByPlantQr = [];
|
||||
|
||||
foreach ($duplicateQrExcel as $message) {//"/Document Numbers '([^']+)' already exists for Plant Code (\S+)/"
|
||||
foreach ($duplicateQrExcel as $message) {// "/Document Numbers '([^']+)' already exists for Plant Code (\S+)/"
|
||||
if (preg_match("/Document Number '([^']+)' already exists for Plant '([^']+)'/", $message, $matches)) {
|
||||
$qrCode = $matches[1];
|
||||
$plantCode = $matches[2];
|
||||
@@ -318,13 +340,13 @@ class InvoiceOutValidationResource extends Resource
|
||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b> : {$count} Document Numbers already exist in uploaded file<br>";
|
||||
} else {
|
||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b> : '"
|
||||
. implode(', ', $uniqueQrCodes)
|
||||
. "' already exist in uploaded file<br>";
|
||||
.implode(', ', $uniqueQrCodes)
|
||||
."' already exist in uploaded file<br>";
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
//->title('Duplicate Document Number in Uploaded File')
|
||||
// ->title('Duplicate Document Number in Uploaded File')
|
||||
->body($errorMsg)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -380,15 +402,16 @@ class InvoiceOutValidationResource extends Resource
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) continue;
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
try {
|
||||
$qrcode = trim($row[1]);
|
||||
$qrcode = trim($row[1]);
|
||||
$plantCode = trim($row[2]);
|
||||
$scannedAt = trim($row[3]);
|
||||
$scannedBy = trim($row[4]);
|
||||
@@ -398,12 +421,12 @@ class InvoiceOutValidationResource extends Resource
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (!$plant) {
|
||||
if (! $plant) {
|
||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||
}
|
||||
|
||||
$formattedDate = null;
|
||||
if (!empty($scannedAt)) {
|
||||
if (! empty($scannedAt)) {
|
||||
try {
|
||||
// $formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||
// ->format('Y-m-d H:i:s');
|
||||
@@ -430,7 +453,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
$record->update([
|
||||
'scanned_at' => $formattedDate,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $operatorName
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted = $record;
|
||||
} else {
|
||||
@@ -440,7 +463,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
'qr_code' => $qrcode,
|
||||
'scanned_at' => $formattedDate,
|
||||
'scanned_by' => $scannedBy,
|
||||
'created_by' => $operatorName
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
// $inserted = InvoiceOutValidation::create([
|
||||
@@ -451,7 +474,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
// 'created_by' => $operatorName
|
||||
// ]);
|
||||
|
||||
if (!$inserted) {
|
||||
if (! $inserted) {
|
||||
throw new \Exception("{$curStat} failed for QR : {$qrcode}");
|
||||
}
|
||||
|
||||
@@ -460,7 +483,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
$failedRecords[] = [
|
||||
'row' => $rowNumber,
|
||||
'qrcode' => $qrcode ?? null,
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -469,13 +492,13 @@ class InvoiceOutValidationResource extends Resource
|
||||
|
||||
if (count($failedRecords) > 0) {
|
||||
$failedSummary = collect($failedRecords)
|
||||
->map(fn($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
||||
->map(fn ($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
||||
->take(5) // limit preview to first 5 errors
|
||||
->implode("\n");
|
||||
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body("'{$successCount}' records inserted. " . count($failedRecords) . " failed.\n\n{$failedSummary}")
|
||||
->body("'{$successCount}' records inserted. ".count($failedRecords)." failed.\n\n{$failedSummary}")
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
@@ -485,9 +508,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Notification::make()
|
||||
->title('Import Failed')
|
||||
@@ -497,14 +518,14 @@ class InvoiceOutValidationResource extends Resource
|
||||
}
|
||||
}
|
||||
})
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import invoice out validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoice Out Data')
|
||||
->color('warning')
|
||||
->exporter(InvoiceOutValidationExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export invoice out validation');
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\InvoiceValidationExporter;
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
use App\Mail\InvoiceNotification;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
@@ -29,7 +30,6 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\View;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -38,6 +38,10 @@ use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Livewire\Livewire;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Filament\Forms\Components\View;
|
||||
|
||||
|
||||
class InvoiceValidationResource extends Resource
|
||||
{
|
||||
@@ -49,6 +53,8 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -119,6 +125,9 @@ class InvoiceValidationResource extends Resource
|
||||
$invNo = $get('invoice_number');
|
||||
$set('serial_number', null);
|
||||
$set('update_invoice', null);
|
||||
//Session::put('invoice_number', $state);
|
||||
session(['invoice_number' => $state]);
|
||||
|
||||
// if (!$invNo) { return; } else { }
|
||||
}),
|
||||
|
||||
@@ -126,17 +135,32 @@ class InvoiceValidationResource extends Resource
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->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([
|
||||
'id' => 'serial_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
'x-on:keydown.enter.prevent' => "
|
||||
let serial = \$event.target.value;
|
||||
if (serial.trim() != '') {
|
||||
\$wire.dispatch('process-scan', serial);
|
||||
\$event.target.value = '';
|
||||
}
|
||||
",
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get, callable $livewire) {
|
||||
$set('update_invoice', 0);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// if (!$invNo) { return; } else { }
|
||||
// if ($state) {
|
||||
// $livewire('process-scan', $state);
|
||||
// $set('serial_number', null);
|
||||
// }
|
||||
})
|
||||
->columnSpan(1),
|
||||
Forms\Components\TextInput::make('total_quantity')
|
||||
@@ -1256,6 +1280,24 @@ 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
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,24 +12,24 @@ use App\Models\StickerMaster;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Storage;
|
||||
use Str;
|
||||
|
||||
class ItemResource extends Resource
|
||||
{
|
||||
@@ -48,125 +48,125 @@ class ItemResource extends Resource
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
// ->preload()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Item::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$plantId) {
|
||||
$set('iPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('iPlantError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iPlantError') ? $get('iPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Category')
|
||||
->placeholder('Scan the Category'),
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->placeholder('Scan the valid code')
|
||||
->autofocus(true)
|
||||
// ->unique(ignoreRecord: true)
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
// ->autocapitalize('characters')
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('code');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$code) {
|
||||
$set('iCodeError', 'Scan the valid code.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($code) < 6) {
|
||||
$set('iCodeError', 'Item code must be at least 6 digits.');
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
|
||||
$set('code',null);
|
||||
$set('iCodeError', 'Item code must contain only alpha-numeric characters.');
|
||||
return;
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
|
||||
->hintColor('danger')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('items', 'code')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('hourly_quantity')
|
||||
->required()
|
||||
->label('Hourly Quantity')
|
||||
->placeholder('Scan the valid quantity')
|
||||
->integer()
|
||||
->default(1)
|
||||
->minValue(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$hourQuan = $get('hourly_quantity');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$hourQuan) {
|
||||
$set('iHourQuanError', 'Scan the valid hourly quantity.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!preg_match('/^[0-9]{1,}$/', $hourQuan)) {
|
||||
$set('hourly_quantity',null);
|
||||
$set('iHourQuanError', 'Quantity must be integer value.');
|
||||
return;
|
||||
}
|
||||
$set('iHourQuanError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iHourQuanError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iHourQuanError') ? $get('iHourQuanError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('uom')
|
||||
->required()
|
||||
->label('Unit of Measure')
|
||||
->placeholder('Scan the valid uom'),
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
Forms\Components\TextInput::make('description')
|
||||
->placeholder('Scan the valid description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->columnSpan(['default' => 1, 'sm' => 1]),
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Item::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $plantId) {
|
||||
$set('iPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('iPlantError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iPlantError') ? $get('iPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Category')
|
||||
->placeholder('Scan the Category'),
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->placeholder('Scan the valid code')
|
||||
->autofocus(true)
|
||||
// ->unique(ignoreRecord: true)
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
// ->autocapitalize('characters')
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('code');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $code) {
|
||||
$set('iCodeError', 'Scan the valid code.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (strlen($code) < 6) {
|
||||
$set('iCodeError', 'Item code must be at least 6 digits.');
|
||||
|
||||
return;
|
||||
} elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
|
||||
$set('code', null);
|
||||
$set('iCodeError', 'Item code must contain only alpha-numeric characters.');
|
||||
|
||||
return;
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
|
||||
->hintColor('danger')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('items', 'code')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('hourly_quantity')
|
||||
->required()
|
||||
->label('Hourly Quantity')
|
||||
->placeholder('Scan the valid quantity')
|
||||
->integer()
|
||||
->default(1)
|
||||
->minValue(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$hourQuan = $get('hourly_quantity');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $hourQuan) {
|
||||
$set('iHourQuanError', 'Scan the valid hourly quantity.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (! preg_match('/^[0-9]{1,}$/', $hourQuan)) {
|
||||
$set('hourly_quantity', null);
|
||||
$set('iHourQuanError', 'Quantity must be integer value.');
|
||||
|
||||
return;
|
||||
}
|
||||
$set('iHourQuanError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iHourQuanError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iHourQuanError') ? $get('iHourQuanError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('uom')
|
||||
->required()
|
||||
->label('Unit of Measure')
|
||||
->placeholder('Scan the valid uom'),
|
||||
|
||||
Forms\Components\TextInput::make('description')
|
||||
->placeholder('Scan the valid description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->columnSpan(['default' => 1, 'sm' => 1]),
|
||||
// ->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
@@ -187,6 +187,7 @@ class ItemResource extends Resource
|
||||
$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')
|
||||
@@ -238,7 +239,135 @@ class ItemResource extends Resource
|
||||
])
|
||||
->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)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('code', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('code')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('Plant');
|
||||
// return $plantId
|
||||
// ? Item::where('plant_id', $plantId)->pluck('code', 'id')
|
||||
// : Item::pluck('code', 'id');
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('description')
|
||||
->label('Search by Description')
|
||||
->placeholder(placeholder: 'Enter Description'),
|
||||
TextInput::make('category')
|
||||
->label('Search by Category')
|
||||
->placeholder(placeholder: 'Enter Category'),
|
||||
TextInput::make('uom')
|
||||
->label('Search by UOM')
|
||||
->placeholder(placeholder: 'Enter UOM'),
|
||||
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['code']) &&
|
||||
empty($data['description']) &&
|
||||
empty($data['uom']) &&
|
||||
empty($data['category']) &&
|
||||
empty($data['created_from']) &&
|
||||
empty($data['created_to'])
|
||||
) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (! empty($data['code'])) {
|
||||
$query->where('id', $data['code']);
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$query->where('description', '%'.$data['description'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
$query->where('category', '%'.$data['category'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['code'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['code'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$indicators[] = 'Description: '.$data['description'];
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$indicators[] = 'UOM: '.$data['uom'];
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
$indicators[] = 'Category: '.$data['category'];
|
||||
}
|
||||
|
||||
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(),
|
||||
@@ -251,7 +380,6 @@ class ItemResource extends Resource
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
|
||||
// Tables\Actions\Action::make('Import Items')
|
||||
// ->label('Import Items')
|
||||
// ->form([
|
||||
@@ -402,7 +530,6 @@ class ItemResource extends Resource
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// $uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
// $matchedItems = StickerMaster::with('item')
|
||||
@@ -483,23 +610,23 @@ class ItemResource extends Resource
|
||||
->label('Import Items')
|
||||
->color('warning')
|
||||
->importer(ItemImporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import item');
|
||||
}),
|
||||
// ->maxRows(100000),
|
||||
// ->maxRows(100000),
|
||||
ExportAction::make()
|
||||
// ->columnMapping(true)
|
||||
// ->columnMapping(true)
|
||||
->label('Export Items')
|
||||
->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)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export item');
|
||||
}),
|
||||
// ->formats([
|
||||
// ExportFormat::Xlsx,
|
||||
// ExportFormat::Csv,
|
||||
// ]),
|
||||
// ->formats([
|
||||
// ExportFormat::Xlsx,
|
||||
// ExportFormat::Csv,
|
||||
// ]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@ class MachineResource extends Resource
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->minLength(5)
|
||||
->placeholder('Scan the valid Machine Name')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
@@ -169,6 +170,7 @@ class MachineResource extends Resource
|
||||
}),
|
||||
Forms\Components\TextInput::make('work_center')
|
||||
->label('Work Center')
|
||||
->minLength(6)
|
||||
->placeholder('Scan the valid Work Center')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
|
||||
@@ -24,6 +24,12 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Smalot\PdfParser\Parser;
|
||||
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
|
||||
{
|
||||
@@ -46,6 +52,22 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
$set('coilNumberError', null);
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('poPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
@@ -106,12 +128,94 @@ class ProcessOrderResource extends Resource
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
// ->readOnly(true),
|
||||
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
$set('process_order', null);
|
||||
$set('coilNumberError', 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(),
|
||||
Forms\Components\TextInput::make('coil_number')
|
||||
->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.');
|
||||
$set('coil_number', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
$set('coilNumberError', null);
|
||||
$set('sfgNumberError', null);
|
||||
} elseif (! $processOrder) {
|
||||
$set('coil_number', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
$set('poPlantError', null);
|
||||
$set('coilNumberError', null);
|
||||
$set('sfgNumberError', null);
|
||||
} elseif ($coilNo || $coilNo == '0') {
|
||||
$existing = ProcessOrder::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\TextInput::make('order_quantity')
|
||||
->label('Order Quantity')
|
||||
@@ -122,10 +226,38 @@ class ProcessOrderResource extends Resource
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->required(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$sfgNo = $get('sfg_number');
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
$set('sfgNumberError', null); // 'Please select a plant first.'
|
||||
} elseif ($sfgNo) {
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('sfg_number', $sfgNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
$set('poPlantError', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
$set('sfgNumberError', "Duplicate SFG : '{$sfgNo}' found!");
|
||||
} else {
|
||||
$set('poPlantError', null);
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('sfgNumberError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('sfgNumberError') ? $get('sfgNumberError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine ID')
|
||||
->required(),
|
||||
->label('Machine ID'),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
@@ -370,8 +502,7 @@ class ProcessOrderResource extends Resource
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
@@ -394,9 +525,131 @@ class ProcessOrderResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
// ->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('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([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
366
app/Filament/Resources/ProductCharacteristicsMasterResource.php
Normal file
366
app/Filament/Resources/ProductCharacteristicsMasterResource.php
Normal file
@@ -0,0 +1,366 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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';
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Exports\QualityValidationExporter;
|
||||
use App\Filament\Imports\QualityValidationImporter;
|
||||
use App\Filament\Resources\QualityValidationResource\Pages;
|
||||
use App\Filament\Resources\QualityValidationResource\RelationManagers;
|
||||
// use App\Jobs\SendInvalidQualityMailJob;
|
||||
use App\Mail\InvalidQualityMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Item;
|
||||
@@ -13,6 +14,8 @@ use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
// use App\Models\User;
|
||||
// use App\Notifications\StatusUpdated;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -45,6 +48,7 @@ class QualityValidationResource extends Resource
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Display';
|
||||
|
||||
public $isSubmitted = false;
|
||||
public $data = [];
|
||||
|
||||
@@ -654,7 +658,6 @@ class QualityValidationResource extends Resource
|
||||
->label('Select Validation')
|
||||
->reactive()
|
||||
->options(fn (callable $get) => $get('part_validation_type_options') ?? [])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
// when user selects something new, hide the image
|
||||
$set('show_validation_image', false);
|
||||
@@ -707,7 +710,6 @@ class QualityValidationResource extends Resource
|
||||
$fileName = "{$value}.png";
|
||||
|
||||
$imageUrl = route('part.validation.image', [
|
||||
'plant' => $plantCode1,
|
||||
'filename' => $fileName
|
||||
]);
|
||||
|
||||
@@ -1732,6 +1734,17 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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)) {
|
||||
$set('tube_sticker_motor_error', null);
|
||||
return;
|
||||
@@ -1833,6 +1846,24 @@ class QualityValidationResource extends Resource
|
||||
if (!$isMatch)
|
||||
{
|
||||
$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);
|
||||
return;
|
||||
}
|
||||
@@ -1857,10 +1888,32 @@ class QualityValidationResource extends Resource
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) {
|
||||
|
||||
$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)) {
|
||||
$set('tube_sticker_pump_error', null);
|
||||
return;
|
||||
@@ -1942,14 +1995,14 @@ class QualityValidationResource extends Resource
|
||||
// ]);
|
||||
$visibleSerialNumber = $get('serial_number');
|
||||
|
||||
$expectedItemCode = trim((string) $get('item_id'));
|
||||
$expectedItemCode = trim((string) $get('item_id'));
|
||||
|
||||
if ($itemCode != $expectedItemCode) {
|
||||
$set('tube_sticker_pump_error', 'Item code does not match.');
|
||||
return;
|
||||
}
|
||||
if ($itemCode != $expectedItemCode) {
|
||||
$set('tube_sticker_pump_error', 'Item code does not match.');
|
||||
return;
|
||||
}
|
||||
|
||||
$set('tube_sticker_pump_error', $serialNumber);
|
||||
$set('tube_sticker_pump_error', $serialNumber);
|
||||
|
||||
// $isMatch = in_array($serialNumber, $visibleSerialNumbers, true);
|
||||
$isMatch = ($visibleSerialNumber == $serialNumber);
|
||||
@@ -1963,6 +2016,62 @@ class QualityValidationResource extends Resource
|
||||
{
|
||||
$set('tube_sticker_pump_error', 'Serial number does not match.');
|
||||
$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;
|
||||
}
|
||||
else {
|
||||
@@ -1990,6 +2099,17 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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)) {
|
||||
$set('tube_sticker_pumpset_error', null);
|
||||
return;
|
||||
@@ -2093,6 +2213,23 @@ class QualityValidationResource extends Resource
|
||||
if (!$isMatch)
|
||||
{
|
||||
$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);
|
||||
return;
|
||||
}
|
||||
@@ -2250,9 +2387,15 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantId = $get('plant_id');
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart1 = $plant?->code;
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
|
||||
$stickerMasterId = $get('sticker_master_id');
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
@@ -2284,12 +2427,13 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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, 'InvalidPartNumber')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2299,7 +2443,7 @@ class QualityValidationResource extends Resource
|
||||
$set('part_validation1', null);
|
||||
|
||||
$fileName = $expectedValue . ".png"; // or .jpg based on your file
|
||||
$fullPath = storage_path("app/private/uploads/PartValidation/{$plantCodePart1}/{$fileName}");
|
||||
$fullPath = storage_path("app/private/uploads/PartValidation/{$fileName}");
|
||||
|
||||
// dd($fullPath);
|
||||
|
||||
@@ -2310,7 +2454,7 @@ class QualityValidationResource extends Resource
|
||||
// ]);
|
||||
if (file_exists($fullPath)) {
|
||||
$imageUrl = route('part.validation.image', [
|
||||
'plant' => $plantCodePart1,
|
||||
// 'plant' => $plantCodePart1,
|
||||
'filename' => $fileName
|
||||
]);
|
||||
} else {
|
||||
@@ -2348,6 +2492,11 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart2 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
$stickerMasterId = $get('sticker_master_id');
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
@@ -2376,12 +2525,13 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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, 'InvalidPartNumber2')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber2')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2441,6 +2591,12 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart3 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
}
|
||||
@@ -2469,12 +2625,13 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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, 'InvalidPartNumber3')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber3')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2532,6 +2689,11 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart4 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
}
|
||||
@@ -2560,12 +2722,13 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$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, 'InvalidPartNumber4')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber4')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2582,7 +2745,7 @@ class QualityValidationResource extends Resource
|
||||
'filename' => $fileName
|
||||
]);
|
||||
|
||||
$set('part_validation2_error_image', $imageUrl);
|
||||
$set('part_validation4_error_image', $imageUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -2679,22 +2842,22 @@ class QualityValidationResource extends Resource
|
||||
else
|
||||
{
|
||||
$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'];
|
||||
$emails = $mailData['emails'];
|
||||
// $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 InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
// if (!empty($emails))
|
||||
// {
|
||||
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
$set('part_validation5', null);
|
||||
return;
|
||||
}
|
||||
@@ -2715,6 +2878,21 @@ class QualityValidationResource extends Resource
|
||||
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');
|
||||
|
||||
$emails = AlertMailRule::where('plant', $plantId)
|
||||
@@ -2731,34 +2909,6 @@ 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
|
||||
{
|
||||
return $table
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
200
app/Filament/Resources/StickerPrintingResource.php
Normal file
200
app/Filament/Resources/StickerPrintingResource.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?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");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,19 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\WorkGroupMasterExporter;
|
||||
use App\Filament\Imports\WorkGroupMasterImporter;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
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\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
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;
|
||||
|
||||
class WorkGroupMasterResource extends Resource
|
||||
@@ -37,68 +35,70 @@ class WorkGroupMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
return;
|
||||
}
|
||||
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');
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'operation_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->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]),
|
||||
if (! $plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required(),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('work_group_masters', 'operation_number')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->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,6 +112,7 @@ class WorkGroupMasterResource extends Resource
|
||||
$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')
|
||||
@@ -177,14 +178,14 @@ class WorkGroupMasterResource extends Resource
|
||||
->label('Import Work Group Masters')
|
||||
->color('warning')
|
||||
->importer(WorkGroupMasterImporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import work group master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Work Group Masters')
|
||||
->color('warning')
|
||||
->exporter(WorkGroupMasterExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export work group master');
|
||||
}),
|
||||
]);
|
||||
|
||||
2519
app/Http/Controllers/CharacteristicsController.php
Normal file
2519
app/Http/Controllers/CharacteristicsController.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -631,10 +631,11 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
Log::info('Process Order POST API called >>', ['request_data' => $request->all()]);
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$processOrder = $request->header('process-order');
|
||||
$data = $request->all();
|
||||
|
||||
Log::info('Process Order POST API >>', ['plant-code' => $plantCode, 'process-order' => $processOrder, 'post-data' => $data]);
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
return response()->json([
|
||||
@@ -665,8 +666,6 @@ class PdfController extends Controller
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
@@ -714,19 +713,19 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($sfgNo == null || $sfgNo == '' || ! $sfgNo) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "SFG number can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
// if ($sfgNo == null || $sfgNo == '' || ! $sfgNo) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "SFG number can't be empty!",
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
if ($machineId == null || $machineId == '' || ! $machineId) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Machine ID can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
// if ($machineId == null || $machineId == '' || ! $machineId) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Machine ID can't be empty!",
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
|
||||
return response()->json([
|
||||
@@ -778,19 +777,23 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('sfg_number', $sfgNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $itemPlant->id;
|
||||
|
||||
if ($sfgNo != null && $sfgNo != '' && Str::length($sfgNo) > 0 && $sfgNo) {
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('sfg_number', $sfgNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
} else {
|
||||
$sfgNo = null;
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', '!=', $itemId)
|
||||
|
||||
@@ -20,191 +20,18 @@ class ProductionStickerReprintController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
// public function downloadQrPdf($palletNo)
|
||||
// {
|
||||
|
||||
// $parts = explode('|', $palletNo);
|
||||
// $itemCode = trim($parts[0]);
|
||||
// $serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// // Retrieve the item record by item code
|
||||
// $item = Item::where('code', $itemCode)->first();
|
||||
|
||||
// if (!$item) {
|
||||
// abort(404, "Item with code {$itemCode} not found.");
|
||||
// }
|
||||
|
||||
// $itemId = $item->id;
|
||||
|
||||
// $production = ProductionQuantity::where('item_id', $itemId)
|
||||
// ->where('serial_number', $serial)
|
||||
// ->first();
|
||||
|
||||
// if (!$production) {
|
||||
// abort(404, "Production data for item code '{$itemCode}' with serial '{$serial}' not found.");
|
||||
// }
|
||||
|
||||
// $productionOrder = $production->production_order;
|
||||
|
||||
// $qrCode = new QrCode($palletNo);
|
||||
// $output = new Output\Png();
|
||||
// $qrBinary = $output->output($qrCode, 100);
|
||||
// $qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
// $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // Decide number of copies
|
||||
// $copies = 1;
|
||||
|
||||
// if ($sticker) {
|
||||
// if ($sticker->serial_number_pump == 1) {
|
||||
// // If pump is selected (regardless of motor), 2 copies
|
||||
// $copies = 2;
|
||||
// } elseif ($sticker->serial_number_motor == 1) {
|
||||
// // Only motor selected, 1 copy
|
||||
// $copies = 1;
|
||||
// }
|
||||
// }
|
||||
// return '
|
||||
// <html>
|
||||
// <head>
|
||||
// <style>
|
||||
// body {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// font-size: 10pt;
|
||||
// font-family: Arial Narrow, Arial, sans-serif;
|
||||
// }
|
||||
|
||||
// .sticker-table {
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// }
|
||||
|
||||
// .text-cell {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// text-align: left;
|
||||
// font-size: 14pt;
|
||||
// font-weight: normal;
|
||||
// line-height: 1.2;
|
||||
// }
|
||||
|
||||
// .text-row {
|
||||
// font-weight: bold;
|
||||
// font-size: 9pt;
|
||||
// }
|
||||
|
||||
// .serial {
|
||||
// text-align: left;
|
||||
// }
|
||||
|
||||
// .po-number {
|
||||
// text-align: right;
|
||||
// white-space: nowrap;
|
||||
// }
|
||||
|
||||
// .desc-row {
|
||||
// font-weight: normal;
|
||||
// font-size: 8pt;
|
||||
// }
|
||||
|
||||
// .qr-cell {
|
||||
// width: 14mm;
|
||||
// text-align: left;
|
||||
// padding-left: 0mm;
|
||||
// padding-top: 0mm;
|
||||
// }
|
||||
|
||||
// img.qr {
|
||||
// width: 20mm;
|
||||
// height: 20mm;
|
||||
// }
|
||||
// </style>
|
||||
// </head>
|
||||
// <body>
|
||||
// <div id="print-container"></div>
|
||||
// <script>
|
||||
// const copies = ' . $copies . ';
|
||||
// const htmlBlock = `
|
||||
// <table class="sticker-table">
|
||||
// <tr>
|
||||
// <td class="qr-cell">
|
||||
// <img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
// </td>
|
||||
// <td class="text-cell">
|
||||
// <div class="text-row">
|
||||
// <pre><span class="serial">' . htmlspecialchars($serial) . '</span> <span class="po-number">' . htmlspecialchars($productionOrder) . '</span></pre>
|
||||
// </div>
|
||||
// <div class="desc-row">
|
||||
// ' . htmlspecialchars($item->description) . '
|
||||
// </div>
|
||||
// </td>
|
||||
// </tr>
|
||||
// </table>
|
||||
// `;
|
||||
|
||||
// const container = document.getElementById("print-container");
|
||||
// for (let i = 0; i < copies; i++) {
|
||||
// container.insertAdjacentHTML("beforeend", htmlBlock);
|
||||
// }
|
||||
|
||||
// window.onload = function () {
|
||||
// window.print();
|
||||
// setTimeout(function () {
|
||||
// window.close();
|
||||
// }, 500);
|
||||
// };
|
||||
// </script>
|
||||
// </body>
|
||||
// </html>
|
||||
// ';
|
||||
|
||||
|
||||
// //Get sticker master data
|
||||
// // $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // //Decide number of copies
|
||||
// // $copies = 1; // default
|
||||
// // if ($sticker) {
|
||||
// // if ($sticker->serial_number_motor == 1) {
|
||||
// // $copies = 1;
|
||||
// // } elseif (is_null($sticker->serial_number_motor) && $sticker->serial_number_pump == 1) {
|
||||
// // $copies = 2;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf = new Mpdf([
|
||||
// // 'mode' => 'utf-8',
|
||||
// // 'format' => [60, 14],
|
||||
// // 'margin_left' => 0,
|
||||
// // 'margin_right' => 0,
|
||||
// // 'margin_top' => 0,
|
||||
// // 'margin_bottom' => 0,
|
||||
// // ]);
|
||||
|
||||
// // for ($i = 0; $i < $copies; $i++) {
|
||||
// // $mpdf->WriteHTML($html);
|
||||
// // if ($i < $copies - 1) {
|
||||
// // $mpdf->AddPage();
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf->Output('qr-label.pdf', 'I');
|
||||
// // exit;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$parts = explode('|', $palletNo);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
if ($serialNumberRaw != null) {
|
||||
$serial = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$serial = trim($serial);
|
||||
} else {
|
||||
$serial = null;
|
||||
}
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
$itemId= $item->id;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages\CreateInvoiceValidation;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -34,14 +33,14 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
// protected $listeners = ['refreshInvoiceData' => 'loadData',];
|
||||
// protected $listeners = ['refreshInvoiceData' => 'loadData',];
|
||||
|
||||
protected $listeners = [
|
||||
'refreshCompletedInvoice' => 'loadCompletedData',
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshMaterialInvoiceData' => 'loadMaterialData',
|
||||
'openCapacitorModal' => 'showCapacitorInputBox'
|
||||
'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
];
|
||||
|
||||
public $capacitorInput = '';
|
||||
@@ -84,7 +83,100 @@ class InvoiceDataTable extends Component
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
// // $this->showCapacitorInput = false;
|
||||
|
||||
// // ->where('serial_number', '!=', '')
|
||||
// $this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
// ->get()
|
||||
// ->map(function ($record) {
|
||||
// return [
|
||||
// 'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'serial_number' => $record->serial_number,
|
||||
// 'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
// 'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
// 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
// 'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
// 'scanned_status' => $record->scanned_status ?? '',
|
||||
// 'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
// 'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
// 'created_at' => $record->created_at,
|
||||
// 'operator_id' => $record->operator_id,
|
||||
// ];
|
||||
// })
|
||||
// ->toArray();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// // Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
// foreach ($this->invoiceData as &$row) {
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// // $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
// $row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
// $curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
// if ($curStick) {
|
||||
// if (Str::length($curStick->panel_box_code) > 0) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1) {
|
||||
// if ($curStick->tube_sticker_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pump == 1 || ($curStick->tube_sticker_pumpset != 1 && $curStick->tube_sticker_pump != 1 && $curStick->pack_slip_pump == 1)) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// } elseif ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1) {
|
||||
// if ($curStick->pack_slip_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pump == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['capacitor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
|
||||
// $this->packageCount += $stickCount - $scannedCount;
|
||||
// }
|
||||
|
||||
// if ($onCapFocus) {
|
||||
// $this->dispatch('focus-capacitor-input');
|
||||
// } else {
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
// }
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
@@ -94,14 +186,56 @@ class InvoiceDataTable extends Component
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
//->where('serial_number', '!=', '')
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
// Eager load stickerMasterRelation and item
|
||||
$invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
|
||||
$this->invoiceData = [];
|
||||
$this->packageCount = 0;
|
||||
|
||||
foreach ($invoiceRecords as $record) {
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
// Compute code
|
||||
$rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
if ($sm) {
|
||||
// Panel box code
|
||||
if (Str::length($sm->panel_box_code) > 0) {
|
||||
$stickCount++;
|
||||
}
|
||||
|
||||
// Tube stickers logic
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
}
|
||||
// Pack slip logic (only if tube sticker block didn't apply)
|
||||
elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Count already scanned
|
||||
$scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
|
||||
// Increment packageCount
|
||||
$this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
$this->invoiceData[] = [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
@@ -113,84 +247,14 @@ class InvoiceDataTable extends Component
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
'code' => $rowCode,
|
||||
'stickCount' => $stickCount,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->packageCount = 0;
|
||||
|
||||
//Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
if ($curStick)
|
||||
{
|
||||
if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1 || Str::length($curStick->panel_box_code) > 0)
|
||||
{
|
||||
if ($curStick->tube_sticker_motor == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pump == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pumpset == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
if (Str::length($curStick->panel_box_code) > 0)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
}
|
||||
else if ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1)
|
||||
{
|
||||
if ($curStick->pack_slip_motor == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pump == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pumpset == 1)
|
||||
{
|
||||
$stickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['motor_scanned_status'] == 1)
|
||||
{
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['pump_scanned_status'] == 1)
|
||||
{
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['capacitor_scanned_status'] == 1)
|
||||
{
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['scanned_status_set'] == 1)
|
||||
{
|
||||
$scannedCount++;
|
||||
}
|
||||
|
||||
$this->packageCount += $stickCount - $scannedCount;
|
||||
}
|
||||
|
||||
if ($onCapFocus)
|
||||
{
|
||||
if ($onCapFocus) {
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
}
|
||||
@@ -207,43 +271,36 @@ class InvoiceDataTable extends Component
|
||||
$this->materialInvoice = true;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
//->where('serial_number', '!=', '')
|
||||
// ->where('serial_number', '!=', '')
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $plantId)->where('serial_number', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'material_type' => StickerMaster::where('id', $record->sticker_master_id)->first()->material_type ?? '',
|
||||
'quantity' => $record->quantity ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'batch_number' => $record->batch_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'material_type' => StickerMaster::where('id', $record->sticker_master_id)->first()->material_type ?? '',
|
||||
'quantity' => $record->quantity ?? '',
|
||||
'serial_number' => $record->serial_number ?? '',
|
||||
'batch_number' => $record->batch_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
//Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
// Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$matType = StickerMaster::where('id', $row['sticker_master_id'] ?? null)->first()->material_type ?? '';
|
||||
if ($matType === 1)
|
||||
{
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$matType = StickerMaster::where('id', $row['sticker_master_id'] ?? null)->first()->material_type ?? '';
|
||||
if ($matType === 1) {
|
||||
$row['material_type'] = 'Individual';
|
||||
}
|
||||
else if ($matType === 2)
|
||||
{
|
||||
} elseif ($matType === 2) {
|
||||
$row['material_type'] = 'Bundle';
|
||||
}
|
||||
else if ($matType === 3)
|
||||
{
|
||||
} elseif ($matType === 3) {
|
||||
$row['material_type'] = 'Quantity';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$row['material_type'] = 'N/A';
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
@@ -275,11 +332,11 @@ class InvoiceDataTable extends Component
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (!$this->capacitorInput) {
|
||||
if (! $this->capacitorInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
if (! preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
@@ -287,6 +344,7 @@ class InvoiceDataTable extends Component
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,9 +356,9 @@ class InvoiceDataTable extends Component
|
||||
$existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
})
|
||||
->exists();
|
||||
->exists();
|
||||
|
||||
if (!$existsInStickerMaster) {
|
||||
if (! $existsInStickerMaster) {
|
||||
Notification::make()
|
||||
->title('Unknown: Panel Box Code')
|
||||
->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
|
||||
@@ -309,12 +367,12 @@ class InvoiceDataTable extends Component
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->capacitorInput = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber)
|
||||
{
|
||||
if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
@@ -343,47 +401,41 @@ class InvoiceDataTable extends Component
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
// if ($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr)
|
||||
{
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr) {
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
|
||||
$scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
if ($packCnt === $scanCnt)
|
||||
{
|
||||
if ($packCnt === $scanCnt) {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'operator_id'=> $operatorName,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -398,15 +450,14 @@ class InvoiceDataTable extends Component
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $matchingValidation->plant_id,
|
||||
// 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totalQuantity,
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
// 'plant_id' => $matchingValidation->plant_id,
|
||||
// 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totalQuantity,
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($totalQuantity === $scannedQuantity) {
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
@@ -414,9 +465,7 @@ class InvoiceDataTable extends Component
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id, false);
|
||||
}
|
||||
}
|
||||
@@ -427,7 +476,7 @@ class InvoiceDataTable extends Component
|
||||
$this->showCapacitorInput = false;
|
||||
$this->capacitorInput = '';
|
||||
$this->dispatch('updateScannedQuantity');
|
||||
//$this->loadData($this->invoiceNumber, $this->plantId);
|
||||
// $this->loadData($this->invoiceNumber, $this->plantId);
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
@@ -435,5 +484,4 @@ class InvoiceDataTable extends Component
|
||||
{
|
||||
return view('livewire.invoice-data-table');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
55
app/Livewire/StickerPrintData.php
Normal file
55
app/Livewire/StickerPrintData.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -20,17 +20,24 @@ class InvalidQualityMail extends Mailable
|
||||
public $invoiceNumber;
|
||||
public $mplantName;
|
||||
public $mProdOrder;
|
||||
|
||||
public $mUserName;
|
||||
|
||||
public $mPartNo;
|
||||
public $mailType;
|
||||
public $greeting;
|
||||
public $subjectLine;
|
||||
|
||||
public $mLinePart;
|
||||
|
||||
public $itemCode;
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mailType = 'InvalidPartNumber')
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mailType = 'InvalidPartNumber')
|
||||
{
|
||||
$this->mPartNo = $parNo;
|
||||
$this->mProdOrder = $mProdOrder;
|
||||
$this->mplantName = $mplantName;
|
||||
$this->mLinePart = $mLinePart;
|
||||
$this->mUserName = $mUserName;
|
||||
$this->mailType = $mailType;
|
||||
}
|
||||
|
||||
@@ -39,20 +46,20 @@ class InvalidQualityMail extends Mailable
|
||||
// dynamic subject based on mail type
|
||||
switch ($this->mailType) {
|
||||
case 'InvalidPartNumber2':
|
||||
$this->subjectLine = "Invalid Part Number 2 Scanned ({$this->mplantName})";
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber3':
|
||||
$this->subjectLine = "Invalid Part Number 3 Scanned ({$this->mplantName})";
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber4':
|
||||
$this->subjectLine = "Invalid Part Number 4 Scanned ({$this->mplantName})";
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber5':
|
||||
$this->subjectLine = "Invalid Part Number 5 Scanned ({$this->mplantName})";
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber':
|
||||
default:
|
||||
$this->subjectLine = "Invalid Part Number 1 Scanned ({$this->mplantName})";
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -70,8 +77,10 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 2:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber3':
|
||||
@@ -79,8 +88,10 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 3:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber4':
|
||||
@@ -88,8 +99,10 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 4:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber5':
|
||||
@@ -97,8 +110,10 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 5:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber':
|
||||
@@ -107,8 +122,10 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 1:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -82,12 +82,14 @@ class InvalidSerialMail extends Mailable
|
||||
public $greeting;
|
||||
public $subjectLine;
|
||||
|
||||
public $mUserName;
|
||||
|
||||
public $itemCode;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat')
|
||||
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mUserName, $mailType = 'InvalidFormat')
|
||||
{
|
||||
$this->serial = $serial;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
@@ -95,6 +97,7 @@ class InvalidSerialMail extends Mailable
|
||||
$this->mInvoiceType = $mInvoiceType;
|
||||
$this->mailType = $mailType;
|
||||
$this->itemCode = $itemCode;
|
||||
$this->mUserName = $mUserName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,58 +107,24 @@ class InvalidSerialMail extends Mailable
|
||||
{
|
||||
// dynamic subject based on mail type
|
||||
switch ($this->mailType) {
|
||||
case 'NotFound':
|
||||
$this->subjectLine = "Serial Number Not Found ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotFoundInvoice':
|
||||
$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})";
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
break;
|
||||
case 'DuplicateCapacitorQR':
|
||||
$this->subjectLine = "Duplicate Capacitor QR ({$this->mplantName})";
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
break;
|
||||
case 'UnknownPumpsetQR':
|
||||
$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})";
|
||||
case 'InvalidPanelBox':
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
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(
|
||||
@@ -170,224 +139,28 @@ class InvalidSerialMail extends Mailable
|
||||
{
|
||||
// dynamic greeting/message body
|
||||
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':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<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>
|
||||
The scanned serial number could not be found in the given invoice.<br><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>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'DuplicateMotorQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned 'Motor' serial number <b>{$this->serial}</b> already completed the scanning process.<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;
|
||||
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;
|
||||
// case 'DuplicateCapacitorQR':
|
||||
// $this->greeting = "
|
||||
// Dear Sir/Madam,<br><br>
|
||||
// The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><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>
|
||||
// <b>Employee Code:</b> {$this->mUserName}<br>
|
||||
// ";
|
||||
// break;
|
||||
}
|
||||
|
||||
return new Content(
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use DateTime;
|
||||
|
||||
class InvoiceDataMail extends Mailable
|
||||
{
|
||||
@@ -23,7 +23,7 @@ class InvoiceDataMail extends Mailable
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType, $tableData = [], $mailSubject)
|
||||
public function __construct($scheduleType, $tableData, $mailSubject)
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
@@ -48,17 +48,19 @@ class InvoiceDataMail extends Mailable
|
||||
$greeting = 'Dear Sir/Madam,<br><br>We are sending here with list of "Despatch pending sale invoice & STO invoice as on date"';
|
||||
|
||||
if ($this->scheduleType == 'Daily') {
|
||||
$firstRecord = \App\Models\InvoiceDataValidation::orderBy('document_date', 'asc')->first();
|
||||
//$lastRecord = \App\Models\InvoiceDataValidation::orderBy('document_date', 'desc')->first();
|
||||
$firstRecord = InvoiceDataValidation::orderBy('document_date', 'asc')->first(); // 'desc'
|
||||
|
||||
if ($firstRecord) {
|
||||
$startDate = null;
|
||||
if ($firstRecord && $firstRecord?->document_date != null && $firstRecord?->document_date != '') {
|
||||
$startDate = \Carbon\Carbon::parse($firstRecord->document_date)->startOfDay();
|
||||
//$endDate = \Carbon\Carbon::parse($lastRecord->document_date)->endOfDay();
|
||||
// $endDate = \Carbon\Carbon::parse($lastRecord->document_date)->endOfDay();
|
||||
} else {
|
||||
$startDate = now()->subDay()->setTime(10, 0, 0);
|
||||
}
|
||||
$endDate = now()->setTime(10, 0, 0);
|
||||
|
||||
// $fromDate = (new DateTime('yesterday 10:00'))->format('d/m/Y H:i') . ':000';//08:00
|
||||
// $toDate = (new DateTime('today 09:59'))->format('d/m/Y H:i') . ':999';//07:59
|
||||
// $toDate = (new DateTime('today 09:59')) ->format('d/m/Y H:i') . ':999';//07:59
|
||||
$reportPeriod = "from: $startDate to $endDate\".<br><br>Please arrange to despatch the same immediately.";
|
||||
$greeting .= $reportPeriod;
|
||||
}
|
||||
@@ -74,17 +76,17 @@ class InvoiceDataMail extends Mailable
|
||||
if ($this->scheduleType == 'Live') {
|
||||
$now = now();
|
||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$greeting .= "from: $fromMinute to $toMinute. <br><br>Please arrange to despatch the same immediately.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.invoice_data_report',
|
||||
with: [
|
||||
'company' => "CRI Digital Manufacturing Solutions",
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => $greeting,
|
||||
'tableData' => $this->tableData,
|
||||
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
47
app/Models/CharacteristicValue.php
Normal file
47
app/Models/CharacteristicValue.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
60
app/Models/ProductCharacteristicsMaster.php
Normal file
60
app/Models/ProductCharacteristicsMaster.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
29
app/Models/StickerPrinting.php
Normal file
29
app/Models/StickerPrinting.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
106
app/Policies/CharacteristicValuePolicy.php
Normal file
106
app/Policies/CharacteristicValuePolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ProductCharacteristicsMasterPolicy.php
Normal file
106
app/Policies/ProductCharacteristicsMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
107
app/Policies/StickerPrintingPolicy.php
Normal file
107
app/Policies/StickerPrintingPolicy.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\FilamentView;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Policies\RolePolicy;
|
||||
use App\Policies\PermissionPolicy;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use App\Policies\RolePolicy;
|
||||
use Filament\Support\Assets\Js;
|
||||
use Filament\Support\Facades\FilamentAsset;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
// use Doctrine\DBAL\Types\Type;
|
||||
|
||||
@@ -28,7 +28,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
@@ -42,21 +41,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
// });
|
||||
|
||||
Gate::before(function (User $user, string $ability) {
|
||||
return $user->isSuperAdmin() ? true: null;
|
||||
return $user->isSuperAdmin() ? true : null;
|
||||
});
|
||||
|
||||
// FilamentAsset::register([
|
||||
// Js::make('chart-js-plugins', Vite::asset('resources/js/filament-chart-js-plugins.js'))->module(),
|
||||
// ]);
|
||||
FilamentAsset::register([
|
||||
Js::make('chart-js-plugins', Vite::asset('resources/js/filament-chart-js-plugins.js'))->module(),
|
||||
Js::make('chart-js-plugins', Vite::asset('resources/js/filament-chart-js-plugins.js'))->module(),
|
||||
]);
|
||||
// if (env('APP_MODE') === 'admin') {
|
||||
// FilamentAsset::register([
|
||||
// Js::make('chart-js-plugins', Vite::asset('resources/js/filament-chart-js-plugins.js'))->module(),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if (env('APP_MODE') === 'admin') {
|
||||
// FilamentAsset::register([
|
||||
// Js::make('chart-js-plugins', Vite::asset('resources/js/filament-chart-js-plugins.js'))->module(),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// URL::forceScheme('https');
|
||||
|
||||
@@ -70,5 +69,82 @@ class AppServiceProvider extends ServiceProvider
|
||||
ini_set('max_execution_time', 300); // 300 seconds = 5 minutes
|
||||
ini_set('memory_limit', '512M'); // 512MB
|
||||
|
||||
// $schedule = app(Schedule::class);
|
||||
|
||||
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
// foreach ($productionRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||
// // ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Invoice report scheduling
|
||||
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Invoice Data Report Scheduling
|
||||
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
// foreach ($invoiceDataRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('10:00');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +213,8 @@ return [
|
||||
|
||||
'user_model' => \App\Models\User::class,
|
||||
|
||||
// 'user_model_class' => \App\Models\User::class,
|
||||
|
||||
'policies_namespace' => 'App\Policies',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -169,6 +169,7 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view import process order']);
|
||||
Permission::updateOrCreate(['name' => 'view export process order']);
|
||||
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import sticker printing']);
|
||||
Permission::updateOrCreate(['name' => 'view export sticker printing']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
"laravel-vite-plugin": "^1.2.0",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"vite": "^6.0.11"
|
||||
"vite": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<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>
|
||||
23
resources/views/forms/components/print-button.blade.php
Normal file
23
resources/views/forms/components/print-button.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
{{-- <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>
|
||||
|
||||
|
||||
81
resources/views/livewire/sticker-print-data.blade.php
Normal file
81
resources/views/livewire/sticker-print-data.blade.php
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
{{-- <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>
|
||||
|
||||
|
||||
92
resources/views/pdf/qrcode.blade.php
Normal file
92
resources/views/pdf/qrcode.blade.php
Normal file
@@ -0,0 +1,92 @@
|
||||
{{-- <!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>
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?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\InvoiceValidationController;
|
||||
use App\Http\Controllers\MachineController;
|
||||
@@ -45,7 +43,6 @@ use Illuminate\Support\Facades\Route;
|
||||
// return $item;
|
||||
// });
|
||||
|
||||
|
||||
// Route::post('/user/update', function (Request $request) {
|
||||
// // Return the request data as JSON
|
||||
|
||||
@@ -56,7 +53,6 @@ use Illuminate\Support\Facades\Route;
|
||||
// ]);
|
||||
// });
|
||||
|
||||
|
||||
// Route::middleware('auth.basic')->post('/user/update', function (Request $request) {
|
||||
// return response()->json([
|
||||
// 'message' => 'Authenticated via Basic Auth',
|
||||
@@ -65,7 +61,6 @@ use Illuminate\Support\Facades\Route;
|
||||
// ]);
|
||||
// });
|
||||
|
||||
|
||||
Route::post('obd/store-data', [ObdController::class, 'store']);
|
||||
|
||||
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
||||
@@ -80,9 +75,11 @@ 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-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');
|
||||
|
||||
//Production Dashboard Controller
|
||||
// Production Dashboard Controller
|
||||
|
||||
Route::get('get/module-name/data', [ModuleController::class, 'get_module']);
|
||||
|
||||
@@ -104,7 +101,7 @@ Route::get('get/module-production-order/data', [ModuleProductionOrderDataControl
|
||||
|
||||
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']);
|
||||
|
||||
@@ -114,7 +111,7 @@ Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class,
|
||||
|
||||
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']);
|
||||
|
||||
@@ -122,19 +119,19 @@ Route::get('get/module-guard-hourly/data', [ModuleGuardHourlyCountController::cl
|
||||
|
||||
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-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
|
||||
|
||||
//Invoice Validation Controller
|
||||
// Invoice Validation Controller
|
||||
|
||||
Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']);
|
||||
|
||||
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']);
|
||||
|
||||
@@ -154,28 +151,39 @@ Route::get('process-order/details', [PdfController::class, 'getProcessOrderData'
|
||||
|
||||
Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
||||
|
||||
|
||||
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::post('laser/route/data', [CharacteristicsController::class, 'test']);//->withoutMiddleware(VerifyCsrfToken::class)
|
||||
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
|
||||
|
||||
// Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
// //..Part Validation - Characteristics
|
||||
|
||||
// //..
|
||||
// // Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
|
||||
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
// // //..Serial or job
|
||||
|
||||
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
// // Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
|
||||
// Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
// // Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
|
||||
// Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
// // //..Job or Master - Characteristics
|
||||
|
||||
//GR Master PDF and Serial Number
|
||||
// // Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// // //..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']);
|
||||
|
||||
@@ -183,7 +191,7 @@ Route::get('grmaster-sno', [PdfController::class, 'getGRSerial']);
|
||||
|
||||
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']);
|
||||
|
||||
|
||||
@@ -1,100 +1,101 @@
|
||||
<?php
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(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:production-report');
|
||||
|
||||
app()->booted(function () {
|
||||
$schedule = app(Schedule::class);
|
||||
// app()->booted(function () {
|
||||
// $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
|
||||
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
if (Schema::hasTable('alert_mail_rules')) {
|
||||
// foreach ($productionRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// Production report scheduling
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
// $command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||
// // ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||
|
||||
foreach ($productionRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
$command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||
// ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||
// // Invoice report scheduling
|
||||
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('07:59');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// Invoice report scheduling
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
// $command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||
|
||||
foreach ($invoiceRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
$command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||
// // Invoice Data Report Scheduling
|
||||
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('07:59');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// foreach ($invoiceDataRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
|
||||
// Invoice Data Report Scheduling
|
||||
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||
|
||||
foreach ($invoiceDataRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
|
||||
$command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('10:00');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('10:00');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
use App\Filament\Pages\CustomLogin;
|
||||
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
@@ -25,8 +25,8 @@ use App\Filament\Pages\CustomLogin;
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/part-validation-image/{plant}/{filename}', function ($plant, $filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$plant}/{$filename}");
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
|
||||
if (!file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
|
||||
Reference in New Issue
Block a user