Compare commits
1 Commits
jothi-patc
...
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,236 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Scheduler extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:scheduler';
|
||||
|
||||
protected $signature = 'custom:scheduler';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $description = 'Command description';
|
||||
|
||||
protected $description = 'Manually trigger scheduler logic';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
// public function handle()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
// --- Production Rules ---
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($productionRules as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:production-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:production-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:production-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Invoice Validation Rules ---
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'InvoiceMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
|
||||
// switch ($rule->schedule_type) {
|
||||
// case 'Live':
|
||||
// try {
|
||||
// Artisan::call('send:invoice-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// ]);
|
||||
|
||||
// Log::info('Invoice report sent | Plant: '.$rule->plant);
|
||||
// } catch (\Throwable $e) {
|
||||
// Log::error("Invoice Live Failed ({$rule->plant}): ".$e->getMessage());
|
||||
// }
|
||||
// break;
|
||||
|
||||
// case 'Hourly':
|
||||
// if (now()->minute == 0) {
|
||||
// Artisan::call('send:invoice-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
|
||||
// case 'Daily':
|
||||
// if (now()->format('H:i') == '07:59') {
|
||||
// Artisan::call('send:invoice-report', [
|
||||
// 'schedule_type' => $rule->schedule_type,
|
||||
// 'plant' => $rule->plant,
|
||||
// ]);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// --- Invoice Data Report Rules ---
|
||||
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
->where('rule_name', 'InvoiceDataMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceDataRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '10:00') {
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$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') == '10:00') {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to call Artisan commands with parameters.
|
||||
*/
|
||||
protected function callArtisanCommand($commandName, $rule)
|
||||
{
|
||||
\Artisan::call($commandName, [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
|
||||
$this->info("Executed {$commandName} for plant: {$rule->plant}");
|
||||
\Log::info("Executed {$commandName} for plant: {$rule->plant}");
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\test;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\test;
|
||||
|
||||
class SendInvoiceReport extends Command
|
||||
{
|
||||
@@ -15,8 +15,9 @@ class SendInvoiceReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report {schedule_type} {plant}';
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -28,10 +29,12 @@ class SendInvoiceReport extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
// $scheduleType = $this->argument('scheduleType');
|
||||
//$scheduleType = $this->argument('scheduleType');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
@@ -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;
|
||||
|
||||
@@ -82,7 +89,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('scanned_status', 'Scanned')
|
||||
->where(function ($query) {
|
||||
->where(function($query) {
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
@@ -121,7 +128,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -157,7 +164,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -186,6 +193,7 @@ class SendInvoiceReport extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
@@ -204,14 +212,16 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\InvoiceTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
')
|
||||
)
|
||||
->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
|
||||
')
|
||||
->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; // ❌ DO NOT SEND MAIL
|
||||
}
|
||||
|
||||
$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,13 +2,15 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ProductionMail;
|
||||
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
|
||||
{
|
||||
@@ -17,7 +19,7 @@ class SendProductionReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'send:production-report';
|
||||
//protected $signature = 'send:production-report';
|
||||
protected $signature = 'send:production-report {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
@@ -30,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
|
||||
@@ -52,30 +55,33 @@ 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) {
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
@@ -84,7 +90,6 @@ class SendProductionReport extends Command
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
/** @phpstan-ignore property.notFound */
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
@@ -108,7 +113,9 @@ class SendProductionReport extends Command
|
||||
}
|
||||
}
|
||||
|
||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
|
||||
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
@@ -121,7 +128,7 @@ class SendProductionReport extends Command
|
||||
// }
|
||||
|
||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
// Preview in console
|
||||
// Preview in console
|
||||
$mail = new ProductionMail($scheduleType, $tableData);
|
||||
$contentVars = $mail->content()->with;
|
||||
|
||||
@@ -133,39 +140,13 @@ class SendProductionReport extends Command
|
||||
$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,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;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CharacteristicValue;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CharacteristicValueExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CharacteristicValue::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
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('machine.name')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('PROCESS ORDER'),
|
||||
ExportColumn::make('coil_number')
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
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')
|
||||
->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;
|
||||
}
|
||||
}
|
||||
@@ -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')
|
||||
@@ -60,23 +58,23 @@ class InvoiceValidationExporter extends Exporter
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your invoice validation export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
$body = 'Your invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -1,71 +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('line.name')
|
||||
->label('LINE NAME'), // machine.workGroupMaster.name
|
||||
ExportColumn::make('machine.workGroupMaster.name')
|
||||
->label('WORK GROUP MASTER'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('characteristics_type')
|
||||
->label('CHARACTERISTICS TYPE'),
|
||||
ExportColumn::make('name')
|
||||
->label('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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,260 +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 Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
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('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('RAW01234')
|
||||
->label('Created By'),
|
||||
];
|
||||
}
|
||||
|
||||
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']);
|
||||
$status = trim($this->data['status']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
$coilNo = trim($this->data['coil_number']);
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
$warnMsg[] = 'Plant code cannot be empty';
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
} elseif ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = 'Work center cannot be empty';
|
||||
} elseif ($lineName == null || $lineName == '') {
|
||||
$warnMsg[] = 'Line cannot be empty';
|
||||
}
|
||||
|
||||
if (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) < 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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 ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$warnMsg[] = 'Coil No cannot be empty';
|
||||
} elseif (! is_numeric($coilNo)) {
|
||||
$warnMsg[] = 'Coil number should contain only numeric values!';
|
||||
}
|
||||
|
||||
if ($status == null || $status == '' || ! $status) {
|
||||
$warnMsg[] = 'Status cannot be empty';
|
||||
} elseif (! in_array($status, ['Ok', 'NotOk'], true)) {
|
||||
$warnMsg[] = "Status must be either 'Ok' or 'NotOk'!";
|
||||
}
|
||||
|
||||
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
|
||||
$warnMsg[] = 'Created By cannot be empty';
|
||||
}
|
||||
|
||||
// $existing = CharacteristicValue::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
// if ($existing) {
|
||||
// $warnMsg[] = "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!";
|
||||
// }
|
||||
|
||||
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 != '') {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return CharacteristicValue::create([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $LineId,
|
||||
'machine_id' => $machineId,
|
||||
'process_order' => trim($this->data['process_order']),
|
||||
'coil_number' => trim($this->data['coil_number']),
|
||||
'status' => trim($this->data['status']),
|
||||
'created_by' => trim($this->data['created_by']),
|
||||
]);
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found'; // '" . $plantCod . "'
|
||||
}
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
// if (Str::length($this->data['uom']) <= 0) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
if (Str::length($description) < 5) {
|
||||
$warnMsg[] = 'Invalid description found';
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || ! is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
$warnMsg[] = 'Invalid hourly quantity found';
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
$warnMsg[] = "Invalid hourly quantity found";
|
||||
}
|
||||
if (! empty($warnMsg)) {
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return Item::updateOrCreate([
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id,
|
||||
],
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'category' => trim($this->data['category']),
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => trim($this->data['uom']),
|
||||
'uom' => trim($this->data['uom'])
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
|
||||
@@ -10,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
|
||||
@@ -39,57 +38,41 @@ class ProcessOrderImporter extends Importer
|
||||
->example('202500123456')
|
||||
->label('PROCESS ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('order_quantity')
|
||||
->exampleHeader('ORDER QUANTITY')
|
||||
->example('100')
|
||||
->label('ORDER QUANTITY')
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('created_by')
|
||||
// ->exampleHeader('CREATED BY')
|
||||
// ->example('RAW01234')
|
||||
// ->label('CREATED BY')
|
||||
// ->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProcessOrder
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
$itemCode = Item::where('code', $this->data['item'])->first();
|
||||
$iCode = trim($this->data['item']);
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $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();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} elseif (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';
|
||||
}
|
||||
} elseif (! $itemCode) {
|
||||
$warnMsg[] = 'Item Code not found';
|
||||
}
|
||||
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
|
||||
if ($processOrder == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found';
|
||||
// }
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'User not found';
|
||||
}
|
||||
|
||||
if ($plant && $itemCode && $processOrder != '') {
|
||||
if ($plant && $processOrder != '') {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -111,7 +94,7 @@ class ProcessOrderImporter extends Importer
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => 0,
|
||||
'received_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'created_by' => $user->name,
|
||||
]);
|
||||
|
||||
// return new ProcessOrder();
|
||||
|
||||
@@ -1,277 +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 Illuminate\Support\Facades\Auth;
|
||||
use Str;
|
||||
|
||||
class ProductCharacteristicsMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ProductCharacteristicsMaster::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('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group Work Center')
|
||||
->example('RMGCGABC')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristics_type')
|
||||
->exampleHeader('Characteristics Type')
|
||||
->example('Process or Product')
|
||||
->label('Characteristics Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->exampleHeader('Characteristics Name')
|
||||
->example('Body')
|
||||
->label('Characteristics Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('inspection_type')
|
||||
->exampleHeader('Inspection Type')
|
||||
->example('Visual or Value')
|
||||
->label('Inspection Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lower')
|
||||
->exampleHeader('Lower')
|
||||
->example('-0.2')
|
||||
->label('Lower')
|
||||
->rules(['numeric']),
|
||||
ImportColumn::make('middle')
|
||||
->exampleHeader('Middle')
|
||||
->example('1')
|
||||
->label('Middle')
|
||||
->numeric()
|
||||
->rules(['numeric']),
|
||||
ImportColumn::make('upper')
|
||||
->exampleHeader('Upper')
|
||||
->example('0.2')
|
||||
->label('Upper')
|
||||
->rules(['numeric']),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By'),
|
||||
// ImportColumn::make('updated_by'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$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();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$itemExists = Item::where('code', $this->data['item'])->first();
|
||||
if (! $itemExists) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
}
|
||||
|
||||
$itemAgainstPlant = Item::where('code', $this->data['item'])
|
||||
->where('plant_id', $plant->id)
|
||||
->first();
|
||||
if (! $itemAgainstPlant) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
} else {
|
||||
$itemId = $itemAgainstPlant->id;
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $this->data['line'])->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
}
|
||||
|
||||
$lineAgainstPlant = Line::where('name', $this->data['line'])
|
||||
->where('plant_id', $plant->id)
|
||||
->first();
|
||||
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line not found for the given plant';
|
||||
} else {
|
||||
$LineId = $lineAgainstPlant->id;
|
||||
}
|
||||
|
||||
$WorkgroupMaster = WorkGroupMaster::where('name', $this->data['work_group_master_id'])->where('plant_id', $plant->id)->first();
|
||||
if (! $WorkgroupMaster) {
|
||||
$warnMsg[] = 'Work Group Master value not found';
|
||||
} else {
|
||||
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
|
||||
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
|
||||
$existsInLine = Line::where('plant_id', $plant->id)
|
||||
->where(function ($q) use ($workGroupMasterId) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
|
||||
}
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (! $existsInLine) {
|
||||
$warnMsg[] = "Work Group Master '{$WorkgroupMaster->name}' is not mapped to any line in this plant";
|
||||
} else {
|
||||
$workGroupMasterId = $WorkgroupMaster->id;
|
||||
}
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $this->data['machine'])->first();
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work Center not found';
|
||||
} else {
|
||||
$machineId = $machine->id;
|
||||
}
|
||||
|
||||
$machineAgainstPlant = Machine::where('work_center', $this->data['machine'])
|
||||
->where('plant_id', $plant->id)
|
||||
->first();
|
||||
|
||||
if (! $machineAgainstPlant) {
|
||||
$warnMsg[] = 'Work Center not found for the given plant';
|
||||
} else {
|
||||
$machineId = $machineAgainstPlant->id;
|
||||
}
|
||||
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (! $user) {
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
}
|
||||
|
||||
if (($this->data['inspection_type'] ?? null) == 'Value') {
|
||||
$upper = $this->data['upper'] ?? null;
|
||||
$lower = $this->data['lower'] ?? null;
|
||||
$middle = $this->data['middle'] ?? null;
|
||||
|
||||
if (is_null($upper) || is_null($lower) || is_null($middle)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, Upper, Lower, and Middle values are required.";
|
||||
} elseif (! is_numeric($upper) || ! is_numeric($lower) || ! is_numeric($middle)) {
|
||||
$warnMsg[] = 'Upper, Lower, and Middle values must be numeric.';
|
||||
} elseif (! ($lower <= $middle && $middle <= $upper)) {
|
||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower ≤ Middle ≤ Upper.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else {
|
||||
$record = ProductCharacteristicsMaster::firstOrNew([
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $itemId,
|
||||
'line_id' => $LineId,
|
||||
'work_group_master_id' => $workGroupMasterId,
|
||||
'machine_id' => $machineId,
|
||||
]);
|
||||
|
||||
$currentUser = Auth::check() ? Auth::user()->name : ($this->data['created_by'] ?? 'System');
|
||||
|
||||
// If record is new, fill all fields
|
||||
if (! $record->exists) {
|
||||
$record->name = $this->data['name'];
|
||||
$record->characteristics_type = $this->data['characteristics_type'];
|
||||
$record->inspection_type = $this->data['inspection_type'];
|
||||
$record->upper = $this->data['upper'] ?? null;
|
||||
$record->lower = $this->data['lower'] ?? null;
|
||||
$record->middle = $this->data['middle'] ?? null;
|
||||
$record->created_by = $currentUser;
|
||||
} else {
|
||||
// Record exists → update only updated_by and updated_at
|
||||
$record->updated_by = $currentUser;
|
||||
$record->touch();
|
||||
}
|
||||
|
||||
$record->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// ProductCharacteristicsMaster::updateOrCreate(
|
||||
// [
|
||||
// 'plant_id' => $plant->id,
|
||||
// 'item_id' => $itemId,
|
||||
// 'line_id' => $LineId,
|
||||
// 'work_group_master_id' => $workGroupMasterId,
|
||||
// 'machine_id'=> $machineId,
|
||||
|
||||
// ],
|
||||
// [
|
||||
// 'name' => $this->data['name'],
|
||||
// 'characteristics_type' => $this->data['characteristics_type'],
|
||||
// 'inspection_type' => $this->data['inspection_type'],
|
||||
// 'upper' => $this->data['upper'] ?? null,
|
||||
// 'lower' => $this->data['lower'] ?? null,
|
||||
// 'middle' => $this->data['middle'] ?? null,
|
||||
// //'created_by' => user ?? $this->data['created_by'],
|
||||
// 'created_by' => Auth::check() ? Auth::user()->name :($this->data['created_by'] ?? null)
|
||||
// ]
|
||||
// );
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// return new WorkGroupMaster();
|
||||
|
||||
// return new ProductCharacteristicsMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your product characteristics master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -641,322 +641,322 @@ class StickerReprint extends Page implements HasForms
|
||||
|
||||
// ********************************
|
||||
|
||||
// $exists = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
// ->where('shift_id', $this->sId)
|
||||
// ->where('line_id', $this->lId)
|
||||
// ->whereDate('created_at', today())
|
||||
// ->latest()
|
||||
// ->exists();
|
||||
$exists = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
->where('shift_id', $this->sId)
|
||||
->where('line_id', $this->lId)
|
||||
->whereDate('created_at', today())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
// if ($exists)
|
||||
// {
|
||||
// $currentDate = date('Y-m-d');
|
||||
if ($exists)
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
// $shiftId = Shift::where('id', $this->sId)
|
||||
// ->first();
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// //$miNs = (int) $miNs;-*/
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
//$miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// Check if current date time is within the range
|
||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Shift')
|
||||
// ->body("Please select a valid shift.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
// ->where('shift_id', $this->sId)
|
||||
// ->where('line_id', $this->lId)
|
||||
// ->whereDate('created_at', Carbon::yesterday())
|
||||
// ->latest()
|
||||
// ->exists();
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
->where('shift_id', $this->sId)
|
||||
->where('line_id', $this->lId)
|
||||
->whereDate('created_at', Carbon::yesterday())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
// if ($existShifts) //if ($existShifts->count() > 0)
|
||||
// { // record exist on yesterday
|
||||
// //$currentDate = date('Y-m-d');
|
||||
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
if ($existShifts) //if ($existShifts->count() > 0)
|
||||
{ // record exist on yesterday
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
// $shiftId = Shift::where('id', $this->sId)
|
||||
// ->first();
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $currentDate = date('Y-m-d');
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
// $shiftId = Shift::where('id', $this->sId)
|
||||
// ->first();
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Plan Not Found')
|
||||
// ->body("Please set production plan first.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Shift')
|
||||
// ->body("Please select a valid shift.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// { // record not exist on yesterday
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // record not exist on yesterday
|
||||
|
||||
// //$currentDate = date('Y-m-d');
|
||||
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
// $shiftId = Shift::where('id', $this->sId)
|
||||
// ->first();
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Plan Not Found')
|
||||
// ->body("Please set production plan first.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $currentDate = date('Y-m-d');
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
// $shiftId = Shift::where('id', $this->sId)
|
||||
// ->first();
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Plan Not Found')
|
||||
// ->body("Please set production plan first.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Shift')
|
||||
// ->body("Please select a valid shift.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// //$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************
|
||||
|
||||
@@ -976,9 +976,7 @@ class StickerReprint extends Page implements HasForms
|
||||
]);
|
||||
}
|
||||
|
||||
// if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData))
|
||||
// {
|
||||
if (!preg_match('/^[A-Za-z0-9]{6,}\|[1-9][A-Za-z0-9]{7,}(\/[A-Za-z0-9]*)?(\|)?$/', $formQRData)) {
|
||||
if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
|
||||
if (strpos($formQRData, '|') === false) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1006,14 +1004,7 @@ class StickerReprint extends Page implements HasForms
|
||||
{
|
||||
$splits = explode('|', $formQRData);
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumberRaw = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if ($sNumberRaw !== null) {
|
||||
$sNumber = preg_replace('/\/.*/', '', $sNumberRaw);
|
||||
$sNumber = trim($sNumber);
|
||||
} else {
|
||||
$sNumber = null;
|
||||
}
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if (!ctype_alnum($iCode)) {
|
||||
$this->form->fill([
|
||||
@@ -1061,7 +1052,6 @@ class StickerReprint extends Page implements HasForms
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!ctype_alnum($sNumber)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1155,33 +1145,9 @@ class StickerReprint extends Page implements HasForms
|
||||
// Only search when all parent IDs are selected
|
||||
$parts = explode('|', $formQRData);
|
||||
$itemCode = trim($parts[0]);
|
||||
|
||||
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// // Remove slash and everything after it
|
||||
// if ($serialNumberRaw != null) {
|
||||
// $serialNumber = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
// $serialNumber = trim($serialNumber);
|
||||
// } else {
|
||||
// $serialNumber = null;
|
||||
// }
|
||||
if ($serialNumberRaw != null) {
|
||||
if (strpos($serialNumberRaw, '/') !== false) {
|
||||
$serialNumber = strstr($serialNumberRaw, '/', true); // gets text before slash
|
||||
} else {
|
||||
$serialNumber = $serialNumberRaw; // keep original
|
||||
|
||||
}
|
||||
|
||||
$serialNumber = trim($serialNumber);
|
||||
|
||||
} else {
|
||||
$serialNumber = null;
|
||||
}
|
||||
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
|
||||
if (!$item) {
|
||||
// Handle unknown item code
|
||||
$this->form->fill([
|
||||
@@ -1284,86 +1250,86 @@ class StickerReprint extends Page implements HasForms
|
||||
return;
|
||||
}
|
||||
|
||||
//$line = Line::find($this->lId);
|
||||
//$lineName = $line ? $line->name : null;
|
||||
$line = Line::find($this->lId);
|
||||
$lineName = $line ? $line->name : null;
|
||||
|
||||
// $categoryName = (Str::length($item->category) > 0) ? $item->category : "";
|
||||
$categoryName = (Str::length($item->category) > 0) ? $item->category : "";
|
||||
|
||||
// if ($categoryName == 'Submersible Motor')
|
||||
// {
|
||||
// if ($lineName != '6 inch motor line')
|
||||
// {
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Line Found')
|
||||
// ->body("Choose '6 inch motor line' to proceed..!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// else if ($categoryName == 'Submersible Pump')
|
||||
// {
|
||||
// if ($lineName != '6 inch pump line')
|
||||
// {
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Line Found')
|
||||
// ->body("Choose '6 inch pump line' to proceed..!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $this->form->fill([
|
||||
// 'plant_id'=> $this->pId,
|
||||
// 'block_name'=> $this->bId,
|
||||
// 'shift_id'=> $this->sId,
|
||||
// 'line_id'=> $this->lId,
|
||||
// 'item_id'=> null,
|
||||
// 'serial_number'=> null,
|
||||
// 'success_msg'=> null,
|
||||
// 'production_order'=> $this->prodOrder,
|
||||
// 'sap_msg_status' => null,
|
||||
// 'sap_msg_description' => null,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'recent_qr' => $this->recQr,
|
||||
// ]);
|
||||
// Notification::make()
|
||||
// ->title('Invalid Category Found')
|
||||
// ->body("Set proper category to proceed..!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
if ($categoryName == 'Submersible Motor')
|
||||
{
|
||||
if ($lineName != '6 inch motor line')
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Line Found')
|
||||
->body("Choose '6 inch motor line' to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ($categoryName == 'Submersible Pump')
|
||||
{
|
||||
if ($lineName != '6 inch pump line')
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Line Found')
|
||||
->body("Choose '6 inch pump line' to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'sap_msg_status' => null,
|
||||
'sap_msg_description' => null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Category Found')
|
||||
->body("Set proper category to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->succId == null) {
|
||||
$this->form->fill([
|
||||
@@ -1398,42 +1364,6 @@ class StickerReprint extends Page implements HasForms
|
||||
$itemCode = trim($parts[0]);
|
||||
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
$originalQR = $this->qrData;
|
||||
|
||||
if (strpos($originalQR, '/') != false)
|
||||
{
|
||||
// Allowed endings
|
||||
$allowed = ['/m', '/M', '/p', '/P', '/m|', '/M|', '/p|', '/P|'];
|
||||
|
||||
$foundValidEnding = false;
|
||||
|
||||
foreach ($allowed as $end) {
|
||||
if (str_ends_with($originalQR, $end)) {
|
||||
$foundValidEnding = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$foundValidEnding) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Code')
|
||||
->body("Invalid QR format: '$originalQR'")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sNoId != null) {
|
||||
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$this->sNoId = trim($this->sNoId);
|
||||
} else {
|
||||
$this->sNoId = null;
|
||||
}
|
||||
|
||||
//$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||
|
||||
ProductionQuantity::create([
|
||||
'plant_id'=> $this->pId,
|
||||
'shift_id'=> $this->sId,
|
||||
@@ -1448,6 +1378,7 @@ class StickerReprint extends Page implements HasForms
|
||||
|
||||
// after success insertion
|
||||
$this->form->fill([
|
||||
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
@@ -1470,7 +1401,7 @@ class StickerReprint extends Page implements HasForms
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
$url = route('download-qr1-pdf', ['palletNo' => urlencode($originalQR)]);
|
||||
$url = route('download-qr1-pdf', ['palletNo' => $this->qrData]);
|
||||
$this->js(<<<JS
|
||||
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||
detail: {
|
||||
@@ -1487,16 +1418,11 @@ class StickerReprint extends Page implements HasForms
|
||||
// Save the form data to the database or perform other operations
|
||||
// For example:
|
||||
$model = ProductionQuantity::create($formValues);
|
||||
// $formValues['serial_number'] = $this->serialNumber;
|
||||
|
||||
// ProductionQuantity::create($formValues);
|
||||
|
||||
// dd('Production Updated Event Dispatched');
|
||||
|
||||
$this->dispatch('productionUpdated');
|
||||
|
||||
|
||||
|
||||
// // Optionally, you can emit an event or perform a redirect after saving
|
||||
// $this->emit('formSaved', $model->id);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
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;
|
||||
@@ -20,13 +17,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException as ValidationValidationException;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class AlertMailRuleResource extends Resource
|
||||
{
|
||||
@@ -60,7 +51,6 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceDataReport' => 'InvoiceDataReport',
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
'QualityValidation' => 'QualityValidation',
|
||||
'InvoiceTransit' => 'InvoiceTransit',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -71,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')
|
||||
@@ -81,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
|
||||
@@ -190,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()
|
||||
@@ -254,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');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,525 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CharacteristicValueExporter;
|
||||
use App\Filament\Imports\CharacteristicValueImporter;
|
||||
use App\Filament\Resources\CharacteristicValueResource\Pages;
|
||||
use App\Filament\Resources\CharacteristicValueResource\RelationManagers;
|
||||
use App\Models\CharacteristicValue;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
class CharacteristicValueResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CharacteristicValue::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Process Order';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('item_id', null);
|
||||
$set('line_id', null);
|
||||
$set('machine_id', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('poPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('item_id', null);
|
||||
$set('machine_id', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('line_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('machine_id', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required()
|
||||
->searchable(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Machine')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('line_id') || !$get('item_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $get('plant_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('process_order', null);
|
||||
$set('coil_number', null);
|
||||
$set('status', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', null);
|
||||
$set('status', null);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('coil_number')
|
||||
->label('Coil Number')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// $set('status', null);
|
||||
// if (! $plantId) {
|
||||
// $set('poPlantError', 'Please select a plant first.');
|
||||
// }
|
||||
// })
|
||||
// ->required(),
|
||||
->label('Coil Number')
|
||||
->default('0')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = $get('process_order');
|
||||
$coilNo = $get('coil_number');
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
} elseif (! $processOrder) {
|
||||
$set('coil_number', null);
|
||||
$set('poPlantError', null);
|
||||
} elseif ($coilNo || $coilNo == '0') {
|
||||
$existing = CharacteristicValue::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
$set('poPlantError', null);
|
||||
$set('coil_number', null);
|
||||
$set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
|
||||
} else {
|
||||
$set('poPlantError', null);
|
||||
$set('coilNumberError', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('coilNumberError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('coilNumberError') ? $get('coilNumberError') : null)
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('observed_value')
|
||||
->label('Observed Value')
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Ok' => 'OK',
|
||||
'NotOk' => 'Not Ok'
|
||||
])
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Machine')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('process_order')
|
||||
->label('Process Order')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('coil_number')
|
||||
->label('Coil Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('observed_value')
|
||||
->label('Observed value')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Select::make('Machine')
|
||||
->label('Select Machine')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
|
||||
if(empty($plantId) || empty($lineId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->placeholder('Enter Process Order'),
|
||||
TextInput::make('coil_number')
|
||||
->label('Coil Number')
|
||||
->placeholder(placeholder: 'Enter Coil Number'),
|
||||
Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Ok' => 'OK',
|
||||
'NotOk' => 'Not Ok'
|
||||
]),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['Machine']) && empty($data['process_order']) && empty($data['coil_number']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (!empty($data['Machine'])) {
|
||||
$query->where('machine_id', $data['Machine']);
|
||||
}
|
||||
|
||||
if (!empty($data['process_order'])) {
|
||||
$query->where('process_order', $data['process_order']);
|
||||
}
|
||||
|
||||
if (!empty($data['coil_number'])) {
|
||||
$query->where('coil_number', $data['coil_number']);
|
||||
}
|
||||
|
||||
if (!empty($data['status'])) {
|
||||
$query->where('status', $data['status']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
|
||||
//$query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Line'])) {
|
||||
$indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (!empty($data['Machine'])) {
|
||||
$indicators[] = 'Machine: ' . Machine::where('id', $data['Machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (!empty($data['process_order'])) {
|
||||
$indicators[] = 'Process Order: ' . $data['process_order'];
|
||||
}
|
||||
|
||||
if (!empty($data['coil_number'])) {
|
||||
$indicators[] = 'Coil Number: ' . $data['coil_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['status'])) {
|
||||
$indicators[] = 'Status: ' . $data['status'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(CharacteristicValueImporter::class)
|
||||
->label('Import Characteristic Value')
|
||||
->color('warning')
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import characteristic value');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(CharacteristicValueExporter::class)
|
||||
->label('Export Characteristic Value')
|
||||
->color('warning')
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export characteristic value');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCharacteristicValues::route('/'),
|
||||
'create' => Pages\CreateCharacteristicValue::route('/create'),
|
||||
'view' => Pages\ViewCharacteristicValue::route('/{record}'),
|
||||
'edit' => Pages\EditCharacteristicValue::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicValueResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCharacteristicValue extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicValueResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicValueResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCharacteristicValue extends EditRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicValueResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicValueResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCharacteristicValues extends ListRecords
|
||||
{
|
||||
protected static string $resource = CharacteristicValueResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicValueResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicValueResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCharacteristicValue extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicValueResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class InvoiceDataValidationResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
protected static ?string $navigationGroup = 'Invoice Management';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
@@ -1,630 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\InvoiceInTransitExporter;
|
||||
use App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||
use App\Filament\Resources\InvoiceInTransitResource\RelationManagers;
|
||||
use App\Models\InvoiceInTransit;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Carbon\Carbon;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
|
||||
|
||||
class InvoiceInTransitResource extends Resource
|
||||
{
|
||||
protected static ?string $model = InvoiceInTransit::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('receiving_plant')
|
||||
->label('Receiving Plant'),
|
||||
Forms\Components\TextInput::make('receiving_plant_name')
|
||||
->label('Receiving Plant Name'),
|
||||
Forms\Components\TextInput::make('invoice_number')
|
||||
->label('Invoice Number'),
|
||||
Forms\Components\TextInput::make('invoice_date')
|
||||
->label('Invoice Date'),
|
||||
Forms\Components\TextInput::make('item_code')
|
||||
->label('Item Code'),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description'),
|
||||
Forms\Components\TextInput::make('quantity')
|
||||
->label('Quantity')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('transport_name')
|
||||
->label('Transport Name'),
|
||||
Forms\Components\TextInput::make('lr_bl_aw_number')
|
||||
->label('LR/BL/AW Number'),
|
||||
Forms\Components\TextInput::make('lr_bl_aw_date')
|
||||
->label('LR/BL/AW Date'),
|
||||
Forms\Components\TextInput::make('pending_days')
|
||||
->label('Pending Days'),
|
||||
Forms\Components\TextInput::make('obd_number')
|
||||
->label('OBD Number'),
|
||||
Forms\Components\TextInput::make('obd_date')
|
||||
->label('OBD Date'),
|
||||
Forms\Components\TextInput::make('shipment_weight')
|
||||
->label('Shipment Weight'),
|
||||
Forms\Components\TextInput::make('unit_price')
|
||||
->label('Unit Price'),
|
||||
Forms\Components\TextInput::make('net_value')
|
||||
->label('Net value'),
|
||||
Forms\Components\TextInput::make('total_item_amount')
|
||||
->label('Total Item Amount'),
|
||||
Forms\Components\TextInput::make('tax_amount')
|
||||
->label('Tax Amount'),
|
||||
Forms\Components\TextInput::make('transport_mode')
|
||||
->label('Transport Mode'),
|
||||
Forms\Components\TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number'),
|
||||
Forms\Components\TextInput::make('e_waybill_number')
|
||||
->label('E Way Bill Number'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('receiving_plant')
|
||||
->label('Receiving Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('receiving_plant_name')
|
||||
->label('Receiving Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_date')
|
||||
->label('Invoice Date')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transport_name')
|
||||
->label('Transport Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lr_bl_aw_number')
|
||||
->label('LR/BL/AW Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lr_bl_aw_date')
|
||||
->label('LR/BL/AW Date')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pending_days')
|
||||
->label('Pending Days')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('obd_number')
|
||||
->label('OBD Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('obd_date')
|
||||
->label('OBD Date')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipment_weight')
|
||||
->label('Shipment Weight')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('unit_price')
|
||||
->label('Unit Price')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('net_value')
|
||||
->label('Net value')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('total_item_amount')
|
||||
->label('Total Item Amount')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tax_amount')
|
||||
->label('Tax Amount')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transport_mode')
|
||||
->label('Transport Mode')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('e_waybill_number')
|
||||
->label('E Way Bill Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('Import Invoice In Transit')
|
||||
->label('Import Invoice In Transit')
|
||||
->form([
|
||||
FileUpload::make('invoice_in_transit_file')
|
||||
->label('Import Invoice In Transit')
|
||||
->preserveFilenames()
|
||||
->storeFiles(false)
|
||||
->reactive()
|
||||
->required()
|
||||
->disk('local')
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
InvoiceInTransit::truncate();
|
||||
$uploadedFile = $data['invoice_in_transit_file'];
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName();
|
||||
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Invoice Master Data' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidPlantCode = [];
|
||||
$invalidPlantCo = [];
|
||||
$invalidPlaCoFound = [];
|
||||
$invalidRecPlant = [];
|
||||
$invalidRecPlantName = [];
|
||||
$invalidInvNo = [];
|
||||
$invalidInvDt = [];
|
||||
$invalidICode = [];
|
||||
$invalidDesc = [];
|
||||
$invalidQty = [];
|
||||
$invalidTransportName = [];
|
||||
$invalidLRBLAWNo = [];
|
||||
$invalidLRBLAWDt = [];
|
||||
$invalidPenDay = [];
|
||||
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plantCode = trim($row[0]);
|
||||
$receivingPlant = trim($row[2]);
|
||||
$receivingPlantName = trim($row[3]);
|
||||
$invoiceNo = trim($row[4]);
|
||||
$invoiceDt = trim($row[5]);
|
||||
$itemCode = trim($row[6]);
|
||||
$des = trim($row[7]);
|
||||
$quantity = trim($row[8]);
|
||||
$transportName = trim($row[9]);
|
||||
$LRBAWNo = trim($row[10]);
|
||||
$LRBAWDt = trim($row[11]);
|
||||
$pendingDays = trim($row[12]);
|
||||
|
||||
if (empty($plantCode)) {
|
||||
$invalidPlantCode[] = "Row {$index}";
|
||||
}
|
||||
if (empty($receivingPlant)) {
|
||||
$invalidRecPlant[] = "Row {$index}";
|
||||
}
|
||||
if (empty($receivingPlantName)) {
|
||||
$invalidRecPlantName[] = "Row {$index}";
|
||||
}
|
||||
if (empty($invoiceNo)) {
|
||||
$invalidInvNo[] = "Row {$index}";
|
||||
}
|
||||
if (empty($invoiceDt)) {
|
||||
$invalidInvDt[] = "Row {$index}";
|
||||
}
|
||||
if (empty($itemCode)) {
|
||||
$invalidICode[] = "Row {$index}";
|
||||
}
|
||||
if (empty($des)) {
|
||||
$invalidDesc[] = "Row {$index}";
|
||||
}
|
||||
if (empty($quantity)) {
|
||||
$invalidQty[] = "Row {$index}";
|
||||
}
|
||||
if (empty($transportName)) {
|
||||
$invalidTransportName[] = "Row {$index}";
|
||||
}
|
||||
if (empty($LRBAWNo)) {
|
||||
$invalidLRBLAWNo[] = "Row {$index}";
|
||||
}
|
||||
if (empty($LRBAWDt)) {
|
||||
$invalidLRBLAWDt[] = "Row {$index}";
|
||||
}
|
||||
if (empty($pendingDays)) {
|
||||
$invalidPenDay[] = "Row {$index}";
|
||||
}
|
||||
|
||||
if (strlen($plantCode) < 4) {
|
||||
$invalidPlantCo[] = $plantCode;
|
||||
} elseif (! Plant::where('code', $plantCode)->first()) {
|
||||
$invalidPlaCoFound[] = $plantCode;
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
//$plantId = $plant->id;
|
||||
|
||||
}
|
||||
|
||||
if (! empty($invalidPlantCode) || ! empty($invalidRecPlant) || ! empty($invalidRecPlantName) || ! empty($invalidInvNo) || ! empty($invalidInvDt) || ! empty($invalidICode) || ! empty($invalidDesc) || ! empty($invalidQty) || ($invalidTransportName) || ! empty($invalidLRBLAWNo) || ! empty($invalidLRBLAWDt) || ! empty($invalidPenDay)) {
|
||||
$errorMsg = '';
|
||||
|
||||
if (! empty($invalidPlantCode)) {
|
||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidPlantCode).'<br>';
|
||||
}
|
||||
if (! empty($invalidRecPlant)) {
|
||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidRecPlant).'<br>';
|
||||
}
|
||||
if (! empty($invalidRecPlantName)) {
|
||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidRecPlantName).'<br>';
|
||||
}
|
||||
if (! empty($invalidInvNo)) {
|
||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidInvNo).'<br>';
|
||||
}
|
||||
if (! empty($invalidInvDt)) {
|
||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidInvDt).'<br>';
|
||||
}
|
||||
if (! empty($invalidICode)) {
|
||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidICode).'<br>';
|
||||
}
|
||||
if (! empty($invalidDesc)) {
|
||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidDesc).'<br>';
|
||||
}
|
||||
if (! empty($invalidQty)) {
|
||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidQty).'<br>';
|
||||
}
|
||||
if (! empty($invalidTransportName)) {
|
||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidTransportName).'<br>';
|
||||
}
|
||||
if (! empty($invalidLRBLAWNo)) {
|
||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidLRBLAWNo).'<br>';
|
||||
}
|
||||
if (! empty($invalidLRBLAWDt)) {
|
||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidLRBLAWDt).'<br>';
|
||||
}
|
||||
if (! empty($invalidPenDay)) {
|
||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidPenDay).'<br>';
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Missing Mandatory Fields')
|
||||
->body($errorMsg)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! empty($invalidPlantCo)) {
|
||||
$invalidPlantCode = array_unique($invalidPlantCo);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes should contain minimum 4 digits:<br>'.implode(', ', $invalidPlantCode))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! empty($invalidPlaCoFound)) {
|
||||
$invalidPlaCoFound = array_unique($invalidPlaCoFound);
|
||||
Notification::make()
|
||||
->title('Invalid Plant Codes')
|
||||
->body('The following plant codes not found in plants:<br>'.implode(', ', $invalidPlaCoFound))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$mandatoryColumns = 23;
|
||||
|
||||
$firstRow = $rows[0] ?? [];
|
||||
|
||||
if (count($firstRow) < $mandatoryColumns) {
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Excel Format')
|
||||
->body('Few columns not found. Columns A to W are mandatory.')
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plantCode = trim($row[0]);
|
||||
$receivingPlant = trim($row[2]);
|
||||
$receivingPlantName = trim($row[3]);
|
||||
$invoiceNo = trim($row[4]);
|
||||
$invoiceDt = trim($row[5]);
|
||||
$itemCode = trim($row[6]);
|
||||
$des = trim($row[7]);
|
||||
$quantity = trim($row[8]);
|
||||
$transportName = trim($row[9]);
|
||||
$LRBAWNo = trim($row[10]);
|
||||
$LRBAWDt = trim($row[11]);
|
||||
$pendingDays = trim($row[12]);
|
||||
$OBDNumber = trim($row[13]);
|
||||
$OBDDate = trim($row[14]);
|
||||
$ShipmentWeight = trim($row[15]);
|
||||
$UnitPrice = trim($row[16]);
|
||||
$NetValue = trim($row[17]);
|
||||
$TotalItemAmount = trim($row[18]);
|
||||
$TaxAmount = trim($row[19]);
|
||||
$TransportMode = trim($row[20]);
|
||||
$VehicleNumber = trim($row[21]);
|
||||
$EWayBillNumber = trim($row[22]);
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||
}
|
||||
|
||||
if (! empty($invoiceDt))
|
||||
{
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $invoiceDt)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $invoiceDt);
|
||||
$formattedDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($invoiceDt)) {
|
||||
$formattedDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($invoiceDt)->format('Y-m-d');
|
||||
} else {
|
||||
$formattedDate = date('Y-m-d', strtotime($invoiceDt));
|
||||
}
|
||||
} else {
|
||||
$formattedDate = null;
|
||||
}
|
||||
if (! empty($LRBAWDt))
|
||||
{
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $LRBAWDt)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $LRBAWDt);
|
||||
$formattedDt = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($LRBAWDt)) {
|
||||
$formattedDt = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($LRBAWDt)->format('Y-m-d');
|
||||
} else {
|
||||
$formattedDt = date('Y-m-d', strtotime($LRBAWDt));
|
||||
}
|
||||
} else {
|
||||
$formattedDt = null;
|
||||
}
|
||||
if (! empty($OBDDate))
|
||||
{
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
|
||||
$formattedDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($OBDDate)) {
|
||||
$formatted = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($OBDDate)->format('Y-m-d');
|
||||
} else {
|
||||
$formatted = date('Y-m-d', strtotime($OBDDate));
|
||||
}
|
||||
} else {
|
||||
$formatted = null;
|
||||
}
|
||||
|
||||
$inserted = InvoiceInTransit::create([
|
||||
'plant_id' => $plant->id,
|
||||
'receiving_plant' => $receivingPlant,
|
||||
'receiving_plant_name' => $receivingPlantName,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'invoice_date' => $formattedDate,
|
||||
'item_code' => $itemCode,
|
||||
'description' => $des,
|
||||
'quantity' => $quantity,
|
||||
'transport_name' => $transportName,
|
||||
'lr_bl_aw_number' => $LRBAWNo,
|
||||
'lr_bl_aw_date' => $formattedDt,
|
||||
'pending_days' => $pendingDays,
|
||||
'obd_number' => $OBDNumber,
|
||||
'obd_date' => $formatted,
|
||||
'shipment_weight' => $ShipmentWeight,
|
||||
'unit_price' => $UnitPrice,
|
||||
'net_value' => $NetValue,
|
||||
'total_item_amount' => $TotalItemAmount,
|
||||
'tax_amount' => $TaxAmount,
|
||||
'transport_mode' => $TransportMode,
|
||||
'vehicle_number' => $VehicleNumber,
|
||||
'e_waybill_number' => $EWayBillNumber,
|
||||
'created_at' => now(),
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
if ($inserted) {
|
||||
Notification::make()
|
||||
->title('Upload Success')
|
||||
->body('Invoice in transit uploaded successfully!')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Insertion Failed')
|
||||
->body('Invoice in transit upload failed!')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import invoice in transit');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoice In Transit')
|
||||
->color('warning')
|
||||
->exporter(InvoiceInTransitExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export invoice in transit');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListInvoiceInTransits::route('/'),
|
||||
'create' => Pages\CreateInvoiceInTransit::route('/create'),
|
||||
'view' => Pages\ViewInvoiceInTransit::route('/{record}'),
|
||||
'edit' => Pages\EditInvoiceInTransit::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceInTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateInvoiceInTransit extends CreateRecord
|
||||
{
|
||||
protected static string $resource = InvoiceInTransitResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceInTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditInvoiceInTransit extends EditRecord
|
||||
{
|
||||
protected static string $resource = InvoiceInTransitResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceInTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListInvoiceInTransits extends ListRecords
|
||||
{
|
||||
protected static string $resource = InvoiceInTransitResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceInTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewInvoiceInTransit extends ViewRecord
|
||||
{
|
||||
protected static string $resource = InvoiceInTransitResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,301 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\InvoiceMasterExporter;
|
||||
use App\Filament\Resources\InvoiceMasterResource\Pages;
|
||||
use App\Filament\Resources\InvoiceMasterResource\RelationManagers;
|
||||
use App\Models\InvoiceMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
|
||||
class InvoiceMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = InvoiceMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('receiving_plant')
|
||||
->label('Receiving Plant'),
|
||||
Forms\Components\TextInput::make('receiving_plant_name')
|
||||
->label('Receiving Plant Name'),
|
||||
Forms\Components\TextInput::make('transit_days')
|
||||
->label('Transit Days'),
|
||||
Forms\Components\TextInput::make('transport_name')
|
||||
->label('Transport Name'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('receiving_plant')
|
||||
->label('Receiving Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('receiving_plant_name')
|
||||
->label('Receiving Plant Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transit_days')
|
||||
->label('Transit Days')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transport_name')
|
||||
->label('Transport Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('Import Invoice Master')
|
||||
->label('Import Invoice Master')
|
||||
->form([
|
||||
FileUpload::make('invoice_master_file')
|
||||
->label('Import Invoice Master')
|
||||
->preserveFilenames()
|
||||
->storeFiles(false)
|
||||
->reactive()
|
||||
->required()
|
||||
->disk('local')
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_master_file'];
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName();
|
||||
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Invoice Master Data' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidReceivePlant = [];
|
||||
$invalidReceivePlantName = [];
|
||||
$invalidTransitDays = [];
|
||||
$invalidTransportName = [];
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$receivingPlant = trim($row[0]);
|
||||
$receivingPlantName = trim($row[1]);
|
||||
$transitDays = trim($row[2]);
|
||||
$transportName = trim($row[3]);
|
||||
|
||||
if (empty($receivingPlant)) {
|
||||
$invalidReceivePlant[] = "Row {$index}";
|
||||
}
|
||||
if (empty($receivingPlantName)) {
|
||||
$invalidReceivePlantName[] = "Row {$index}";
|
||||
}
|
||||
if (empty($transitDays)) {
|
||||
$invalidTransitDays[] = "Row {$index}";
|
||||
}
|
||||
if (empty($transportName)) {
|
||||
$invalidTransportName[] = "Row {$index}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! empty($invalidReceivePlant) || ! empty($invalidReceivePlantName) || ! empty($invalidTransitDays) || ! empty($invalidTransportName)) {
|
||||
$errorMsg = '';
|
||||
|
||||
if (! empty($invalidReceivePlant)) {
|
||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidReceivePlant).'<br>';
|
||||
}
|
||||
if (! empty($invalidReceivePlantName)) {
|
||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidReceivePlantName).'<br>';
|
||||
}
|
||||
if (! empty($invalidTransitDays)) {
|
||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidTransitDays).'<br>';
|
||||
}
|
||||
if (! empty($invalidTransportName)) {
|
||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidTransportName).'<br>';
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Missing Mandatory Fields')
|
||||
->body($errorMsg)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$receivingPlant = trim($row[0]);
|
||||
$receivingPlantName = trim($row[1]);
|
||||
$transitDays = trim($row[2]);
|
||||
$transportName = trim($row[3]);
|
||||
|
||||
$inserted = InvoiceMaster::create([
|
||||
'receiving_plant' => $receivingPlant,
|
||||
'receiving_plant_name' => $receivingPlantName,
|
||||
'transit_days' => $transitDays,
|
||||
'transport_name' => $transportName,
|
||||
'created_at' => now(),
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
if ($inserted) {
|
||||
Notification::make()
|
||||
->title('Upload Success')
|
||||
->body('Invoice master uploaded successfully!')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Insertion Failed')
|
||||
->body('Invoice master upload failed!')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
})
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import invoice master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoice Master')
|
||||
->color('warning')
|
||||
->exporter(InvoiceMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export invoice master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListInvoiceMasters::route('/'),
|
||||
'create' => Pages\CreateInvoiceMaster::route('/create'),
|
||||
'view' => Pages\ViewInvoiceMaster::route('/{record}'),
|
||||
'edit' => Pages\EditInvoiceMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateInvoiceMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = InvoiceMasterResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditInvoiceMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = InvoiceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListInvoiceMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = InvoiceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InvoiceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\InvoiceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewInvoiceMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = InvoiceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class InvoiceOutValidationResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
protected static ?string $navigationGroup = 'Invoice Management';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,6 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
@@ -53,7 +52,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
public $excel_file;
|
||||
public $mInvoiceNo;
|
||||
|
||||
public function getFormActions(): array
|
||||
{
|
||||
@@ -71,7 +69,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
|
||||
|
||||
// $this->dispatch('playNotificationSound');
|
||||
$this->dispatch('playNotificationSound');
|
||||
if ($totQuan == $scanSQuan) {
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->plantId,
|
||||
@@ -104,8 +102,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
|
||||
$parts = explode('.', $invoiceNumber);
|
||||
|
||||
$this->showCapacitorInput = false;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
@@ -121,62 +117,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// ..GET SERIAL INVOICE API
|
||||
|
||||
if(strlen($invoiceNumber) > 15)
|
||||
{
|
||||
|
||||
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
||||
|
||||
if (empty($payloadJson)) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = json_decode($payloadJson, true);
|
||||
|
||||
|
||||
if (!isset($payload['data'])) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$documentData = $payload['data'];
|
||||
|
||||
if($documentData == '' || $documentData == ''){
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract DocNo
|
||||
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
||||
|
||||
if (!isset($matches[1])) {
|
||||
Notification::make()
|
||||
->title('Invoice number not found.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($matches[1])) {
|
||||
$invoiceNumber = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
//dd($invoiceNumber);
|
||||
|
||||
// ..
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
@@ -2320,7 +2260,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function processSer($serNo)
|
||||
public function processSerialNumber($serNo)
|
||||
{
|
||||
$serNo = trim($serNo);
|
||||
$mSerNo = $serNo;
|
||||
@@ -2430,18 +2370,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2464,19 +2404,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2499,19 +2439,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2541,18 +2481,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playWarnSound');
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2573,18 +2513,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2615,18 +2555,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2648,18 +2588,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playWarnSound');
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2690,18 +2630,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2728,18 +2668,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2765,18 +2705,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2801,6 +2741,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotValidMaterialType')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2830,6 +2783,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2858,6 +2824,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Material';
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'Item')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3119,6 +3098,22 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// ..Mail
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, 'InvalidFormat')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3160,6 +3155,23 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('play-warn-sound');
|
||||
|
||||
// ..Mail
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFound')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
// ..
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3191,11 +3203,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
@@ -3230,6 +3240,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundItemS')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3282,6 +3305,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotValidPackage')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3320,6 +3356,18 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(3)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotMotorQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -3341,6 +3389,21 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// ..Mail
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateMotorQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3401,6 +3464,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
@@ -3438,6 +3514,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotPumpQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3457,6 +3547,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3518,6 +3622,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
@@ -3557,6 +3675,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'MissingPanelBox')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3577,6 +3709,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateCapacitorQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3619,6 +3765,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'UnknownPumpsetQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3639,6 +3799,20 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpsetQR')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3700,19 +3874,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
// $mInvoiceType = 'Serial';
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
$mInvoiceType = 'Serial';
|
||||
$mailData = $this->getMail();
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -3746,12 +3920,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
#[On('process-scan')]
|
||||
public function processSerial($serial)
|
||||
{
|
||||
$this->processSer($serial);
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Scan Invoice Validation';
|
||||
|
||||
@@ -24,16 +24,6 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use Storage;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use App\Models\Line;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use App\Models\Item;
|
||||
use App\Models\User;
|
||||
|
||||
// use App\Models\PalletValidation;
|
||||
// use Dom\Text;
|
||||
|
||||
class ProcessOrderResource extends Resource
|
||||
{
|
||||
@@ -85,7 +75,7 @@ class ProcessOrderResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -94,23 +84,20 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
if ($plantId && $itemId) {
|
||||
// Get the item code using item_id
|
||||
$itemCode = Item::where('id', $itemId)->value('code');
|
||||
$itemCode = \App\Models\Item::where('id', $itemId)->value('code');
|
||||
|
||||
if ($itemCode) {
|
||||
// Now get the item description using plant_id + code
|
||||
$item = Item::where('plant_id', $plantId)
|
||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||
->where('code', $itemCode)
|
||||
->first();
|
||||
|
||||
$set('item_description', $item?->description);
|
||||
$set('item_uom', $item?->uom);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
$set('item_uom', null);
|
||||
}
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
$set('item_uom', null);
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
@@ -122,7 +109,8 @@ class ProcessOrderResource extends Resource
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
$itemId = $get('item_id');
|
||||
if ($get('id')) {
|
||||
$item = Item::where('id', $itemId)->first()?->description;
|
||||
|
||||
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
||||
if ($item) {
|
||||
$set('item_description', $item);
|
||||
} else {
|
||||
@@ -131,22 +119,6 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('item_uom')
|
||||
->label('UOM')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
$itemId = $get('item_id');
|
||||
if ($get('id')) {
|
||||
$item = Item::where('id', $itemId)->first()?->uom;
|
||||
if ($item) {
|
||||
$set('item_uom', $item);
|
||||
} else {
|
||||
$set('item_uom', null);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -167,34 +139,6 @@ class ProcessOrderResource extends Resource
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, \Closure $fail) use ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = $value;
|
||||
//$currentId = $get('id'); // current editing record id
|
||||
|
||||
if (! $plantId || ! $processOrder) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', '!=', $itemId)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate Process Order!')
|
||||
->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
|
||||
}
|
||||
};
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('coil_number')
|
||||
->label('Coil Number')
|
||||
@@ -288,16 +232,10 @@ class ProcessOrderResource extends Resource
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('Upload PDF Now')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
@@ -385,9 +323,6 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->action(function ($get) {
|
||||
$equipmentNumber = $get('process_order');
|
||||
|
||||
@@ -482,6 +417,7 @@ class ProcessOrderResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
@@ -499,11 +435,6 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Uom')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('process_order')
|
||||
->label('Process Order')
|
||||
->alignCenter()
|
||||
@@ -561,135 +492,9 @@ class ProcessOrderResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->placeholder('Enter Process Order'),
|
||||
TextInput::make('sfg_number')
|
||||
->label('Sfg Number')
|
||||
->placeholder(placeholder: 'Enter Sfg Number'),
|
||||
TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->placeholder(placeholder: 'Enter Machine Name'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['sfg_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['machine_name'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (!empty($data['process_order'])) {
|
||||
$query->where('process_order', $data['process_order']);
|
||||
}
|
||||
|
||||
if (!empty($data['sfg_number'])) {
|
||||
$query->where('sfg_number', $data['sfg_number']);
|
||||
}
|
||||
|
||||
if (!empty($data['machine_name'])) {
|
||||
// $query->where('machine_name', $data['machine_name']);
|
||||
$query->where('machine_name', 'like', '%' . $data['machine_name'] . '%');
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
//$query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (!empty($data['process_order'])) {
|
||||
$indicators[] = 'Process Order: ' . $data['process_order'];
|
||||
}
|
||||
|
||||
if (!empty($data['sfg_number'])) {
|
||||
$indicators[] = 'Sfg Number: ' . $data['sfg_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['machine_name'])) {
|
||||
$indicators[] = 'Machine Name: ' . $data['machine_name'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
@@ -702,130 +507,6 @@ class ProcessOrderResource extends Resource
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('reprint_process')
|
||||
->label('Re-Print Process Order')
|
||||
->form([
|
||||
Forms\Components\Section::make()
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant')
|
||||
->label('Select Plant')
|
||||
// ->options(Plant::pluck('name', 'id')->toArray())
|
||||
->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()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('process_order', null);
|
||||
$set('coil_number', null);
|
||||
$set('received_quantity', null);
|
||||
$set('machine_name', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
$set('coil_number', null);
|
||||
$set('received_quantity', null);
|
||||
$set('machine_name', null);
|
||||
}),
|
||||
TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->required()
|
||||
->placeholder('Enter Process Order')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('coil_number', null);
|
||||
$set('received_quantity', null);
|
||||
$set('machine_name', null);
|
||||
}),
|
||||
Select::make('coil_number')
|
||||
->label('Coil Number')
|
||||
->nullable()
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
|
||||
if(empty($plantId) || empty($itemId) || empty($processOrder)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return ProcessOrder::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->where('process_order', $processOrder)
|
||||
->pluck('coil_number', 'coil_number');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
|
||||
if(!$plantId || !$itemId || !$processOrder || !$state) {
|
||||
$set('received_quantity', null);
|
||||
$set('machine_name', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$processOrderData = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $state)
|
||||
->first();
|
||||
|
||||
$set('received_quantity', $processOrderData?->received_quantity);
|
||||
$set('machine_name', $processOrderData?->machine_name);
|
||||
}),
|
||||
TextInput::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->readOnly(),
|
||||
|
||||
TextInput::make('machine_name')
|
||||
->label('Machine ID')
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
])
|
||||
// ->action(function (array $data) {
|
||||
// $selectedPalletNumber = $data['pallet_list'];
|
||||
// return redirect()->route('download-reprint-qr-pdf', ['palletNo' => $selectedPalletNumber]);
|
||||
// })
|
||||
->action(function (array $data) {
|
||||
$username = Filament::auth()->user()->name;
|
||||
return redirect()->route('download-reprint-process-pdf', [
|
||||
'plant' => $data['plant'],
|
||||
'item' => $data['Item'],
|
||||
'process_order' => $data['process_order'],
|
||||
'coil_number' => $data['coil_number'],
|
||||
'name' => $username,
|
||||
]);
|
||||
})
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view reprint process order');
|
||||
}),
|
||||
ImportAction::make()
|
||||
->label('Import Process Order')
|
||||
->color('warning')
|
||||
|
||||
@@ -1,575 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\ProductCharacteristicsMasterExporter;
|
||||
use App\Filament\Imports\ProductCharacteristicsMasterImporter;
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
class ProductCharacteristicsMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ProductCharacteristicsMaster::class;
|
||||
|
||||
protected static ?string $navigationGroup = 'Process Order';
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
//->relationship('item', 'code')
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('machine_id', null);
|
||||
|
||||
if (!$get('work_group_master_id')) {
|
||||
$set('machine_id', null);
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
// ->relationship('line', 'name'),
|
||||
Forms\Components\Select::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('line_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$line = Line::find($get('line_id'));
|
||||
$workGroupIds = [];
|
||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
||||
$column = "work_group{$i}_id";
|
||||
if (!empty($line->$column)) {
|
||||
$workGroupIds[] = $line->$column;
|
||||
}
|
||||
}
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $get('plant_id'))->whereIn('id', $workGroupIds)->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (!$lineId) {
|
||||
$set('mGroupWorkError', 'Please select a line first.');
|
||||
$set('machine_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// $grpWrkCnr = Line::find($lineId)->group_work_center;
|
||||
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
// {
|
||||
// $set('mGroupWorkError', 'Please select a group work center line.');
|
||||
// $set('line_id', null);
|
||||
// return;
|
||||
// }
|
||||
$set('mGroupWorkError', null);
|
||||
$set('machine_id', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mGroupWorkError') ? 'border-red-500' : '',
|
||||
])
|
||||
// ->dehydrateStateUsing(fn ($state) => null)
|
||||
->hint(fn ($get) => $get('mGroupWorkError') ? $get('mGroupWorkError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('machine', 'name'),
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
$workGroupId = $get('work_group_master_id');
|
||||
|
||||
if (empty($plantId) || empty($lineId) || empty($workGroupId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->where('work_group_master_id', $workGroupId)
|
||||
->pluck('work_center', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (!$get('plant_id') || !$get('line_id') || !$get('work_group_master_id')) {
|
||||
$set('machine_id', null);
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
->options([
|
||||
'Product' => 'Product',
|
||||
'Process' => 'Process',
|
||||
])
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name'),
|
||||
Forms\Components\Select::make('inspection_type')
|
||||
->label('Inspection Type')
|
||||
->options([
|
||||
'Visual' => 'Visual',
|
||||
'Value' => 'Value',
|
||||
])
|
||||
->reactive()
|
||||
->required(),
|
||||
// Forms\Components\Select::make('result')
|
||||
// ->label('Visual Type')
|
||||
// ->reactive()
|
||||
// ->options(function (callable $get) {
|
||||
// if ($get('inspection_type') == 'Visual') {
|
||||
// return [
|
||||
// 'Ok' => 'OK',
|
||||
// 'NotOk' => 'Not Ok',
|
||||
// ];
|
||||
// }
|
||||
// return []; //empty options if type ≠ Visual
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state, $set) {
|
||||
// $set('result', $state); // store in form state only
|
||||
// session()->put('temp_result', $state);
|
||||
// })
|
||||
// ->hidden(fn (callable $get) => $get('inspection_type') != 'Visual'),
|
||||
Forms\Components\TextInput::make('upper')
|
||||
->label('Upper')
|
||||
->numeric()
|
||||
->default(0.0)
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
Forms\Components\TextInput::make('lower')
|
||||
->label('Lower')
|
||||
->numeric()
|
||||
->default(0.0)
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||
Forms\Components\TextInput::make('middle')
|
||||
->label('Middle')
|
||||
->numeric()
|
||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value')
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, \Closure $fail) use ($get) {
|
||||
$lower = $get('lower');
|
||||
$upper = $get('upper');
|
||||
$middle = $value;
|
||||
|
||||
if (!is_null($lower) && !is_null($upper) && !is_null($middle)) {
|
||||
if (!($lower <= $middle && $middle <= $upper)) {
|
||||
$fail("Middle must be between Lower and Upper (Lower ≤ Middle ≤ Upper).");
|
||||
}
|
||||
}
|
||||
};
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('workGroupMaster.name')
|
||||
->label('Group Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('machine.work_center')
|
||||
// ->label('Work Center')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('inspection_type')
|
||||
->label('Inspection Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lower')
|
||||
->label('Lower')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('middle')
|
||||
->label('Middle')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('upper')
|
||||
->label('Upper')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Select Line')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Select::make('work_group_master')
|
||||
->label('Select Work Group Master')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if(empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Machine')
|
||||
->label('Select Machine')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
|
||||
if(empty($plantId) || empty($lineId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
|
||||
|
||||
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
|
||||
})
|
||||
->reactive(),
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $set('process_order', null);
|
||||
// }),
|
||||
// TextInput::make('process_order')
|
||||
// ->label('Process Order')
|
||||
// ->placeholder('Enter Process Order'),
|
||||
// TextInput::make('coil_number')
|
||||
// ->label('Coil Number')
|
||||
// ->placeholder(placeholder: 'Enter Coil Number'),
|
||||
Select::make('characteristics_type')
|
||||
->label('Characteristics Type')
|
||||
->options([
|
||||
'Product' => 'Product',
|
||||
'Process' => 'Process'
|
||||
]),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['work_group_master']) && empty($data['Machine']) && empty($data['characteristics_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (!empty($data['work_group_master'])) {
|
||||
$query->where('work_group_master_id', $data['work_group_master']);
|
||||
}
|
||||
|
||||
if (!empty($data['Machine'])) {
|
||||
$query->where('machine_id', $data['Machine']);
|
||||
}
|
||||
|
||||
if (!empty($data['characteristics_type'])) {
|
||||
$query->where('characteristics_type', $data['characteristics_type']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
|
||||
//$query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Line'])) {
|
||||
$indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (!empty($data['work_group_master'])) {
|
||||
$indicators[] = 'Work Group Master: ' . WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['Machine'])) {
|
||||
$indicators[] = 'Machine: ' . Machine::where('id', $data['Machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (!empty($data['characteristics_type'])) {
|
||||
$indicators[] = 'Characteristics Type: ' . $data['characteristics_type'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Product Characteristics Masters')
|
||||
->color('warning')
|
||||
->importer(ProductCharacteristicsMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import product characteristics master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Product Characteristics Masters')
|
||||
->color('warning')
|
||||
->exporter(ProductCharacteristicsMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export product characteristics master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListProductCharacteristicsMasters::route('/'),
|
||||
'create' => Pages\CreateProductCharacteristicsMaster::route('/create'),
|
||||
'view' => Pages\ViewProductCharacteristicsMaster::route('/{record}'),
|
||||
'edit' => Pages\EditProductCharacteristicsMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Characteristics';
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProductCharacteristicsMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProductCharacteristicsMasterResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Create Characteristics'; // This will replace the "New product characteristics master"
|
||||
}
|
||||
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Characteristics';
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProductCharacteristicsMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductCharacteristicsMasterResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Edit Characteristics'; // This will replace the "New product characteristics master"
|
||||
}
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
|
||||
$model = $this->getRecord(); // actual model instance
|
||||
|
||||
// Step 1: Fill the actual saved fields first
|
||||
$this->form->fill([
|
||||
'plant_id' => $model->plant_id,
|
||||
'line_id' => $model->line_id,
|
||||
'item_id' => $model->item_id,
|
||||
'machine_id' => $model->machine_id,
|
||||
'name' => $model->name,
|
||||
'type' => $model->type,
|
||||
'upper' => $model->upper,
|
||||
'lower' => $model->lower,
|
||||
'middle' => $model->middle,
|
||||
'work_group_master_id' => optional($model->machine)->work_group_master_id,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProductCharacteristicsMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProductCharacteristicsMasterResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Characteristics'; // This will replace the "New product characteristics master"
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductCharacteristicsMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductCharacteristicsMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProductCharacteristicsMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProductCharacteristicsMasterResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'View Characteristics';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Exports\QualityValidationExporter;
|
||||
use App\Filament\Imports\QualityValidationImporter;
|
||||
use App\Filament\Resources\QualityValidationResource\Pages;
|
||||
use App\Filament\Resources\QualityValidationResource\RelationManagers;
|
||||
// use App\Jobs\SendInvalidQualityMailJob;
|
||||
use App\Mail\InvalidQualityMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Item;
|
||||
@@ -14,8 +13,6 @@ use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
// use App\Models\User;
|
||||
// use App\Notifications\StatusUpdated;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -48,7 +45,6 @@ class QualityValidationResource extends Resource
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Display';
|
||||
|
||||
public $isSubmitted = false;
|
||||
public $data = [];
|
||||
|
||||
@@ -658,6 +654,7 @@ class QualityValidationResource extends Resource
|
||||
->label('Select Validation')
|
||||
->reactive()
|
||||
->options(fn (callable $get) => $get('part_validation_type_options') ?? [])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
// when user selects something new, hide the image
|
||||
$set('show_validation_image', false);
|
||||
@@ -710,6 +707,7 @@ class QualityValidationResource extends Resource
|
||||
$fileName = "{$value}.png";
|
||||
|
||||
$imageUrl = route('part.validation.image', [
|
||||
'plant' => $plantCode1,
|
||||
'filename' => $fileName
|
||||
]);
|
||||
|
||||
@@ -1734,17 +1732,6 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$set('tube_sticker_motor_error', null);
|
||||
|
||||
// $mPorder = $get('production_order');
|
||||
|
||||
// $mPlantId = $get('plant_id');
|
||||
//$plant = Plant::find($mPlantId);
|
||||
// $plantCodePart4 = $plant?->code;
|
||||
|
||||
// $mlineId = $get('line_id');
|
||||
|
||||
// $mLine = Line::find($mlineId);
|
||||
// $mLinePart = $mLine?->name;
|
||||
|
||||
if (empty($state)) {
|
||||
$set('tube_sticker_motor_error', null);
|
||||
return;
|
||||
@@ -1846,24 +1833,6 @@ class QualityValidationResource extends Resource
|
||||
if (!$isMatch)
|
||||
{
|
||||
$set('tube_sticker_motor_error', 'Serial number does not match.');
|
||||
|
||||
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mUserName = Filament::auth()->user()->name;
|
||||
|
||||
// if (!empty($emails))
|
||||
// {
|
||||
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerMotor')
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
$set('tube_sticker_motor_qr', null);
|
||||
return;
|
||||
}
|
||||
@@ -1888,32 +1857,10 @@ class QualityValidationResource extends Resource
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) {
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
|
||||
$set('tube_sticker_pump_error', null);
|
||||
|
||||
// $mPorder = $get('production_order');
|
||||
|
||||
// $mPlantId = $get('plant_id');
|
||||
// $plant = Plant::find($mPlantId);
|
||||
// $mPlantName = $plant?->name;
|
||||
|
||||
// $mlineId = $get('line_id');
|
||||
|
||||
// $mLine = Line::find($mlineId);
|
||||
// $mLinePart = $mLine?->name;
|
||||
|
||||
// $mPorder = $get('production_order');
|
||||
// $mPlantId = $get('plant_id');
|
||||
// $mlineId = $get('line_id');
|
||||
// $mUserName = Filament::auth()->user()?->name ?? 'Unknown';
|
||||
|
||||
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
//$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (empty($state)) {
|
||||
$set('tube_sticker_pump_error', null);
|
||||
return;
|
||||
@@ -1995,14 +1942,14 @@ class QualityValidationResource extends Resource
|
||||
// ]);
|
||||
$visibleSerialNumber = $get('serial_number');
|
||||
|
||||
$expectedItemCode = trim((string) $get('item_id'));
|
||||
$expectedItemCode = trim((string) $get('item_id'));
|
||||
|
||||
if ($itemCode != $expectedItemCode) {
|
||||
$set('tube_sticker_pump_error', 'Item code does not match.');
|
||||
return;
|
||||
}
|
||||
if ($itemCode != $expectedItemCode) {
|
||||
$set('tube_sticker_pump_error', 'Item code does not match.');
|
||||
return;
|
||||
}
|
||||
|
||||
$set('tube_sticker_pump_error', $serialNumber);
|
||||
$set('tube_sticker_pump_error', $serialNumber);
|
||||
|
||||
// $isMatch = in_array($serialNumber, $visibleSerialNumbers, true);
|
||||
$isMatch = ($visibleSerialNumber == $serialNumber);
|
||||
@@ -2016,62 +1963,6 @@ class QualityValidationResource extends Resource
|
||||
{
|
||||
$set('tube_sticker_pump_error', 'Serial number does not match.');
|
||||
$set('tube_sticker_pump_qr', null);
|
||||
// $user = User::where('name', $mUserName)->first();
|
||||
|
||||
// if ($user) {
|
||||
// $user->notify(new StatusUpdated($state));
|
||||
// }
|
||||
|
||||
|
||||
// $currentUser = Filament::auth()->user();
|
||||
|
||||
// if ($currentUser) {
|
||||
// $currentUser->notify(new StatusUpdated($state)); // standard Laravel DB notification
|
||||
|
||||
// // refresh Filament bell
|
||||
// $livewire->dispatch('refreshFilamentNotifications');
|
||||
// }
|
||||
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Status Updated')
|
||||
// ->body("Serial number scanned: $state")
|
||||
// ->danger()
|
||||
// ->sendToDatabase($currentUser);
|
||||
|
||||
//$user->notify(new StatusUpdated($state));
|
||||
|
||||
//Notification::send($user, new StatusUpdated($state));
|
||||
|
||||
|
||||
//dd($user);
|
||||
// $user->notify(new StatusUpdated($state));
|
||||
// Inside a Filament page or resource
|
||||
//$this->notify('success', "Serial number scanned: $state");
|
||||
|
||||
// dispatch(new SendInvalidQualityMailJob(
|
||||
// $state, $mPorder, $mPlantId, $mlineId, $mUserName, 'InvalidTubeStickerPump'
|
||||
// ))->afterResponse();
|
||||
|
||||
|
||||
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mUserName = Filament::auth()->user()->name;
|
||||
|
||||
// if (!empty($emails))
|
||||
// {
|
||||
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->queue(
|
||||
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -2099,17 +1990,6 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$set('tube_sticker_pumpset_error', null);
|
||||
|
||||
$mPorder = $get('production_order');
|
||||
|
||||
$mPlantId = $get('plant_id');
|
||||
//$plant = Plant::find($mPlantId);
|
||||
// $plantCodePart4 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
if (empty($state)) {
|
||||
$set('tube_sticker_pumpset_error', null);
|
||||
return;
|
||||
@@ -2213,23 +2093,6 @@ class QualityValidationResource extends Resource
|
||||
if (!$isMatch)
|
||||
{
|
||||
$set('tube_sticker_pumpset_error', 'Serial number does not match.');
|
||||
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mUserName = Filament::auth()->user()->name;
|
||||
|
||||
// if (!empty($emails))
|
||||
// {
|
||||
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
$set('tube_sticker_pumpset_qr', null);
|
||||
return;
|
||||
}
|
||||
@@ -2387,15 +2250,9 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantId = $get('plant_id');
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart1 = $plant?->code;
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
|
||||
$stickerMasterId = $get('sticker_master_id');
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
@@ -2427,13 +2284,12 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (!empty($emails))
|
||||
{
|
||||
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2443,7 +2299,7 @@ class QualityValidationResource extends Resource
|
||||
$set('part_validation1', null);
|
||||
|
||||
$fileName = $expectedValue . ".png"; // or .jpg based on your file
|
||||
$fullPath = storage_path("app/private/uploads/PartValidation/{$fileName}");
|
||||
$fullPath = storage_path("app/private/uploads/PartValidation/{$plantCodePart1}/{$fileName}");
|
||||
|
||||
// dd($fullPath);
|
||||
|
||||
@@ -2454,7 +2310,7 @@ class QualityValidationResource extends Resource
|
||||
// ]);
|
||||
if (file_exists($fullPath)) {
|
||||
$imageUrl = route('part.validation.image', [
|
||||
// 'plant' => $plantCodePart1,
|
||||
'plant' => $plantCodePart1,
|
||||
'filename' => $fileName
|
||||
]);
|
||||
} else {
|
||||
@@ -2492,11 +2348,6 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart2 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
$stickerMasterId = $get('sticker_master_id');
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
@@ -2525,13 +2376,12 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (!empty($emails))
|
||||
{
|
||||
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber2')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber2')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2591,12 +2441,6 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart3 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
}
|
||||
@@ -2625,13 +2469,12 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (!empty($emails))
|
||||
{
|
||||
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber3')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber3')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2689,11 +2532,6 @@ class QualityValidationResource extends Resource
|
||||
$plant = Plant::find($mPlantId);
|
||||
$plantCodePart4 = $plant?->code;
|
||||
|
||||
$mlineId = $get('line_id');
|
||||
|
||||
$mLine = Line::find($mlineId);
|
||||
$mLinePart = $mLine?->name;
|
||||
|
||||
if (!$stickerMasterId) {
|
||||
return;
|
||||
}
|
||||
@@ -2722,13 +2560,12 @@ class QualityValidationResource extends Resource
|
||||
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
if (!empty($emails))
|
||||
{
|
||||
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber4')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber4')
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -2745,7 +2582,7 @@ class QualityValidationResource extends Resource
|
||||
'filename' => $fileName
|
||||
]);
|
||||
|
||||
$set('part_validation4_error_image', $imageUrl);
|
||||
$set('part_validation2_error_image', $imageUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -2842,22 +2679,22 @@ class QualityValidationResource extends Resource
|
||||
else
|
||||
{
|
||||
$set('part_validation5_error', "Invalid input for part validation 5.");
|
||||
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
$mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
|
||||
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
|
||||
// if (!empty($emails))
|
||||
// {
|
||||
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
if (!empty($emails))
|
||||
{
|
||||
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
}
|
||||
$set('part_validation5', null);
|
||||
return;
|
||||
}
|
||||
@@ -2878,21 +2715,6 @@ class QualityValidationResource extends Resource
|
||||
public static function getMailData($plantId)
|
||||
{
|
||||
|
||||
$globalEmails = AlertMailRule::where('plant', 0)
|
||||
->where('module', 'QualityValidation')
|
||||
->where('rule_name', 'QualityMail')
|
||||
->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', ''))
|
||||
->pluck('email')
|
||||
->toArray();
|
||||
|
||||
if (!empty($globalEmails)) {
|
||||
return [
|
||||
'plant_id' => 0,
|
||||
'plant_name' => 'All Plants',
|
||||
'emails' => $globalEmails,
|
||||
];
|
||||
}
|
||||
|
||||
$mPlantName = Plant::where('id', $plantId)->value('name');
|
||||
|
||||
$emails = AlertMailRule::where('plant', $plantId)
|
||||
@@ -2909,6 +2731,34 @@ class QualityValidationResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// public function getMail(){
|
||||
// //$plantId = $this->form->getState()['plant_id'];
|
||||
// $plantId = $this->data['plant_id'] ?? null;
|
||||
// //$this->plantId = $plantId;
|
||||
// dd($plantId);
|
||||
// $mInvoiceType = 'Serial';
|
||||
// $mPlantName = Plant::where('id', $plantId)->value('name');
|
||||
// $emails = AlertMailRule::where('plant', $plantId)
|
||||
// //->where('plant', $plantName)
|
||||
// ->where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'InvoiceMail')
|
||||
// ->where(function ($query) {
|
||||
// $query->whereNull('schedule_type')
|
||||
// ->orWhere('schedule_type', '');
|
||||
// })
|
||||
// ->pluck('email')
|
||||
// ->toArray();
|
||||
|
||||
// return [
|
||||
// 'plant_id' => $plantId,
|
||||
// 'plant_name' => $mPlantName,
|
||||
// 'invoice_type' => $mInvoiceType,
|
||||
// 'emails' => $emails,
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
|
||||
@@ -844,56 +844,50 @@ class StickerMasterResource extends Resource
|
||||
|
||||
$plantCode = $plant->code;
|
||||
|
||||
// $sticker = StickerMaster::where('plant_id', $plantId)
|
||||
// ->where('item_id', $itemId)
|
||||
// ->first();
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->first();
|
||||
|
||||
// if (! $sticker) {
|
||||
// Notification::make()
|
||||
// ->title('Unknown Sticker Master')
|
||||
// ->body('Sticker Master data not found.')
|
||||
// ->danger()
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// }
|
||||
if (! $sticker) {
|
||||
Notification::make()
|
||||
->title('Unknown Sticker Master')
|
||||
->body('Sticker Master data not found.')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
}
|
||||
|
||||
// $value = $sticker->{$column};
|
||||
$value = $sticker->{$column};
|
||||
|
||||
// if (empty($value)) {
|
||||
// Notification::make()
|
||||
// ->title('Unknown Part validation')
|
||||
// ->body("Selected validation '$column' has no value.")
|
||||
// ->danger()
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// }
|
||||
if (empty($value)) {
|
||||
Notification::make()
|
||||
->title('Unknown Part validation')
|
||||
->body("Selected validation '$column' has no value.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
}
|
||||
|
||||
// $newFileName = $value.'.png';
|
||||
$newFileName = $value.'.png';
|
||||
|
||||
$originalName = $uploadedFile->getClientOriginalName();
|
||||
$directory = 'uploads/PartValidation';
|
||||
$directory = "uploads/PartValidation/{$plantCode}";
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
if (! $disk->exists($directory)) {
|
||||
$disk->makeDirectory($directory, 0755, true);
|
||||
}
|
||||
|
||||
// $fullPath = Storage::disk('local')->path($directory);
|
||||
|
||||
// $directory = "uploads/PartValidation/{$plantCode}";
|
||||
|
||||
// $disk = Storage::disk('local');
|
||||
// if (! $disk->exists($directory)) {
|
||||
// $disk->makeDirectory($directory, 0755, true);
|
||||
// }
|
||||
|
||||
// $path = $uploadedFile->storeAs(
|
||||
// $directory,
|
||||
// $newFileName,
|
||||
// 'local'
|
||||
// );
|
||||
try {
|
||||
$path = $disk->putFileAs($directory, $uploadedFile, $originalName);
|
||||
$path = $uploadedFile->storeAs(
|
||||
$directory,
|
||||
$newFileName,
|
||||
'local'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Upload Failed')
|
||||
|
||||
@@ -26,8 +26,6 @@ class StickerPrintingResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Sticker Reprint';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -40,6 +38,7 @@ class StickerPrintingResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource\Pages;
|
||||
use App\Filament\Resources\TestingTempResource\RelationManagers;
|
||||
use App\Models\TestingTemp;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
class TestingTempResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TestingTemp::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('File Name'),
|
||||
Forms\Components\Select::make('selected_file')
|
||||
->label('Select Uploaded File')
|
||||
->options(function () {
|
||||
return collect(Storage::disk('local')->files('uploads'))
|
||||
->mapWithKeys(function ($file) {
|
||||
return [
|
||||
$file => basename($file), // value => label
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('Upload')
|
||||
// ->acceptedFileTypes(['application/pdf'])
|
||||
->storeFiles(false)
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive(),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('File Upload')
|
||||
->color('success')
|
||||
->action(function ($get) {
|
||||
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
|
||||
$baseName = $get('name');
|
||||
$extension = $uploaded->getClientOriginalExtension();
|
||||
|
||||
$finalFileName = $baseName . '.' . $extension;
|
||||
|
||||
$uploaded->storeAs(
|
||||
'uploads',
|
||||
$finalFileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title("File uploaded successfully: {$finalFileName}")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
|
||||
// Action::make('downloadAttachment')
|
||||
// ->label('Download File')
|
||||
// ->action(function ($get) {
|
||||
|
||||
// $fileName = basename($get('selected_file'));
|
||||
|
||||
// //dd($fileName);
|
||||
|
||||
// // if (!$fileName) {
|
||||
// // Notification::make()
|
||||
// // ->title('Enter file name to download')
|
||||
// // ->danger()
|
||||
// // ->send();
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// $files = Storage::disk('local')->files('uploads');
|
||||
|
||||
// foreach ($files as $file) {
|
||||
|
||||
// if (pathinfo($file, PATHINFO_FILENAME) === $fileName) {
|
||||
// dd($fileName);
|
||||
// Notification::make()
|
||||
// ->title("File downloaded successfully")
|
||||
// ->success()
|
||||
// ->send();
|
||||
|
||||
// return response()->download(
|
||||
// Storage::disk('local')->path($file)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Notification::make()
|
||||
// // ->title('File not found')
|
||||
// // ->danger()
|
||||
// // ->send();
|
||||
// }),
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download File')
|
||||
->action(function ($get) {
|
||||
|
||||
$filePath = $get('selected_file'); // uploads/filename.pdf
|
||||
|
||||
if (!$filePath || !Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('File not found')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('File downloaded successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return response()->download(
|
||||
Storage::disk('local')->path($filePath)
|
||||
);
|
||||
}),
|
||||
|
||||
Action::make('deleteAttachment')
|
||||
->label('Delete File')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->action(function ($get) {
|
||||
|
||||
$filePath = $get('selected_file'); // uploads/filename.pdf
|
||||
|
||||
if (!$filePath || !Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('File not found')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('local')->delete($filePath);
|
||||
|
||||
Notification::make()
|
||||
->title('File deleted successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTestingTemps::route('/'),
|
||||
'create' => Pages\CreateTestingTemp::route('/create'),
|
||||
'view' => Pages\ViewTestingTemp::route('/{record}'),
|
||||
'edit' => Pages\EditTestingTemp::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestingTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTestingTemp extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TestingTempResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestingTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTestingTemp extends EditRecord
|
||||
{
|
||||
protected static string $resource = TestingTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestingTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTestingTemps extends ListRecords
|
||||
{
|
||||
protected static string $resource = TestingTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TestingTempResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTestingTemp extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TestingTempResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,21 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\WorkGroupMasterExporter;
|
||||
use App\Filament\Imports\WorkGroupMasterImporter;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class WorkGroupMasterResource extends Resource
|
||||
@@ -35,70 +37,68 @@ class WorkGroupMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required(),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('work_group_masters', 'operation_number')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->reactive()
|
||||
->columnSpan(['default' => 1, 'sm' => 3]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->minLength(6)
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'operation_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->minLength(5)
|
||||
->reactive()
|
||||
->columnSpan(['default' => 1, 'sm' => 3]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,6 @@ class WorkGroupMasterResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
@@ -178,14 +177,14 @@ class WorkGroupMasterResource extends Resource
|
||||
->label('Import Work Group Masters')
|
||||
->color('warning')
|
||||
->importer(WorkGroupMasterImporter::class)
|
||||
->visible(function () {
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import work group master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Work Group Masters')
|
||||
->color('warning')
|
||||
->exporter(WorkGroupMasterExporter::class)
|
||||
->visible(function () {
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export work group master');
|
||||
}),
|
||||
]);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,27 +22,189 @@ class ProductionStickerReprintController extends Controller
|
||||
|
||||
// public function downloadQrPdf($palletNo)
|
||||
// {
|
||||
public function downloadQrPdf(Request $request)
|
||||
|
||||
// $parts = explode('|', $palletNo);
|
||||
// $itemCode = trim($parts[0]);
|
||||
// $serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// // Retrieve the item record by item code
|
||||
// $item = Item::where('code', $itemCode)->first();
|
||||
|
||||
// if (!$item) {
|
||||
// abort(404, "Item with code {$itemCode} not found.");
|
||||
// }
|
||||
|
||||
// $itemId = $item->id;
|
||||
|
||||
// $production = ProductionQuantity::where('item_id', $itemId)
|
||||
// ->where('serial_number', $serial)
|
||||
// ->first();
|
||||
|
||||
// if (!$production) {
|
||||
// abort(404, "Production data for item code '{$itemCode}' with serial '{$serial}' not found.");
|
||||
// }
|
||||
|
||||
// $productionOrder = $production->production_order;
|
||||
|
||||
// $qrCode = new QrCode($palletNo);
|
||||
// $output = new Output\Png();
|
||||
// $qrBinary = $output->output($qrCode, 100);
|
||||
// $qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
// $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // Decide number of copies
|
||||
// $copies = 1;
|
||||
|
||||
// if ($sticker) {
|
||||
// if ($sticker->serial_number_pump == 1) {
|
||||
// // If pump is selected (regardless of motor), 2 copies
|
||||
// $copies = 2;
|
||||
// } elseif ($sticker->serial_number_motor == 1) {
|
||||
// // Only motor selected, 1 copy
|
||||
// $copies = 1;
|
||||
// }
|
||||
// }
|
||||
// return '
|
||||
// <html>
|
||||
// <head>
|
||||
// <style>
|
||||
// body {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// font-size: 10pt;
|
||||
// font-family: Arial Narrow, Arial, sans-serif;
|
||||
// }
|
||||
|
||||
// .sticker-table {
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// }
|
||||
|
||||
// .text-cell {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// text-align: left;
|
||||
// font-size: 14pt;
|
||||
// font-weight: normal;
|
||||
// line-height: 1.2;
|
||||
// }
|
||||
|
||||
// .text-row {
|
||||
// font-weight: bold;
|
||||
// font-size: 9pt;
|
||||
// }
|
||||
|
||||
// .serial {
|
||||
// text-align: left;
|
||||
// }
|
||||
|
||||
// .po-number {
|
||||
// text-align: right;
|
||||
// white-space: nowrap;
|
||||
// }
|
||||
|
||||
// .desc-row {
|
||||
// font-weight: normal;
|
||||
// font-size: 8pt;
|
||||
// }
|
||||
|
||||
// .qr-cell {
|
||||
// width: 14mm;
|
||||
// text-align: left;
|
||||
// padding-left: 0mm;
|
||||
// padding-top: 0mm;
|
||||
// }
|
||||
|
||||
// img.qr {
|
||||
// width: 20mm;
|
||||
// height: 20mm;
|
||||
// }
|
||||
// </style>
|
||||
// </head>
|
||||
// <body>
|
||||
// <div id="print-container"></div>
|
||||
// <script>
|
||||
// const copies = ' . $copies . ';
|
||||
// const htmlBlock = `
|
||||
// <table class="sticker-table">
|
||||
// <tr>
|
||||
// <td class="qr-cell">
|
||||
// <img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
// </td>
|
||||
// <td class="text-cell">
|
||||
// <div class="text-row">
|
||||
// <pre><span class="serial">' . htmlspecialchars($serial) . '</span> <span class="po-number">' . htmlspecialchars($productionOrder) . '</span></pre>
|
||||
// </div>
|
||||
// <div class="desc-row">
|
||||
// ' . htmlspecialchars($item->description) . '
|
||||
// </div>
|
||||
// </td>
|
||||
// </tr>
|
||||
// </table>
|
||||
// `;
|
||||
|
||||
// const container = document.getElementById("print-container");
|
||||
// for (let i = 0; i < copies; i++) {
|
||||
// container.insertAdjacentHTML("beforeend", htmlBlock);
|
||||
// }
|
||||
|
||||
// window.onload = function () {
|
||||
// window.print();
|
||||
// setTimeout(function () {
|
||||
// window.close();
|
||||
// }, 500);
|
||||
// };
|
||||
// </script>
|
||||
// </body>
|
||||
// </html>
|
||||
// ';
|
||||
|
||||
|
||||
// //Get sticker master data
|
||||
// // $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // //Decide number of copies
|
||||
// // $copies = 1; // default
|
||||
// // if ($sticker) {
|
||||
// // if ($sticker->serial_number_motor == 1) {
|
||||
// // $copies = 1;
|
||||
// // } elseif (is_null($sticker->serial_number_motor) && $sticker->serial_number_pump == 1) {
|
||||
// // $copies = 2;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf = new Mpdf([
|
||||
// // 'mode' => 'utf-8',
|
||||
// // 'format' => [60, 14],
|
||||
// // 'margin_left' => 0,
|
||||
// // 'margin_right' => 0,
|
||||
// // 'margin_top' => 0,
|
||||
// // 'margin_bottom' => 0,
|
||||
// // ]);
|
||||
|
||||
// // for ($i = 0; $i < $copies; $i++) {
|
||||
// // $mpdf->WriteHTML($html);
|
||||
// // if ($i < $copies - 1) {
|
||||
// // $mpdf->AddPage();
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf->Output('qr-label.pdf', 'I');
|
||||
// // exit;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
// $palletNo = urldecode($palletNo);
|
||||
$palletNo = urldecode($request->query('palletNo'));
|
||||
|
||||
if (!$palletNo) {
|
||||
abort(400, 'palletNo is required');
|
||||
}
|
||||
|
||||
$parts = explode('|', $palletNo);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// dd($serialNumberRaw);
|
||||
|
||||
if ($serialNumberRaw != null) {
|
||||
$serial = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$serial = trim($serial);
|
||||
} else {
|
||||
$serial = null;
|
||||
}
|
||||
$serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
$itemId= $item->id;
|
||||
@@ -61,42 +223,14 @@ class ProductionStickerReprintController extends Controller
|
||||
|
||||
$productionOrder = $production->production_order ?? '';
|
||||
|
||||
if(!preg_match('/\//', $palletNo)){
|
||||
if ($item->category == 'Submersible Motor')
|
||||
{
|
||||
$copies = 1;
|
||||
}
|
||||
elseif ($item->category == 'Submersible Pump')
|
||||
{
|
||||
$copies = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ($item->category == 'Submersible Motor')
|
||||
{
|
||||
// if ($item->category == 'Submersible Motor')
|
||||
// {
|
||||
// $copies = 1;
|
||||
// }
|
||||
// elseif ($item->category == 'Submersible Pump')
|
||||
// {
|
||||
// $copies = 1;
|
||||
// }
|
||||
$copies = 1;
|
||||
|
||||
if ($serialNumberRaw) {
|
||||
// Check if serial ends with /m or /M, optionally followed by |
|
||||
if (preg_match('/\/[mM](\|)?$/', $serialNumberRaw)) {
|
||||
$copies = 1;
|
||||
}
|
||||
// Check if serial ends with /p or /P, optionally followed by |
|
||||
elseif (preg_match('/\/[pP](\|)?$/', $serialNumberRaw)) {
|
||||
$copies = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $palletNo = preg_replace('/\/.*/', '', $palletNo);
|
||||
|
||||
elseif ($item->category == 'Submersible Pump')
|
||||
{
|
||||
$copies = 2;
|
||||
}
|
||||
// 5. Generate QR Code (base64)
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png();
|
||||
@@ -112,8 +246,6 @@ class ProductionStickerReprintController extends Controller
|
||||
'copies'=> $copies,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -83,100 +83,7 @@ class InvoiceDataTable extends Component
|
||||
// $this->showCapacitorInput = false;
|
||||
}
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
// // $this->showCapacitorInput = false;
|
||||
|
||||
// // ->where('serial_number', '!=', '')
|
||||
// $this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
// ->get()
|
||||
// ->map(function ($record) {
|
||||
// return [
|
||||
// 'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'serial_number' => $record->serial_number,
|
||||
// 'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
// 'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
// 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
// 'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
// 'scanned_status' => $record->scanned_status ?? '',
|
||||
// 'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
// 'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
// 'created_at' => $record->created_at,
|
||||
// 'operator_id' => $record->operator_id,
|
||||
// ];
|
||||
// })
|
||||
// ->toArray();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// // Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
// foreach ($this->invoiceData as &$row) {
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// // $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
// $row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
// $curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
// if ($curStick) {
|
||||
// if (Str::length($curStick->panel_box_code) > 0) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1) {
|
||||
// if ($curStick->tube_sticker_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pump == 1 || ($curStick->tube_sticker_pumpset != 1 && $curStick->tube_sticker_pump != 1 && $curStick->pack_slip_pump == 1)) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->tube_sticker_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// } elseif ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1) {
|
||||
// if ($curStick->pack_slip_motor == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pump == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// if ($curStick->pack_slip_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['capacitor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
|
||||
// $this->packageCount += $stickCount - $scannedCount;
|
||||
// }
|
||||
|
||||
// if ($onCapFocus) {
|
||||
// $this->dispatch('focus-capacitor-input');
|
||||
// } else {
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
// }
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
@@ -186,70 +93,80 @@ class InvoiceDataTable extends Component
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
// Eager load stickerMasterRelation and item
|
||||
$invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
// ->where('serial_number', '!=', '')
|
||||
$this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $plantId)->where('scanned_status', null)
|
||||
->get()
|
||||
->map(function ($record) {
|
||||
return [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
'scanned_status' => $record->scanned_status ?? '',
|
||||
'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
$this->invoiceData = [];
|
||||
$this->packageCount = 0;
|
||||
|
||||
foreach ($invoiceRecords as $record) {
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
// Compute code
|
||||
$rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
// Loop through and replace 'code' using related StickerMaster > Item > code
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
if ($sm) {
|
||||
// Panel box code
|
||||
if (Str::length($sm->panel_box_code) > 0) {
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$curStick = StickerMaster::where('id', $row['sticker_master_id'])->first();
|
||||
if ($curStick) {
|
||||
if (Str::length($curStick->panel_box_code) > 0) {
|
||||
$stickCount++;
|
||||
}
|
||||
|
||||
// Tube stickers logic
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
}
|
||||
// Pack slip logic (only if tube sticker block didn't apply)
|
||||
elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
if ($curStick->tube_sticker_motor == 1 || $curStick->tube_sticker_pump == 1 || $curStick->tube_sticker_pumpset == 1) {
|
||||
if ($curStick->tube_sticker_motor == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pump == 1 || ($curStick->tube_sticker_pumpset != 1 && $curStick->tube_sticker_pump != 1 && $curStick->pack_slip_pump == 1)) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->tube_sticker_pumpset == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
} elseif ($curStick->pack_slip_motor == 1 || $curStick->pack_slip_pump == 1 || $curStick->pack_slip_pumpset == 1) {
|
||||
if ($curStick->pack_slip_motor == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pump == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
if ($curStick->pack_slip_pumpset == 1) {
|
||||
$stickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Count already scanned
|
||||
$scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
if ($row['motor_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['pump_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['capacitor_scanned_status'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
if ($row['scanned_status_set'] == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
|
||||
// Increment packageCount
|
||||
$this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
$this->invoiceData[] = [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
'scanned_status' => $record->scanned_status ?? '',
|
||||
'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
'code' => $rowCode,
|
||||
'stickCount' => $stickCount,
|
||||
];
|
||||
$this->packageCount += $stickCount - $scannedCount;
|
||||
}
|
||||
|
||||
if ($onCapFocus) {
|
||||
|
||||
@@ -20,24 +20,17 @@ class InvalidQualityMail extends Mailable
|
||||
public $invoiceNumber;
|
||||
public $mplantName;
|
||||
public $mProdOrder;
|
||||
|
||||
public $mUserName;
|
||||
|
||||
public $mPartNo;
|
||||
public $mailType;
|
||||
public $greeting;
|
||||
public $subjectLine;
|
||||
|
||||
public $mLinePart;
|
||||
|
||||
public $itemCode;
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mailType = 'InvalidPartNumber')
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mailType = 'InvalidPartNumber')
|
||||
{
|
||||
$this->mPartNo = $parNo;
|
||||
$this->mProdOrder = $mProdOrder;
|
||||
$this->mplantName = $mplantName;
|
||||
$this->mLinePart = $mLinePart;
|
||||
$this->mUserName = $mUserName;
|
||||
$this->mailType = $mailType;
|
||||
}
|
||||
|
||||
@@ -46,20 +39,20 @@ class InvalidQualityMail extends Mailable
|
||||
// dynamic subject based on mail type
|
||||
switch ($this->mailType) {
|
||||
case 'InvalidPartNumber2':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
$this->subjectLine = "Invalid Part Number 2 Scanned ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber3':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
$this->subjectLine = "Invalid Part Number 3 Scanned ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber4':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
$this->subjectLine = "Invalid Part Number 4 Scanned ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber5':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
$this->subjectLine = "Invalid Part Number 5 Scanned ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber':
|
||||
default:
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
$this->subjectLine = "Invalid Part Number 1 Scanned ({$this->mplantName})";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,10 +70,8 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 2:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber3':
|
||||
@@ -88,10 +79,8 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 3:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber4':
|
||||
@@ -99,10 +88,8 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 4:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber5':
|
||||
@@ -110,10 +97,8 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 5:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidPartNumber':
|
||||
@@ -122,10 +107,8 @@ class InvalidQualityMail extends Mailable
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned part number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 1:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -82,14 +82,12 @@ class InvalidSerialMail extends Mailable
|
||||
public $greeting;
|
||||
public $subjectLine;
|
||||
|
||||
public $mUserName;
|
||||
|
||||
public $itemCode;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mUserName, $mailType = 'InvalidFormat')
|
||||
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat')
|
||||
{
|
||||
$this->serial = $serial;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
@@ -97,7 +95,6 @@ class InvalidSerialMail extends Mailable
|
||||
$this->mInvoiceType = $mInvoiceType;
|
||||
$this->mailType = $mailType;
|
||||
$this->itemCode = $itemCode;
|
||||
$this->mUserName = $mUserName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,24 +104,58 @@ class InvalidSerialMail extends Mailable
|
||||
{
|
||||
// dynamic subject based on mail type
|
||||
switch ($this->mailType) {
|
||||
case 'NotFound':
|
||||
$this->subjectLine = "Serial Number Not Found ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotFoundInvoice':
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
$this->subjectLine = "Serial Number Not Found in Invoice ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotFoundItemS':
|
||||
$this->subjectLine = "Item Code Not Found ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotValidPackage':
|
||||
$this->subjectLine = "Not Valid Package ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidMaterialFormat':
|
||||
$this->subjectLine = "Invalid Qr code format Found material ({$this->mplantName})";
|
||||
break;
|
||||
case 'DuplicateMotorQR':
|
||||
$this->subjectLine = "Duplicate Serial Number ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotMotorQR':
|
||||
$this->subjectLine = "Item Code doesn't have Motor QR ({$this->mplantName})";
|
||||
break;
|
||||
case 'CompletedSerialInvoice':
|
||||
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
|
||||
break;
|
||||
case 'NotPumpQR':
|
||||
$this->subjectLine = "Item Code doesn't have Pump QR ({$this->mplantName})";
|
||||
break;
|
||||
case 'DuplicatePumpQR':
|
||||
$this->subjectLine = "Duplicate Serial Number ({$this->mplantName})";
|
||||
break;
|
||||
case 'CSerialInvoice':
|
||||
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
|
||||
break;
|
||||
case 'MissingPanelBox':
|
||||
$this->subjectLine = "Missing Panel Box ({$this->mplantName})";
|
||||
break;
|
||||
case 'DuplicateCapacitorQR':
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
$this->subjectLine = "Duplicate Capacitor QR ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPanelBox':
|
||||
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
case 'UnknownPumpsetQR':
|
||||
$this->subjectLine = "Unknown PumpSet QR ({$this->mplantName})";
|
||||
break;
|
||||
case 'DuplicatePumpsetQR':
|
||||
$this->subjectLine = "Duplicate PumpSet QR ({$this->mplantName})";
|
||||
break;
|
||||
case 'ComSerInv':
|
||||
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidFormat':
|
||||
default:
|
||||
$this->subjectLine = "Invalid Serial Format Found ({$this->mplantName})";
|
||||
break;
|
||||
// case 'CompletedSerialInvoice':
|
||||
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
// break;
|
||||
// case 'CSerialInvoice':
|
||||
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
// break;
|
||||
// case 'ComSerInv':
|
||||
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
|
||||
// break;
|
||||
}
|
||||
|
||||
return new Envelope(
|
||||
@@ -139,28 +170,224 @@ class InvalidSerialMail extends Mailable
|
||||
{
|
||||
// dynamic greeting/message body
|
||||
switch ($this->mailType) {
|
||||
case 'NotFound':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
The scanned Serial Number <b>{$this->serial}</b> was not found in the database
|
||||
for the plant <b>{$this->mplantName}</b>.<br><br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
|
||||
Please verify the serial number.
|
||||
";
|
||||
break;
|
||||
case 'NotFoundInvoice':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
The scanned serial number could not be found in the given invoice.<br><br>
|
||||
The scanned Serial Number <b>'{$this->serial}'</b> was not found in the Invoice Number <b>'{$this->invoiceNumber}'</b>
|
||||
for the plant <b>{$this->mplantName}</b>.<br><br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
|
||||
Please verify the serial number.
|
||||
";
|
||||
break;
|
||||
case 'NotFoundItemS':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item Code <b>'{$this->itemCode}'</b> with Serial Number<b>'{$this->serial}'</b> not found in sticker master
|
||||
for the plant <b>{$this->mplantName}</b>.<br><br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br><br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
|
||||
Please verify the Item Code.
|
||||
";
|
||||
break;
|
||||
case 'NotValidPackage':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned Item Code<b>'{$this->itemCode}'</b> doesn't have valid package type to proceed!
|
||||
for the plant <b>{$this->mplantName}</b>.<br><br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br><br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br><br>
|
||||
Please verify the Item Code.
|
||||
";
|
||||
break;
|
||||
case 'InvalidMaterialFormat':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned serial number format appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
// case 'DuplicateCapacitorQR':
|
||||
// $this->greeting = "
|
||||
// Dear Sir/Madam,<br><br>
|
||||
// The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br>
|
||||
// <b>Plant:</b> {$this->mplantName}<br>
|
||||
// <b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
// <b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
// <b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
// <b>Employee Code:</b> {$this->mUserName}<br>
|
||||
// ";
|
||||
// break;
|
||||
case 'DuplicateMotorQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned 'Motor' serial number <b>{$this->serial}</b> already completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'NotMotorQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned Item Code <b>{$this->itemCode}</b> doesn't have 'Motor' QR to proceed!<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'CompletedSerialInvoice':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'NotPumpQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Pump' QR to proceed!<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'DuplicatePumpQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned 'Pump' serial number already completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'CSerialInvoice':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'MissingPanelBox':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Panel Box Code' to proceed!<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'DuplicateCapacitorQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned 'Capacitor' serial number already completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'UnknownPumpsetQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned Item Code <b>'{$this->itemCode}'</b> doesn't have 'Pump Set' QR to proceed!<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'DuplicatePumpsetQR':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Scanned 'Pump Set' serial number already completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ComSerInv':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ItemNotFound':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item code <b>'{$this->itemCode}'</b> not found in database.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ItemNotFoundDB':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item code <b>'{$this->itemCode}'</b> not found in database for choosed plant.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ItemNotValidMaterialType':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item code <b>'{$this->itemCode}'</b> doesn't have a valid material type.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ItemNotInvoice':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item code <b>'{$this->itemCode}'</b> doesn't exist in invoice.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'ItemNotInvoice':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Item code <b>'{$this->itemCode}'</b> doesn't exist in invoice.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidFormat':
|
||||
default:
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned serial number format appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Invoice Type:</b> {$this->mInvoiceType}
|
||||
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
|
||||
<b>Scanned QR Code:</b> {$this->serial}<br>
|
||||
";
|
||||
break;
|
||||
}
|
||||
|
||||
return new Content(
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceTransitMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $scheduleType;
|
||||
|
||||
public $tableData;
|
||||
|
||||
public $mailSubject;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType, $tableData, $mailSubject)
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
$this->mailSubject = $mailSubject ?? 'Invoice In Transit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->mailSubject,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
// public function content(): Content
|
||||
// {
|
||||
// return new Content(
|
||||
// view: 'view.name',
|
||||
// );
|
||||
// }
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
$greeting = '<b>Dear Service Provider</b>,<br><br>The following consignments to our branch warehouse are overdue beyond the agreed timeline.Immediate delivery is required today; Failure to complain will result to not able to fulfill customer requirements and leads to potential sales loss.Please treat this as the critical and confirm despatch without delay. <br><br><b> Dear C.R.I Branch Team,</b> <br><br> Please follow and ensure the same.';
|
||||
|
||||
//$greeting1 = 'Dear C.R.I Branch Team, <br><br> Please follow and ensure the same';
|
||||
|
||||
if (strtolower($this->scheduleType) == 'daily') {
|
||||
|
||||
$dates = collect($this->tableData)
|
||||
->pluck('lr_bl_aw_date')
|
||||
->filter()
|
||||
->map(fn ($d) => Carbon::parse($d));
|
||||
|
||||
if ($dates->isNotEmpty()) {
|
||||
$startDate = $dates->min()->startOfDay();
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
}
|
||||
|
||||
$endDate = now();
|
||||
|
||||
// $reportPeriod = "<br><br>"
|
||||
// . "Report Period: <b>{$startDate->format('d-m-Y')}</b> "
|
||||
// . "to <b>{$endDate->format('d-m-Y')}.</b>";
|
||||
// . "<br>Please arrange to receipt the same immediately.";
|
||||
|
||||
//$greeting .= $reportPeriod;
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Hourly') {
|
||||
$now = now();
|
||||
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||
$toHour = $now->format('H:i:s');
|
||||
$reportDate = $now->format('d/m/Y');
|
||||
$greeting .= "from: $reportDate, $fromHour to $toHour. <br><br>Please arrange to receipt the same immediately.";
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Live') {
|
||||
$now = now();
|
||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$greeting .= "from: $fromMinute to $toMinute. <br><br>Please arrange to receipt the same immediately.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.invoice-in-transit-report',
|
||||
with: [
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => $greeting,
|
||||
'tableData' => $this->tableData,
|
||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ class AlertMailRule extends Model
|
||||
protected $fillable = [
|
||||
'module',
|
||||
'plant',
|
||||
'invoice_master_id',
|
||||
'rule_name',
|
||||
'email',
|
||||
'cc_emails',
|
||||
@@ -24,9 +23,8 @@ class AlertMailRule extends Model
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function invoiceMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(InvoiceMaster::class);
|
||||
//return $this->belongsTo(InvoiceMaster::class, 'invoice_master_id');
|
||||
}
|
||||
// public function plant(): BelongsTo
|
||||
// {
|
||||
// return $this->belongsTo(Plant::class);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CharacteristicValue extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'machine_id',
|
||||
'process_order',
|
||||
'coil_number',
|
||||
'status',
|
||||
'observed_value',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceInTransit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"receiving_plant",
|
||||
"receiving_plant_name",
|
||||
"invoice_number",
|
||||
"invoice_date",
|
||||
"item_code",
|
||||
"description",
|
||||
"quantity",
|
||||
"transport_name",
|
||||
"lr_bl_aw_number",
|
||||
"lr_bl_aw_date",
|
||||
"pending_days",
|
||||
"obd_number",
|
||||
"obd_date",
|
||||
"shipment_weight",
|
||||
"unit_price",
|
||||
"net_value",
|
||||
"total_item_amount",
|
||||
"tax_amount",
|
||||
"transport_mode",
|
||||
"vehicle_number",
|
||||
"e_waybill_number",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"receiving_plant",
|
||||
"receiving_plant_name",
|
||||
"transit_days",
|
||||
"transport_name",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
];
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class ProductCharacteristicsMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'work_group_master_id',
|
||||
'machine_id',
|
||||
'name',
|
||||
'inspection_type',
|
||||
'characteristics_type',
|
||||
'upper',
|
||||
'lower',
|
||||
'middle',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function workGroupMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
// public function machine()
|
||||
// {
|
||||
// return $this->belongsTo(\App\Models\Machine::class, 'machine_id');
|
||||
// }
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TestingTemp extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\CharacteristicValue;
|
||||
use App\Models\User;
|
||||
|
||||
class CharacteristicValuePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, CharacteristicValue $characteristicvalue): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete CharacteristicValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any CharacteristicValue');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\InvoiceInTransit;
|
||||
use App\Models\User;
|
||||
|
||||
class InvoiceInTransitPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, InvoiceInTransit $invoiceintransit): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete InvoiceInTransit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any InvoiceInTransit');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\InvoiceMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class InvoiceMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, InvoiceMaster $invoicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete InvoiceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any InvoiceMaster');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class ProductCharacteristicsMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ProductCharacteristicsMaster $productcharacteristicsmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ProductCharacteristicsMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ProductCharacteristicsMaster');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\TestingTemp;
|
||||
use App\Models\User;
|
||||
|
||||
class TestingTempPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, TestingTemp $testingtemp): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete TestingTemp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any TestingTemp');
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE product_characteristics_masters(
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
line_id BIGINT DEFAULT NULL,
|
||||
work_group_master_id BIGINT DEFAULT NULL,
|
||||
machine_id BIGINT DEFAULT NULL,
|
||||
name TEXT DEFAULT NULL,
|
||||
inspection_type TEXT DEFAULT NULL,
|
||||
characteristics_type TEXT DEFAULT NULL
|
||||
upper DOUBLE PRECISION DEFAULT 0.0,
|
||||
lower DOUBLE PRECISION DEFAULT 0.0,
|
||||
middle DOUBLE PRECISION DEFAULT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items(id),
|
||||
FOREIGN KEY (work_group_master_id) REFERENCES work_group_masters(id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product_characteristics_masters');
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE process_orders
|
||||
ALTER COLUMN order_quantity TYPE NUMERIC
|
||||
USING order_quantity::NUMERIC;
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||
$table->dropUnique('work_group_masters_plant_id_operation_number_key');
|
||||
});
|
||||
|
||||
// $sql = <<<'SQL'
|
||||
// ALTER TABLE work_group_masters
|
||||
// DROP INDEX work_group_masters_plant_id_operation_number_key;
|
||||
// SQL;
|
||||
|
||||
// DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE characteristic_values (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
line_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
|
||||
process_order TEXT DEFAULT NULL,
|
||||
coil_number TEXT DEFAULT NULL,
|
||||
status TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items (id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('characteristic_values');
|
||||
}
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// received_quantity → NUMERIC(10,6)
|
||||
|
||||
DB::statement(<<<SQL
|
||||
ALTER TABLE process_orders
|
||||
ALTER COLUMN received_quantity TYPE NUMERIC(10,6)
|
||||
USING received_quantity::NUMERIC(10,6);
|
||||
SQL);
|
||||
|
||||
// order_quantity → NUMERIC(10,6)
|
||||
|
||||
DB::statement(<<<SQL
|
||||
ALTER TABLE process_orders
|
||||
ALTER COLUMN order_quantity TYPE NUMERIC(10,6)
|
||||
USING order_quantity::NUMERIC(10,6);
|
||||
SQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement(<<<SQL
|
||||
ALTER TABLE process_orders
|
||||
ALTER COLUMN received_quantity TYPE NUMERIC(10,3)
|
||||
USING received_quantity::NUMERIC(10,3);
|
||||
SQL);
|
||||
|
||||
// order_quantity → NUMERIC(10,6)
|
||||
|
||||
DB::statement(<<<SQL
|
||||
ALTER TABLE process_orders
|
||||
ALTER COLUMN order_quantity TYPE NUMERIC(10,3)
|
||||
USING order_quantity::NUMERIC(10,3);
|
||||
SQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement(<<<SQL
|
||||
ALTER TABLE characteristic_values
|
||||
ADD COLUMN observed_value NUMERIC(10,3);
|
||||
SQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('characteristic_values', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE invoice_in_transits (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
receiving_plant TEXT DEFAULT NULL,
|
||||
receiving_plant_name TEXT DEFAULT NULL,
|
||||
invoice_number TEXT DEFAULT NULL,
|
||||
invoice_date TEXT DEFAULT NULL,
|
||||
item_code TEXT DEFAULT NULL,
|
||||
description TEXT DEFAULT NULL,
|
||||
quantity NUMERIC(10,3) DEFAULT NULL,
|
||||
transport_name TEXT DEFAULT NULL,
|
||||
lr_bl_aw_number TEXT DEFAULT NULL,
|
||||
lr_bl_aw_date TEXT DEFAULT NULL,
|
||||
pending_days TEXT DEFAULT NULL,
|
||||
obd_number TEXT DEFAULT NULL,
|
||||
obd_date TEXT DEFAULT NULL,
|
||||
shipment_weight TEXT DEFAULT NULL,
|
||||
unit_price TEXT DEFAULT NULL,
|
||||
net_value TEXT DEFAULT NULL,
|
||||
total_item_amount TEXT DEFAULT NULL,
|
||||
tax_amount TEXT DEFAULT NULL,
|
||||
transport_mode TEXT DEFAULT NULL,
|
||||
vehicle_number TEXT DEFAULT NULL,
|
||||
e_waybill_number TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoice_in_transits');
|
||||
}
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE invoice_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
receiving_plant TEXT DEFAULT NULL,
|
||||
receiving_plant_name TEXT DEFAULT NULL,
|
||||
transit_days TEXT DEFAULT NULL,
|
||||
transport_name TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoice_masters');
|
||||
}
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE alert_mail_rules
|
||||
ADD COLUMN invoice_master_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT invoice_masters_invoice_master_id_fkey
|
||||
FOREIGN KEY (invoice_master_id) REFERENCES invoice_masters(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('alert_mail_rules', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE testing_temps (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
name TEXT DEFAULT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('testing_temps');
|
||||
}
|
||||
};
|
||||
@@ -171,12 +171,5 @@ class PermissionSeeder extends Seeder
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import sticker printing']);
|
||||
Permission::updateOrCreate(['name' => 'view export sticker printing']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import invoice master']);
|
||||
Permission::updateOrCreate(['name' => 'view export invoice master']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import invoice in transit']);
|
||||
Permission::updateOrCreate(['name' => 'view export invoice in transit']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Hash;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
@@ -16,20 +17,20 @@ class UserSeeder extends Seeder
|
||||
['email' => 'dhanabalan.saravanan@cripumps.com'],
|
||||
[
|
||||
'name' => 'Dhanabalan S',
|
||||
'password' => bcrypt('SdHaNa$1997'),
|
||||
'password' => bcrypt('SdHaNa@123'),
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
$user1->assignRole('Super Admin');
|
||||
|
||||
$user2 = User::updateOrCreate(
|
||||
['email' => 'ranjith.bala@cripumps.com'],
|
||||
['email' => 'ranjith@cripumps.com'],
|
||||
[
|
||||
'name' => 'Ranjith B',
|
||||
'password' => bcrypt('Ranjii$5503'),
|
||||
'password' => bcrypt('Ranjii@5503'),
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
$user2->assignRole('Super Admin');
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Invoice Data Report</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Arial, sans-serif;
|
||||
background-color: #f9fafb;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
h2 {
|
||||
color: #215c98;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #020813da;
|
||||
padding: 8px 10px;
|
||||
text-align: center;
|
||||
white-space: nowrap !important;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.td-left {
|
||||
text-align: left !important;
|
||||
}
|
||||
th {
|
||||
background-color: #215c98;
|
||||
color: #fff;
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
.status-wentout {
|
||||
color: #10b981;
|
||||
font-weight: bold;
|
||||
}
|
||||
/* .status-pending {
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
} */
|
||||
.status-pending-yellow {
|
||||
color: #eab308;
|
||||
font-weight: bold;
|
||||
}
|
||||
.status-pending-red {
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
margin-top: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: center; font-weight: bold;">
|
||||
{{ $company }}
|
||||
</div>
|
||||
<br>
|
||||
<p>{!! $greeting !!}</p>
|
||||
<div class="container">
|
||||
@if(empty($tableData))
|
||||
<p style="text-align:center;">No invoice in transit data available.</p>
|
||||
@else
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Receiving Plant Code</th>
|
||||
<th>Plant Name</th>
|
||||
<th>Receiving Plant Name</th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Transport Name</th>
|
||||
<th>LR Number</th>
|
||||
<th>LR Date</th>
|
||||
<th>Transit Days</th>
|
||||
<th>Pending Days</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($tableData as $row)
|
||||
<tr>
|
||||
<td>{{ $row['no'] }}</td>
|
||||
<td>{{ $row['receiving_plant'] }}</td>
|
||||
<td>{{ $row['plant'] }}</td>
|
||||
<td>{{ $row['receiving_plant_name'] }}</td>
|
||||
<td>{{ $row['invoice_number'] }}</td>
|
||||
<td class="td-left">{{ $row['transport_name'] }}</td>
|
||||
<td>{{ $row['lr_bl_aw_number'] }}</td>
|
||||
<td>
|
||||
@if(!empty($row['lr_bl_aw_date']) && $row['lr_bl_aw_date'] != '-')
|
||||
{{ \Carbon\Carbon::parse($row['lr_bl_aw_date'])->format('d-M-Y') }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
|
||||
{{-- <td>{{ $row['lr_bl_aw_date'] }}</td> --}}
|
||||
<td>{{ $row['transit_days'] }}</td>
|
||||
<td>{{ $row['status'] }}</td>
|
||||
|
||||
{{-- <td class="{{ $row['status_class'] ?? '' }}">
|
||||
{{ $row['status'] }}
|
||||
</td> --}}
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
<p>{!! $wishes !!}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CharacteristicsController;
|
||||
//use App\Http\Controllers\CharacteristicsController;
|
||||
|
||||
// use App\Http\Controllers\CharacteristicsController;
|
||||
use App\Http\Controllers\EquipmentMasterController;
|
||||
use App\Http\Controllers\InvoiceValidationController;
|
||||
use App\Http\Controllers\MachineController;
|
||||
@@ -43,6 +45,7 @@ use Illuminate\Support\Facades\Route;
|
||||
// return $item;
|
||||
// });
|
||||
|
||||
|
||||
// Route::post('/user/update', function (Request $request) {
|
||||
// // Return the request data as JSON
|
||||
|
||||
@@ -53,6 +56,7 @@ use Illuminate\Support\Facades\Route;
|
||||
// ]);
|
||||
// });
|
||||
|
||||
|
||||
// Route::middleware('auth.basic')->post('/user/update', function (Request $request) {
|
||||
// return response()->json([
|
||||
// 'message' => 'Authenticated via Basic Auth',
|
||||
@@ -61,6 +65,7 @@ use Illuminate\Support\Facades\Route;
|
||||
// ]);
|
||||
// });
|
||||
|
||||
|
||||
Route::post('obd/store-data', [ObdController::class, 'store']);
|
||||
|
||||
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
|
||||
@@ -75,13 +80,9 @@ Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrP
|
||||
|
||||
Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf');
|
||||
|
||||
// Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
|
||||
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
|
||||
|
||||
//Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->where('palletNo', '.*')->name('download-qr1-pdf');
|
||||
Route::get('/download-qr1-pdf', [ProductionStickerReprintController::class, 'downloadQrPdf'])
|
||||
->name('download-qr1-pdf');
|
||||
|
||||
// Production Dashboard Controller
|
||||
//Production Dashboard Controller
|
||||
|
||||
Route::get('get/module-name/data', [ModuleController::class, 'get_module']);
|
||||
|
||||
@@ -103,7 +104,7 @@ Route::get('get/module-production-order/data', [ModuleProductionOrderDataControl
|
||||
|
||||
Route::get('get/module-production-linestop/data', [ModuleProductionLineStopController::class, 'get_moduleProductionLineStop']);
|
||||
|
||||
// Invoice Dashboard Controller
|
||||
//Invoice Dashboard Controller
|
||||
|
||||
Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']);
|
||||
|
||||
@@ -113,7 +114,7 @@ Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class,
|
||||
|
||||
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
|
||||
|
||||
// Guard Dashboard Controller
|
||||
//Guard Dashboard Controller
|
||||
|
||||
Route::get('get/module-guard-day/data', [ModuleGuardDayCountController::class, 'get_guardDay_countData']);
|
||||
|
||||
@@ -121,19 +122,19 @@ Route::get('get/module-guard-hourly/data', [ModuleGuardHourlyCountController::cl
|
||||
|
||||
Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get_guard_name_Data']);
|
||||
|
||||
// Power house controller
|
||||
//Power house controller
|
||||
|
||||
Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']);
|
||||
|
||||
Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
|
||||
|
||||
// Invoice Validation Controller
|
||||
//Invoice Validation Controller
|
||||
|
||||
Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']);
|
||||
|
||||
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
|
||||
|
||||
// Testing panel Controller
|
||||
//Testing panel Controller
|
||||
|
||||
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']);
|
||||
|
||||
@@ -153,39 +154,28 @@ Route::get('process-order/details', [PdfController::class, 'getProcessOrderData'
|
||||
|
||||
Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
||||
|
||||
|
||||
Route::get('sap/files', [SapFileController::class, 'readFiles']);
|
||||
|
||||
// ..Laser Marking - Characteristics
|
||||
//..Laser Marking - Characteristics
|
||||
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
|
||||
|
||||
// ..Part Validation - Characteristics
|
||||
// Route::post('laser/route/data', [CharacteristicsController::class, 'test']);//->withoutMiddleware(VerifyCsrfToken::class)
|
||||
|
||||
// Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
|
||||
// ..Serial or job
|
||||
// //..
|
||||
|
||||
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
// Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
|
||||
// Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
|
||||
// ..Job or Master - Characteristics
|
||||
|
||||
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// ..serial auto or manual
|
||||
|
||||
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
// ..Product Characteristics
|
||||
|
||||
Route::get('characteristics/get/master', [CharacteristicsController::class, 'getCharMaster']);
|
||||
|
||||
Route::post('characteristics/values', [CharacteristicsController::class, 'storeCharValues']);
|
||||
|
||||
// GR Master PDF and Serial Number
|
||||
//GR Master PDF and Serial Number
|
||||
|
||||
Route::get('grNumber-pdf', [PdfController::class, 'getGRPdf']);
|
||||
|
||||
@@ -193,7 +183,7 @@ Route::get('grmaster-sno', [PdfController::class, 'getGRSerial']);
|
||||
|
||||
Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']);
|
||||
|
||||
Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
|
||||
// Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
|
||||
|
||||
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
|
||||
|
||||
@@ -9,88 +11,87 @@ Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Artisan::command('auto:scheduler', function () {
|
||||
$this->call('custom:scheduler');
|
||||
})->everyMinute()->withoutOverlapping();
|
||||
// Schedule::command('send:invoice-report');
|
||||
// Schedule::command('send:production-report');
|
||||
|
||||
// app()->booted(function () {
|
||||
// $schedule = app(Schedule::class);
|
||||
app()->booted(function () {
|
||||
$schedule = app(Schedule::class);
|
||||
|
||||
// // $schedule->command('report:send-daily-production')->dailyAt('07:59');
|
||||
// // Production report scheduling
|
||||
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
// $schedule->command('report:send-daily-production')->dailyAt('07:59');
|
||||
// Production report scheduling
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
// foreach ($productionRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
foreach ($productionRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||
// // ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||
$command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||
// ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('07:59');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// // Invoice report scheduling
|
||||
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
// Invoice report scheduling
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
foreach ($invoiceRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||
$command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('07:59');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('07:59');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// // Invoice Data Report Scheduling
|
||||
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
// ->select('plant', 'schedule_type')
|
||||
// ->distinct()
|
||||
// ->get();
|
||||
// Invoice Data Report Scheduling
|
||||
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
// foreach ($invoiceDataRules as $rule) {
|
||||
// $type = $rule->schedule_type;
|
||||
// $plantId = $rule->plant;
|
||||
foreach ($invoiceDataRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
$plantId = $rule->plant;
|
||||
|
||||
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||
$command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||
|
||||
// switch ($type) {
|
||||
// case 'Live':
|
||||
// $command->everyMinute();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $command->hourly();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $command->dailyAt('10:00');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
switch ($type) {
|
||||
case 'Live':
|
||||
$command->everyMinute();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$command->hourly();
|
||||
break;
|
||||
case 'Daily':
|
||||
$command->dailyAt('10:00');
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
|
||||
use App\Filament\Pages\CustomLogin;
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
@@ -25,8 +25,8 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
Route::get('/part-validation-image/{plant}/{filename}', function ($plant, $filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$plant}/{$filename}");
|
||||
|
||||
if (!file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
|
||||
Reference in New Issue
Block a user