Compare commits
1 Commits
ranjith-de
...
dhana-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7d27a9dc0 |
23
.github/workflows/gemini-pr-review.yaml
vendored
23
.github/workflows/gemini-pr-review.yaml
vendored
@@ -5,20 +5,15 @@ name: Gemini PR Review
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
gemini-pr-review:
|
||||
review:
|
||||
runs-on: ubuntu-latest
|
||||
name: Gemini PR Review
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0 # This fetches the full history
|
||||
|
||||
@@ -27,6 +22,7 @@ jobs:
|
||||
with:
|
||||
node-version: '24'
|
||||
|
||||
|
||||
- name: Get npm cache directory
|
||||
id: npm-cache-dir
|
||||
run: |
|
||||
@@ -40,14 +36,8 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-npm-global-
|
||||
|
||||
- name: Install Gemini CLI globally (if not already installed)
|
||||
run: |
|
||||
if ! command -v gemini &> /dev/null; then
|
||||
echo "Gemini CLI not found, installing..."
|
||||
npm install -g --loglevel=http @google/gemini-cli
|
||||
else
|
||||
echo "Gemini CLI already installed."
|
||||
fi
|
||||
- name: Install Gemini CLI globally
|
||||
run: npm install -g --loglevel=http @google/gemini-cli
|
||||
|
||||
- name: Generate git diff and review with Gemini
|
||||
id: review
|
||||
@@ -62,6 +52,7 @@ jobs:
|
||||
|
||||
cat /tmp/gemini-client-error*.json || true
|
||||
|
||||
|
||||
- name: Post output to PR comment
|
||||
id: post_comment
|
||||
run: |
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Scheduler extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:scheduler';
|
||||
|
||||
protected $signature = 'custom:scheduler';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $description = 'Command description';
|
||||
|
||||
protected $description = 'Manually trigger scheduler logic';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
// public function handle()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$this->call('approval:trigger-mails');
|
||||
|
||||
// --- 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') == '11:30') {
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$invoiceTransitRules = AlertMailRule::where('module', 'InvoiceTransit')
|
||||
->where('rule_name', 'InvoiceTransitMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceTransitRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '11:00') {
|
||||
try {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
|
||||
Log::info('Invoice Transit executed', [
|
||||
'plant' => $rule->plant,
|
||||
'type' => $rule->schedule_type,
|
||||
]);
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
Log::error('Invoice Transit FAILED', [
|
||||
'plant' => $rule->plant,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
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}");
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,12 @@ use App\Mail\InvoiceDataMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendInvoiceDataReport extends Command
|
||||
{
|
||||
@@ -45,14 +49,7 @@ class SendInvoiceDataReport extends Command
|
||||
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$todayRecordExists = InvoiceDataValidation::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
if (!$todayRecordExists) {
|
||||
$this->info('No records created today. Mail not sent.');
|
||||
$this->error("No valid plant(s) found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +105,7 @@ class SendInvoiceDataReport extends Command
|
||||
->where('distribution_channel_desc', $selectedDistribution)
|
||||
->whereBetween('document_date', [$startDate, $endDate])
|
||||
->orderBy('document_date', 'asc')
|
||||
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location', 'remark')
|
||||
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location')
|
||||
->get()
|
||||
->unique('document_number')
|
||||
->values();
|
||||
@@ -117,6 +114,7 @@ class SendInvoiceDataReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter invoices directly — exclude ones with '-' in document_number
|
||||
$invoices = $invoices->filter(function ($inv) {
|
||||
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
||||
});
|
||||
@@ -136,6 +134,7 @@ class SendInvoiceDataReport extends Command
|
||||
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
|
||||
->toArray();
|
||||
|
||||
//where('plant_id', $plant->id)
|
||||
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
//->whereBetween('scanned_at', [$startDate, $endDate])
|
||||
->distinct('qr_code')
|
||||
@@ -165,6 +164,7 @@ class SendInvoiceDataReport extends Command
|
||||
return !in_array($doc, $wentOutInvoices, true);
|
||||
});
|
||||
|
||||
|
||||
if ($pendingInvoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -194,7 +194,6 @@ class SendInvoiceDataReport extends Command
|
||||
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
||||
'status' => 'Pending',
|
||||
'status_class' => $statusColor,
|
||||
'remark' => $inv->remark,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -204,7 +203,6 @@ class SendInvoiceDataReport extends Command
|
||||
->values()
|
||||
->map(function ($item, $index) {
|
||||
$item['no'] = $index + 1;
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
@@ -216,7 +214,7 @@ class SendInvoiceDataReport extends Command
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
||||
$this->table(
|
||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status', 'Remark'],// 'Distribution Type'
|
||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type'
|
||||
$tableData
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
@@ -238,13 +236,13 @@ class SendInvoiceDataReport extends Command
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->info("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -18,6 +18,7 @@ class SendInvoiceReport extends Command
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@@ -28,6 +29,8 @@ class SendInvoiceReport extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
@@ -49,14 +52,18 @@ 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;
|
||||
|
||||
@@ -70,7 +77,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -86,7 +93,7 @@ class SendInvoiceReport extends Command
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
@@ -108,7 +115,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -122,7 +129,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
@@ -144,7 +151,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -158,7 +165,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
@@ -180,104 +187,26 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Send to SerialInvoiceMail recipients
|
||||
if ($mailRules->has('SerialInvoiceMail')) {
|
||||
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
// }
|
||||
foreach ($mailRules->get('SerialInvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
// }
|
||||
foreach ($mailRules->get('MaterialInvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to InvoiceMail recipients (all three tables)
|
||||
if ($mailRules->has('InvoiceMail')) {
|
||||
//$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
// $this->info("✅ Sent InvoiceMail to: {$email}");
|
||||
// }
|
||||
foreach ($mailRules->get('InvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,6 +221,7 @@ class SendInvoiceReport extends Command
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\InvoiceTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceInTransit;
|
||||
use App\Models\InvoiceMaster;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SendInvoiceTransitReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:invoice-transit-report {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
|
||||
$mailRules = AlertMailRule::where('module', 'InvoiceTransit')
|
||||
->where('rule_name', 'InvoiceTransitMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->get();
|
||||
|
||||
$plants = ($plantId == 0)
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
$plantCodes = $plants->pluck('name', 'id');
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$todayRecordExists = InvoiceInTransit::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
if (!$todayRecordExists) {
|
||||
$this->info('No records created today. Mail not sent.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
$results = DB::table('invoice_in_transits as it')
|
||||
->join('invoice_masters as im', function ($join) {
|
||||
$join->on('im.receiving_plant_name', '=', 'it.receiving_plant_name')->on('im.transport_name', '=', 'it.transport_name');
|
||||
})
|
||||
->select(
|
||||
'it.invoice_number',
|
||||
'it.receiving_plant',
|
||||
'it.plant_id',
|
||||
'it.receiving_plant_name',
|
||||
'it.lr_bl_aw_date',
|
||||
'it.lr_bl_aw_number',
|
||||
'im.id as invoice_master_id',
|
||||
'im.transport_name',
|
||||
DB::raw('CAST(im.transit_days AS INTEGER) as transit_days'),
|
||||
// DB::raw('(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE)) as delayed_days')
|
||||
// DB::raw('
|
||||
// GREATEST(
|
||||
// 0,
|
||||
// (CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE) - 1)
|
||||
// - CAST(im.transit_days AS INTEGER)
|
||||
// ) AS delayed_days
|
||||
// ')
|
||||
DB::raw('
|
||||
GREATEST(
|
||||
1,
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER)
|
||||
) AS delayed_days
|
||||
')
|
||||
|
||||
)
|
||||
->when($plantId != 0, fn ($q) => $q->where('it.plant_id', $plantId))
|
||||
->whereNotNull('it.lr_bl_aw_date')
|
||||
->whereRaw('
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER) > 0
|
||||
')
|
||||
->distinct('it.invoice_number')
|
||||
->get();
|
||||
|
||||
if ($results->isEmpty()) {
|
||||
$this->info('No invoice transit records found for today.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$tableData = [];
|
||||
|
||||
foreach ($mailRules as $rule) {
|
||||
|
||||
$ruleInvoices = $results->where('invoice_master_id', $rule->invoice_master_id);
|
||||
// $ruleInvoices = $results->filter(fn($item) => $item->invoice_master_id == (int)$rule->invoice_master_id);
|
||||
|
||||
if ($ruleInvoices->isEmpty()) {
|
||||
$this->info("Skipping rule {$rule->id} — no invoice transit data.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceMaster = InvoiceMaster::find($rule->invoice_master_id);
|
||||
|
||||
$mailSubject = $invoiceMaster
|
||||
? "Despatch Invoice In Transit ({$invoiceMaster->receiving_plant_name} - {$invoiceMaster->transport_name})"
|
||||
: 'Despatch Invoice In Transit';
|
||||
|
||||
if ($ruleInvoices->isEmpty()) {
|
||||
$tableData = [];
|
||||
$this->info("No despatch invoices in transit found for rule {$rule->id}.");
|
||||
} else {
|
||||
|
||||
$tableData = $ruleInvoices->values()->map(function ($item, $index) use ($plantCodes) {
|
||||
return [
|
||||
'no' => $index + 1,
|
||||
'plant' => $plantCodes[$item->plant_id],
|
||||
'receiving_plant' => $item->receiving_plant,
|
||||
'receiving_plant_name' => $item->receiving_plant_name,
|
||||
'invoice_number' => $item->invoice_number,
|
||||
'transport_name' => $item->transport_name,
|
||||
'lr_bl_aw_date' => $item->lr_bl_aw_date,
|
||||
'lr_bl_aw_number' => $item->lr_bl_aw_number,
|
||||
'transit_days' => $item->transit_days,
|
||||
'status' => $item->delayed_days.' Days',
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
}
|
||||
|
||||
$mail = new InvoiceTransitMail($scheduleType, $tableData, $mailSubject);
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule {$rule->id} — no To emails.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info(
|
||||
"Mail sent → Rule {$rule->id} | Invoice Master ID: {$rule->invoice_master_id} | To: ".implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ProductionMail;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ProductionMail;
|
||||
use App\Models\Line;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use DB;
|
||||
|
||||
class SendProductionReport extends Command
|
||||
{
|
||||
@@ -31,10 +32,11 @@ class SendProductionReport extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// ini_set('max_execution_time', 0); // disable limit
|
||||
// set_time_limit(0);
|
||||
ini_set('max_execution_time', 0); // disable limit
|
||||
set_time_limit(0);
|
||||
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
||||
@@ -53,272 +55,98 @@ class SendProductionReport extends Command
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
|
||||
$this->error("No valid plant(s) found.");
|
||||
return;
|
||||
}
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
if (strtolower($scheduleType) == '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);
|
||||
}
|
||||
|
||||
$PlanstartDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$planendDate = now()->setTime(7, 59, 0);
|
||||
$PlanstartDate = now()->setTime(8, 0, 0);
|
||||
$planendDate = now()->copy()->addDay()->setTime(7, 59, 0);
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
//.
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
|
||||
// $month = $startDate->month;
|
||||
// $year = $startDate->year;
|
||||
|
||||
// $workingDays = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->value('working_days') ?? 0;
|
||||
|
||||
// $totalTargetQuantity = 0;
|
||||
|
||||
// $monthlyPlan = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereMonth('created_at', $month)
|
||||
// ->whereYear('created_at', $year)
|
||||
// ->sum('plan_quantity'); // / $workingDays
|
||||
|
||||
// $dailyTarget = $workingDays > 0
|
||||
// ? $monthlyPlan / $workingDays
|
||||
// : 0;
|
||||
|
||||
// $dailyTarget = round($dailyTarget, 2);
|
||||
|
||||
// // $totalTargetQuantity = round($totalTargetQuantity, 2);
|
||||
|
||||
// $monthStart = $startDate->copy()->startOfMonth();
|
||||
// $completedDays = $monthStart->diffInDays($startDate);
|
||||
|
||||
// $expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
// if (strtolower($line->type) == 'fg line') {
|
||||
// $productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
// } else {
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
// }
|
||||
|
||||
// $previousRemaining = max(0, $expectedTillYesterday - $productionQuantity);
|
||||
|
||||
// $totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'type' => $line->type,
|
||||
// 'targetQuantity' => $totalTargetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//..New Logic
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
|
||||
$month = $startDate->month;
|
||||
$year = $startDate->year;
|
||||
|
||||
$workingDays = ProductionPlan::where('plant_id', $plant->id)
|
||||
$targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->value('working_days') ?? 0;
|
||||
|
||||
$monthlyPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
$dailyTarget = $workingDays > 0 ? $monthlyPlan / $workingDays : 0;
|
||||
|
||||
$dailyTarget = round($dailyTarget, 2);
|
||||
|
||||
$leaveDatesString = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->value('leave_dates');
|
||||
|
||||
$leaveDates = $leaveDatesString ? explode(',', $leaveDatesString) : [];
|
||||
|
||||
$monthStart = $startDate->copy()->startOfMonth();
|
||||
$yesterday = $startDate->copy()->subDay();
|
||||
|
||||
$completedDays = 0;
|
||||
$currentDate = $monthStart->copy();
|
||||
|
||||
while ($currentDate->lte($yesterday)) {
|
||||
|
||||
if (!in_array($currentDate->format('Y-m-d'), $leaveDates)) {
|
||||
$completedDays++;
|
||||
}
|
||||
|
||||
$currentDate->addDay();
|
||||
}
|
||||
|
||||
$expectedTillYesterday = $dailyTarget * $completedDays;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$producedTillYesterday = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
|
||||
} else {
|
||||
|
||||
$producedTillYesterday = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->where('created_at', '<', $startDate)
|
||||
->count();
|
||||
}
|
||||
|
||||
$previousRemaining = max(0, $expectedTillYesterday - $producedTillYesterday);
|
||||
|
||||
$totalTargetQuantity = round($dailyTarget + $previousRemaining, 2);
|
||||
|
||||
$itemIds = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->distinct()
|
||||
->pluck('item_id');
|
||||
|
||||
$totalHourlyQuantity = Item::whereIn('id', $itemIds)
|
||||
->sum('hourly_quantity');
|
||||
|
||||
$capacityQuan = $totalHourlyQuantity * 22.5;
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
} else {
|
||||
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
}
|
||||
|
||||
if ($capacityQuan > 0) {
|
||||
$efficiency = ($productionQuantity / $capacityQuan) * 100;
|
||||
} else {
|
||||
$efficiency = 0;
|
||||
}
|
||||
|
||||
$efficiency = round($efficiency, 2);
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'type' => $line->type,
|
||||
'line' => $line->name,
|
||||
'capacityQuantity' => floor($capacityQuan),
|
||||
'targetQuantity' => floor($totalTargetQuantity),
|
||||
'type' => $line->type,
|
||||
'targetQuantity' => $targetQuantity,
|
||||
'productionQuantity' => $productionQuantity,
|
||||
'efficiency' => $efficiency . '%',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// $service = new \App\Services\ProductionTargetService();
|
||||
|
||||
// $year = $startDate->year;
|
||||
// $month = $startDate->month;
|
||||
|
||||
// [$records, $dates] = $service->generate(
|
||||
// $plantId,
|
||||
// $year,
|
||||
// $month,
|
||||
// );
|
||||
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
// if (!empty($emails)) {
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new ProductionMail($tableData));
|
||||
// }
|
||||
// } else {
|
||||
// $this->info('No recipients found for ProductionMailAlert.');
|
||||
// }
|
||||
|
||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
// Preview in console
|
||||
$mail = new ProductionMail($scheduleType, $tableData);
|
||||
|
||||
// $mail = new ProductionMail($scheduleType,$tableData,$records,$dates);
|
||||
|
||||
$contentVars = $mail->content()->with;
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Production Report');
|
||||
$this->table(
|
||||
['No', 'Plant', 'Line', 'Type', 'Capacity Quantity', 'Target Quantity', 'Production Quantity'],
|
||||
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
|
||||
$tableData
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
|
||||
// Send mails
|
||||
// if (! empty($emails)) {
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
|
||||
// }
|
||||
// $this->info('Production report sent to '.count($emails).' recipient(s).');
|
||||
// } else {
|
||||
// $this->warn('No recipients found for ProductionMailAlert.');
|
||||
// }
|
||||
foreach ($mailRules as $rule)
|
||||
{
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
if (!empty($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
} else {
|
||||
$this->warn('No recipients found for ProductionMailAlert.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,410 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class TriggerPendingApprovalMails extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:trigger-pending-approval-mails';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $description = 'Command description';
|
||||
|
||||
// /**
|
||||
// * Execute the console command.
|
||||
// */
|
||||
// public function handle()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
protected $signature = 'approval:trigger-mails';
|
||||
protected $description = 'Trigger approval mail manually';
|
||||
|
||||
public $pdfPath;
|
||||
|
||||
public $subjectLine;
|
||||
|
||||
public $wfId;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Approval mail job started');
|
||||
|
||||
// .. Characteristic Mail trigger logic
|
||||
|
||||
// $records = RequestCharacteristic::whereNull('approver_status1')
|
||||
// ->whereNull('approver_status2')
|
||||
// ->whereNull('approver_status3')
|
||||
// ->get();
|
||||
|
||||
$records = RequestCharacteristic::where(function ($q) {
|
||||
$q->whereNull('approver_status1')
|
||||
->orWhere('approver_status1', 'Hold');
|
||||
})
|
||||
->where(function ($q) {
|
||||
$q->whereNull('approver_status2')
|
||||
->orWhere('approver_status2', 'Hold');
|
||||
})
|
||||
->where(function ($q) {
|
||||
$q->whereNull('approver_status3')
|
||||
->orWhere('approver_status3', 'Hold');
|
||||
})
|
||||
->get();
|
||||
|
||||
$records = $records->filter(function ($item) {
|
||||
$approver = CharacteristicApproverMaster::find($item->characteristic_approver_master_id);
|
||||
return $approver && $approver->approver_type == 'Characteristic';
|
||||
});
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No pending approvals');
|
||||
return;
|
||||
}
|
||||
|
||||
$grouped = $records->groupBy(function ($item) {
|
||||
$this->wfId = $item->work_flow_id;
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
|
||||
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
|
||||
|
||||
$this->info($pendingApprovers->approver_status1, $pendingApprovers->approver_status2);
|
||||
|
||||
|
||||
$approverNameFromMaster = null;
|
||||
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
|
||||
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
|
||||
$first = $groupRecords->first();
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$characteristics = $groupRecords->map(fn ($r) => [
|
||||
'work_flow_id' => $r->work_flow_id,
|
||||
'characteristic_name' => $r->characteristic_name,
|
||||
'current_value' => $r->current_value,
|
||||
'update_value' => $r->update_value,
|
||||
])->toArray();
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- SECOND MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
|
||||
$this->info(
|
||||
"mail_status: {$first->mail_status}, ".
|
||||
"approver_status1: {$first->approver_status1}, ".
|
||||
"trigger_at: {$first->trigger_at}, ".
|
||||
"now: {$now}"
|
||||
);
|
||||
|
||||
$level = 2;
|
||||
$mail = $approver->mail2;
|
||||
$name = $approver->name2;
|
||||
|
||||
if ($approver->duration2 > 0) {
|
||||
|
||||
$duration = number_format((float)$approver->duration2, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
|
||||
} else {
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
|
||||
$updateData['mail_status'] = 'Sent-Mail2';
|
||||
}
|
||||
|
||||
// --- THIRD MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent-Mail2' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 3;
|
||||
$mail = $approver->mail3;
|
||||
$name = $approver->name3;
|
||||
|
||||
$updateData['trigger_at'] = null;
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
|
||||
|
||||
$subjectLine = 'Characteristic Approval Mail';
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// .. Quality Mail trigger logic
|
||||
|
||||
$qualityRecords = RequestCharacteristic::where(function ($q) {
|
||||
$q->whereNull('approver_status1')
|
||||
->orWhere('approver_status1', 'Hold');
|
||||
})
|
||||
->where(function ($q) {
|
||||
$q->whereNull('approver_status2')
|
||||
->orWhere('approver_status2', 'Hold');
|
||||
})
|
||||
->where(function ($q) {
|
||||
$q->whereNull('approver_status3')
|
||||
->orWhere('approver_status3', 'Hold');
|
||||
})
|
||||
->get();
|
||||
|
||||
$qualityRecords = $qualityRecords->filter(function ($item) {
|
||||
$approver = CharacteristicApproverMaster::find($item->characteristic_approver_master_id);
|
||||
return $approver && $approver->approver_type == 'Quality';
|
||||
});
|
||||
|
||||
if ($qualityRecords->isEmpty()) {
|
||||
$this->info('No quality pending approvals');
|
||||
return;
|
||||
}
|
||||
|
||||
$grouped = $qualityRecords->groupBy(function ($item) {
|
||||
$this->wfId = $item->work_flow_id;
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
|
||||
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
|
||||
|
||||
$approverNameFromMaster = null;
|
||||
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
|
||||
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
|
||||
$first = $groupRecords->first();
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- SECOND MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 2;
|
||||
$mail = $approver->mail2;
|
||||
$name = $approver->name2;
|
||||
|
||||
if ($approver->duration2 > 0) {
|
||||
|
||||
$duration = number_format((float)$approver->duration2, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
// IMPORTANT: use NOW, not old trigger
|
||||
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
|
||||
} else {
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
|
||||
$updateData['mail_status'] = 'Sent-Mail2';
|
||||
}
|
||||
|
||||
// --- THIRD MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent-Mail2' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 3;
|
||||
$mail = $approver->mail3;
|
||||
$name = $approver->name3;
|
||||
|
||||
$updateData['trigger_at'] = null;
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdfPath = ($f = glob(storage_path('app/private/uploads/LaserDocs/' . $first->work_flow_id . '.*')))
|
||||
? 'uploads/LaserDocs/' . basename($f[0])
|
||||
: null;
|
||||
|
||||
$this->info( $pdfPath);
|
||||
|
||||
$subjectLine = 'Quality Approval Mail';
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
}
|
||||
|
||||
$this->table(
|
||||
['ID', 'Plant', 'Machine', 'Level', 'Mail', 'Status'],
|
||||
$rows
|
||||
);
|
||||
|
||||
$this->info('Approval mail job completed');
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class InvoicePendingReasonExport implements FromArray, WithHeadings, WithMapping
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected array $data;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Plant Code',
|
||||
'Document Number',
|
||||
'Remark',
|
||||
'Customer Trade Name',
|
||||
'Location',
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
return [
|
||||
$row['plant_id'] ?? '',
|
||||
$row['document_number'] ?? '',
|
||||
$row['remark'] ?? '',
|
||||
$row['customer_trade_name'] ?? '',
|
||||
$row['location'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Support\Facades\View as FacadesView;
|
||||
use Illuminate\View\View as ViewView;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
// use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStartRow;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Events\BeforeExport;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
// {
|
||||
// public function __construct(
|
||||
// public $records,
|
||||
// ) {}
|
||||
|
||||
// // public function view(): View
|
||||
// // {
|
||||
// // return view('exports.export-isi-pdf', [
|
||||
// // 'records' => $this->records,
|
||||
// // ]);
|
||||
// // }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// // Top two rows (Company info + Motor KW/HP)
|
||||
// return [
|
||||
// ['C.R.I. Pumps Private Limited', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Unit: MOTOR FREE RUN TEST REGISTER'],
|
||||
// ['Motor KW/HP : - / -', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Phase : -'],
|
||||
// // Column headers
|
||||
// [
|
||||
// 'Date', 'Motor SNo', 'Item Code', 'Motor Type',
|
||||
// 'Voltage', 'Current', 'Power', 'IR.Hot', 'IR.Cool', 'Frequency', 'Speed', 'Leakage Current', // AFTER FREE RUN
|
||||
// 'Voltage', 'Current', 'Power', // LOCKED ROTOR TEST
|
||||
// 'No Load Pickup Voltage', 'Room Temp.', 'High Voltage Test', 'Result', 'Remark'
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
|
||||
// public function registerEvents(): array
|
||||
// {
|
||||
// return [
|
||||
// AfterSheet::class => function (AfterSheet $event) {
|
||||
// $sheet = $event->sheet->getDelegate();
|
||||
|
||||
// // Merge top rows for company info
|
||||
// $sheet->mergeCells('A1:S1'); // Company Name
|
||||
// $sheet->mergeCells('T1:T1'); // Unit/Register info
|
||||
// $sheet->mergeCells('A2:S2'); // Motor KW/HP row
|
||||
// $sheet->mergeCells('T2:T2'); // Phase
|
||||
|
||||
// // Merge headers for grouped columns (AFTER FREE RUN & LOCKED ROTOR TEST)
|
||||
// $sheet->mergeCells('E3:L3'); // AFTER FREE RUN
|
||||
// $sheet->mergeCells('M3:O3'); // LOCKED ROTOR TEST
|
||||
|
||||
// // Optional: style headers
|
||||
// $sheet->getStyle('A1:T3')->getFont()->setBold(true);
|
||||
// $sheet->getStyle('A1:T3')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
// $sheet->getStyle('A1:T3')->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// // Set column widths (optional for better visibility)
|
||||
// $columns = range('A', 'T');
|
||||
// foreach ($columns as $col) {
|
||||
// $sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
// }
|
||||
// },
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// class MotorFreeRunExport implements FromCollection, WithMapping, WithStartRow
|
||||
// {
|
||||
// protected Collection $records;
|
||||
|
||||
// public function __construct(Collection $records)
|
||||
// {
|
||||
// $this->records = $records;
|
||||
// }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function startRow(): int
|
||||
// {
|
||||
// return 3; // insert data starting from row 3
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// return [
|
||||
// $record['Date'] ?? '',
|
||||
// $record['Output'] ?? '',
|
||||
// $record['Motor SNo'] ?? '',
|
||||
// $record['Item Code'] ?? '',
|
||||
// $record['Motor Type'] ?? '',
|
||||
// $record['kw'] ?? '',
|
||||
// $record['hp'] ?? '',
|
||||
// $record['phase'] ?? '',
|
||||
// $record['isi_model'] ?? '',
|
||||
// $record['Voltage_Before'] ?? '',
|
||||
// $record['Current_Before'] ?? '',
|
||||
// $record['Power_Before'] ?? '',
|
||||
// $record['Resistance_RY'] ?? '',
|
||||
// $record['Resistance_YB'] ?? '',
|
||||
// $record['Resistance_BR'] ?? '',
|
||||
// $record['Insulation_Resistance'] ?? '',
|
||||
// $record['Frequency_Before'] ?? '',
|
||||
// $record['Speed_Before'] ?? '',
|
||||
// $record['Voltage_After'] ?? '',
|
||||
// $record['Current_After'] ?? '',
|
||||
// $record['Power_After'] ?? '',
|
||||
// $record['IR_Hot'] ?? '',
|
||||
// $record['IR_Cool'] ?? '',
|
||||
// $record['Leakage_Current'] ?? '',
|
||||
// $record['Frequency_After'] ?? '',
|
||||
// $record['Speed_After'] ?? '',
|
||||
// $record['Voltage_Locked'] ?? '',
|
||||
// $record['Current_Locked'] ?? '',
|
||||
// $record['Power_Locked'] ?? '',
|
||||
// $record['No_Load_Pickup_Voltage'] ?? '',
|
||||
// $record['Room_Temp'] ?? '',
|
||||
// $record['High_Voltage_Test'] ?? '',
|
||||
// $record['Batch_Number'] ?? '',
|
||||
// $record['Batch_Count'] ?? '',
|
||||
// $record['Result'] ?? '',
|
||||
// $record['Remark'] ?? '',
|
||||
// $record['Tested_By'] ?? '',
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
class MotorFreeRunExport implements WithCustomStartCell, WithMapping, WithStartRow, WithChunkReading
|
||||
{
|
||||
protected $records;
|
||||
protected $templatePath;
|
||||
|
||||
public function __construct($records)
|
||||
{
|
||||
$this->records = $records;
|
||||
// dd($this->records);
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->records;
|
||||
}
|
||||
|
||||
public function startRow(): int
|
||||
{
|
||||
return 7; // Start inserting data from row 7
|
||||
}
|
||||
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7'; // Start inserting data from row 7 column A
|
||||
}
|
||||
|
||||
public function map($record): array
|
||||
{
|
||||
return [
|
||||
$record['Date'] ?? '',
|
||||
$record['Output'] ?? '',
|
||||
$record['Motor SNo'] ?? '',
|
||||
$record['Item Code'] ?? '',
|
||||
$record['Motor Type'] ?? '',
|
||||
$record['kw'] ?? '',
|
||||
$record['hp'] ?? '',
|
||||
$record['phase'] ?? '',
|
||||
$record['isi_model'] ?? '',
|
||||
$record['Voltage_Before'] ?? '',
|
||||
$record['Current_Before'] ?? '',
|
||||
$record['Power_Before'] ?? '',
|
||||
$record['Resistance_RY'] ?? '',
|
||||
$record['Resistance_YB'] ?? '',
|
||||
$record['Resistance_BR'] ?? '',
|
||||
$record['Insulation_Resistance'] ?? '',
|
||||
$record['Frequency_Before'] ?? '',
|
||||
$record['Speed_Before'] ?? '',
|
||||
$record['Voltage_After'] ?? '',
|
||||
$record['Current_After'] ?? '',
|
||||
$record['Power_After'] ?? '',
|
||||
$record['IR_Hot'] ?? '',
|
||||
$record['IR_Cool'] ?? '',
|
||||
$record['Leakage_Current'] ?? '',
|
||||
$record['Frequency_After'] ?? '',
|
||||
$record['Speed_After'] ?? '',
|
||||
$record['Voltage_Locked'] ?? '',
|
||||
$record['Current_Locked'] ?? '',
|
||||
$record['Power_Locked'] ?? '',
|
||||
$record['No_Load_Pickup_Voltage'] ?? '',
|
||||
$record['Room_Temp'] ?? '',
|
||||
$record['High_Voltage_Test'] ?? '',
|
||||
$record['Batch_Number'] ?? '',
|
||||
$record['Batch_Count'] ?? '',
|
||||
$record['Result'] ?? '',
|
||||
$record['Remark'] ?? '',
|
||||
$record['Tested_By'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
public function chunkSize(): int
|
||||
{
|
||||
return 1000; // load 1000 records at a time
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
|
||||
{
|
||||
|
||||
protected array $data;
|
||||
protected array $dates;
|
||||
|
||||
public function __construct(array $data, array $dates)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->dates = $dates;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$headings = [
|
||||
'Plant Name',
|
||||
'Line Name',
|
||||
'Item Code',
|
||||
];
|
||||
|
||||
// Add dynamic headings for each date: Target / Produced
|
||||
foreach ($this->dates as $date) {
|
||||
$headings[] = $date . ' - Item Quantity';
|
||||
$headings[] = $date . ' - Target Plan';
|
||||
$headings[] = $date . ' - Produced Quantity';
|
||||
}
|
||||
|
||||
return $headings;
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$mapped = [
|
||||
$row['plant_name'] ?? '',
|
||||
$row['line_name'] ?? '',
|
||||
$row['item_code'] ?? '',
|
||||
];
|
||||
|
||||
foreach ($this->dates as $date) {
|
||||
$mapped[] = $row['daily_hourly_quantity'][$date] ?? '-';
|
||||
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
|
||||
$mapped[] = $row['produced_quantity'][$date] ?? '-';
|
||||
}
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\TestingPanelReading;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
// use Maatwebsite\Excel\Concerns\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
// class TestingPanelReadingExport implements FromCollection
|
||||
// {
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
// return TestingPanelReading::all();
|
||||
// }
|
||||
// }
|
||||
|
||||
// class TestingPanelReadingExport implements FromQuery, WithChunkReading, ShouldQueue, WithHeadings
|
||||
// {
|
||||
// protected array $ids;
|
||||
// protected int $counter = 0;
|
||||
|
||||
// public function __construct(array $ids)
|
||||
// {
|
||||
// $this->ids = $ids;
|
||||
// }
|
||||
// public function query()
|
||||
// {
|
||||
// return TestingPanelReading::query()
|
||||
// ->whereIn('id', $this->ids)
|
||||
// ->select('id', 'plant_id', 'line_id', 'motor_testing_master_id', 'machine_id', 'output', 'serial_number', 'winded_serial_number', 'before_fr_volt', 'before_fr_cur', 'before_fr_pow', 'before_fr_res_ry', 'before_fr_res_yb', 'before_fr_res_br', 'before_fr_ir', 'before_fr_ir_r', 'before_fr_ir_y', 'before_fr_ir_b', 'before_fr_freq', 'before_fr_speed', 'after_fr_vol', 'after_fr_cur', 'after_fr_pow', 'after_fr_ir_hot','after_fr_ir_hot_r', 'after_fr_ir_hot_y', 'after_fr_ir_hot_b', 'after_fr_ir_cool', 'after_fr_ir_cool_r', 'after_fr_ir_cool_y', 'after_fr_ir_cool_b', 'after_fr_freq', 'after_fr_speed', 'after_fr_leak_cur', 'locked_rt_volt', 'locked_rt_cur', 'locked_rt_pow', 'no_load_pickup_volt', 'room_temperature', 'hv_test', 'batch_number', 'batch_count', 'result', 'remark', 'rework_count', 'update_count', 'output_flag', 'tested_by', 'updated_by', 'created_at', 'updated_at', 'scanned_at', 'created_at');
|
||||
// }
|
||||
|
||||
// public function chunkSize(): int
|
||||
// {
|
||||
// return 1000; // process 1000 rows at a time
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// return ['NO', 'PLANT', 'LINE', 'MOTORTESTINGMASTER', 'MACHINE', 'OUTPUT', 'SERIAL NUMBER', 'WINDED SERIAL NUMBER', 'BEFORE FR VOLT', 'BEFORE FR CUR', 'BEFORE FR POW', 'BEFORE FR RES RY', 'BEFORE FR RES YB', 'BEFORE FR RES BR', 'BEFORE FR IR', 'BEFORE FR IR R', 'BEFORE FR IR Y', 'BEFORE FR IR B', 'BEFORE FR FREQ', 'BEFORE FR SPEED', 'AFTER FR VOL', 'AFTER FR CUR', 'AFTER FR POW', 'AFTER FR IR HOT', 'AFTER FR IR HOT R', 'AFTER FR IR HOT Y', 'AFTER FR IR HOT B', 'AFTER FR IR COOL', 'AFTER FR IR COOL R', 'AFTER FR IR COOL Y', 'AFTER FR IR COOL B', 'AFTER FR FREQ', 'AFTER FR SPEED', 'AFTER FR LEAK CUR', 'LOCKED RT VOLT', 'LOCKED RT CUR', 'LOCKED RT POW', 'NO LOAD PICKUP VOLT', 'ROOM TEMPERATURE', 'HV TEST', 'BATCH NUMBER', 'BATCH COUNT', 'RESULT', 'REMARK', 'REWORK COUNT', 'UPDATE COUNT', 'OUTPUT FLAG', 'TETSED BY', 'UPDATED BY', 'CREATED AT', 'UPDATED AT', 'SCANNED AT', 'CREATED AT'];
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// $this->counter++;
|
||||
// return [
|
||||
// $this->counter, // No.
|
||||
// $record->plant_id,
|
||||
// $record->line_id,
|
||||
// $record->motor_testing_master_id,
|
||||
// $record->machine_id,
|
||||
// $record->output,
|
||||
// $record->serial_number,
|
||||
// $record->winded_serial_number,
|
||||
// $record->before_fr_volt,
|
||||
// $record->before_fr_cur,
|
||||
// $record->before_fr_pow,
|
||||
// $record->before_fr_res_ry,
|
||||
// $record->before_fr_res_yb,
|
||||
// $record->before_fr_res_br,
|
||||
// $record->before_fr_ir,
|
||||
// $record->before_fr_ir_r,
|
||||
// $record->before_fr_ir_y,
|
||||
// $record->before_fr_ir_b,
|
||||
// $record->before_fr_freq,
|
||||
// $record->before_fr_speed,
|
||||
// $record->after_fr_vol,
|
||||
// $record->after_fr_cur,
|
||||
// $record->after_fr_pow,
|
||||
// $record->after_fr_ir_hot,
|
||||
// $record->after_fr_ir_hot_r,
|
||||
// $record->after_fr_ir_hot_y,
|
||||
// $record->after_fr_ir_hot_b,
|
||||
// $record->after_fr_ir_cool,
|
||||
// $record->after_fr_ir_cool_r,
|
||||
// $record->after_fr_ir_cool_y,
|
||||
// $record->after_fr_ir_cool_b,
|
||||
// $record->after_fr_freq,
|
||||
// $record->after_fr_speed,
|
||||
// $record->after_fr_leak_cur,
|
||||
// $record->locked_rt_volt,
|
||||
// $record->locked_rt_cur,
|
||||
// $record->locked_rt_pow,
|
||||
// $record->no_load_pickup_volt,
|
||||
// $record->room_temperature,
|
||||
// $record->hv_test,
|
||||
// $record->batch_number,
|
||||
// $record->batch_count,
|
||||
// $record->result,
|
||||
// $record->remark,
|
||||
// $record->rework_count,
|
||||
// $record->update_count,
|
||||
// $record->output_flag,
|
||||
// $record->tested_by,
|
||||
// $record->updated_by,
|
||||
// // $record->created_at,
|
||||
// $record->updated_at,
|
||||
// $record->scanned_at,
|
||||
// $record->created_at,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
class TestingPanelReadingExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $records;
|
||||
protected $isAllStarDelta;
|
||||
|
||||
public function __construct($records, $isAllStarDelta)
|
||||
{
|
||||
$this->records = $records;
|
||||
$this->isAllStarDelta = $isAllStarDelta;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->records)->map(function ($record) {
|
||||
if (!$this->isAllStarDelta) {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return array_keys($this->collection()->first() ?? []);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class AlertMailRuleExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = AlertMailRule::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('module')
|
||||
->label('MODULE'),
|
||||
ExportColumn::make('rule_name')
|
||||
->label('RULE NAME'),
|
||||
ExportColumn::make('email')
|
||||
->label('EMAIL'),
|
||||
ExportColumn::make('schedule_type')
|
||||
->label('SCHEDULE TYPE'),
|
||||
ExportColumn::make('plant')
|
||||
->label('PLANT CODE')
|
||||
->formatStateUsing(function ($state) {
|
||||
// $state is the plant ID from the database
|
||||
if ($state == 0) {
|
||||
return 'All Plants';
|
||||
}
|
||||
|
||||
$plant = Plant::find($state);
|
||||
return $plant ? $plant->code : 'Unknown';
|
||||
}),
|
||||
ExportColumn::make('cc_emails')
|
||||
->label('CC EMAILS'),
|
||||
ExportColumn::make('invoiceMaster.receiving_plant_name')
|
||||
->label('RECEIVING PLANT NAME'),
|
||||
ExportColumn::make('invoiceMaster.transport_name')
|
||||
->label('TRANSPORT NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your alert mail rule 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,18 +24,17 @@ class BlockExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('BLOCK NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CharacteristicApproverMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
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('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('approver_type')
|
||||
->label('APPROVER TYPE'),
|
||||
ExportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('mail1')
|
||||
->label('APPROVER MAIL 1'),
|
||||
ExportColumn::make('duration1')
|
||||
->label('DURATION 1'),
|
||||
ExportColumn::make('name2')
|
||||
->label('APPROVER NAME 2'),
|
||||
ExportColumn::make('mail2')
|
||||
->label('APPROVER MAIL 2'),
|
||||
ExportColumn::make('duration2')
|
||||
->label('DURATION 2'),
|
||||
ExportColumn::make('name3')
|
||||
->label('APPROVER NAME 3'),
|
||||
ExportColumn::make('mail3')
|
||||
->label('APPROVER MAIL 3'),
|
||||
ExportColumn::make('duration3')
|
||||
->label('DURATION 3'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your characteristic approver 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;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CharacteristicValue;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
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
|
||||
{
|
||||
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('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('PROCESS ORDER'),
|
||||
ExportColumn::make('coil_number')
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('spec_value')
|
||||
->label('Spec. Value')
|
||||
->formatStateUsing(function ($record) {
|
||||
|
||||
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)
|
||||
->where('item_id', $record->item_id)
|
||||
->where('line_id', $record->line_id)
|
||||
->where('machine_id', $record->machine_id)
|
||||
->first();
|
||||
|
||||
return $specVal?->lower . ' - ' . $specVal?->upper;
|
||||
}),
|
||||
ExportColumn::make('observed_value')
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
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 CheckPointNameExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('CHECK POINT NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -24,8 +24,8 @@ class CheckPointTimeExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('checkPointNames1.name')
|
||||
->label('CHECK POINT 1'),
|
||||
ExportColumn::make('checkPointNames2.name')
|
||||
|
||||
@@ -1,367 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ClassCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ClassCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ClassCharacteristic::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('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('class')
|
||||
->label('CLASS'),
|
||||
ExportColumn::make('arbid')
|
||||
->label('ARBID'),
|
||||
ExportColumn::make('gamng')
|
||||
->label('GAMNG'),
|
||||
ExportColumn::make('lmnga')
|
||||
->label('LMNGA'),
|
||||
ExportColumn::make('gernr')
|
||||
->label('GERNR'),
|
||||
ExportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD'),
|
||||
ExportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPS'),
|
||||
ExportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND'),
|
||||
ExportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREEOFPROTECTION'),
|
||||
ExportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY'),
|
||||
ExportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIR ROT'),
|
||||
ExportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE'),
|
||||
ExportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX'),
|
||||
ExportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN'),
|
||||
ExportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY'),
|
||||
ExportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR'),
|
||||
ExportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP'),
|
||||
ExportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY'),
|
||||
ExportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD'),
|
||||
ExportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING'),
|
||||
ExportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX'),
|
||||
ExportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM'),
|
||||
ExportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR'),
|
||||
ExportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP'),
|
||||
ExportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE'),
|
||||
ExportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP'),
|
||||
ExportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLINGFLOW'),
|
||||
ExportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES'),
|
||||
ExportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL'),
|
||||
ExportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET'),
|
||||
ExportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE'),
|
||||
ExportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE'),
|
||||
ExportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE'),
|
||||
ExportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMPSERIES'),
|
||||
ExportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL'),
|
||||
ExportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER'),
|
||||
ExportColumn::make('zmm_region')
|
||||
->label('ZMM REGION'),
|
||||
ExportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICEFACTOR'),
|
||||
ExportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS'),
|
||||
ExportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED'),
|
||||
ExportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION'),
|
||||
ExportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTIONXDELIVERY'),
|
||||
ExportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLYSOURCE'),
|
||||
ExportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE'),
|
||||
ExportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUSTLOAD'),
|
||||
ExportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS'),
|
||||
ExportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE'),
|
||||
ExportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE'),
|
||||
ExportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING'),
|
||||
ExportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI'),
|
||||
ExportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISIMOTOR'),
|
||||
ExportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISIPUMP'),
|
||||
ExportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISIPUMPSET'),
|
||||
ExportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL'),
|
||||
ExportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES'),
|
||||
ExportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEADRANGE'),
|
||||
ExportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY'),
|
||||
ExportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION'),
|
||||
ExportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE'),
|
||||
ExportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISIREFERENCE'),
|
||||
ExportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY'),
|
||||
ExportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE'),
|
||||
ExportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITORSTART'),
|
||||
ExportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITORRUN'),
|
||||
ExportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH'),
|
||||
ExportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE'),
|
||||
ExportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION'),
|
||||
ExportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVRALL'),
|
||||
ExportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODYMOC'),
|
||||
ExportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTORMOC'),
|
||||
ExportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL'),
|
||||
ExportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUTPOWER'),
|
||||
ExportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD'),
|
||||
ExportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP'),
|
||||
ExportColumn::make('zmm_de')
|
||||
->label('ZMM DE'),
|
||||
ExportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGERANGE'),
|
||||
ExportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS'),
|
||||
ExportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAMESIZE'),
|
||||
ExportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER'),
|
||||
ExportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATIONCLASS'),
|
||||
ExportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAXFLOW'),
|
||||
ExportColumn::make('zmm_minhead')
|
||||
->label('ZMM MINHEAD'),
|
||||
ExportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST'),
|
||||
ExportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE'),
|
||||
ExportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR'),
|
||||
ExportColumn::make('zmm_tagno')
|
||||
->label('ZMM TANGO'),
|
||||
ExportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE'),
|
||||
ExportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER'),
|
||||
ExportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR'),
|
||||
ExportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS'),
|
||||
ExportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR'),
|
||||
ExportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE'),
|
||||
ExportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET'),
|
||||
ExportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE'),
|
||||
ExportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR'),
|
||||
ExportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF'),
|
||||
ExportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP'),
|
||||
ExportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISIVALVE'),
|
||||
ExportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC'),
|
||||
ExportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABELPERIOD'),
|
||||
ExportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH'),
|
||||
ExportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO'),
|
||||
ExportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFGMONYR'),
|
||||
ExportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODELYEAR'),
|
||||
ExportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET'),
|
||||
ExportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE'),
|
||||
ExportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR'),
|
||||
ExportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF'),
|
||||
ExportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP'),
|
||||
ExportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACKTYPE'),
|
||||
ExportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL'),
|
||||
ExportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR'),
|
||||
ExportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSETTYPE'),
|
||||
ExportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE'),
|
||||
ExportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL'),
|
||||
ExportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE'),
|
||||
ExportColumn::make('zmm_usp')
|
||||
->label('ZMM USP'),
|
||||
ExportColumn::make('mark_status')
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME'),
|
||||
ExportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME'),
|
||||
ExportColumn::make('marked_by')
|
||||
->label('MARKED BY'),
|
||||
ExportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME'),
|
||||
ExportColumn::make('man_marked_by')
|
||||
->label('MANUAL MARKED BY'),
|
||||
ExportColumn::make('motor_marked_status')
|
||||
->label('MOTOR MARKED STATUS'),
|
||||
ExportColumn::make('motor_marked_physical_count')
|
||||
->label('MOTOR MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME'),
|
||||
ExportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY'),
|
||||
ExportColumn::make('pump_marked_status')
|
||||
->label('PUMP MARKED STATUS'),
|
||||
ExportColumn::make('pump_marked_physical_count')
|
||||
->label('PUMP MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME'),
|
||||
ExportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY'),
|
||||
ExportColumn::make('name_plate_marked_status')
|
||||
->label('NAME PLATE MARKED STATUS'),
|
||||
ExportColumn::make('name_plate_expected_time')
|
||||
->label('NAME PLATE EXPECTED TIME'),
|
||||
ExportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY'),
|
||||
ExportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME'),
|
||||
ExportColumn::make('pump_machine_name')
|
||||
->label('PUMP MACHINE NAME'),
|
||||
ExportColumn::make('name_plate_machine_name')
|
||||
->label('NAME PLATE MACHINE NAME'),
|
||||
ExportColumn::make('pumpset_machine_name')
|
||||
->label('PUMPSET MACHINE NAME'),
|
||||
ExportColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation_2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME'),
|
||||
ExportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS'),
|
||||
ExportColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your class characteristic 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;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CustomerPoMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CustomerPoMaster::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('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('customer_po')
|
||||
->label('CUSTOMER PO'),
|
||||
ExportColumn::make('customer_name')
|
||||
->label('CUSTOMER NAME'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
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 customer po 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;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ class DeviceMasterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,8 +21,8 @@ class DeviceMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('DEVICE NAME'),
|
||||
ExportColumn::make('mac_address')
|
||||
|
||||
@@ -10,9 +10,7 @@ use Filament\Actions\Exports\Models\Export;
|
||||
class EbReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
|
||||
public static $rowNumber = 0;
|
||||
|
||||
static $rowNumber = 0;
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
@@ -22,8 +20,8 @@ class EbReadingExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('lcd_segment_check')
|
||||
->label('LCD SEGMENT CHECK'),
|
||||
ExportColumn::make('meter_serial_no')
|
||||
|
||||
@@ -14,7 +14,6 @@ class EquipmentMasterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,8 +21,8 @@ class EquipmentMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('name')
|
||||
|
||||
@@ -14,7 +14,6 @@ class GrMasterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,10 +21,10 @@ class GrMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
->label('ITEM'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('gr_number')
|
||||
|
||||
@@ -24,8 +24,8 @@ class GuardNameExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('GUARD NAME'),
|
||||
ExportColumn::make('identification1')
|
||||
|
||||
@@ -24,8 +24,8 @@ class GuardPatrolEntryExporter extends Exporter
|
||||
}),
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('guardNames.name')
|
||||
->label('GUARD NAME'),
|
||||
ExportColumn::make('checkPointNames.name')
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\InvoiceInTransit;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class InvoiceInTransitExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceInTransit::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'),
|
||||
ExportColumn::make('receiving_plant')
|
||||
->label('RECEIVING PLANT'),
|
||||
ExportColumn::make('receiving_plant_name')
|
||||
->label('RECEIVING PLANT NAME'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('invoice_date')
|
||||
->label('INVOICE DATE'),
|
||||
ExportColumn::make('item_code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('transport_name')
|
||||
->label('TRANSPORT NAME'),
|
||||
ExportColumn::make('lr_bl_aw_number')
|
||||
->label('LR_BL_AW NUMBER'),
|
||||
ExportColumn::make('lr_bl_aw_date')
|
||||
->label('LR_BL_AW DATE'),
|
||||
ExportColumn::make('pending_days')
|
||||
->label('PENDING DAYS'),
|
||||
ExportColumn::make('obd_number')
|
||||
->label('OBD NUMBER'),
|
||||
ExportColumn::make('obd_date')
|
||||
->label('OBD DATE'),
|
||||
ExportColumn::make('shipment_weight')
|
||||
->label('SHIPMENT WEIGHT'),
|
||||
ExportColumn::make('unit_price')
|
||||
->label('UNIT PRICE'),
|
||||
ExportColumn::make('net_value')
|
||||
->label('NET VALUE'),
|
||||
ExportColumn::make('total_item_amount')
|
||||
->label('TOTAL ITEM AMOUNT'),
|
||||
ExportColumn::make('tax_amount')
|
||||
->label('TAX AMOUNT'),
|
||||
ExportColumn::make('transport_mode')
|
||||
->label('TRANSPORT MODE'),
|
||||
ExportColumn::make('vehicle_number')
|
||||
->label('VEHICLE NUMBER'),
|
||||
ExportColumn::make('e_waybill_number')
|
||||
->label('E_WAYBILL 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 invoice in transit 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;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\InvoiceMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class InvoiceMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceMaster::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('receiving_plant')
|
||||
->label('Receiving Plant'),
|
||||
ExportColumn::make('receiving_plant_name')
|
||||
->label('Receiving Plant Name'),
|
||||
ExportColumn::make('transit_days')
|
||||
->label('Transit Days'),
|
||||
ExportColumn::make('transport_name')
|
||||
->label('Transport Name'),
|
||||
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 invoice 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;
|
||||
}
|
||||
}
|
||||
@@ -24,16 +24,14 @@ class InvoiceValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('stickerMaster.item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
@@ -44,8 +42,6 @@ class InvoiceValidationExporter extends Exporter
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
@@ -63,13 +59,9 @@ class InvoiceValidationExporter extends Exporter
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
|
||||
@@ -24,8 +24,8 @@ class ItemExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('code')
|
||||
|
||||
@@ -24,12 +24,12 @@ class LineExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('LINE NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('type')
|
||||
->label('LINE TYPE'),
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('no_of_operation')
|
||||
->label('NO OF OPERATION'),
|
||||
ExportColumn::make('workGroup1.name')
|
||||
|
||||
@@ -22,12 +22,12 @@ class MachineExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('name')
|
||||
->label('MACHINE NAME'),
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('workGroupMaster.name')
|
||||
|
||||
@@ -14,7 +14,6 @@ class MfmMeterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,14 +21,14 @@ class MfmMeterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('device.name')
|
||||
->label('DEVICE NAME'),
|
||||
ExportColumn::make('sequence')
|
||||
->label('SEQUENCE'),
|
||||
ExportColumn::make('name')
|
||||
->label('METER NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
@@ -14,7 +14,6 @@ class MfmParameterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,12 +21,12 @@ class MfmParameterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('deviceName.name')
|
||||
->label('Device Name'),
|
||||
ExportColumn::make('name')
|
||||
->label('PARAMETER NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('mfmMeter.name')
|
||||
->label('MFM METER'),
|
||||
ExportColumn::make('register_id')
|
||||
|
||||
@@ -23,7 +23,7 @@ class MotorTestingMasterExporter extends Exporter
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('item.code')
|
||||
|
||||
@@ -24,36 +24,26 @@ class ProcessOrderExporter extends Exporter
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('PROCESS ORDER'),
|
||||
ExportColumn::make('coil_number')
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('order_quantity')
|
||||
->label('ORDER QUANTITY'),
|
||||
ExportColumn::make('updated_order_quantity')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ExportColumn::make('received_quantity')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ExportColumn::make('sfg_number')
|
||||
->label('SFG NUMBER'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('scrap_quantity')
|
||||
->label('SCRAP QUANTITY'),
|
||||
ExportColumn::make('rework_status')
|
||||
->label('REWORK STATUS'),
|
||||
->label('MACHINE ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
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')
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ProductCharacteristicsMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ProductCharacteristicsMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'), // machine.workGroupMaster.name
|
||||
ExportColumn::make('machine.workGroupMaster.name')
|
||||
->label('GROUP WORK CENTER'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('characteristics_type')
|
||||
->label('CHARACTERISTICS TYPE'),
|
||||
ExportColumn::make('name')
|
||||
->label('CHARACTERISTICS NAME'),
|
||||
ExportColumn::make('inspection_type')
|
||||
->label('INSPECTION TYPE'),
|
||||
ExportColumn::make('lower')
|
||||
->label('LOWER'),
|
||||
ExportColumn::make('middle')
|
||||
->label('MIDDLE'),
|
||||
ExportColumn::make('upper')
|
||||
->label('UPPER'),
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -37,13 +37,13 @@ class ProductionLineStopExporter extends Exporter
|
||||
ExportColumn::make('stop_min')
|
||||
->label('STOP MINUTE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK NAME'),
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT NAME'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -29,13 +29,13 @@ class ProductionPlanExporter extends Exporter
|
||||
ExportColumn::make('production_quantity')
|
||||
->label('PRODUCTION QUANTITY'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK NAME'),
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT NAME'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -33,13 +33,13 @@ class ProductionQuantityExporter extends Exporter
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK NAME'),
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT NAME'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('sap_msg_status')
|
||||
->label('SAP MESSAGE STATUS'),
|
||||
ExportColumn::make('sap_msg_description')
|
||||
|
||||
@@ -24,18 +24,16 @@ class QualityValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('stickerMaster.item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
@@ -56,14 +54,14 @@ class QualityValidationExporter extends Exporter
|
||||
->label('NAME PLATE PUMP'),
|
||||
ExportColumn::make('name_plate_pumpset')
|
||||
->label('NAME PLATE PUMPSET'),
|
||||
ExportColumn::make('warranty_card')
|
||||
->label('WARRANTY CARD'),
|
||||
ExportColumn::make('tube_sticker_motor')
|
||||
->label('TUBE STICKER MOTOR'),
|
||||
ExportColumn::make('tube_sticker_pump')
|
||||
->label('TUBE STICKER PUMP'),
|
||||
ExportColumn::make('tube_sticker_pumpset')
|
||||
->label('TUBE STICKER PUMPSET'),
|
||||
ExportColumn::make('warranty_card')
|
||||
->label('WARRANTY CARD'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class RequestCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = RequestCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
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('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('work_flow_id')
|
||||
->label('WORK FLOW ID'),
|
||||
ExportColumn::make('characteristicApproverMaster.machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('JOB NUMBER'),
|
||||
ExportColumn::make('characteristicApproverMaster.approver_type')
|
||||
->label('APPROVER TYPE'),
|
||||
ExportColumn::make('characteristicApproverMaster.characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('characteristic_name')
|
||||
->label('CHARACTERISTIC NAME'),
|
||||
ExportColumn::make('current_value')
|
||||
->label('CURRENT VALUE'),
|
||||
ExportColumn::make('update_value')
|
||||
->label('UPDATE VALUE'),
|
||||
ExportColumn::make('characteristicApproverMaster.name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('approver_status1')
|
||||
->label('APPROVER STATUS 1'),
|
||||
ExportColumn::make('approver_remark1')
|
||||
->label('APPROVER REMARK 1'),
|
||||
ExportColumn::make('approved1_at')
|
||||
->label('APPROVED AT 1'),
|
||||
ExportColumn::make('characteristicApproverMaster.name2')
|
||||
->label('APPROVER NAME 2'),
|
||||
ExportColumn::make('approver_status2')
|
||||
->label('APPROVER STATUS 2'),
|
||||
ExportColumn::make('approver_remark2')
|
||||
->label('APPROVER REMARK 2'),
|
||||
ExportColumn::make('approved2_at')
|
||||
->label('APPROVED AT 2'),
|
||||
ExportColumn::make('characteristicApproverMaster.name3')
|
||||
->label('APPROVER NAME 3'),
|
||||
ExportColumn::make('approver_status3')
|
||||
->label('APPROVER STATUS 3'),
|
||||
ExportColumn::make('approver_remark3')
|
||||
->label('APPROVER REMARK 3'),
|
||||
ExportColumn::make('approved3_at')
|
||||
->label('APPROVED AT 1'),
|
||||
ExportColumn::make('mail_status')
|
||||
->label('MAIL STATUS'),
|
||||
ExportColumn::make('trigger_at')
|
||||
->label('TRIGGERED AT'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your request characteristic 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;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ class SerialValidationExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,8 +21,8 @@ class SerialValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
|
||||
@@ -25,11 +25,11 @@ class ShiftExporter extends Exporter
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('block.name')
|
||||
->label('BLOCK NAME'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('SHIFT NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('start_time')
|
||||
->label('START TIME'),
|
||||
ExportColumn::make('duration')
|
||||
|
||||
@@ -24,8 +24,8 @@ class StickerMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
@@ -76,12 +76,8 @@ class StickerMasterExporter extends Exporter
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StockDataMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StockDataMaster::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('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('location')
|
||||
->label('LOCATION'),
|
||||
ExportColumn::make('bin')
|
||||
->label('BIN'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('batch')
|
||||
->label('BATCH'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('doc_no')
|
||||
->label('DOCUMENT NUMBER'),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ExportColumn::make('capacitor_scanned_status')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status_set')
|
||||
->label('SCANNED STATUS SET'),
|
||||
ExportColumn::make('panel_box_item_code')
|
||||
->label('PANEL BOX ITEM CODE'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_sno')
|
||||
->label('PANEL BOX SNO'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_quantity')
|
||||
->label('SCANNED QUANTITY'),
|
||||
ExportColumn::make('system_stock')
|
||||
->label('SYSTEM STOCK')
|
||||
->state(fn ($record) => $record->quantity),
|
||||
ExportColumn::make('scanned_stock')
|
||||
->label('SCANNED STOCK')
|
||||
->state(fn ($record) => $record->scanned_quantity),
|
||||
ExportColumn::make('duplicate_stock')
|
||||
->label('DUPLICATE STOCK')
|
||||
->state(function ($record) {
|
||||
return \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
}),
|
||||
ExportColumn::make('not_in_stock')
|
||||
->label('NOT IN STOCK')
|
||||
->state(function ($record) {
|
||||
return \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
}),
|
||||
ExportColumn::make('physical_stock')
|
||||
->label('PHYSICAL STOCK')
|
||||
->state(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = $record->scanned_quantity ?? 0;
|
||||
|
||||
return $scanned + $duplicate + $notInStock;
|
||||
}),
|
||||
|
||||
ExportColumn::make('stock_difference')
|
||||
->label('STOCK DIFFERENCE COUNT')
|
||||
->state(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = (int) $record->scanned_quantity;
|
||||
|
||||
$physicalStock = $scanned + $duplicate + $notInStock;
|
||||
|
||||
$systemStock = (int) $record->quantity;
|
||||
|
||||
$difference = $physicalStock - $systemStock;
|
||||
|
||||
return max($difference, 0);
|
||||
}),
|
||||
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 stock data 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;
|
||||
}
|
||||
}
|
||||
@@ -24,18 +24,18 @@ class TestingPanelReadingExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE NAME'),
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('motorTestingMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('motorTestingMaster.item.description')
|
||||
->label('MODEL DESCRIPTION'),
|
||||
->label('MODEL'),
|
||||
ExportColumn::make('output')
|
||||
->label('OUTPUT NAME'),
|
||||
->label('OUTPUT'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
@@ -125,7 +125,7 @@ class TestingPanelReadingExporter extends Exporter
|
||||
ExportColumn::make('rework_count')
|
||||
->label('REWORK COUNT'),
|
||||
ExportColumn::make('update_count')
|
||||
->label('UPDATED COUNT'),
|
||||
->label('UPDATE COUNT'),
|
||||
ExportColumn::make('output_flag')
|
||||
->label('OUTPUT FLAG'),
|
||||
ExportColumn::make('tested_by')
|
||||
|
||||
@@ -24,8 +24,8 @@ class WeightValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('obd_number')
|
||||
|
||||
@@ -14,7 +14,6 @@ class WorkGroupMasterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -22,12 +21,12 @@ class WorkGroupMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('WORK GROUP NAME'),
|
||||
->label('NAME'),
|
||||
ExportColumn::make('description')
|
||||
->label('WORK GROUP DESCRIPTION'),
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('operation_number')
|
||||
->label('OPERATION NUMBER'),
|
||||
ExportColumn::make('created_by')
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class AlertMailRuleImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = AlertMailRule::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('module')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Module')
|
||||
->example('ProductionQuantities/InvoiceValidation/QualityValidation/InvoiceDataReport/InvoiceTransit')
|
||||
->label('Module')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('rule_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Rule Name')
|
||||
->example('ProductionMail/InvoiceMail/QualityMail/InvoiceDataMail/InvoiceTransitMail')
|
||||
->label('Rule Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('email')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Email')
|
||||
->example('admin@cripumps.com,ranjith.bala@cripumps.com')
|
||||
->label('Email')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('schedule_type')
|
||||
->exampleHeader('Schedule Type')
|
||||
->example('Daily/Live/Hourly')
|
||||
->label('Schedule Type'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000 or All Plants')
|
||||
->label('Plant Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('cc_emails')
|
||||
->exampleHeader('CC Email')
|
||||
->example('admin@cripumps.com,ranjith.bala@cripumps.com')
|
||||
->label('CC Email')
|
||||
->rules(['nullable', 'string']),
|
||||
//->rules(['cc_emails']),
|
||||
// ImportColumn::make('invoiceMaster')
|
||||
// ->relationship(),
|
||||
ImportColumn::make('receiving_plant_name')
|
||||
->exampleHeader('Receiving Plant Name')
|
||||
->example('BANGALORE')
|
||||
->label('Receiving Plant Name')
|
||||
->requiredMapping(),
|
||||
ImportColumn::make('transporter_name')
|
||||
->exampleHeader('Transporter Name')
|
||||
->example('SAFEXPRESS PRIVATE LIMITED')
|
||||
->label('Transporter Name')
|
||||
->requiredMapping(),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?AlertMailRule
|
||||
{
|
||||
$warnMsg = [];
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (strtolower($this->data['plant']) == 'all plants') {
|
||||
$this->data['plant'] = 0;
|
||||
} else {
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant code '{$this->data['plant']}' not found.";
|
||||
$this->data['plant'] = null;
|
||||
} else {
|
||||
$this->data['plant'] = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
$receivingPlantName = $this->data['receiving_plant_name'] ?? null;
|
||||
$transporterName = $this->data['transporter_name'] ?? null;
|
||||
|
||||
if (!$receivingPlantName || !$transporterName)
|
||||
{
|
||||
$warnMsg [] = 'Both Receiving Plant Name and Transporter Name are required.';
|
||||
}
|
||||
|
||||
$invoiceMaster = \App\Models\InvoiceMaster::where('receiving_plant_name', $receivingPlantName)
|
||||
->where('transport_name', $transporterName)
|
||||
->first();
|
||||
|
||||
if (!$invoiceMaster) {
|
||||
$warnMsg [] = "Invoice Master not found for Receiving Plant '{$receivingPlantName}' and Transporter '{$transporterName}'.";
|
||||
}
|
||||
|
||||
$this->data['invoice_master_id'] = $invoiceMaster->id;
|
||||
|
||||
unset($this->data['receiving_plant_name'], $this->data['transporter_name']);
|
||||
|
||||
if(! empty($warnMsg)){
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return AlertMailRule::Create([
|
||||
'module' => $this->data['module'],
|
||||
'rule_name' => $this->data['rule_name'],
|
||||
'email' => $this->data['email'],
|
||||
'schedule_type' => $this->data['schedule_type'],
|
||||
'plant' => $this->data['plant'],
|
||||
'cc_emails' => $this->data['cc_emails'] ?? null,
|
||||
'invoice_master_id' => $invoiceMaster->id,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
//return new AlertMailRule();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your alert mail rule 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,6 +8,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Notification;
|
||||
use Str;
|
||||
|
||||
class BlockImporter extends Importer
|
||||
@@ -19,16 +20,16 @@ class BlockImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('BLOCK NAME')
|
||||
->exampleHeader('Block Name')
|
||||
->example('Block A')
|
||||
->label('BLOCK NAME')
|
||||
->label('Block Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -36,28 +37,21 @@ class BlockImporter extends Importer
|
||||
public function resolveRecord(): ?Block
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
// $warnMsg[] = "Plant '" . $plantCod . "' not found";
|
||||
}
|
||||
$warnMsg[] = "Plant not found";
|
||||
// $warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = 'Block name not found';
|
||||
$warnMsg[] = "Block name not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return Block::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'plant_id' => $plant->id
|
||||
]);
|
||||
// return Block::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class CharacteristicApproverMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->examples(['1000','1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->examples(['RMGLAS02','RMGLAS02'])
|
||||
->label('Work Center')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->examples(['15002635','17002635'])
|
||||
->label('Machine Name'),
|
||||
ImportColumn::make('name1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 1')
|
||||
->examples(['Suresh.D','Suresh.D'])
|
||||
->label('Approver Name 1'),
|
||||
ImportColumn::make('mail1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 1')
|
||||
->examples(['suresh@cripumps.com','suresh@cripumps.com'])
|
||||
->label('Approver Mail 1'),
|
||||
ImportColumn::make('name2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 2')
|
||||
->examples(['Ramesh.G','Ramesh.G'])
|
||||
->label('Approver Name 2'),
|
||||
ImportColumn::make('mail2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 2')
|
||||
->examples(['ramesh@cripumps.com','ramesh@cripumps.com'])
|
||||
->label('Approver Mail 2'),
|
||||
ImportColumn::make('name3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 3')
|
||||
->examples(['Ganesh.K','Ganesh.K'])
|
||||
->label('Approver Name 3'),
|
||||
ImportColumn::make('mail3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 3')
|
||||
->examples(['ganesh@cripumps.com','ganesh@cripumps.com'])
|
||||
->label('Approver Mail 3'),
|
||||
ImportColumn::make('duration1')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 1')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 1'),
|
||||
ImportColumn::make('duration2')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 2')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 2'),
|
||||
ImportColumn::make('duration3')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 3')
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 3'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Characteristic Field')
|
||||
->examples(['MV SERIES','PV SERIES'])
|
||||
->label('Characteristic Field'),
|
||||
ImportColumn::make('approver_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Type')
|
||||
->examples(['Characteristic','Quality'])
|
||||
->label('Approver Type'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CharacteristicApproverMaster
|
||||
{
|
||||
// return CharacteristicApproverMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new CharacteristicApproverMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your characteristic approver 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;
|
||||
}
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CharacteristicValue;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class CharacteristicValueImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CharacteristicValue::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('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGS09745')
|
||||
->label('Work Center')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('process_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Process Order')
|
||||
->example('23455256352')
|
||||
->label('Process Order'),
|
||||
ImportColumn::make('coil_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Coil Number')
|
||||
->example('0')
|
||||
->label('Coil Number'),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Status')
|
||||
->example('Ok')
|
||||
->label('Status'),
|
||||
ImportColumn::make('observed_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Observed Value')
|
||||
->example('RAW01234')
|
||||
->label('Observed Value'),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('RAW01234')
|
||||
->label('Created By'),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CharacteristicValue
|
||||
{
|
||||
// return CharacteristicValue::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$lineId = null;
|
||||
$machineId = null;
|
||||
// $itemAgainstPlant = null;
|
||||
|
||||
$plantCode = $this->data['plant'];
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$iCode = trim($this->data['item']);
|
||||
$workCenter = trim($this->data['machine']);
|
||||
$lineName = trim($this->data['line']);
|
||||
$coilNo = trim($this->data['coil_number']);
|
||||
$obserVal = trim($this->data['observed_value']);
|
||||
$status = trim($this->data['status']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
$warnMsg[] = 'Plant code cannot be empty';
|
||||
} elseif ($iCode == null || $iCode == '') {// process_order
|
||||
$warnMsg[] = 'Item code cannot be empty';
|
||||
} elseif ($processOrder == null || $processOrder == '') {//
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
} elseif ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = 'Work center cannot be empty';
|
||||
} elseif ($lineName == null || $lineName == '') {
|
||||
$warnMsg[] = 'Line name cannot be empty';
|
||||
} elseif ($coilNo == null || $coilNo == '') {
|
||||
$warnMsg[] = 'Coil number cannot be empty';
|
||||
} elseif ($obserVal == null || $obserVal == '') {
|
||||
$warnMsg[] = 'Observed value cannot be empty';
|
||||
} elseif ($status == null || $status == '') {
|
||||
$warnMsg[] = 'Status cannot be empty';
|
||||
}
|
||||
|
||||
if (Str::length($plantCode) > 0 && (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode))) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $lineName)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$workCenterExist = Machine::where('work_center', $workCenter)->first();
|
||||
if (! $workCenterExist) {
|
||||
$warnMsg[] = 'Work Center not found';
|
||||
}
|
||||
|
||||
// $workCenterAgainstPlant = Machine::where('work_center', $workCenter)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->first();
|
||||
|
||||
// if (!$workCenterAgainstPlant) {
|
||||
// $warnMsg[] = 'Work center not found for the given plant';
|
||||
// } else {
|
||||
// $MachineId = $workCenterAgainstPlant->id;
|
||||
// }
|
||||
|
||||
if ($plantId != null && $lineId != null) {
|
||||
$machineAgaPlantLine = Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->where('work_center', $workCenter)
|
||||
->first();
|
||||
|
||||
if (! $machineAgaPlantLine) {
|
||||
$warnMsg[] = 'Work center not found for the given plant and line';
|
||||
} else {
|
||||
$machineId = $machineAgaPlantLine->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($coilNo) > 0 && ! is_numeric($coilNo)) {
|
||||
$warnMsg[] = 'Coil number should contain only numeric values!';
|
||||
}
|
||||
|
||||
if (Str::length($obserVal) > 0 && ! is_numeric($obserVal)) {
|
||||
$warnMsg[] = 'Observed value should contain only numeric values!';
|
||||
}
|
||||
|
||||
if (Str::length($status) > 0 && ! in_array($status, ['Ok', 'NotOk'], true)) {
|
||||
$warnMsg[] = "Status must be either 'Ok' or 'NotOk'!";
|
||||
}
|
||||
// else {
|
||||
// if (Str::length($status) <= 0 || ! is_numeric($status) || ! preg_match('/^\d+(\.\d+)?$/', $status)
|
||||
// ) {
|
||||
// $status = 'NotOk';
|
||||
// } else {
|
||||
// $specVal = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
|
||||
// if (! $specVal) {
|
||||
// $status = 'NotOk';
|
||||
// }
|
||||
|
||||
// $lowLimit = $specVal?->lower ?? 0;
|
||||
// $uppLimit = $specVal?->upper ?? 0;
|
||||
|
||||
// if (Str::length($lowLimit) <= 0 || ! is_numeric($lowLimit) || ! preg_match('/^\d+(\.\d+)?$/', $lowLimit)
|
||||
// ) {
|
||||
// $status = 'NotOk';
|
||||
// } elseif (Str::length($uppLimit) <= 0 || ! is_numeric($uppLimit) || ! preg_match('/^\d+(\.\d+)?$/', $uppLimit)
|
||||
// ) {
|
||||
// $status = 'NotOk';
|
||||
// }
|
||||
|
||||
// if (($lowLimit == 0 && $uppLimit == 0) || ($uppLimit == 0)) {
|
||||
// $status = 'NotOk';
|
||||
// }
|
||||
|
||||
// if ($lowLimit > $obserVal || $uppLimit < $obserVal) {
|
||||
// $status = 'NotOk';
|
||||
// }
|
||||
// $status = 'Ok';
|
||||
// }
|
||||
// }
|
||||
|
||||
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
|
||||
$warnMsg[] = 'Created By cannot be empty';
|
||||
}
|
||||
|
||||
if ($plantId) {
|
||||
$user = User::where('name', $createdBy)->first();
|
||||
|
||||
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'Created By user name not found!';
|
||||
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
|
||||
$warnMsg[] = "Created By user '{$createdBy}' not found for Plant '{$plantCode}'!";
|
||||
} elseif (! $user->hasRole(['Super Admin', 'Process Quality Manager', 'Process Manager', 'Process Supervisor', 'Process Employee'])) {
|
||||
$warnMsg[] = 'Created By user does not have rights!';
|
||||
}
|
||||
}
|
||||
|
||||
if ($plantId && $processOrder) {
|
||||
$existing = CharacteristicValue::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
$warnMsg[] = "Coil number '{$coilNo}' already exists for Plant '{$plantCode}' and Process Order '{$processOrder}'.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($plant && $itemCode && $processOrder != '' && $processOrder != null) {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
}
|
||||
|
||||
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
|
||||
if (! $updatedBy) {
|
||||
$warnMsg[] = 'Invalid updated by user name found';
|
||||
}
|
||||
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($fdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
if (! isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return CharacteristicValue::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => $coilNo,
|
||||
],
|
||||
[
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'status' => $status,
|
||||
'observed_value' => $obserVal,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// return null;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ class CheckPointNameImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
@@ -43,22 +43,16 @@ class CheckPointNameImporter extends Importer
|
||||
public function resolveRecord(): ?CheckPointName
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found'; // '" . $plantCod . "'
|
||||
}
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
|
||||
$warnMsg[] = 'Invalid check point name found';
|
||||
$warnMsg[] = "Invalid check point name found";
|
||||
}
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = 'Invalid created by name found';
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
@@ -66,10 +60,10 @@ class CheckPointNameImporter extends Importer
|
||||
|
||||
return CheckPointName::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'created_by' => $this->data['created_by'],
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
// // return CheckPointName::firstOrNew([
|
||||
|
||||
@@ -21,10 +21,10 @@ class CheckPointTimeImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('checkPointNames1')
|
||||
->requiredMapping()
|
||||
@@ -73,50 +73,49 @@ class CheckPointTimeImporter extends Importer
|
||||
public function resolveRecord(): ?CheckPointTime
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$checkPointNames1 = null;
|
||||
$checkPointNames2 = null;
|
||||
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 . "'
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames1 = CheckPointName::where('name', $this->data['checkPointNames1'])->first();
|
||||
if (!$checkPointNames1) {
|
||||
$warnMsg[] = 'Check point 1 not found';
|
||||
} else {
|
||||
$warnMsg[] = "Check point 1 not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames2 = CheckPointName::where('name', $this->data['checkPointNames2'])->first();
|
||||
if (!$checkPointNames2) {
|
||||
$warnMsg[] = 'Check point 2 not found';
|
||||
} else {
|
||||
$warnMsg[] = "Check point 2 not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($checkPointNames1->id === $checkPointNames2->id) {
|
||||
$warnMsg[] = "Check point 1 and 2 can't be the same";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['sequence_number']) < 1 || !is_numeric($this->data['sequence_number']) || $this->data['sequence_number'] <= 0) {
|
||||
$warnMsg[] = 'Invalid sequence number found';
|
||||
$warnMsg[] = "Invalid sequence number found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['time_lapse']) < 1 || !is_numeric($this->data['time_lapse']) || $this->data['time_lapse'] <= 0) {
|
||||
$warnMsg[] = 'Invalid time lapse found';
|
||||
$warnMsg[] = "Invalid time lapse found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['time_lapse_cushioning']) < 1 || !is_numeric($this->data['time_lapse_cushioning']) || $this->data['time_lapse_cushioning'] <= 0) {
|
||||
$warnMsg[] = 'Invalid time lapse cushioning found';
|
||||
$warnMsg[] = "Invalid time lapse cushioning found";
|
||||
}
|
||||
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = 'Invalid created by name found';
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
@@ -125,12 +124,12 @@ class CheckPointTimeImporter extends Importer
|
||||
'plant_id' => $plant->id,
|
||||
'check_point1_id' => $checkPointNames1->id,
|
||||
'check_point2_id' => $checkPointNames2->id,
|
||||
'sequence_number' => $this->data['sequence_number'],
|
||||
'sequence_number' => $this->data['sequence_number']
|
||||
],
|
||||
[
|
||||
'time_lapse' => $this->data['time_lapse'],
|
||||
'time_lapse_cushioning' => $this->data['time_lapse_cushioning'],
|
||||
'created_by' => $this->data['created_by'],
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
// // return CheckPointTime::firstOrNew([
|
||||
|
||||
@@ -1,697 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ClassCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ClassCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ClassCharacteristic::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('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGLAS01')
|
||||
->label('WORK CENTER')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('AUFNR')
|
||||
->exampleHeader('AUFNR')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('class')
|
||||
->label('CLASS')
|
||||
->exampleHeader('CLASS')
|
||||
->example('ZLASER'),
|
||||
ImportColumn::make('arbid')
|
||||
->label('ARBID')
|
||||
->exampleHeader('ARBID')
|
||||
->example('LASER'),
|
||||
ImportColumn::make('gamng')
|
||||
->label('GAMNG')
|
||||
->exampleHeader('GAMNG')
|
||||
->example('1.000'),
|
||||
ImportColumn::make('lmnga')
|
||||
->label('LMNGA')
|
||||
->exampleHeader('LMNGA')
|
||||
->example('1'),
|
||||
ImportColumn::make('gernr')
|
||||
->label('GERNR')
|
||||
->exampleHeader('GERNR')
|
||||
->example('12345678901234'),
|
||||
ImportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD')
|
||||
->exampleHeader('ZZ1 CN BILL ORD')
|
||||
->example('INDIA'),
|
||||
ImportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPS')
|
||||
->exampleHeader('ZMM AMPS')
|
||||
->example('11A'),
|
||||
ImportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND')
|
||||
->exampleHeader('ZMM BRAND')
|
||||
->example('CRI'),
|
||||
ImportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREEOFPROTECTION')
|
||||
->exampleHeader('ZMM DEGREEOFPROTECTION')
|
||||
->example('IP55'),
|
||||
ImportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY')
|
||||
->exampleHeader('ZMM DELIVERY')
|
||||
->example('65MM'),
|
||||
ImportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIR ROT')
|
||||
->exampleHeader('ZMM DIR ROT')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE')
|
||||
->exampleHeader('ZMM DISCHARGE')
|
||||
->example('17m³/h'),
|
||||
ImportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX')
|
||||
->exampleHeader('ZMM DISCHARGE MAX')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN')
|
||||
->exampleHeader('ZMM DISCHARGE MIN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY')
|
||||
->exampleHeader('ZMM DUTY')
|
||||
->example('DUTY S1'),
|
||||
ImportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR')
|
||||
->exampleHeader('ZMM EFF MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP')
|
||||
->exampleHeader('ZMM EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY')
|
||||
->exampleHeader('ZMM FREQUENCY')
|
||||
->example('50Hz'),
|
||||
ImportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD')
|
||||
->exampleHeader('ZMM HEAD')
|
||||
->example('77M'),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING')
|
||||
->exampleHeader('ZMM HEADING')
|
||||
->example('PRESSURE BOOSTER SYSTEM'),
|
||||
ImportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX')
|
||||
->exampleHeader('ZMM HEAD MAX')
|
||||
->example('96m'),
|
||||
ImportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM')
|
||||
->exampleHeader('ZMM HEAD MINIMUM')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR')
|
||||
->exampleHeader('ZMM IDX EFF MTR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP')
|
||||
->exampleHeader('ZMM IDX EFF PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE')
|
||||
->exampleHeader('ZMM KVACODE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP')
|
||||
->exampleHeader('ZMM MAXAMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLINGFLOW')
|
||||
->exampleHeader('ZMM MINCOOLINGFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES')
|
||||
->exampleHeader('ZMM MOTORSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL')
|
||||
->exampleHeader('ZMM MOTOR MODEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET')
|
||||
->exampleHeader('ZMM OUTLET')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE')
|
||||
->exampleHeader('ZMM PHASE')
|
||||
->example('3Ph'),
|
||||
ImportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE')
|
||||
->exampleHeader('ZMM PRESSURE')
|
||||
->example('16bar'),
|
||||
ImportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE')
|
||||
->exampleHeader('ZMM PUMPFLOWTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMPSERIES')
|
||||
->exampleHeader('ZMM PUMPSERIES')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL')
|
||||
->exampleHeader('ZMM PUMP MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER')
|
||||
->exampleHeader('ZMM RATEDPOWER')
|
||||
->example('5.5kW/7.5HP'),
|
||||
ImportColumn::make('zmm_region')
|
||||
->label('ZMM REGION')
|
||||
->exampleHeader('ZMM REGION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICEFACTOR')
|
||||
->exampleHeader('ZMM SERVICEFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->exampleHeader('ZMM SERVICEFACTORMAXIMUMAMPS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED')
|
||||
->exampleHeader('ZMM SPEED')
|
||||
->example('2900rpm'),
|
||||
ImportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION')
|
||||
->exampleHeader('ZMM SUCTION')
|
||||
->example('65mm'),
|
||||
ImportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTIONXDELIVERY')
|
||||
->exampleHeader('ZMM SUCTIONXDELIVERY')
|
||||
->example('50 x 50mm'),
|
||||
ImportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLYSOURCE')
|
||||
->exampleHeader('ZMM SUPPLYSOURCE')
|
||||
->example('AC SUPPLY'),
|
||||
ImportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE')
|
||||
->exampleHeader('ZMM TEMPERATURE')
|
||||
->example('90°C'),
|
||||
ImportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUSTLOAD')
|
||||
->exampleHeader('ZMM THRUSTLOAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS')
|
||||
->exampleHeader('ZMM VOLTS')
|
||||
->example('415V'),
|
||||
ImportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE')
|
||||
->exampleHeader('ZMM WIRE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE')
|
||||
->exampleHeader('ZMM PACKAGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING')
|
||||
->exampleHeader('ZMM PVARRAYRATING')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI')
|
||||
->exampleHeader('ZMM ISI')
|
||||
->example('Y'),
|
||||
ImportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISIMOTOR')
|
||||
->exampleHeader('ZMM ISIMOTOR')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISIPUMP')
|
||||
->exampleHeader('ZMM ISIPUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISIPUMPSET')
|
||||
->exampleHeader('ZMM ISIPUMPSET')
|
||||
->example('IS:12615'),
|
||||
ImportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL')
|
||||
->exampleHeader('ZMM PUMPSET MODEL')
|
||||
->example('MVHS-15/07TR'),
|
||||
ImportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES')
|
||||
->exampleHeader('ZMM STAGES')
|
||||
->example('7'),
|
||||
ImportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEADRANGE')
|
||||
->exampleHeader('ZMM HEADRANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY')
|
||||
->exampleHeader('ZMM OVERALL EFFICIENCY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION')
|
||||
->exampleHeader('ZMM CONNECTION')
|
||||
->example('STAR/DELTA'),
|
||||
ImportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE')
|
||||
->exampleHeader('ZMM MIN BORE SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISIREFERENCE')
|
||||
->exampleHeader('ZMM ISIREFERENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY')
|
||||
->exampleHeader('ZMM CATEGORY')
|
||||
->example('B'),
|
||||
ImportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE')
|
||||
->exampleHeader('ZMM SUBMERGENCE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITORSTART')
|
||||
->exampleHeader('ZMM CAPACITORSTART')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITORRUN')
|
||||
->exampleHeader('ZMM CAPACITORRUN')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH')
|
||||
->exampleHeader('ZMM INCH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE')
|
||||
->exampleHeader('ZMM MOTOR TYPE')
|
||||
->example('TEFC'),
|
||||
ImportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION')
|
||||
->exampleHeader('ZMM DISMANTLE DIRECTION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVERALL')
|
||||
->exampleHeader('ZMM EFF OVERALL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODYMOC')
|
||||
->exampleHeader('ZMM BODYMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTORMOC')
|
||||
->exampleHeader('ZMM ROTORMOC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL')
|
||||
->exampleHeader('ZMM DLWL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUTPOWER')
|
||||
->exampleHeader('ZMM INPUTPOWER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD')
|
||||
->exampleHeader('ZMM IMP OD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP')
|
||||
->exampleHeader('ZMM AMBTEMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_de')
|
||||
->label('ZMM DE')
|
||||
->exampleHeader('ZMM DE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGERANGE')
|
||||
->exampleHeader('ZMM DISCHARGERANGE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS')
|
||||
->exampleHeader('ZMM EFFICIENCY CLASS')
|
||||
->example('IE2'),
|
||||
ImportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAMESIZE')
|
||||
->exampleHeader('ZMM FRAMESIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER')
|
||||
->exampleHeader('ZMM IMPELLERDIAMETER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATIONCLASS')
|
||||
->exampleHeader('ZMM INSULATIONCLASS')
|
||||
->example('F'),
|
||||
ImportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAXFLOW')
|
||||
->exampleHeader('ZMM MAXFLOW')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_minhead')
|
||||
->label('ZMM MINHEAD')
|
||||
->exampleHeader('ZMM MINHEAD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST')
|
||||
->exampleHeader('ZMM MTRLOFCONST')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE')
|
||||
->exampleHeader('ZMM NDE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR')
|
||||
->exampleHeader('ZMM POWERFACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_tagno')
|
||||
->label('ZMM TAGNO')
|
||||
->exampleHeader('ZMM TAGNO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR')
|
||||
->exampleHeader('ZMM YEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME')
|
||||
->exampleHeader('ZMM LASER NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP')
|
||||
->exampleHeader('ZMM LOGO CP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE')
|
||||
->exampleHeader('ZMM LOGO CE')
|
||||
->example('NO'),
|
||||
ImportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF')
|
||||
->exampleHeader('ZMM LOGO NSF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE')
|
||||
->exampleHeader('ZMM BEENOTE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER')
|
||||
->exampleHeader('ZMM BEENUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR')
|
||||
->exampleHeader('ZMM BEESTAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS')
|
||||
->exampleHeader('ZMM CODECLASS')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR')
|
||||
->exampleHeader('ZMM COLOUR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE')
|
||||
->exampleHeader('ZMM GRADE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET')
|
||||
->exampleHeader('ZMM GRWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE')
|
||||
->exampleHeader('ZMM GRWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR')
|
||||
->exampleHeader('ZMM GRWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF')
|
||||
->exampleHeader('ZMM GRWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP')
|
||||
->exampleHeader('ZMM GRWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISIVALVE')
|
||||
->exampleHeader('ZMM ISIVALVE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC')
|
||||
->exampleHeader('ZMM ISI WC')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABELPERIOD')
|
||||
->exampleHeader('ZMM LABELPERIOD')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH')
|
||||
->exampleHeader('ZMM LENGTH')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO')
|
||||
->exampleHeader('ZMM LICENSE CML NO')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFGMONYR')
|
||||
->exampleHeader('ZMM MFGMONYR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODELYEAR')
|
||||
->exampleHeader('ZMM MODELYEAR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION')
|
||||
->exampleHeader('ZMM MOTORIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET')
|
||||
->exampleHeader('ZMM NEWT PSET')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE')
|
||||
->exampleHeader('ZMM NEWT CABLE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR')
|
||||
->exampleHeader('ZMM NEWT MOTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF')
|
||||
->exampleHeader('ZMM NEWT PF')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP')
|
||||
->exampleHeader('ZMM NEWT PUMP')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACKTYPE')
|
||||
->exampleHeader('ZMM PACKTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL')
|
||||
->exampleHeader('ZMM PANEL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR')
|
||||
->exampleHeader('ZMM PERFORMANCE FACTOR')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION')
|
||||
->exampleHeader('ZMM PUMPIDENTIFICATION')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSETTYPE')
|
||||
->exampleHeader('ZMM PSETTYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE')
|
||||
->exampleHeader('ZMM SIZE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL')
|
||||
->exampleHeader('ZMM EFF TTL')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE')
|
||||
->exampleHeader('ZMM TYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_usp')
|
||||
->label('ZMM USP')
|
||||
->exampleHeader('ZMM USP')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->exampleHeader('MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->exampleHeader('MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->exampleHeader('MARKED EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->exampleHeader('MARKED BY')
|
||||
->example('TEST001'),
|
||||
ImportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MANUAL MARKED STATUS')
|
||||
->example('0'),
|
||||
ImportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME')
|
||||
->exampleHeader('MANUAL MARKED DATETIME')
|
||||
->example(''),
|
||||
ImportColumn::make('man_marked_by')
|
||||
->label('MANUAL MARKED BY')
|
||||
->exampleHeader('MANUAL MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_marked_status')
|
||||
->label('MOTOR MARKED STATUS')
|
||||
->exampleHeader('MOTOR MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_marked_physical_count')
|
||||
->label('MOTOR MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MOTOR MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->exampleHeader('MOTOR EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->exampleHeader('MOTOR MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_marked_status')
|
||||
->label('PUMP MARKED STATUS')
|
||||
->exampleHeader('PUMP MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_marked_physical_count')
|
||||
->label('PUMP MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('PUMP MARKED PHYSICAL COUNT')
|
||||
->example('0'),
|
||||
ImportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->exampleHeader('PUMP EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->exampleHeader('PUMP MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_marked_status')
|
||||
->label('NAME PLATE MARKED STATUS')
|
||||
->exampleHeader('NAME PLATE MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_expected_time')
|
||||
->label('NAME PLATE EXPECTED TIME')
|
||||
->exampleHeader('NAME PLATE EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY')
|
||||
->exampleHeader('NAME PLATE MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS')
|
||||
->exampleHeader('MOTOR PUMP PUMPSET STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->exampleHeader('MOTOR MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_machine_name')
|
||||
->label('PUMP MACHINE NAME')
|
||||
->exampleHeader('PUMP MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_machine_name')
|
||||
->label('NAME PLATE MACHINE NAME')
|
||||
->exampleHeader('NAME PLATE MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pumpset_machine_name')
|
||||
->label('PUMPSET MACHINE NAME')
|
||||
->exampleHeader('PUMPSET MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1')
|
||||
->exampleHeader('PART VALIDATION 1')
|
||||
->example(''),
|
||||
ImportColumn::make('part_validation_2')
|
||||
->label('PART VALIDATION 2')
|
||||
->exampleHeader('PART VALIDATION 2')
|
||||
->example(''),
|
||||
ImportColumn::make('samlight_logged_name')
|
||||
->label('SAMLGHT LOGGED NAME')
|
||||
->exampleHeader('SAMLGHT LOGGED NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS')
|
||||
->exampleHeader('PENDING RELEASED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID')
|
||||
->exampleHeader('HAS WORK FLOW ID')
|
||||
->example('0'),
|
||||
ImportColumn::make('created_at')
|
||||
->label('CREATED AT')
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('TEST001'),
|
||||
ImportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('TEST001'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ClassCharacteristic
|
||||
{
|
||||
// return ClassCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ClassCharacteristic;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your class characteristic 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;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class ConfigurationImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Configuration;
|
||||
return new Configuration();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class CustomerPoMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CustomerPoMaster::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('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('customer_po')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Customer PO')
|
||||
->example('1JA0029512')
|
||||
->label('Customer PO')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('customer_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Customer Name')
|
||||
->example('KANKARIA MACHINERY STORE')
|
||||
->label('Customer Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Quantity')
|
||||
->example('5')
|
||||
->label('Quantity')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('created_by')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Created By')
|
||||
// ->example('Admin')
|
||||
// ->label('Created By')
|
||||
// ->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CustomerPoMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$item = null;
|
||||
|
||||
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';
|
||||
} else {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['customer_po']) < 9) {
|
||||
$warnMsg[] = 'Invalid Customer PO number found';
|
||||
}
|
||||
|
||||
if (empty($this->data['customer_po'])) {
|
||||
$warnMsg[] = 'Customer PO cannot be empty.';
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found';
|
||||
// }
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
//else { // if (empty($warnMsg))
|
||||
// $grMaster = GrMaster::where('plant_id', $plant->id)
|
||||
// ->where('serial_number', $this->data['serial_number'])
|
||||
// ->latest()
|
||||
// ->first();
|
||||
|
||||
// if ($grMaster) {
|
||||
// throw new RowImportFailedException('Serial number already exist!');
|
||||
// }
|
||||
// }
|
||||
|
||||
CustomerPoMaster::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $item->id,
|
||||
'customer_po' => $this->data['customer_po'],
|
||||
'customer_name' => $this->data['customer_name'],
|
||||
'quantity' => $this->data['quantity'] ?? null,
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
// return new CustomerPoMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your customer po 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;
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,10 @@ class DeviceMasterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
@@ -53,7 +53,7 @@ class DeviceMasterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new DeviceMaster;
|
||||
return new DeviceMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -16,10 +16,10 @@ class EbReadingImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lcd_segment_check')
|
||||
->label('LCD Segment Check')
|
||||
@@ -227,7 +227,7 @@ class EbReadingImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new EbReading;
|
||||
return new EbReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -16,10 +16,10 @@ class EquipmentMasterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
@@ -93,7 +93,7 @@ class EquipmentMasterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new EquipmentMaster;
|
||||
return new EquipmentMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Item;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use App\Models\User;
|
||||
|
||||
class GrMasterImporter extends Importer
|
||||
{
|
||||
@@ -21,10 +21,10 @@ class GrMasterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
@@ -63,47 +63,44 @@ class GrMasterImporter extends Importer
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$item = null;
|
||||
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
$warnMsg[] = "Item not found";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
|
||||
if (empty($this->data['gr_number'])) {
|
||||
$warnMsg[] = 'GR Number cannot be empty.';
|
||||
$warnMsg[] = "GR Number cannot be empty.";
|
||||
}
|
||||
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = 'User not found';
|
||||
$warnMsg[] = "User not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else { // if (empty($warnMsg))
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
$grMaster = GrMaster::where('plant_id', $plant->id)
|
||||
->where('serial_number', $this->data['serial_number'])
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($grMaster) {
|
||||
throw new RowImportFailedException('Serial number already exist!');
|
||||
throw new RowImportFailedException("Serial number already exist!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ class GuardNameImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
@@ -54,25 +54,19 @@ class GuardNameImporter extends Importer
|
||||
public function resolveRecord(): ?GuardName
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found'; // '" . $plantCod . "'
|
||||
}
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
|
||||
$warnMsg[] = 'Invalid guard name found';
|
||||
$warnMsg[] = "Invalid guard name found";
|
||||
}
|
||||
if (Str::length($this->data['identification1']) < 5) {
|
||||
$warnMsg[] = 'Invalid identification-1 found';
|
||||
$warnMsg[] = "Invalid identification-1 found";
|
||||
}
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = 'Invalid created by name found';
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
@@ -80,12 +74,12 @@ class GuardNameImporter extends Importer
|
||||
|
||||
return GuardName::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'identification1' => $this->data['identification1'],
|
||||
'identification2' => $this->data['identification2'],
|
||||
'created_by' => $this->data['created_by'],
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ class GuardPatrolEntryImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('guardNames')
|
||||
->requiredMapping()
|
||||
@@ -68,27 +68,27 @@ class GuardPatrolEntryImporter extends Importer
|
||||
public function resolveRecord(): ?GuardPatrolEntry
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$guardNames = null;
|
||||
$checkPointNames = null;
|
||||
$patrolDateTime = null; //$fdateTime = null;
|
||||
|
||||
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 . "'
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
else
|
||||
{
|
||||
$guardNames = GuardName::where('plant_id', $plant->id)->where('name', $this->data['guardNames'])->first();
|
||||
if (!$guardNames) {
|
||||
$warnMsg[] = 'Guard name not found';
|
||||
} else {
|
||||
$warnMsg[] = "Guard name not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames = CheckPointName::where('plant_id', $plant->id)->where('name', $this->data['checkPointNames'])->first();
|
||||
if (!$checkPointNames) {
|
||||
$warnMsg[] = 'Check point name not found';
|
||||
} else {
|
||||
$warnMsg[] = "Check point name not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$patrolTime = $this->data['patrol_time'];//$fromDate = $this->data['from_datetime'];
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
@@ -105,11 +105,12 @@ class GuardPatrolEntryImporter extends Importer
|
||||
if (!isset($patrolDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Patrol DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$guardEntryFound = GuardPatrolEntry::where('plant_id', $plant->id)->where('guard_name_id', $guardNames->id)->where('check_point_name_id', $checkPointNames->id)->where('patrol_time', $patrolDateTime->format('Y-m-d H:i:s'))->first();
|
||||
if ($guardEntryFound) {
|
||||
$warnMsg[] = 'Duplicate guard patrol entry found';
|
||||
}
|
||||
$warnMsg[] = "Duplicate guard patrol entry found";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +119,7 @@ class GuardPatrolEntryImporter extends Importer
|
||||
|
||||
$createdBy = Filament::auth()->user()->name;// ?? 'Admin'
|
||||
if (!$createdBy) {
|
||||
$warnMsg[] = 'Invalid created by name found';
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -129,15 +130,14 @@ class GuardPatrolEntryImporter extends Importer
|
||||
'plant_id' => $plant->id,
|
||||
'guard_name_id' => $guardNames->id,
|
||||
'check_point_name_id' => $checkPointNames->id,
|
||||
'patrol_time' => $patrolDateTime->format('Y-m-d H:i:s'),
|
||||
'patrol_time' => $patrolDateTime->format('Y-m-d H:i:s')
|
||||
],
|
||||
[
|
||||
'reader_code' => null,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $createdBy,
|
||||
'updated_by' => $createdBy
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return GuardPatrolEntry::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class InvoiceValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::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('item_reference')// stickerMaster
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
// ->relationship()// resolveUsing: 'items.code'
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('INVOICE NUMBER')
|
||||
->example('RAW0009611')
|
||||
->label('INVOICE NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('12345678901234')
|
||||
->label('SERIAL NUMBER'),
|
||||
ImportColumn::make('motor_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MOTOR SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ImportColumn::make('pump_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PUMP SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ImportColumn::make('capacitor_scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CAPACITOR SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ImportColumn::make('scanned_status_set')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PUMPSET SCANNED STATUS')
|
||||
->example('')
|
||||
->label('PUMPSET SCANNED STATUS'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SCANNED STATUS')
|
||||
->example('Scanned')
|
||||
->label('SCANNED STATUS'),
|
||||
ImportColumn::make('panel_box_code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX CODE')
|
||||
->example('PBOX0123')
|
||||
->label('PANEL BOX CODE'),
|
||||
ImportColumn::make('panel_box_supplier')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX SUPPLIER')
|
||||
->example('1900433')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ImportColumn::make('panel_box_serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PANEL BOX SERIAL NUMBER')
|
||||
->example('2512/101236')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ImportColumn::make('load_rate')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOAD RATE')
|
||||
->example('0')
|
||||
->label('LOAD RATE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPLOAD STATUS')
|
||||
->example('N')
|
||||
->label('UPLOAD STATUS')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('batch_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('BATCH NUMBER')
|
||||
->example('')
|
||||
->label('BATCH NUMBER'),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QUANTITY')
|
||||
->example('')
|
||||
->label('QUANTITY'),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OPERATOR ID')
|
||||
->example('USER1')
|
||||
->label('OPERATOR ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('')
|
||||
->label('CREATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('USER1')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('USER1')
|
||||
->label('UPDATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('')
|
||||
->label('UPDATED BY')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?InvoiceValidation
|
||||
{
|
||||
// return InvoiceValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$iCode = trim($this->data['item_reference']) ?? null;
|
||||
$invoiceNumber = trim($this->data['invoice_number']) ?? null;
|
||||
$serialNumber = trim($this->data['serial_number']) ?? null;
|
||||
$curMotorQr = trim($this->data['motor_scanned_status']) ?? null;
|
||||
$curPumpQr = trim($this->data['pump_scanned_status']) ?? null;
|
||||
$curPumpSetQr = trim($this->data['scanned_status_set']) ?? null;
|
||||
$curCapacitorQr = trim($this->data['capacitor_scanned_status']) ?? null;
|
||||
$curScanStatus = trim($this->data['scanned_status']) ?? null;
|
||||
$curPanelBoxCode = trim($this->data['panel_box_code']) ?? null;
|
||||
$curPanelBoxSupplier = trim($this->data['panel_box_supplier']) ?? null;
|
||||
$curPanelBoxSerialNumber = trim($this->data['panel_box_serial_number']) ?? null;
|
||||
$loadRate = trim($this->data['load_rate']) ?? 0;
|
||||
$uploadStatus = trim($this->data['upload_status']) ?? 'N';
|
||||
$batchNumber = null; // trim($this->data['batch_number']) ??
|
||||
$quantity = null; // trim($this->data['quantity']) ??
|
||||
$operatorId = trim($this->data['operator_id']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
$updatedBy = trim($this->data['updated_by']);
|
||||
$createdAt = $this->data['created_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
|
||||
$packCnt = 0;
|
||||
$scanCnt = 0;
|
||||
$hasMotorQr = null;
|
||||
$hasPumpQr = null;
|
||||
$hasPumpSetQr = null;
|
||||
$hasCapacitorQr = null;
|
||||
$hadMotorQr = null;
|
||||
$hadPumpQr = null;
|
||||
$hadPumpSetQr = null;
|
||||
$hadCapacitorQr = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif ($invoiceNumber == null || $invoiceNumber == '') {
|
||||
$warnMsg[] = "Invoice number can't be empty!";
|
||||
} elseif ($serialNumber == null || $serialNumber == '') {
|
||||
$warnMsg[] = "Serial number can't be empty!";
|
||||
} elseif ($curMotorQr != null && $curMotorQr != '' && $curMotorQr != '1' && $curMotorQr != 1) {
|
||||
$warnMsg[] = 'Motor scanned status is invalid!';
|
||||
} elseif ($curPumpQr != null && $curPumpQr != '' && $curPumpQr != '1' && $curPumpQr != 1) {
|
||||
$warnMsg[] = 'Pump scanned status is invalid!';
|
||||
} elseif ($curPumpSetQr != null && $curPumpSetQr != '' && $curPumpSetQr != '1' && $curPumpSetQr != 1) {
|
||||
$warnMsg[] = 'PumpSet scanned status is invalid!';
|
||||
} elseif ($curCapacitorQr != null && $curCapacitorQr != '' && $curCapacitorQr != '1' && $curCapacitorQr != 1) {
|
||||
$warnMsg[] = 'Capacitor scanned status is invalid!';
|
||||
} elseif ($curScanStatus != null && $curScanStatus != '' && $curScanStatus != 'Scanned') {
|
||||
$warnMsg[] = 'Scanned status is invalid!';
|
||||
} elseif ($loadRate == null || $loadRate == '' || ! is_numeric($loadRate)) {
|
||||
$warnMsg[] = 'Invalid load rate found!';
|
||||
} elseif ($uploadStatus != 'N' && $uploadStatus != 'Y') {
|
||||
$warnMsg[] = 'Invalid upload status found!';
|
||||
} elseif ($operatorId == null || $operatorId == '') {
|
||||
$warnMsg[] = "Operator ID can't be empty!";
|
||||
} elseif ($createdBy == null || $createdBy == '') {
|
||||
$warnMsg[] = "Created by user can't be empty!";
|
||||
} elseif ($updatedBy == null || $updatedBy == '') {
|
||||
$warnMsg[] = "Updated by user can't be empty!";
|
||||
}
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) > 0) {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master for the given plant!';
|
||||
} elseif ($itemCode->material_type != '' && $itemCode->material_type != null) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Material invoice item code found!';
|
||||
} else {
|
||||
$stickId = $itemCode->id;
|
||||
$invalidPackage = false;
|
||||
|
||||
$hasMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $itemCode->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasCapacitorQr = $itemCode->panel_box_code ?? null;
|
||||
|
||||
if (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr) {// && ! $hasCapacitorQr
|
||||
$hasMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
} else {
|
||||
if (! $hasPumpSetQr && ! $hasPumpQr) {
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
}
|
||||
|
||||
$hasTubeMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPackMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasTubePumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasPackPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
if ($hasTubeMotorQr != $hasPackMotorQr || $hasTubePumpSetQr != $hasPackPumpSetQr) {
|
||||
$invalidPackage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) || $invalidPackage) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = "Item code doesn't have valid package type to proceed!";
|
||||
} else {
|
||||
if ($hasMotorQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasPumpQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasPumpSetQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
if ($hasCapacitorQr) {
|
||||
$packCnt++;
|
||||
}
|
||||
// if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
// $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasCapacitorQr ? $packCnt + 1 : $packCnt;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
if (! $hasMotorQr) {
|
||||
$curMotorQr = null;
|
||||
}
|
||||
if (! $hasPumpQr) {
|
||||
$curPumpQr = null;
|
||||
}
|
||||
if (! $hasPumpSetQr) {
|
||||
$curPumpSetQr = null;
|
||||
}
|
||||
if (! $hasCapacitorQr) {
|
||||
$curCapacitorQr = null;
|
||||
$curPanelBoxCode = null;
|
||||
$curPanelBoxSupplier = null;
|
||||
$curPanelBoxSerialNumber = null;
|
||||
}
|
||||
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||
|
||||
if ($record && $record->sticker_master_id != $stickId) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Item code mismatch with existing record!';
|
||||
} elseif ($record) {
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)
|
||||
->whereHas('stickerMasterRelation.item', function ($query) use ($plantId, $iCode) {
|
||||
$query->where('plant_id', $plantId)->where('code', $iCode);
|
||||
})
|
||||
->first();
|
||||
|
||||
$invalidPackage = false;
|
||||
|
||||
if ($record) {
|
||||
|
||||
$hadMotorQr = $record->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $record->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||
$hadCapacitorQr = $record->capacitor_scanned_status ?? null;
|
||||
|
||||
if ($hadMotorQr && $hasMotorQr) {
|
||||
$curMotorQr = $hadMotorQr;
|
||||
}
|
||||
if ($hadPumpQr && $hasPumpQr) {
|
||||
$curPumpQr = $hadPumpQr;
|
||||
}
|
||||
if ($hadPumpSetQr && $hasPumpSetQr) {
|
||||
$curPumpSetQr = $hadPumpSetQr;
|
||||
}
|
||||
if ($hadCapacitorQr && $hasCapacitorQr) {
|
||||
$curCapacitorQr = $hadCapacitorQr;
|
||||
$curPanelBoxCode = $record->panel_box_code ?? null;
|
||||
$curPanelBoxSupplier = $record->panel_box_supplier ?? null;
|
||||
$curPanelBoxSerialNumber = $record->panel_box_serial_number ?? null;
|
||||
}
|
||||
|
||||
$warnMsg[] = 'Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||
if ($record->invoice_number != $invoiceNumber) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Invoice number mismatch with existing record!';
|
||||
// throw new RowImportFailedException('Invoice number mismatch with existing record!');
|
||||
} elseif ($record->scanned_status == 'Scanned') {
|
||||
$stickId = null;
|
||||
|
||||
return null;
|
||||
} else {
|
||||
// if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curCapacitorQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
$record->motor_scanned_status = $curMotorQr;
|
||||
$record->pump_scanned_status = $curPumpQr;
|
||||
$record->scanned_status_set = $curPumpSetQr;
|
||||
$record->capacitor_scanned_status = $curCapacitorQr;
|
||||
$record->panel_box_code = $curPanelBoxCode;
|
||||
$record->panel_box_supplier = $curPanelBoxSupplier;
|
||||
$record->panel_box_serial_number = $curPanelBoxSerialNumber;
|
||||
if ($packCnt == $scanCnt) {
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->updated_by = $updatedBy;
|
||||
$record->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
$cDateTime = null;
|
||||
$uDateTime = null;
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($cDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
if (! isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
$scanCnt = $curCapacitorQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
if ($packCnt == $scanCnt) {
|
||||
$curScanStatus = 'Scanned';
|
||||
} else {
|
||||
$curScanStatus = null;
|
||||
}
|
||||
}
|
||||
// $curScanStatus
|
||||
|
||||
InvoiceValidation::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'serial_number' => $serialNumber,
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'motor_scanned_status' => $curMotorQr,
|
||||
'pump_scanned_status' => $curPumpQr,
|
||||
'scanned_status_set' => $curPumpSetQr,
|
||||
'capacitor_scanned_status' => $curCapacitorQr,
|
||||
'panel_box_code' => $curPanelBoxCode,
|
||||
'panel_box_supplier' => $curPanelBoxSupplier,
|
||||
'panel_box_serial_number' => $curPanelBoxSerialNumber,
|
||||
'scanned_status' => $curScanStatus,
|
||||
'load_rate' => $loadRate,
|
||||
'upload_status' => $uploadStatus,
|
||||
'batch_number' => null,
|
||||
'quantity' => null,
|
||||
'operator_id' => $operatorId,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
// return new InvoiceValidation;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your invoice validation 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,8 +8,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Str;
|
||||
|
||||
class ItemImporter extends Importer
|
||||
{
|
||||
@@ -49,10 +48,10 @@ class ItemImporter extends Importer
|
||||
->label('Unit of Measure'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code') // Lookup Plant by code column
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -60,46 +59,36 @@ 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']);
|
||||
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found'; // '" . $plantCod . "'
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
$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';
|
||||
$warnMsg[] = "Invalid hourly quantity found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return Item::updateOrCreate([
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id,
|
||||
'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;
|
||||
|
||||
@@ -87,10 +87,10 @@ class LineImporter extends Importer
|
||||
->label('Work Group Center 10'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -98,24 +98,18 @@ class LineImporter extends Importer
|
||||
public function resolveRecord(): ?Line
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
throw new RowImportFailedException('Plant not found');
|
||||
}
|
||||
throw new RowImportFailedException("Plant '{$this->data['plant']}' not found");
|
||||
}
|
||||
|
||||
if (Str::length($this->data['name'] ?? '') <= 0) {
|
||||
throw new RowImportFailedException('Line name not found');
|
||||
throw new RowImportFailedException("Line name not found");
|
||||
}
|
||||
|
||||
if (Str::length($this->data['type'] ?? '') <= 0) {
|
||||
throw new RowImportFailedException('Line type not found');
|
||||
throw new RowImportFailedException("Line type not found");
|
||||
}
|
||||
|
||||
$noOfOps = (int) ($this->data['no_of_operation'] ?? 0);
|
||||
@@ -124,7 +118,8 @@ class LineImporter extends Importer
|
||||
throw new RowImportFailedException("'No of Operation' is required and must be a number $noOfOps");
|
||||
}
|
||||
|
||||
if ($noOfOps > 10) {
|
||||
if ($noOfOps > 10)
|
||||
{
|
||||
throw new RowImportFailedException("Invalid 'No Of Operation' value: {$noOfOps}, maximum allowed is 10");
|
||||
}
|
||||
|
||||
@@ -137,7 +132,7 @@ class LineImporter extends Importer
|
||||
}
|
||||
if (!empty($missingGroups)) {
|
||||
throw new RowImportFailedException(
|
||||
'Invalid data: Required work groups missing values in: '.implode(', ', $missingGroups)
|
||||
"Invalid data: Required work groups missing values in: " . implode(', ', $missingGroups)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -165,7 +160,7 @@ class LineImporter extends Importer
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
throw new RowImportFailedException("Work group '{$workGroupName}' not found in plant '{$plantCod}'");
|
||||
throw new RowImportFailedException("Work group '{$workGroupName}' not found in plant '{$this->data['plant']}'");
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plant->id)
|
||||
@@ -174,20 +169,21 @@ class LineImporter extends Importer
|
||||
->first();
|
||||
|
||||
if ($existsInLines) {
|
||||
$warnMsg[] = "Work group '{$workGroupName}' is already assigned to another line in plant '{$plantCod}'";
|
||||
$warnMsg[] = "Work group '{$workGroupName}' is already assigned to another line in plant '{$this->data['plant']}'";
|
||||
}
|
||||
|
||||
$this->data["work_group{$i}_id"] = $workGroupRecord->id;
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
if (!empty($warnMsg))
|
||||
{
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Line::updateOrCreate(
|
||||
[
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'type' => $this->data['type'],
|
||||
|
||||
@@ -10,6 +10,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class LocatorInvoiceValidationImporter extends Importer
|
||||
@@ -115,44 +116,48 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
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();
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = 'Invalid invoice number found';
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = 'Invalid pallet number found';
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = 'Invalid locator number found';
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($scannedStat) > 0 && $scannedStat != 'Scanned') {
|
||||
$warnMsg[] = 'Invalid scanned status found';
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = 'Invalid upload status found';
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = 'Created by not found';
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
if (Str::length($scannedBy) > 0) {
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = 'Scanned by not found';
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = 'Updated by not found';
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +178,8 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (Str::length($scannedAt) > 0) {
|
||||
if (Str::length($scannedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
@@ -189,7 +195,8 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($updatedAt) > 0) {
|
||||
if (Str::length($updatedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
@@ -202,7 +209,9 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
@@ -224,7 +233,7 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
LocatorInvoiceValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNo,
|
||||
@@ -237,10 +246,9 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
'updated_at' => (Str::length($updatedAt) > 0) ? $uDateTime->format('Y-m-d H:i:s') : null,
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return LocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -21,9 +21,9 @@ class MachineImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->exampleHeader('Machine')
|
||||
->example(['1600251'])
|
||||
->label('Machine Name')
|
||||
->label('Machine')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_center')
|
||||
->requiredMapping()
|
||||
@@ -41,16 +41,16 @@ class MachineImporter extends Importer
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line Name')
|
||||
->exampleHeader('Line')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -58,37 +58,37 @@ class MachineImporter extends Importer
|
||||
public function resolveRecord(): ?Machine
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$machine = $this->data['name'];
|
||||
$workCenter = $this->data['work_center'];
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->first();
|
||||
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!';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found!";
|
||||
}
|
||||
else {
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->where('plant_id', $plant->id)->first();
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
if ($line) {
|
||||
$grpWrkCnr = $line->no_of_operation;
|
||||
if (! $grpWrkCnr || $grpWrkCnr < 1) {// Str::length($grpWrkCnr) < 1)
|
||||
$warnMsg[] = 'Group work center line not found!';
|
||||
} elseif (! $groupWorkCenter) {
|
||||
$warnMsg[] = 'Group work center not found!';
|
||||
} else {
|
||||
if (!$grpWrkCnr || $grpWrkCnr < 1)//Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$warnMsg[] = "Group work center line not found!";
|
||||
}
|
||||
else if (!$groupWorkCenter) {
|
||||
$warnMsg[] = "Group work center not found!";
|
||||
}
|
||||
else {
|
||||
$dupMachine = Machine::where('plant_id', $plant->id)->where('work_center', '!=', $workCenter)->where('name', $machine)->first();
|
||||
if ($dupMachine) {
|
||||
$warnMsg[] = 'Duplicate machine name found!';
|
||||
} else {
|
||||
$warnMsg[] = "Duplicate machine name found!";
|
||||
}
|
||||
else {
|
||||
$isValidGroupWork = false;
|
||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
||||
$column = "work_group{$i}_id";
|
||||
if (!empty($line->$column)) {
|
||||
if ($groupWorkCenter->id == $line->$column) {
|
||||
if ($line->$column == $groupWorkCenter->id) {
|
||||
$isValidGroupWork = true;
|
||||
break;
|
||||
}
|
||||
@@ -96,18 +96,19 @@ class MachineImporter extends Importer
|
||||
}
|
||||
|
||||
if (!$isValidGroupWork) {
|
||||
$warnMsg[] = 'Group work center does not match with line!';
|
||||
$warnMsg[] = "Group work center does not match with line!";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$warnMsg[] = 'Line not found!';
|
||||
}
|
||||
else
|
||||
{
|
||||
$warnMsg[] = "Line not found!";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = 'Machine name not found!';
|
||||
$warnMsg[] = "Machine name not found!";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -117,15 +118,14 @@ class MachineImporter extends Importer
|
||||
Machine::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'work_center' => $workCenter,
|
||||
'work_center' => $workCenter
|
||||
],
|
||||
[
|
||||
'line_id' => $line->id,
|
||||
'name' => $machine,
|
||||
'work_group_master_id' => $groupWorkCenter->id,
|
||||
'work_group_master_id' => $groupWorkCenter->id
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return Machine::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -16,10 +16,10 @@ class MfmMeterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('Device Name')
|
||||
->requiredMapping()
|
||||
@@ -56,7 +56,7 @@ class MfmMeterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmMeter;
|
||||
return new MfmMeter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -16,10 +16,10 @@ class MfmParameterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('deviceName')
|
||||
->requiredMapping()
|
||||
@@ -82,7 +82,7 @@ class MfmParameterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmParameter;
|
||||
return new MfmParameter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -237,7 +237,7 @@ class MotorTestingMasterImporter extends Importer
|
||||
$plantCod = trim($this->data['plant']);
|
||||
$iCode = trim($this->data['item']);
|
||||
$sCode = trim($this->data['subassembly_code']);
|
||||
$isiModel = (trim($this->data['isi_model']) == '1') ? true : false;
|
||||
$isiModel = (trim($this->data['isi_model']) == "1") ? true : false;
|
||||
$phase = trim($this->data['phase']);
|
||||
$kw = trim($this->data['kw']);
|
||||
$hp = trim($this->data['hp']);
|
||||
@@ -270,25 +270,40 @@ class MotorTestingMasterImporter extends Importer
|
||||
$updatedBy = trim($this->data['updated_by']);
|
||||
|
||||
$plant = null;
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} elseif (Str::length($sCode) < 6 || ! ctype_alnum($sCode)) {
|
||||
$warnMsg[] = 'Invalid sub-assembly code found';
|
||||
} else {
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod))
|
||||
{
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else if (Str::length($iCode) < 6 || !ctype_alnum($iCode))
|
||||
{
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
else if (Str::length($sCode) < 6 || !ctype_alnum($sCode))
|
||||
{
|
||||
$warnMsg[] = "Invalid sub-assembly code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
$codeExist = Item::where('code', $iCode)->first();
|
||||
if ($plant) {
|
||||
if ($plant)
|
||||
{
|
||||
$iCode = Item::where('code', $iCode)->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} elseif (! $codeExist) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} elseif (! $iCode) {
|
||||
$warnMsg[] = 'Item code not found for choosed plant';
|
||||
} else {
|
||||
if (!$plant)
|
||||
{
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else if (!$codeExist)
|
||||
{
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
else if (!$iCode)
|
||||
{
|
||||
$warnMsg[] = "Item code not found for choosed plant";
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (Str::length($isiModel) <= 0 || $isiModel == "0" || $isiModel == "1") {
|
||||
// $warnMsg[] = "Invalid ISI Model found";
|
||||
// }
|
||||
@@ -296,89 +311,89 @@ class MotorTestingMasterImporter extends Importer
|
||||
// {
|
||||
// $isiModel = ($isiModel == "1");
|
||||
// }
|
||||
if (Str::length($phase) <= 0 || ($phase != 'Single' && $phase != 'Three')) {// !is_string($phase) ||
|
||||
$warnMsg[] = 'Invalid phase found';
|
||||
if (Str::length($phase) <= 0 || ($phase != "Single" && $phase != "Three")) {//!is_string($phase) ||
|
||||
$warnMsg[] = "Invalid phase found";
|
||||
}
|
||||
if (Str::length($hp) <= 0 || !is_numeric($hp)) {
|
||||
$warnMsg[] = 'Invalid HP found';
|
||||
$warnMsg[] = "Invalid HP found";
|
||||
}
|
||||
if (Str::length($kw) <= 0 || !is_numeric($kw)) {
|
||||
$warnMsg[] = 'Invalid KW found';
|
||||
$warnMsg[] = "Invalid KW found";
|
||||
}
|
||||
if (Str::length($volt) <= 0 || !is_numeric($volt)) {
|
||||
$warnMsg[] = 'Invalid volt found';
|
||||
$warnMsg[] = "Invalid volt found";
|
||||
}
|
||||
if (Str::length($current) <= 0 || !is_numeric($current)) {
|
||||
$warnMsg[] = 'Invalid current found';
|
||||
$warnMsg[] = "Invalid current found";
|
||||
}
|
||||
if (Str::length($rpm) <= 0 || !is_numeric($rpm)) {
|
||||
$warnMsg[] = 'Invalid RPM found';
|
||||
$warnMsg[] = "Invalid RPM found";
|
||||
}
|
||||
if (Str::length($torque) <= 0 || !is_numeric($torque)) {
|
||||
$warnMsg[] = 'Invalid torque found';
|
||||
$warnMsg[] = "Invalid torque found";
|
||||
}
|
||||
if (Str::length($frequency) <= 0 || !is_numeric($frequency)) {
|
||||
$warnMsg[] = 'Invalid frequency found';
|
||||
$warnMsg[] = "Invalid frequency found";
|
||||
}
|
||||
if (Str::length($connection) <= 0 || ($connection != 'Star-Delta' && $connection != 'Star' && $connection != 'Delta')) {
|
||||
$warnMsg[] = 'Invalid connection found';
|
||||
if (Str::length($connection) <= 0 || ($connection != "Star-Delta" && $connection != "Star" && $connection != "Delta")) {
|
||||
$warnMsg[] = "Invalid connection found";
|
||||
}
|
||||
if (Str::length($insResLimit) <= 0 || !is_numeric($insResLimit)) {
|
||||
$warnMsg[] = 'Invalid insulation resistance limit found';
|
||||
$warnMsg[] = "Invalid insulation resistance limit found";
|
||||
}
|
||||
if (Str::length($insResType) <= 0 || ($insResType != 'O' && $insResType != 'M' && $insResType != 'G')) {
|
||||
$warnMsg[] = 'Invalid insulation resistance type found';
|
||||
if (Str::length($insResType) <= 0 || ($insResType != "O" && $insResType != "M" && $insResType != "G")) {
|
||||
$warnMsg[] = "Invalid insulation resistance type found";
|
||||
}
|
||||
if (Str::length($routineTestTime) <= 0 || !isValidTimeFormat($routineTestTime)) {
|
||||
$warnMsg[] = 'Invalid routine test time found';
|
||||
$warnMsg[] = "Invalid routine test time found";
|
||||
}
|
||||
if (Str::length($resRyLl) <= 0 || !is_numeric($resRyLl)) {
|
||||
$warnMsg[] = 'Invalid resistance RY lower limit found';
|
||||
$warnMsg[] = "Invalid resistance RY lower limit found";
|
||||
}
|
||||
if (Str::length($resRyUl) <= 0 || !is_numeric($resRyUl)) {
|
||||
$warnMsg[] = 'Invalid resistance RY upper limit found';
|
||||
$warnMsg[] = "Invalid resistance RY upper limit found";
|
||||
}
|
||||
if (Str::length($resYbLl) <= 0 || !is_numeric($resYbLl)) {
|
||||
$warnMsg[] = 'Invalid resistance YB lower limit found';
|
||||
$warnMsg[] = "Invalid resistance YB lower limit found";
|
||||
}
|
||||
if (Str::length($resYbUl) <= 0 || !is_numeric($resYbUl)) {
|
||||
$warnMsg[] = 'Invalid resistance YB upper limit found';
|
||||
$warnMsg[] = "Invalid resistance YB upper limit found";
|
||||
}
|
||||
if (Str::length($resBrLl) <= 0 || !is_numeric($resBrLl)) {
|
||||
$warnMsg[] = 'Invalid resistance BR lower limit found';
|
||||
$warnMsg[] = "Invalid resistance BR lower limit found";
|
||||
}
|
||||
if (Str::length($resBrUl) <= 0 || !is_numeric($resBrUl)) {
|
||||
$warnMsg[] = 'Invalid resistance BR upper limit found';
|
||||
$warnMsg[] = "Invalid resistance BR upper limit found";
|
||||
}
|
||||
if (Str::length($lockVoltLimit) <= 0 || !is_numeric($lockVoltLimit)) {
|
||||
$warnMsg[] = 'Invalid locked volt limit found';
|
||||
$warnMsg[] = "Invalid locked volt limit found";
|
||||
}
|
||||
if (Str::length($leakCurLimit) <= 0 || !is_numeric($leakCurLimit)) {
|
||||
$warnMsg[] = 'Invalid leakage current limit found';
|
||||
$warnMsg[] = "Invalid leakage current limit found";
|
||||
}
|
||||
if (Str::length($lockCurLl) <= 0 || !is_numeric($lockCurLl)) {
|
||||
$warnMsg[] = 'Invalid locked current lower limit found';
|
||||
$warnMsg[] = "Invalid locked current lower limit found";
|
||||
}
|
||||
if (Str::length($lockCurUl) <= 0 || !is_numeric($lockCurUl)) {
|
||||
$warnMsg[] = 'Invalid locked current upper limit found';
|
||||
$warnMsg[] = "Invalid locked current upper limit found";
|
||||
}
|
||||
if (Str::length($noloadCurLl) <= 0 || !is_numeric($noloadCurLl)) {
|
||||
$warnMsg[] = 'Invalid no load current lower limit found';
|
||||
$warnMsg[] = "Invalid no load current lower limit found";
|
||||
}
|
||||
if (Str::length($noloadCurUl) <= 0 || !is_numeric($noloadCurUl)) {
|
||||
$warnMsg[] = 'Invalid no load current upper limit found';
|
||||
$warnMsg[] = "Invalid no load current upper limit found";
|
||||
}
|
||||
if (Str::length($noloadPowLl) <= 0 || !is_numeric($noloadPowLl)) {
|
||||
$warnMsg[] = 'Invalid no load power lower limit found';
|
||||
$warnMsg[] = "Invalid no load power lower limit found";
|
||||
}
|
||||
if (Str::length($noloadPowUl) <= 0 || !is_numeric($noloadPowUl)) {
|
||||
$warnMsg[] = 'Invalid no load power upper limit found';
|
||||
$warnMsg[] = "Invalid no load power upper limit found";
|
||||
}
|
||||
if (Str::length($noloadSpdLl) <= 0 || !is_numeric($noloadSpdLl)) {
|
||||
$warnMsg[] = 'Invalid no load speed lower limit found';
|
||||
$warnMsg[] = "Invalid no load speed lower limit found";
|
||||
}
|
||||
if (Str::length($noloadSpdUl) <= 0 || !is_numeric($noloadSpdUl)) {
|
||||
$warnMsg[] = 'Invalid no load speed upper limit found';
|
||||
$warnMsg[] = "Invalid no load speed upper limit found";
|
||||
}
|
||||
|
||||
$oldCode = MotorTestingMaster::where('item_id', $iCode->id)->where('plant_id', $plant->id)->first();
|
||||
@@ -386,20 +401,22 @@ class MotorTestingMasterImporter extends Importer
|
||||
if ($oldCode) {
|
||||
$created = $oldCode->created_by ? User::where('name', $oldCode->created_by)->first() : null;
|
||||
if (!$created) {
|
||||
$warnMsg[] = 'Created by not found on update';
|
||||
$warnMsg[] = "Created by not found on update";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = 'Updated by not found on update';
|
||||
$warnMsg[] = "Updated by not found on update";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = 'Created by not found';
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = 'Updated by not found';
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,7 +428,7 @@ class MotorTestingMasterImporter extends Importer
|
||||
|
||||
MotorTestingMaster::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $iCode->id,
|
||||
'item_id' => $iCode->id
|
||||
],
|
||||
[
|
||||
'subassembly_code' => $sCode,
|
||||
@@ -448,7 +465,6 @@ class MotorTestingMasterImporter extends Importer
|
||||
'updated_by' => $updated->name,
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return MotorTestingMaster::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
@@ -470,14 +486,12 @@ class MotorTestingMasterImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
function isValidTimeFormat($time)
|
||||
{
|
||||
function isValidTimeFormat($time) {
|
||||
// If time starts with a single digit hour without leading zero, pad it
|
||||
if (preg_match('/^\d(:\d{2}:\d{2})$/', $time, $matches)) {
|
||||
$time = '0' . $time;
|
||||
}
|
||||
|
||||
$dateTime = DateTime::createFromFormat('H:i:s', $time);
|
||||
|
||||
return $dateTime && $dateTime->format('H:i:s') === $time;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
|
||||
class PalletValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PalletValidation::class;
|
||||
@@ -122,41 +123,45 @@ class PalletValidationImporter extends Importer
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
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();
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = 'Invalid pallet number found';
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($palletStat) > 0 && $palletStat != 'Completed') {
|
||||
$warnMsg[] = 'Invalid pallet status found';
|
||||
$warnMsg[] = "Invalid pallet status found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = 'Invalid locator number found';
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($palletNo) <= 0 && Str::length($locatorNo) <= 0) {
|
||||
$warnMsg[] = 'Pallet and locator number found';
|
||||
$warnMsg[] = "Pallet and locator number found";
|
||||
}
|
||||
if (Str::length($locatorQty) < 0 || !is_numeric($locatorQty) || $locatorQty < 0 || $locatorQty > 2) {
|
||||
$warnMsg[] = 'Invalid locator quantity found';
|
||||
$warnMsg[] = "Invalid locator quantity found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = 'Created by not found';
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = 'Scanned by not found';
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = 'Updated by not found';
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
@@ -191,7 +196,8 @@ class PalletValidationImporter extends Importer
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
try
|
||||
{
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
@@ -202,7 +208,9 @@ class PalletValidationImporter extends Importer
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
@@ -223,7 +231,7 @@ class PalletValidationImporter extends Importer
|
||||
PalletValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'pallet_number' => $palletNo,
|
||||
@@ -235,10 +243,9 @@ class PalletValidationImporter extends Importer
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return PalletValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -51,16 +51,16 @@ class PlantImporter extends Importer
|
||||
$warnMsg = [];
|
||||
$company = Company::where('name', $this->data['company'])->first();
|
||||
if (!$company) {
|
||||
$warnMsg[] = 'Company name not found';
|
||||
$warnMsg[] = "Company name not found";
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = 'Plant name not found';
|
||||
$warnMsg[] = "Plant name not found";
|
||||
}
|
||||
if (Str::length($this->data['code']) < 4 || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
if (Str::length($this->data['address']) < 3) {
|
||||
$warnMsg[] = 'Invalid address found';
|
||||
$warnMsg[] = "Invalid address found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
@@ -71,9 +71,10 @@ class PlantImporter extends Importer
|
||||
$plantCode = Plant::where('code', $this->data['code'])->first();
|
||||
$plantName = Plant::where('name', $this->data['name'])->first();
|
||||
if ($plantName) {
|
||||
throw new RowImportFailedException('Duplicate plant name found');
|
||||
} elseif ($plantCode) {
|
||||
throw new RowImportFailedException('Duplicate plant code found');
|
||||
throw new RowImportFailedException("Duplicate plant name found");
|
||||
}
|
||||
else if ($plantCode) {
|
||||
throw new RowImportFailedException("Duplicate plant code found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ class PlantImporter extends Importer
|
||||
],
|
||||
[
|
||||
'address' => $this->data['address'],
|
||||
'company_id' => $company->id,
|
||||
'company_id' => $company->id
|
||||
]
|
||||
);
|
||||
// return Plant::firstOrNew([
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\User;
|
||||
@@ -11,7 +10,6 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProcessOrderImporter extends Importer
|
||||
@@ -24,15 +22,10 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1200')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(' Poly Wrapped Wire SFG')
|
||||
->label('LINE NAME')
|
||||
->relationship(resolveUsing: 'name'),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
@@ -41,381 +34,68 @@ class ProcessOrderImporter extends Importer
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('process_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PROCESS ORDER')
|
||||
->example('2025002123456')
|
||||
->example('202500123456')
|
||||
->label('PROCESS ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('order_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ORDER QUANTITY')
|
||||
->example('1000')
|
||||
->label('ORDER QUANTITY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_order_quantity')
|
||||
->exampleHeader('UPDATED ORDER QUANTITY')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
// ->example('01')
|
||||
->label('COIL NUMBER'),
|
||||
ImportColumn::make('received_quantity')
|
||||
->exampleHeader('RECEIVED QUANTITY')
|
||||
// ->example('01')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ImportColumn::make('sfg_number')
|
||||
->exampleHeader('SFG NUMBER')
|
||||
// ->example('200000220613-72')
|
||||
->label('SFG NUMBER'),
|
||||
ImportColumn::make('machine_name')
|
||||
->exampleHeader('MACHINE NAME')
|
||||
// ->example('WMIWRM13 - 2-L2')
|
||||
->label('MACHINE NAME'),
|
||||
ImportColumn::make('scrap_quantity')
|
||||
->exampleHeader('SCRAP QUANTITY')
|
||||
// ->example('0')
|
||||
->label('SCRAP QUANTITY'),
|
||||
ImportColumn::make('rework_status')
|
||||
->exampleHeader('REWORK STATUS')
|
||||
// ->example('0')
|
||||
->label('REWORK STATUS'),
|
||||
ImportColumn::make('created_at')
|
||||
->exampleHeader('CREATED AT')
|
||||
// ->example('2026-02-20 13:00:00')
|
||||
->label('CREATED AT'),
|
||||
ImportColumn::make('updated_at')
|
||||
->exampleHeader('UPDATED AT')
|
||||
// ->example('2026-02-20 13:00:00')
|
||||
->label('UPDATED AT'),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('CREATED BY')
|
||||
// ->example('RAW01234')
|
||||
->label('CREATED BY'),
|
||||
ImportColumn::make('updated_by')
|
||||
->exampleHeader('UPDATED BY')
|
||||
// ->example('RAW01234')
|
||||
->label('UPDATED BY'),
|
||||
->example('RAW01234')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProcessOrder
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = null;
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$plantId = null;
|
||||
$item = null;
|
||||
$iCode = trim($this->data['item']) ?? '';
|
||||
$itemId = null;
|
||||
$lineNam = trim($this->data['line']) ?? '';
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$coilNo = trim($this->data['coil_number'] ?? '');
|
||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
|
||||
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
|
||||
$reworkStatus = trim($this->data['rework_status'] ?? '');
|
||||
$recQuan = trim($this->data['received_quantity'] ?? '');
|
||||
$createdAt = trim($this->data['created_at'] ?? '');
|
||||
$createdBy = trim($this->data['created_by'] ?? '');
|
||||
$updatedAt = trim($this->data['updated_at'] ?? '');
|
||||
$updatedBy = trim($this->data['updated_by'] ?? '');
|
||||
// $user = Filament::auth()->user();
|
||||
// $operatorName = $user->name;
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
$itemCode = Item::where('code', $this->data['item'])->first();
|
||||
$iCode = trim($this->data['item']);
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
}
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = "Process order can't be empty!";
|
||||
} elseif ($processOrder && (Str::contains($processOrder, '.') || Str::contains($processOrder, 'E', ignoreCase: true))) {
|
||||
$warnMsg[] = 'Invalid process order found!';
|
||||
}
|
||||
if ($lineNam == null || $lineNam == '') {
|
||||
$warnMsg[] = "Line name can't be empty!";
|
||||
}
|
||||
if ($orderQuan == null || $orderQuan == '') {
|
||||
$warnMsg[] = "Order quantity can't be empty!";
|
||||
} elseif ($orderQuan == 0 || $orderQuan == '0') {
|
||||
$warnMsg[] = "Order quantity can't be zero!";
|
||||
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
|
||||
$warnMsg[] = 'Invalid order quantity found!';
|
||||
}
|
||||
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
|
||||
$updatedOrderQuan = $orderQuan;
|
||||
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
|
||||
$warnMsg[] = 'Invalid Updated order quantity found!';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$coilNo = '0';
|
||||
}
|
||||
if ($scrapQuan == null || $scrapQuan == '') {
|
||||
$scrapQuan = 0;
|
||||
}
|
||||
if ($recQuan == null || $recQuan == '') {
|
||||
$recQuan = 0;
|
||||
}
|
||||
if ($reworkStatus == null || $reworkStatus = '' || $reworkStatus == 0 || $reworkStatus = '0') {
|
||||
$reworkStatus = 0;
|
||||
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
||||
$reworkStatus = 1;
|
||||
} else {
|
||||
$warnMsg[] = 'Invalid rework status found!';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} elseif (! $itemCode) {
|
||||
$warnMsg[] = 'Item Code not found';
|
||||
}
|
||||
|
||||
// TESTING PURPOSE ONLY - TO CHECK DUPLICATE PROCESS ORDER WITH SAME COIL NUMBER FOR THE SAME PLANT
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->first();
|
||||
// if ($existing) {
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->where('coil_number', $coilNo)->first();
|
||||
// if ($existing) {
|
||||
// $warnMsg[] = 'Process Order with coil number already exists!';
|
||||
// } else {
|
||||
// $warnMsg[] = 'Process order already exists!';
|
||||
// }
|
||||
// } else {
|
||||
// $warnMsg[] = 'New process order found!';
|
||||
// }
|
||||
// if (! empty($warnMsg)) {
|
||||
// throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
// }
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
if ($processOrder == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'User not found';
|
||||
}
|
||||
|
||||
if ($plantId && $itemCode && $lineId && $processOrder != '') {
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
if ($plant && $processOrder != '') {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found!';
|
||||
// }
|
||||
|
||||
if (! $createdBy) {
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
} elseif (! $updatedBy) {
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
$receivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($existing) {
|
||||
$liveOrdQuan = (float) $existing->order_quantity;
|
||||
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
|
||||
|
||||
$allowedIncrease = $liveOrdQuan * 0.10;
|
||||
|
||||
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
|
||||
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
|
||||
|
||||
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existingCoil) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineName,
|
||||
'rework_status' => $reworkStatus,
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $updatedAt,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
'updated_by' => $updatedBy,
|
||||
'updated_at' => $updatedAt,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$coilNo = '0';
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// // ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||
ProcessOrder::create([
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => $itemId,
|
||||
'process_order' => $processOrder,
|
||||
return ProcessOrder::create([
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $itemCode->id,
|
||||
'process_order' => trim($this->data['process_order']),
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'order_quantity' => 0,
|
||||
'received_quantity' => 0,
|
||||
'scrap_quantity' => 0,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'created_by' => $user->name,
|
||||
]);
|
||||
} elseif (! $existing) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => $itemId,
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineName,
|
||||
'rework_status' => $reworkStatus,
|
||||
// 'created_at' => $createdAt,
|
||||
// 'updated_at' => $updatedAt,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
} else {// $coilNo = '0'
|
||||
if ($existing->process_order == $processOrder) {
|
||||
throw new RowImportFailedException('Process order already exist for the given plant!');
|
||||
} elseif ($existing->rework_status == 1 && $reworkStatus == 0) {
|
||||
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
|
||||
} else {
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
'updated_by' => $updatedBy,
|
||||
// 'updated_at' => $updatedAt,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
// return new ProcessOrder();
|
||||
}
|
||||
|
||||
@@ -1,324 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\User;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductCharacteristicsMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ProductCharacteristicsMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->label('PLANT CODE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example(['1000', '1000'])
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->label('ITEM CODE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example(['123456', '123456'])
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->label('LINE NAME')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_group_master_id')
|
||||
->label('GROUP WORK CENTER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('GROUP WORK CENTER')
|
||||
->example(['RMGSTR01', 'RMGSTR01'])
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->label('WORK CENTER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example(['RMISTR01', 'RMISTR02'])
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristics_type')
|
||||
->label('CHARACTERISTICS TYPE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTICS TYPE')
|
||||
->example(['Product', 'Process'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->label('CHARACTERISTICS NAME')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTICS NAME')
|
||||
->example(['TEST01', 'TEST02'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('inspection_type')
|
||||
->label('INSPECTION TYPE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('INSPECTION TYPE')
|
||||
->example(['Value', 'Visual'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lower')
|
||||
->label('LOWER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOWER')
|
||||
->example(['5', '0'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('middle')
|
||||
->label('MIDDLE')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MIDDLE')
|
||||
->example(['10', '0'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upper')
|
||||
->label('UPPER')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPPER')
|
||||
->example(['15', '0'])
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('created_by'),
|
||||
// ImportColumn::make('updated_by'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$itemCod = trim($this->data['item']) ?? null;
|
||||
$lineNam = trim($this->data['line']) ?? null;
|
||||
$groupWorkCenter = trim($this->data['work_group_master_id']) ?? null;
|
||||
$workCenter = trim($this->data['machine']) ?? null;
|
||||
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
||||
$charNam = trim($this->data['name']) ?? null;
|
||||
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
||||
$lower = trim($this->data['lower']) ?? null;
|
||||
$middle = trim($this->data['middle']) ?? null;
|
||||
$upper = trim($this->data['upper']) ?? null;
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = null;
|
||||
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$lineId = null;
|
||||
$workGroupMasterId = null;
|
||||
$machineId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
}
|
||||
if ($itemCod == null || $itemCod == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($lineNam == null || $lineNam == '') {
|
||||
$warnMsg[] = "Line name can't be empty!";
|
||||
}
|
||||
if ($groupWorkCenter == null || $groupWorkCenter == '') {
|
||||
$warnMsg[] = "Group work center can't be empty!";
|
||||
}
|
||||
if ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = "Work center can't be empty!";
|
||||
}
|
||||
if ($charTyp != 'Product' && $charTyp != 'Process') {
|
||||
$warnMsg[] = "Characteristics type must be either 'Product' or 'Process'!";
|
||||
}
|
||||
if ($charNam == null || $charNam == '') {
|
||||
$warnMsg[] = "Characteristics name can't be empty!";
|
||||
}
|
||||
if ($inspectTyp != 'Visual' && $inspectTyp != 'Value') {
|
||||
$warnMsg[] = "Inspection type must be either 'Visual' or 'Value'!";
|
||||
}
|
||||
if ($lower == null || $lower == '' || $middle == null || $middle == '' || $upper == null || $upper == '' || $upper == 0 || $upper == '0') {
|
||||
$lower = 0;
|
||||
$middle = 0;
|
||||
$upper = 0;
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
$itemExists = Item::where('code', $itemCod)->first();
|
||||
if (! $itemExists) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
$itemAgainstPlant = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $itemAgainstPlant) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $groupWorkCenter)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Group work center not found!';
|
||||
} else {
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $groupWorkCenter)->where('plant_id', $plantId)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Group work center not found for the given plant!';
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
|
||||
$existsInLine = Line::where('plant_id', $plantId)->where('id', $lineId)
|
||||
->where(function ($q) use ($workGroupMasterId) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
|
||||
}
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (! $existsInLine) {
|
||||
$workGroupMasterId = null;
|
||||
$warnMsg[] = "Group work center '{$WorkgroupMaster->name}' is not mapped for the given line!";
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found!';
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found for the given plant!';
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given line!";
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given group work center!";
|
||||
} else {
|
||||
$machineId = $machine->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::where('name', $createdBy)->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'Created by user not found!';
|
||||
} else {
|
||||
$updatedBy = $createdBy;
|
||||
}
|
||||
|
||||
if ($inspectTyp == 'Value') {
|
||||
if (is_null($upper) || is_null($lower) || is_null($middle)) {
|
||||
$warnMsg[] = '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.';
|
||||
} else {
|
||||
$lower = (float) $lower;
|
||||
$middle = (float) $middle;
|
||||
$upper = (float) $upper;
|
||||
if ($lower == $upper) {
|
||||
if ($lower != $middle) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower = Middle = Upper.";
|
||||
}
|
||||
} elseif (! ($lower < $middle && $middle < $upper)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower < Middle < Upper.";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lower = 0;
|
||||
$middle = 0;
|
||||
$upper = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if ($machineId) {
|
||||
$record = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->where('machine_id', $machineId)->where('item_id', $itemId)->where('characteristics_type', $charTyp)->where('name', $charNam)->first();
|
||||
if ($record) {
|
||||
$createdBy = $record->created_by ?? $createdBy;
|
||||
}
|
||||
|
||||
ProductCharacteristicsMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $lineId,
|
||||
'work_group_master_id' => $workGroupMasterId,
|
||||
'machine_id' => $machineId,
|
||||
'characteristics_type' => $charTyp,
|
||||
'name' => $charNam,
|
||||
],
|
||||
[
|
||||
'inspection_type' => $inspectTyp,
|
||||
'lower' => $lower,
|
||||
'middle' => $middle,
|
||||
'upper' => $upper,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductionLineStopImporter extends Importer
|
||||
{
|
||||
@@ -79,10 +78,10 @@ class ProductionLineStopImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000', '1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
@@ -96,57 +95,56 @@ class ProductionLineStopImporter extends Importer
|
||||
public function resolveRecord(): ?ProductionLineStop
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
$shift = null;
|
||||
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';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
}
|
||||
if (!$line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = 'Block not found';
|
||||
} elseif ($plant) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = 'Shift not found';
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
$linestop = LineStop::where('code', $this->data['linestop'])->first();
|
||||
if (!$linestop) {
|
||||
$warnMsg[] = 'Line stop code not found';
|
||||
$warnMsg[] = "Line stop code not found";
|
||||
}
|
||||
$stophour = is_numeric($this->data['stop_hour']) && $this->data['stop_hour'] >= 0;
|
||||
$stopmin = is_numeric($this->data['stop_min']) && $this->data['stop_min'] >= 0 && $this->data['stop_min'] <= 60;
|
||||
if (!$stophour && !$stopmin) {
|
||||
$warnMsg[] = 'Invalid stop hour/minute found';
|
||||
} elseif (! $stophour) {
|
||||
$warnMsg[] = 'Invalid stop hour found';
|
||||
} elseif (! $stopmin) {
|
||||
$warnMsg[] = 'Invalid stop min found';
|
||||
} else {
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
else if (!$stophour) {
|
||||
$warnMsg[] = "Invalid stop hour found";
|
||||
}
|
||||
else if (!$stopmin) {
|
||||
$warnMsg[] = "Invalid stop min found";
|
||||
}
|
||||
else {
|
||||
$stophour = (int)$this->data['stop_hour'];
|
||||
$stopmin = (int)$this->data['stop_min'];
|
||||
if ($stophour == 0 && $stopmin == 0) {
|
||||
$warnMsg[] = 'Invalid stop hour/minute found';
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
}
|
||||
$validHourMin = ($stophour == 0 && $stopmin == 0) ? false : true;
|
||||
if (!$validHourMin) {
|
||||
$warnMsg[] = 'Invalid stop hour/minute found';
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
$fromDate = $this->data['from_datetime'];
|
||||
$toDate = $this->data['to_datetime'];
|
||||
@@ -203,7 +201,7 @@ class ProductionLineStopImporter extends Importer
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -221,7 +219,6 @@ class ProductionLineStopImporter extends Importer
|
||||
'stop_min' => (int)$this->data['stop_min'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
|
||||
return null;
|
||||
// return ProductionLineStop::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
@@ -24,33 +23,11 @@ class ProductionPlanImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
// ImportColumn::make('created_at')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Created DateTime')
|
||||
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
// ->label('Created DateTime')
|
||||
// ->rules(['required']),
|
||||
|
||||
ImportColumn::make('plant')
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000', '1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example(['123456', '210987'])
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Created DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plan_quantity')
|
||||
->requiredMapping()
|
||||
@@ -59,151 +36,196 @@ class ProductionPlanImporter extends Importer
|
||||
->label('Plan Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
// ImportColumn::make('production_quantity')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Production Quantity')
|
||||
// ->example(['0', '0'])
|
||||
// ->label('Production Quantity')
|
||||
// ->numeric()
|
||||
// ->rules(['required', 'integer']),
|
||||
|
||||
// ImportColumn::make('block_reference')
|
||||
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||
// ->exampleHeader('Block Name')
|
||||
// ->example(['Block A', 'Block A'])
|
||||
// ->label('Block Name')
|
||||
// ->rules(['required']), // Or remove if not required
|
||||
// ImportColumn::make('shift')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Shift Name') // ID
|
||||
// ->example(['Day', 'Night']) // '2', '7'
|
||||
// ->label('Shift Name') // ID
|
||||
// ->relationship(resolveUsing: 'name')
|
||||
// ->rules(['required']),
|
||||
|
||||
// ImportColumn::make('updated_at')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Updated DateTime')
|
||||
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
// ->label('Updated DateTime')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('operator_id')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Operator ID')
|
||||
// ->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
// ->label('Operator ID')
|
||||
// ->rules(['required']),
|
||||
ImportColumn::make('production_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Quantity')
|
||||
->example(['0', '0'])
|
||||
->label('Production Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name') //ID
|
||||
->example(['Day', 'Night']) //'2', '7'
|
||||
->label('Shift Name') // ID
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionPlan
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$itemCod = $this->data['item'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
|
||||
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';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (!$line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
|
||||
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
|
||||
|
||||
if(!$itemAgaPlant){
|
||||
$warnMsg[] = 'Item not found against plant code';
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (Str::length($this->data['plan_quantity']) < 0 || !is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||
$warnMsg[] = 'Invalid plan quantity found';
|
||||
$warnMsg[] = "Invalid plan quantity found";
|
||||
}
|
||||
if (Str::length($this->data['production_quantity']) < 0 || !is_numeric($this->data['production_quantity']) || $this->data['production_quantity'] < 0) {
|
||||
$warnMsg[] = "Invalid production quantity found";
|
||||
}
|
||||
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
$fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else {
|
||||
$fDateOnly = $fdateTime->toDateString();
|
||||
}
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$fromDate) {
|
||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) {
|
||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else {
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('shift_id', $shift->id)
|
||||
->where('line_id', $line->id)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->whereDate('created_at', $fDateOnly)
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionPlan) {
|
||||
|
||||
$recordDate = now();
|
||||
$month = $recordDate->month;
|
||||
$year = $recordDate->year;
|
||||
|
||||
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->first();
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
// if($productionPlan->production_quantity)
|
||||
// {
|
||||
// throw new RowImportFailedException("{$productionPlan->created_at}, {$productionPlan->production_quantity}");
|
||||
// }
|
||||
// $warnMsg[] = "Production plan already exist on '{$fDateOnly}'!";
|
||||
|
||||
$productionPlan->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'operator_id' => $operatorName,
|
||||
// 'production_quantity' => $productionPlan->production_quantity,
|
||||
// 'created_at' => $productionPlan->created_at,//$fdateTime->format('Y-m-d H:i:s'),
|
||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
$productionPlan->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$recordDate = now();
|
||||
$month = $recordDate->month;
|
||||
$year = $recordDate->year;
|
||||
|
||||
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->first();
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'item_id' => $itemAgaPlant->id,
|
||||
// 'shift_id' => $shift->id,
|
||||
'shift_id' => $shift->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'working_days' => $workingDays,
|
||||
'created_at' =>now(),
|
||||
'updated_at' => now(),
|
||||
'operator_id' => $operatorName,
|
||||
'production_quantity' => $this->data['production_quantity'],
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
|
||||
return null;
|
||||
// return ProductionPlan::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
// return new ProductionPlan();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -59,9 +59,9 @@ class ProductionQuantityImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->exampleHeader('Block')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->label('Block')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
@@ -72,10 +72,10 @@ class ProductionQuantityImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000', '1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
@@ -95,51 +95,43 @@ class ProductionQuantityImporter extends Importer
|
||||
public function resolveRecord(): ?ProductionQuantity
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
$shift = null;
|
||||
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';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (!$line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = 'Block not found';
|
||||
} elseif ($plant) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = 'Shift not found';
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
$warnMsg[] = "Item not found";
|
||||
}
|
||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14 || !is_numeric($this->data['production_order']))) {
|
||||
$warnMsg[] = 'Invalid production order found';
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
$fromDate = $this->data['created_at'];
|
||||
@@ -196,19 +188,20 @@ class ProductionQuantityImporter extends Importer
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else { // if (empty($warnMsg))
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
$productionQuan = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('serial_number', $this->data['serial_number'])
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionQuan) {
|
||||
throw new RowImportFailedException('Serial number already exist!');
|
||||
throw new RowImportFailedException("Serial number already exist!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +216,6 @@ class ProductionQuantityImporter extends Importer
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
|
||||
// ProductionQuantity::updateOrCreate([
|
||||
// 'serial_number' => $this->data['serial_number'],
|
||||
// 'plant_id' => $plant->id,
|
||||
@@ -267,7 +259,7 @@ class ProductionQuantityImporter extends Importer
|
||||
'line_id' => $this->resolveLineId($row['line']),
|
||||
'shift_id' => $this->resolveShiftId($row['shift']),
|
||||
'plant_id' => $this->resolvePlantId($row['plant']),
|
||||
'updated_at' => $row['updated_at'],
|
||||
'updated_at' => $row['updated_at']
|
||||
]);
|
||||
} finally {
|
||||
// Always disable flag even if errors occur
|
||||
|
||||
@@ -14,6 +14,7 @@ use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class QualityValidationImporter extends Importer
|
||||
@@ -100,11 +101,6 @@ class QualityValidationImporter extends Importer
|
||||
->exampleHeader('Name Plate PumpSet')
|
||||
->example('1')
|
||||
->label('Name Plate PumpSet'),
|
||||
ImportColumn::make('warranty_card')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Warranty Card')
|
||||
->example('1')
|
||||
->label('Warranty Card'),
|
||||
ImportColumn::make('tube_sticker_motor')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Motor')
|
||||
@@ -120,6 +116,11 @@ class QualityValidationImporter extends Importer
|
||||
->exampleHeader('Tube Sticker PumpSet')
|
||||
->example('1')
|
||||
->label('Tube Sticker PumpSet'),
|
||||
ImportColumn::make('warranty_card')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Warranty Card')
|
||||
->example('1')
|
||||
->label('Warranty Card'),
|
||||
ImportColumn::make('part_validation1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 1')
|
||||
@@ -159,10 +160,10 @@ class QualityValidationImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
@@ -182,19 +183,13 @@ class QualityValidationImporter extends Importer
|
||||
public function resolveRecord(): ?QualityValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$stickMaster = null;
|
||||
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';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
$uniqueCode = trim($this->data['sticker_master_id_code']);// stickerMaster.item
|
||||
$stickMaster = StickerMaster::select('id')->with('item')
|
||||
@@ -204,19 +199,19 @@ class QualityValidationImporter extends Importer
|
||||
}
|
||||
|
||||
if (!$line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
|
||||
if (!$stickMaster) {
|
||||
$warnMsg[] = 'Sticker item code not found';
|
||||
$warnMsg[] = "Sticker item code not found";
|
||||
}
|
||||
|
||||
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
|
||||
$warnMsg[] = 'Invalid production order found';
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
if (!ctype_alnum($this->data['serial_number']) || Str::length($this->data['serial_number']) < 9) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
// dd($stickMaster);
|
||||
|
||||
@@ -226,7 +221,7 @@ class QualityValidationImporter extends Importer
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
@@ -287,7 +282,7 @@ class QualityValidationImporter extends Importer
|
||||
QualityValidation::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'sticker_master_id' => $stickMaster,//->id
|
||||
'serial_number' => $this->data['serial_number'],
|
||||
'serial_number' => $this->data['serial_number']
|
||||
],
|
||||
[
|
||||
'line_id' => $line->id,
|
||||
|
||||
@@ -135,47 +135,51 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
$reworkedBy = $this->data['reworked_by'];
|
||||
|
||||
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();
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = 'Invalid invoice number found';
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = 'Invalid pallet number found';
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = 'Invalid locator number found';
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if ($scannedStat != 'Scanned') {
|
||||
$warnMsg[] = 'Invalid scanned status found';
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = 'Invalid upload status found';
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = 'Created by not found';
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = 'Scanned by not found';
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = 'Updated by not found';
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
$reworked = User::where('name', $reworkedBy)->first();
|
||||
if (!$reworked) {
|
||||
$warnMsg[] = 'Reworked by not found';
|
||||
$warnMsg[] = "Reworked by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
@@ -221,7 +225,9 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
@@ -241,7 +247,9 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
|
||||
if (!isset($rDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Reworked DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($rDateTime)) {
|
||||
if ($cDateTime->greaterThan($rDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Reworked DateTime'.";
|
||||
@@ -275,10 +283,9 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'reworked_by' => $reworkedBy,
|
||||
'reworked_by' => $reworkedBy
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// // return ReworkLocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -52,10 +52,10 @@ class ShiftImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
@@ -69,35 +69,25 @@ class ShiftImporter extends Importer
|
||||
public function resolveRecord(): ?Shift
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$block = null;
|
||||
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();
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$block = Block::where('name', $this->data['block'])->where('plant_id', $plant->id)->first();
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
|
||||
$block = Block::where('name', $this->data['block'])->where('plant_id', $plant->id)->first();
|
||||
if (!$block) {
|
||||
$warnMsg[] = 'Block not found';
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
if (Str::length($this->data['duration']) < 0 || !is_numeric($this->data['duration'])) {
|
||||
$warnMsg[] = 'Invalid duration found';
|
||||
$warnMsg[] = "Invalid duration found";
|
||||
}
|
||||
if (Str::length($this->data['start_time']) < 0) {
|
||||
$warnMsg[] = 'Invalid start time found';
|
||||
$warnMsg[] = "Invalid start time found";
|
||||
}
|
||||
if (Str::length($this->data['end_time']) < 0) {
|
||||
$warnMsg[] = 'Invalid end time found';
|
||||
$warnMsg[] = "Invalid end time found";
|
||||
}
|
||||
if (Str::length($this->data['status']) < 0 || $this->data['status'] != 'Active') {
|
||||
$warnMsg[] = 'Invalid shift status found';
|
||||
$warnMsg[] = "Invalid shift status found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -115,9 +105,8 @@ class ShiftImporter extends Importer
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
|
||||
return $shift;
|
||||
} else {
|
||||
// Safe to create new
|
||||
@@ -128,7 +117,7 @@ class ShiftImporter extends Importer
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
}
|
||||
// return Shift::firstOrNew([
|
||||
|
||||
@@ -9,7 +9,6 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class StickerMasterImporter extends Importer
|
||||
@@ -152,10 +151,10 @@ class StickerMasterImporter extends Importer
|
||||
->example(''),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT NAME')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -163,122 +162,69 @@ class StickerMasterImporter extends Importer
|
||||
public function resolveRecord(): ?StickerMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']);
|
||||
$itemCod = trim($this->data['item']);
|
||||
$panelCod = trim($this->data['panel_box_code']);
|
||||
$plant = null;
|
||||
$item = null;
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$parts = null;
|
||||
$validParts = null;
|
||||
$part1 = trim($this->data['part_validation1']);
|
||||
$part2 = trim($this->data['part_validation2']);
|
||||
$part3 = trim($this->data['part_validation3']);
|
||||
$part4 = trim($this->data['part_validation4']);
|
||||
$part5 = trim($this->data['part_validation5']);
|
||||
$laserPart1 = trim($this->data['laser_part_validation1']);
|
||||
$laserPart2 = trim($this->data['laser_part_validation2']);
|
||||
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
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();
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found for the plant';
|
||||
} else {
|
||||
$itemId = $item->id;
|
||||
|
||||
if (! $laserPart1 && ! (Str::length($laserPart2) == 1 && is_numeric($laserPart2))) {
|
||||
$laserPart1 = $laserPart2;
|
||||
$laserPart2 = null;
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
|
||||
if (Str::length($panelCod) > 0 && (Str::length($panelCod) < 6 || ! ctype_alnum($panelCod))) {
|
||||
$warnMsg[] = 'Invalid panel box code found';
|
||||
} elseif ($panelCod) {
|
||||
$parts = [$part1, $part2, $part3, $part4];
|
||||
$validParts = array_values(array_filter($parts, fn ($p) => ! empty($p)));
|
||||
[$part1, $part2, $part3, $part4] = array_pad($validParts, 4, '');
|
||||
} else {
|
||||
$parts = [$part1, $part2, $part3, $part4, $part5];
|
||||
$validParts = array_values(array_filter($parts, fn ($p) => ! empty($p)));
|
||||
[$part1, $part2, $part3, $part4, $part5] = array_pad($validParts, 5, '');
|
||||
else
|
||||
{
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||
$warnMsg[] = "Serial number motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = 'Serial number pump must be 1 or empty';
|
||||
$warnMsg[] = "Serial number pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Serial number pumpset must be 1 or empty';
|
||||
$warnMsg[] = "Serial number pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = 'Pack slip motor must be 1 or empty';
|
||||
$warnMsg[] = "Pack slip motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pump must be 1 or empty';
|
||||
$warnMsg[] = "Pack slip pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pumpset must be 1 or empty';
|
||||
$warnMsg[] = "Pack slip pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = 'Name plate motor must be 1 or empty';
|
||||
$warnMsg[] = "Name plate motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = 'Name plate pump must be 1 or empty';
|
||||
$warnMsg[] = "Name plate pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Name plate pumpset must be 1 or empty';
|
||||
$warnMsg[] = "Name plate pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker motor must be 1 or empty';
|
||||
$warnMsg[] = "Tube sticker motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pump must be 1 or empty';
|
||||
$warnMsg[] = "Tube sticker pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pumpset must be 1 or empty';
|
||||
$warnMsg[] = "Tube sticker pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = 'Warranty card must be 1 or empty';
|
||||
$warnMsg[] = "Warranty card must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = "Invalid panel box code found";
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || !is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = 'Load rate must be greater than or equal to 0';
|
||||
$warnMsg[] = "Load rate must be greater than or equal to 0";
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (!is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { //($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
||||
}
|
||||
|
||||
if (empty($warnMsg)) {
|
||||
$recExist = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first()?->created_by;
|
||||
|
||||
if ($recExist) {
|
||||
$createdBy = $recExist;
|
||||
}
|
||||
}
|
||||
}
|
||||
$warnMsg[] = "Material type must be 1 or 2 or 3 or empty";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,8 +234,8 @@ class StickerMasterImporter extends Importer
|
||||
}
|
||||
|
||||
StickerMaster::updateOrCreate([
|
||||
'item_id' => $itemId,
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $item->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
@@ -305,21 +251,18 @@ class StickerMasterImporter extends Importer
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
|
||||
'warranty_card' => $this->data['warranty_card'],
|
||||
'part_validation1' => $part1,
|
||||
'part_validation2' => $part2,
|
||||
'part_validation3' => $part3,
|
||||
'part_validation4' => $part4,
|
||||
'part_validation5' => $part5,
|
||||
'laser_part_validation1' => $laserPart1,
|
||||
'laser_part_validation2' => $laserPart2,
|
||||
'panel_box_code' => $panelCod,
|
||||
'part_validation1' => $this->data['part_validation1'],
|
||||
'part_validation2' => $this->data['part_validation2'],
|
||||
'part_validation3' => $this->data['part_validation3'],
|
||||
'part_validation4' => $this->data['part_validation4'],
|
||||
'part_validation5' => $this->data['part_validation5'],
|
||||
'laser_part_validation1' => $this->data['laser_part_validation1'],
|
||||
'laser_part_validation2' => $this->data['laser_part_validation2'],
|
||||
'panel_box_code' => $this->data['panel_box_code'],
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type'],
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'material_type' => $this->data['material_type']
|
||||
]);
|
||||
|
||||
return null;
|
||||
// return StickerMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerPrinting;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Str;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class StickerPrintingImporter extends Importer
|
||||
{
|
||||
@@ -48,26 +49,30 @@ class StickerPrintingImporter extends Importer
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$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'];
|
||||
|
||||
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!';
|
||||
}
|
||||
}
|
||||
// --- Check duplicate in DB ---
|
||||
$existsInDB = StickerPrinting::where('plant_id', $plant->id)
|
||||
->where('serial_number', $serial)
|
||||
->first();
|
||||
|
||||
if (Str::length($serial) < 9 || ! ctype_alnum($serial)) {
|
||||
$warnMsg[] = 'Invalid serial number found';
|
||||
} elseif ($plant) {
|
||||
$existing = StickerPrinting::where('plant_id', $plant->id)->where('serial_number', $serial)->first();
|
||||
if ($existing) {
|
||||
$warnMsg[] = "Serial number '{$serial}' already exists for plant '{$plantCod}'!"; // throw new RowImportFailedException("Serial number already exists for this plant!");
|
||||
}
|
||||
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)) {
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class StockDataMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StockDataMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->examples(['1000', '1000'])
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('TYPE')
|
||||
->examples(['FG', 'NON-FG'])
|
||||
->label('TYPE'),
|
||||
ImportColumn::make('location')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LOCATION')
|
||||
->examples(['2001', '2002'])
|
||||
->label('LOCATION')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_reference')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->examples(['123456', '246118'])
|
||||
->label('ITEM CODE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->examples(['200235236622', '200235236623'])
|
||||
->label('SERIAL NUMBER'),
|
||||
ImportColumn::make('batch')
|
||||
->requiredMapping()
|
||||
->exampleHeader('BATCH')
|
||||
->examples(['20102', '20103'])
|
||||
->label('BATCH'),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QUANTITY')
|
||||
->examples(['1', '1'])
|
||||
->label('QUANTITY'),
|
||||
ImportColumn::make('doc_no')
|
||||
->requiredMapping()
|
||||
->exampleHeader('DOCUMENT NUMBER')
|
||||
->examples(['82128', '21222'])
|
||||
->label('DOCUMENT NUMBER'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StockDataMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$typeValue = $this->data['type'];
|
||||
$iCode = trim($this->data['item_reference']) ?? null;
|
||||
$location = trim($this->data['location']) ?? null;
|
||||
$serialNumber = trim($this->data['serial_number']) ?? null;
|
||||
$batch = trim($this->data['batch']) ?? null;
|
||||
$quantity = trim($this->data['quantity']) ?? null;
|
||||
$docNo = trim($this->data['doc_no']) ?? null;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($typeValue == null || $typeValue == '') {
|
||||
$warnMsg[] = "Type can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif ($location == null || $location == '') {
|
||||
$warnMsg[] = "Location can't be empty!";
|
||||
} elseif ($serialNumber == null || $serialNumber == '') {
|
||||
$warnMsg[] = "Serial number can't be empty!";
|
||||
}
|
||||
// else if ($batch == null || $batch == '') {
|
||||
// $warnMsg[] = "Batch can't be empty!";
|
||||
// }
|
||||
elseif ($quantity == null || $quantity == '') {
|
||||
$warnMsg[] = "Quantity can't be empty!";
|
||||
}
|
||||
// else if ($docNo == null || $docNo == '') {
|
||||
// $warnMsg[] = "Doc No can't be empty!";
|
||||
// }
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) > 0) {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master for the given plant!';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$typeValue = strtoupper($typeValue);
|
||||
|
||||
if (! in_array($typeValue, ['FG', 'NON-FG'])) {
|
||||
$warnMsg[] = 'Invalid type found! It should be either FG or NON-FG.';
|
||||
} elseif (Str::length($location) < 4) {
|
||||
$warnMsg[] = 'Location should contain minimum 4 digits!';
|
||||
} elseif (! ctype_digit((string) $location)) {
|
||||
$warnMsg[] = 'Location must be an integer!';
|
||||
} elseif (Str::length($serialNumber) < 9) {
|
||||
$warnMsg[] = 'Serial number should contain minimum 9 digits!';
|
||||
} elseif (! ctype_alnum($serialNumber)) {
|
||||
$warnMsg[] = 'Serial number should contain alpha-numeric values!';
|
||||
} elseif (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
|
||||
$warnMsg[] = 'Quantity must be an integer and greater than 0!';
|
||||
}
|
||||
|
||||
if ($batch) {
|
||||
if (Str::length($batch) < 5) {
|
||||
$warnMsg[] = 'Batch should contain minimum 5 digits!';
|
||||
}
|
||||
}
|
||||
|
||||
if ($docNo) {
|
||||
if (Str::length($docNo) < 5) {
|
||||
$warnMsg[] = 'Document number contain minimum 5 digits!';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$type = match ($typeValue) {
|
||||
'FG' => '0',
|
||||
'NON-FG' => '1',
|
||||
default => null,
|
||||
};
|
||||
|
||||
$stickId = $itemCode->id;
|
||||
|
||||
$record = StockDataMaster::where([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'serial_number' => $serialNumber,
|
||||
])->first();
|
||||
|
||||
if ($record) {
|
||||
|
||||
$record->update([
|
||||
'type' => $type,
|
||||
'location' => $location ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'quantity' => $quantity ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
||||
StockDataMaster::create([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'type' => $type,
|
||||
'location' => $location ?? null,
|
||||
'serial_number' => $serialNumber ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'quantity' => $quantity ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your stock data 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;
|
||||
}
|
||||
}
|
||||
@@ -80,17 +80,11 @@ class TestingPanelReadingImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('tested_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
@@ -107,7 +101,7 @@ class TestingPanelReadingImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TestingPanelReading;
|
||||
return new TestingPanelReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -18,7 +18,7 @@ class UserImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant_id')
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
@@ -54,31 +54,31 @@ class UserImporter extends Importer
|
||||
public function resolveRecord(): ?User
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant_id'];
|
||||
$plant = null;
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) <= 0) {
|
||||
$plant = null;
|
||||
$plantCod = null;
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (Str::length($this->data['plant']) > 0) {
|
||||
if (Str::length($this->data['plant']) < 4 || !is_numeric($this->data['plant']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['plant'])) {
|
||||
$warnMsg[] = "Invalid plant code found!";
|
||||
}
|
||||
else {
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$plant = $plant->id ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['name']) < 3) {
|
||||
$warnMsg[] = 'Invalid user name found!';
|
||||
if (Str::length($this->data['name']) < 1) {
|
||||
$warnMsg[] = "User name not found!";
|
||||
}
|
||||
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
||||
if (Str::length($this->data['email']) < 5) {
|
||||
$warnMsg[] = 'Invalid email found!';
|
||||
$warnMsg[] = "Invalid email found!";
|
||||
}
|
||||
if (Str::length($this->data['password']) < 3) {
|
||||
$warnMsg[] = 'Invalid password found!';
|
||||
$warnMsg[] = "Invalid password found!";
|
||||
}
|
||||
// Validate roles if provided
|
||||
$roles = [];
|
||||
@@ -93,8 +93,9 @@ class UserImporter extends Importer
|
||||
$warnMsg[] = "Role : '{$roleName}' does not exist!";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$warnMsg[] = 'User roles not found!';
|
||||
}
|
||||
else {
|
||||
$warnMsg[] = "User roles not found!";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
|
||||
@@ -75,10 +75,10 @@ class WeightValidationImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT NAME')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
@@ -92,75 +92,62 @@ class WeightValidationImporter extends Importer
|
||||
public function resolveRecord(): ?WeightValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$iCode = $this->data['item'];
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
if (Str::length($this->data['item']) < 6 || !ctype_alnum($this->data['item'])) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemAgainstPlant = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemAgainstPlant) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
} else {
|
||||
$itemId = $itemAgainstPlant->id;
|
||||
else
|
||||
{
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
}
|
||||
}
|
||||
else { //if (!$item)
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
|
||||
$obdNum = $this->data['obd_number'];
|
||||
if (Str::length($obdNum) < 8 || !ctype_alnum($obdNum)) {
|
||||
$warnMsg[] = 'Invalid OBD number found';
|
||||
$warnMsg[] = "Invalid OBD number found";
|
||||
}
|
||||
$lineNum = $this->data['line_number'];
|
||||
if (Str::length($lineNum) < 1 || !is_numeric($lineNum)) {
|
||||
$warnMsg[] = 'Invalid line number found';
|
||||
$warnMsg[] = "Invalid line number found";
|
||||
}
|
||||
$batchNum = $this->data['batch_number'];
|
||||
if (Str::length($batchNum) < 8 || !is_numeric($batchNum)) {
|
||||
$warnMsg[] = 'Invalid batch number found';
|
||||
$warnMsg[] = "Invalid batch number found";
|
||||
}
|
||||
$heatNum = $this->data['heat_number'];
|
||||
if (Str::length($heatNum) < 4) {
|
||||
$warnMsg[] = 'Invalid heat number found';
|
||||
$warnMsg[] = "Invalid heat number found";
|
||||
}
|
||||
$actWeight = $this->data['obd_weight'];
|
||||
if (Str::length($actWeight) < 1 || !is_numeric($actWeight)) {
|
||||
$warnMsg[] = 'Invalid actual weight found';
|
||||
$warnMsg[] = "Invalid actual weight found";
|
||||
}
|
||||
$vehicleNum = $this->data['vehicle_number'];
|
||||
if (Str::length($vehicleNum) < 10 || !ctype_alnum($vehicleNum)) {
|
||||
$warnMsg[] = 'Invalid vehicle number found';
|
||||
$warnMsg[] = "Invalid vehicle number found";
|
||||
}
|
||||
$bundleNum = $this->data['bundle_number'];
|
||||
if (Str::length($bundleNum) < 1 || !is_numeric($bundleNum)) {
|
||||
$warnMsg[] = 'Invalid bundle number found';
|
||||
$warnMsg[] = "Invalid bundle number found";
|
||||
}
|
||||
$pickWeight = $this->data['picked_weight'];
|
||||
if (Str::length($pickWeight) < 1 || !is_numeric($pickWeight)) {
|
||||
$warnMsg[] = 'Invalid picked weight found';
|
||||
$warnMsg[] = "Invalid picked weight found";
|
||||
}
|
||||
$scanBy = $this->data['scanned_by'];
|
||||
if (Str::length($scanBy) < 3 || !ctype_alnum($scanBy)) {
|
||||
$warnMsg[] = 'Invalid scanned by name found';
|
||||
$warnMsg[] = "Invalid scanned by name found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -168,19 +155,19 @@ class WeightValidationImporter extends Importer
|
||||
}
|
||||
|
||||
return WeightValidation::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'plant_id' => $plant->id,
|
||||
'obd_number' => $obdNum,
|
||||
'line_number' => $lineNum,
|
||||
'line_number' => $lineNum
|
||||
],
|
||||
[
|
||||
'item_id' => $itemId,
|
||||
'item_id' => $item->id,
|
||||
'batch_number' => $batchNum,
|
||||
'heat_number' => $heatNum,
|
||||
'obd_weight' => $actWeight,
|
||||
'vehicle_number' => $vehicleNum,
|
||||
'bundle_number' => $bundleNum,
|
||||
'picked_weight' => $pickWeight,
|
||||
'scanned_by' => $scanBy,
|
||||
'scanned_by' => $scanBy
|
||||
]
|
||||
);
|
||||
// return WeightValidation::firstOrNew([
|
||||
|
||||
@@ -20,22 +20,22 @@ class WorkGroupMasterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Name')
|
||||
->exampleHeader('Name')
|
||||
->example('RMGCEABC')
|
||||
->label('Work Group Name')
|
||||
->label('Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('description')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Description')
|
||||
->exampleHeader('Description')
|
||||
->example('Testing Model 1')
|
||||
->label('Work Group Description')
|
||||
->label('Description')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operation_number')
|
||||
->requiredMapping()
|
||||
@@ -52,6 +52,8 @@ class WorkGroupMasterImporter extends Importer
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function resolveRecord(): ?WorkGroupMaster
|
||||
{
|
||||
// return WorkGroupMaster::firstOrNew([
|
||||
@@ -59,81 +61,75 @@ class WorkGroupMasterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plantId = null;
|
||||
|
||||
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();
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['name']) <= 0) { //|| !ctype_alnum($this->data['description'])
|
||||
$warnMsg[] = 'Invalid work group name found';
|
||||
$warnMsg[] = "Invalid name found";
|
||||
}
|
||||
|
||||
if (Str::length(trim($this->data['description'])) <= 0) {
|
||||
$warnMsg[] = 'Invalid work group description found';
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
|
||||
$desc = trim($this->data['description']);
|
||||
|
||||
if (Str::length($desc) > 44) {
|
||||
$warnMsg[] = ' work group description should be less than 44 digits.';
|
||||
$warnMsg[] = "Description should be less than 44 digits.";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['operation_number']) <= 0) {
|
||||
$warnMsg[] = 'Invalid operation number found';
|
||||
$warnMsg[] = "Invalid operation number found";
|
||||
}
|
||||
|
||||
if (! is_numeric($this->data['operation_number'])) {
|
||||
$warnMsg[] = 'Invalid operation number found must be numeric';
|
||||
if(!is_numeric($this->data['operation_number']))
|
||||
{
|
||||
$warnMsg[] = "Invalid operation number found must be numeric";
|
||||
}
|
||||
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check (plant_id, name)
|
||||
$existingByName = WorkGroupMaster::where('plant_id', $plantId)
|
||||
$existingByName = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByName) {
|
||||
throw new RowImportFailedException('Work group name already exists for this plant!');
|
||||
throw new RowImportFailedException("Work group name already exists for this plant!");
|
||||
}
|
||||
|
||||
//Check (plant_id, operation_number)
|
||||
$existingByOpNum = WorkGroupMaster::where('plant_id', $plantId)
|
||||
$existingByOpNum = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('operation_number', $this->data['operation_number'])
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByOpNum) {
|
||||
throw new RowImportFailedException('Operation number already exists for this plant!');
|
||||
throw new RowImportFailedException("Operation number already exists for this plant!");
|
||||
}
|
||||
|
||||
//Check (plant_id)
|
||||
$existingByOperator = WorkGroupMaster::where('plant_id', $plantId)
|
||||
$existingByOperator = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByOperator) {
|
||||
throw new RowImportFailedException('Already work group name assigned to another plant!');
|
||||
throw new RowImportFailedException("Already work group name assigned to another plant!");
|
||||
}
|
||||
}
|
||||
|
||||
WorkGroupMaster::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'plant_id' => $plant->id,
|
||||
'name' => $this->data['name'],
|
||||
'description' => $this->data['description'],
|
||||
'operation_number' => $this->data['operation_number'],
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -10,8 +9,6 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -19,108 +16,57 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift';
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.dashboard';
|
||||
|
||||
// public function mount(): void
|
||||
// {
|
||||
// session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
// $this->filtersForm->fill([
|
||||
// 'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// // 'success_status' => null
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// public function filtersForm(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->statePath('filters') // Store form state in 'filters'
|
||||
// ->schema([
|
||||
// Select::make('plant')
|
||||
// ->label('Select Plant')
|
||||
// ->reactive()
|
||||
// // ->options(Plant::pluck('name', 'id'))
|
||||
// ->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,callable $set) {
|
||||
// session(['selected_plant' => $state]); // fixed typo
|
||||
// //$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// // Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
// }),
|
||||
|
||||
// // Select::make('success_status')
|
||||
// // ->label('Select Status')
|
||||
// // ->options([
|
||||
// // 'Ok' => 'Ok',
|
||||
// // 'Not Ok' => 'Not Ok',
|
||||
// // ])
|
||||
// // ->reactive()
|
||||
// // ->afterStateUpdated(function ($state) {
|
||||
// // session(['success_status' => $state]);
|
||||
// // }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
// }
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
public function mount(): void
|
||||
{
|
||||
return '';
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Store form state in 'filters'
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]); // fixed typo
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
}),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Welcome';
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (CumulativeChart::canView()) {
|
||||
$widgets[] = CumulativeChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class InvoiceDataDashboard extends Page
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-data-dashboard';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
protected static ?string $navigationGroup = 'Invoice Management';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
|
||||
@@ -1,460 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Imports\InvoicePendingReasonImport;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Storage;
|
||||
|
||||
class InvoicePendingReason extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-pending-reason';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
|
||||
public ?string $file = null;
|
||||
|
||||
public array $importErrors = [];
|
||||
|
||||
public array $invoicePending = [];
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->filtersForm->fill([
|
||||
'plant_id' => null,
|
||||
'document_number' => null,
|
||||
'remark' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->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,$livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if($plantId){
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
}
|
||||
else{
|
||||
$this->dispatch('emptyData');
|
||||
}
|
||||
|
||||
$set('document_number', null);
|
||||
$set('customer_trade_name', null);
|
||||
$set('location', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Select::make('document_number')
|
||||
->label('Document Number')
|
||||
->required()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
||||
->distinct()
|
||||
->pluck('distribution_channel_desc')
|
||||
->filter(fn ($v) => trim($v) !== '')
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$distributions[] = '';
|
||||
|
||||
$pendingInvoices = collect();
|
||||
|
||||
foreach ($distributions as $distribution) {
|
||||
|
||||
$invoices = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('distribution_channel_desc', $distribution)
|
||||
->select('id', 'document_number')
|
||||
->get()
|
||||
->unique('document_number')
|
||||
->filter(fn ($inv) =>
|
||||
! empty($inv->document_number) &&
|
||||
! str_contains($inv->document_number, '-')
|
||||
);
|
||||
|
||||
if (trim($distribution) == '') {
|
||||
$invoices = $invoices->filter(fn ($inv) =>
|
||||
str_starts_with($inv->document_number, '7')
|
||||
);
|
||||
}
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceNumbers = $invoices->pluck('document_number')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$wentOut = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
->distinct()
|
||||
->pluck('qr_code')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$pending = $invoices->filter(function ($inv) use ($wentOut) {
|
||||
$doc = preg_replace('/\s+/', '', strtoupper($inv->document_number));
|
||||
return ! in_array($doc, $wentOut, true);
|
||||
});
|
||||
|
||||
$pendingInvoices = $pendingInvoices->merge($pending);
|
||||
}
|
||||
|
||||
return $pendingInvoices
|
||||
->unique('document_number')
|
||||
->pluck('document_number', 'document_number')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
$documentNumber = $get('document_number');
|
||||
|
||||
$customers = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->value('customer_trade_name');
|
||||
|
||||
$location = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->value('location');
|
||||
|
||||
$set('customer_trade_name', $customers);
|
||||
$set('location', $location);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pqBlockError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pqBlockError') ? $get('pqBlockError') : null)
|
||||
->hintColor('danger'),
|
||||
TextInput::make('customer_trade_name')
|
||||
->label('Customer Trade Name')
|
||||
->required()
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->columnSpan(1),
|
||||
TextInput::make('location')
|
||||
->label('Location')
|
||||
->required()
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->columnSpan(1),
|
||||
TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->reactive()
|
||||
->maxLength(40)
|
||||
->helperText('Max 40 characters allowed.')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter.prevent' => 'addRemark($event.target.value)',
|
||||
])
|
||||
->autofocus()
|
||||
->required(),
|
||||
FileUpload::make('file')
|
||||
->label('Upload Excel File')
|
||||
->required()
|
||||
->disk('local')
|
||||
->multiple(false)
|
||||
->directory('invoice-pending')
|
||||
->dehydrated(false)
|
||||
//->preserveFilenames()
|
||||
//->storeFiles()
|
||||
//storeFileNamesIn('original_name')
|
||||
// ->visibility('private')
|
||||
->acceptedFileTypes([
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-excel',
|
||||
'text/csv',
|
||||
])
|
||||
->rules(['mimes:xlsx,xls,csv'])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile) {
|
||||
$set('file', $state->store('invoice-pending'));
|
||||
}
|
||||
}),
|
||||
])
|
||||
->columns(3);
|
||||
}
|
||||
|
||||
public function addRemark(){
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$documentNumber = $this->filters['document_number'] ?? null;
|
||||
$remark = $this->filters['remark'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant first..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
if (! $documentNumber) {
|
||||
Notification::make()
|
||||
->title('Document Number')
|
||||
->body("please select document number..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
if ($remark == '') {
|
||||
Notification::make()
|
||||
->title('Remark')
|
||||
->body("Remark can't be empty..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->update([
|
||||
'remark' => $remark,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
'plant_id' => $plantId,
|
||||
'document_number' => $documentNumber,
|
||||
'remark' => null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Remark updated successfully')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
// public function importPendingReason()
|
||||
// {
|
||||
|
||||
// $file = $this->filters['file'] ?? null;
|
||||
|
||||
// $absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
// Excel::import(new InvoicePendingReasonImport, $absolutePath);
|
||||
|
||||
// $this->reset('filters.file');
|
||||
|
||||
// Notification::make()
|
||||
// ->title('File processed and database updated successfully')
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
public function importPendingReason()
|
||||
{
|
||||
$file = $this->filters['file'] ?? null;
|
||||
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (empty($file)) {
|
||||
Notification::make()
|
||||
->title('Please upload a file')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// if (
|
||||
// empty($fileFilter) ||
|
||||
// !is_array($fileFilter) ||
|
||||
// empty($fileFilter[0])
|
||||
// ) {
|
||||
// Notification::make()
|
||||
// ->title('Please upload a file')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// $filePath = $fileFilter[0];
|
||||
|
||||
// if (!is_string($filePath)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid file upload')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
$absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
$import = new InvoicePendingReasonImport();
|
||||
|
||||
try {
|
||||
|
||||
Excel::import(
|
||||
$import,
|
||||
$absolutePath
|
||||
);
|
||||
|
||||
if(!empty($import->plantCodeEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant code can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->docNoEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document number can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (! empty($import->duplicateExcelDocs)) {
|
||||
|
||||
$duplicates = collect($import->duplicateExcelDocs)
|
||||
->map(function ($rows, $key) {
|
||||
[$plant, $doc] = explode('|', $key);
|
||||
return "{$plant}-{$doc}";
|
||||
})
|
||||
->implode(', ');
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Duplicate Document Numbers found in Excel: {$duplicates}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingPlantCodes)) {
|
||||
$codes = implode(', ', array_keys($import->missingPlantCodes));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant codes not found: {$codes}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingDocNo)) {
|
||||
$docNo = implode(', ', array_keys($import->missingDocNo));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document numbers not found: {$docNo}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($import->validRows as $row) {
|
||||
InvoiceDataValidation::where('plant_id', $row['plant_id'])
|
||||
->where('document_number', $row['document_number'])
|
||||
->update([
|
||||
'remark' => $row['remark'],
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Import successful')
|
||||
->body('All records updated successfully.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import error')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function exportPendingReason()
|
||||
{
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId);
|
||||
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice pending reason');
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionCalender extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-calender';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production';
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected $listeners = ['setWorkingDays'];
|
||||
|
||||
public $pId;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function setWorkingDays($days = null)
|
||||
{
|
||||
$this->form->fill([
|
||||
'working_days' => $days ?? 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
//->options(Plant::pluck('name', 'id'))
|
||||
->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();
|
||||
})
|
||||
->columnSpan(['default' => 10, 'sm' => 7])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('working_days', null);
|
||||
}),
|
||||
TextInput::make('working_days')
|
||||
->label('No. of Working Days')
|
||||
->numeric()
|
||||
->readOnly()
|
||||
->columnSpan(['default' => 10, 'sm' => 2])
|
||||
->required()
|
||||
->minValue(0)
|
||||
->maxValue(31)
|
||||
->placeholder('Enter working days')
|
||||
->id('working_days'),
|
||||
|
||||
Hidden::make('month')
|
||||
->label('Month')
|
||||
->id('month'),
|
||||
|
||||
Hidden::make('year')
|
||||
->label('Year')
|
||||
->id('year'),
|
||||
|
||||
Hidden::make('selected_dates')
|
||||
->label('Selected Dates')
|
||||
->id('selected_dates'),
|
||||
|
||||
ViewField::make('save')
|
||||
->view('forms.save')
|
||||
->columnSpan(['default' => 10, 'sm' => 1]),
|
||||
|
||||
ViewField::make('calendar')
|
||||
->view('forms.calendar')
|
||||
->columnspan(10),
|
||||
])
|
||||
->columns(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveWorkingDays(){
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$workingDays = $this->filters['working_days'] ?? null;
|
||||
$month = $this->filters['month'] ?? null;
|
||||
$year = $this->filters['year'] ?? null;
|
||||
$dates = $this->filters['selected_dates'] ?? null;
|
||||
|
||||
if (!$plantId) {
|
||||
Notification::make()
|
||||
->title('Unknown Plant')
|
||||
->body("Please select a plant first!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$workingDays) {
|
||||
Notification::make()
|
||||
->title('Unknown Working Days')
|
||||
->body("Working days can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$month) {
|
||||
Notification::make()
|
||||
->title('Unknown Month')
|
||||
->body("month can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$year) {
|
||||
Notification::make()
|
||||
->title('Unknown Year')
|
||||
->body("Year can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$updated = ProductionPlan::where('plant_id', $plantId)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->update([
|
||||
'working_days' => $workingDays,
|
||||
'leave_dates' => $dates,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if ($updated) {
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Working days updated successfully!")
|
||||
->success()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No Records Updated')
|
||||
->body("No production plans found for this plant and month.")
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production calender page');
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,217 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionTarget extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-target';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production';
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('year')
|
||||
->label('Year')
|
||||
->reactive()
|
||||
// ->searchable()
|
||||
->options([
|
||||
'2025' => '2025',
|
||||
'2026' => '2026',
|
||||
'2027' => '2027',
|
||||
'2028' => '2028',
|
||||
'2029' => '2029',
|
||||
'2030' => '2030',
|
||||
'2031' => '2031',
|
||||
'2032' => '2032',
|
||||
'2033' => '2033',
|
||||
'2034' => '2034',
|
||||
'2035' => '2035',
|
||||
'2036' => '2036',
|
||||
'2037' => '2037',
|
||||
'2038' => '2038',
|
||||
'2039' => '2039',
|
||||
'2040' => '2040',
|
||||
])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$set('month', null);
|
||||
$set('plant_id', null);
|
||||
$set('line_id', null);
|
||||
$set('category', null);
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
// $this->dispatch('loadData',$plantId, $lineId, $state, '');
|
||||
$this->dispatch('loadData',$state, '', '', '', '');
|
||||
}),
|
||||
|
||||
Select::make('month')
|
||||
->label('Month')
|
||||
->reactive()
|
||||
// ->searchable()
|
||||
->options([
|
||||
'01' => 'January',
|
||||
'02' => 'February',
|
||||
'03' => 'March',
|
||||
'04' => 'April',
|
||||
'05' => 'May',
|
||||
'06' => 'June',
|
||||
'07' => 'July',
|
||||
'08' => 'August',
|
||||
'09' => 'September',
|
||||
'10' => 'October',
|
||||
'11' => 'November',
|
||||
'12' => 'December',
|
||||
])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
|
||||
$set('plant_id', null);
|
||||
$set('line_id', null);
|
||||
$set('category', null);
|
||||
|
||||
$year = $get('year');
|
||||
|
||||
$this->dispatch('loadData',$year, $state, '', '', '');
|
||||
|
||||
// $plantId = $get('plant_id');
|
||||
// $lineId = $get('line_id');
|
||||
// // $month = $get('month');
|
||||
// $year = $get('year');
|
||||
|
||||
// $month = (int) $get('month');
|
||||
|
||||
// if (!$month) {
|
||||
// return;
|
||||
// }
|
||||
// $this->dispatch('loadData', $plantId, $lineId, $month, $year);
|
||||
}),
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
// ->searchable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
// dd($state);
|
||||
$set('line_id', null);
|
||||
$set('category', null);
|
||||
$this->dispatch('loadData',$state, '', '', '', '');
|
||||
}),
|
||||
Select::make('line_id')
|
||||
->label('Line')
|
||||
->required()
|
||||
->relationship('line', 'name')
|
||||
// ->searchable()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
// $month = $get('month');
|
||||
$year = $get('year');
|
||||
|
||||
$month = (int) $get('month');
|
||||
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
||||
}),
|
||||
|
||||
TextInput::make('category')
|
||||
->label('Category')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
// $month = $get('month');
|
||||
$year = $get('year');
|
||||
|
||||
$month = (int) $get('month');
|
||||
$category = $get('category');
|
||||
$this->dispatch('loadData',$year, $month, $plantId, $lineId, $category);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(5)
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(){
|
||||
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$lineId = $this->filters['line_id'] ?? null;
|
||||
$year = $this->filters['year'] ?? null;
|
||||
$month = $this->filters['month'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $lineId) {
|
||||
Notification::make()
|
||||
->title('Line')
|
||||
->body("please select line to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $year) {
|
||||
Notification::make()
|
||||
->title('Year')
|
||||
->body("please select year to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $month) {
|
||||
Notification::make()
|
||||
->title('Month')
|
||||
->body("please select month to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production target page');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static ?string $slug = 'production-line-count';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// 'success_status' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->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,callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
}),
|
||||
|
||||
// Select::make('success_status')
|
||||
// ->label('Select Status')
|
||||
// ->options([
|
||||
// 'Ok' => 'Ok',
|
||||
// 'Not Ok' => 'Not Ok',
|
||||
// ])
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['success_status' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class WireMasterPrint extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.wire-master-print';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Packing';
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId, $palletNo, $serialNo;
|
||||
public $snoCount = 0;
|
||||
|
||||
public bool $disableSerialNo = false;
|
||||
public bool $disablePalletNo = false;
|
||||
|
||||
public $locatorNumber;
|
||||
public $state = [];
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $scanLocator;
|
||||
|
||||
public $locators;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=>$this->plantId,
|
||||
'pallet_quantity' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
//->options(Plant::pluck('name', 'id'))
|
||||
->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(),
|
||||
Select::make('customer_po_master_id')
|
||||
->label('Customer PO')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||
})
|
||||
->required(),
|
||||
select::make('scan_pallet_no')
|
||||
->label('Scan Pallet No')
|
||||
->reactive()
|
||||
->options(function ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$customerPoId = $get('customer_po_master_id');
|
||||
|
||||
if (! $plantId || ! $customerPoId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$palletNumbers = WireMasterPacking::query()
|
||||
->select('wire_packing_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('customer_po_master_id', $customerPoId)
|
||||
->whereNotNull('wire_packing_number')
|
||||
->groupBy('wire_packing_number')
|
||||
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||
->orderBy('wire_packing_number', 'asc')
|
||||
->pluck('wire_packing_number')
|
||||
->toArray();
|
||||
|
||||
return collect($palletNumbers)
|
||||
->mapWithKeys(fn ($number) => [$number => $number])
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
$palletNo = $state;
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
})
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processPalletNo($event.target.value)',
|
||||
]),
|
||||
// TextInput::make('customer_name')
|
||||
// ->label('Customer Name')
|
||||
// ->required()
|
||||
// ->reactive(),
|
||||
])
|
||||
->columns(3)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processPalletNo($palletNo)
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$palletNo= $this->form->getState()['scan_pallet_no'];
|
||||
|
||||
$palletNo = trim($palletNo) ?? null;
|
||||
|
||||
$operatorName = Filament::auth()->user()->name;
|
||||
|
||||
if ($palletNo == null || $palletNo == '')
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadLocator' ,'',$plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_no' => null,
|
||||
'scan_pallet_no' => null,
|
||||
'scan_locator_no' => null,
|
||||
'pallet_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
// else if (strlen($palletNo) < 10)
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
// ->danger()
|
||||
// ->duration(5000)
|
||||
// ->send();
|
||||
|
||||
// $this->dispatch('loadLocator' ,'',$plantId);
|
||||
// $this->form->fill
|
||||
// ([
|
||||
// 'plant_id' => $plantId,
|
||||
// 'scan_serial_no' => null,
|
||||
// 'scan_pallet_no' => null,
|
||||
// 'scan_locator_no' => null,
|
||||
// 'pallet_quantity' => 0,
|
||||
// 'created_by' => $operatorName,
|
||||
// 'scanned_by' => $operatorName,
|
||||
// ]);
|
||||
// return;
|
||||
// }
|
||||
|
||||
$Palletexists = WireMasterPacking::where('wire_packing_number', $palletNo)
|
||||
->where('plant_id', $plantId)->first();
|
||||
if(!$Palletexists)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNo' does not found in wire master packing table.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData' ,'',$plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_pallet_no' => null,
|
||||
'pallet_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNo)
|
||||
->count();
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_pallet_no' => $palletNo,
|
||||
'pallet_quantity' => $this->snoCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function saveCustomerPO(){
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$palletNo= $this->form->getState()['scan_pallet_no'];
|
||||
|
||||
$palletNo = trim($palletNo) ?? null;
|
||||
|
||||
$customerPO = $this->form->getState()['customer_po'];
|
||||
|
||||
$customerPO = trim($customerPO) ?? null;
|
||||
|
||||
$customerName = $this->form->getState()['customer_name'];
|
||||
|
||||
$customerName = trim($customerName) ?? null;
|
||||
|
||||
if (!$plantId || !$palletNo) {
|
||||
return; // optional validation
|
||||
}
|
||||
|
||||
$record = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNo)
|
||||
->update([
|
||||
'customer_po' => $customerPO,
|
||||
'customer_name' => $customerName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if($record){
|
||||
Notification::make()
|
||||
->title("Customer PO updated successfully for the pallet number '$palletNo'")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Customer PO updation failed for the pallet number '$palletNo'")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function printPallet()
|
||||
{
|
||||
$palletNumber = $this->form->getState()['scan_pallet_no'] ?? null;
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$customerId = $this->form->getState()['customer_po_master_id'] ?? null;
|
||||
|
||||
$state = $this->form->getState();
|
||||
|
||||
// $customerCode = $state['customer_po'] ?? null;
|
||||
// $customerName = $state['customer_name'] ?? null;
|
||||
|
||||
if (!$palletNumber) {
|
||||
Notification::make()
|
||||
->title("Pallet number cant't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// return redirect()->route('print.pallet', [
|
||||
// 'pallet' => $palletNumber,
|
||||
// 'plant' => $plantId,
|
||||
// ]);
|
||||
$this->dispatch('open-pdf', url: route('print.pallet', [
|
||||
'pallet' => $state['scan_pallet_no'],
|
||||
'plant' => $state['plant_id'],
|
||||
'customer' => $state['customer_po_master_id'],
|
||||
]));
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view wire master print page');
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,28 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\AlertMailRuleExporter;
|
||||
use App\Filament\Imports\AlertMailRuleImporter;
|
||||
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceMaster;
|
||||
use App\Models\Plant;
|
||||
use Dotenv\Exception\ValidationException;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
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\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Illuminate\Validation\ValidationException as ValidationValidationException;
|
||||
|
||||
class AlertMailRuleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AlertMailRule::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-m-bell-alert';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Alert Mail';
|
||||
|
||||
@@ -43,8 +38,7 @@ class AlertMailRuleResource extends Resource
|
||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(fn ($get) => ! $get('is_active'))
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||
@@ -57,7 +51,6 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceDataReport' => 'InvoiceDataReport',
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
'QualityValidation' => 'QualityValidation',
|
||||
'InvoiceTransit' => 'InvoiceTransit',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -68,7 +61,6 @@ class AlertMailRuleResource extends Resource
|
||||
'ProductionMail' => 'Production Mail',
|
||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
||||
'QualityMail' => 'Quality Mail',
|
||||
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
@@ -78,81 +70,35 @@ class AlertMailRuleResource extends Resource
|
||||
->label('CC Emails'),
|
||||
Forms\Components\Select::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->required()
|
||||
->options([
|
||||
'Live' => 'Live',
|
||||
'Hourly' => 'Hourly',
|
||||
'Daily' => 'Daily',
|
||||
]),
|
||||
Forms\Components\Select::make('receiving_plant_name')
|
||||
->label('Receiving Plant')
|
||||
->options(
|
||||
InvoiceMaster::query()
|
||||
->whereNotNull('receiving_plant_name')
|
||||
->select('receiving_plant_name')
|
||||
->distinct()
|
||||
->pluck('receiving_plant_name', 'receiving_plant_name')
|
||||
)
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('invoice_master_id', null);
|
||||
}),
|
||||
Forms\Components\Select::make('invoice_master_id')
|
||||
->label('Transporter Name')
|
||||
->options(function (callable $get) {
|
||||
$recPlant = $get('receiving_plant_name');
|
||||
|
||||
if (! $recPlant) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return InvoiceMaster::query()
|
||||
->where('receiving_plant_name', $recPlant)
|
||||
->whereNotNull('transport_name')
|
||||
->where('transport_name', '!=', '')
|
||||
->orderBy('transport_name')
|
||||
->pluck('transport_name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->searchable(),
|
||||
Checkbox::make('is_active')
|
||||
->label('All Plants Reports')
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
|
||||
->reactive(),
|
||||
// Forms\Components\Actions::make([
|
||||
// Action::make('sendInvoiceData')
|
||||
// ->label('Invoice Data Report')
|
||||
// ->action(function ($get) {
|
||||
|
||||
// $plantIds = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
// ->orderBy('plant')
|
||||
// ->pluck('plant')
|
||||
// ->toArray();
|
||||
|
||||
// foreach ($plantIds as $plantId) {
|
||||
// Artisan::call('send:invoice-data-report', [
|
||||
// 'schedule_type' => 'Daily',
|
||||
// 'plant' => $plantId,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // Notify user in Filament
|
||||
// Notification::make()
|
||||
// ->title('Invoice data report sent successfully!')
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }),
|
||||
|
||||
// ]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(2),
|
||||
->columns(6),
|
||||
]);
|
||||
}
|
||||
|
||||
// Optionally, also override for update/editing
|
||||
// public static function mutateFormDataBeforeSave(array $data): array
|
||||
// {
|
||||
// dd('test');
|
||||
// if ($data['is_active']) {
|
||||
// $data['plant'] = 'All Plants';
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -163,7 +109,6 @@ class AlertMailRuleResource 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')
|
||||
@@ -176,7 +121,6 @@ class AlertMailRuleResource extends Resource
|
||||
if (! $plants) {
|
||||
$plants = Plant::pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
return $plants[$state] ?? 'All Plants';
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('module')
|
||||
@@ -189,14 +133,6 @@ class AlertMailRuleResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name')
|
||||
->label('Receiving Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoiceMaster.transport_name')
|
||||
->label('Transporter')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('TO Emails')
|
||||
->searchable()
|
||||
@@ -253,22 +189,6 @@ class AlertMailRuleResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Alert Mail Rule')
|
||||
->color('warning')
|
||||
->importer(AlertMailRuleImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import alert mail rule');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Alert Mail Rule')
|
||||
->color('warning')
|
||||
->exporter(AlertMailRuleExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export alert mail rule');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user