Compare commits
1 Commits
a1f5fa0457
...
renovate/l
| Author | SHA1 | Date | |
|---|---|---|---|
| c7620c11b4 |
@@ -39,8 +39,6 @@ class Scheduler extends Command
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$this->call('approval:trigger-mails');
|
||||
|
||||
// --- Production Rules ---
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
@@ -76,6 +74,7 @@ class Scheduler extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Invoice Validation Rules ---
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'InvoiceMail')
|
||||
@@ -112,7 +111,6 @@ class Scheduler extends Command
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
|
||||
// switch ($rule->schedule_type) {
|
||||
@@ -176,7 +174,7 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '11:30') {
|
||||
if (now()->format('H:i') == '10:00') {
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
@@ -211,25 +209,11 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '10:45') {
|
||||
try {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
|
||||
Log::info('Invoice Transit executed', [
|
||||
'plant' => $rule->plant,
|
||||
'type' => $rule->schedule_type,
|
||||
]);
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
Log::error('Invoice Transit FAILED', [
|
||||
'plant' => $rule->plant,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
}
|
||||
if (now()->format('H:i') == '10:00') {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ use App\Mail\InvoiceDataMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendInvoiceDataReport extends Command
|
||||
{
|
||||
@@ -45,7 +49,7 @@ class SendInvoiceDataReport extends Command
|
||||
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
$this->error("No valid plant(s) found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,7 +105,7 @@ class SendInvoiceDataReport extends Command
|
||||
->where('distribution_channel_desc', $selectedDistribution)
|
||||
->whereBetween('document_date', [$startDate, $endDate])
|
||||
->orderBy('document_date', 'asc')
|
||||
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location', 'remark')
|
||||
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location')
|
||||
->get()
|
||||
->unique('document_number')
|
||||
->values();
|
||||
@@ -110,6 +114,7 @@ class SendInvoiceDataReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter invoices directly — exclude ones with '-' in document_number
|
||||
$invoices = $invoices->filter(function ($inv) {
|
||||
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
||||
});
|
||||
@@ -129,6 +134,7 @@ class SendInvoiceDataReport extends Command
|
||||
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
|
||||
->toArray();
|
||||
|
||||
//where('plant_id', $plant->id)
|
||||
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
//->whereBetween('scanned_at', [$startDate, $endDate])
|
||||
->distinct('qr_code')
|
||||
@@ -158,6 +164,7 @@ class SendInvoiceDataReport extends Command
|
||||
return !in_array($doc, $wentOutInvoices, true);
|
||||
});
|
||||
|
||||
|
||||
if ($pendingInvoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -175,7 +182,7 @@ class SendInvoiceDataReport extends Command
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
// 'no' => $no++,
|
||||
//'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
// 'distribution_type' => $selectedDistribution,
|
||||
'customer_code' => $inv->customer_code,
|
||||
@@ -187,7 +194,6 @@ class SendInvoiceDataReport extends Command
|
||||
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
||||
'status' => 'Pending',
|
||||
'status_class' => $statusColor,
|
||||
'remark' => $inv->remark,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -197,7 +203,6 @@ class SendInvoiceDataReport extends Command
|
||||
->values()
|
||||
->map(function ($item, $index) {
|
||||
$item['no'] = $index + 1;
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
@@ -209,7 +214,7 @@ class SendInvoiceDataReport extends Command
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
||||
$this->table(
|
||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status', 'Remark'],// 'Distribution Type'
|
||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type'
|
||||
$tableData
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
@@ -231,13 +236,13 @@ class SendInvoiceDataReport extends Command
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->info("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -86,7 +86,7 @@ class SendInvoiceReport extends Command
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
@@ -108,7 +108,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -122,7 +122,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
@@ -144,7 +144,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -158,7 +158,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
@@ -180,104 +180,25 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Send to SerialInvoiceMail recipients
|
||||
if ($mailRules->has('SerialInvoiceMail')) {
|
||||
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
// }
|
||||
foreach ($mailRules->get('SerialInvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
// }
|
||||
foreach ($mailRules->get('MaterialInvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to InvoiceMail recipients (all three tables)
|
||||
if ($mailRules->has('InvoiceMail')) {
|
||||
//$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
// $this->info("✅ Sent InvoiceMail to: {$email}");
|
||||
// }
|
||||
foreach ($mailRules->get('InvoiceMail') as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,6 +213,5 @@ class SendInvoiceReport extends Command
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ class SendInvoiceTransitReport extends Command
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
$results = DB::table('invoice_in_transits as it')
|
||||
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');
|
||||
})
|
||||
@@ -84,18 +84,17 @@ class SendInvoiceTransitReport extends Command
|
||||
')
|
||||
|
||||
)
|
||||
->when($plantId != 0, fn ($q) => $q->where('it.plant_id', $plantId))
|
||||
->when($plantId != 0, fn($q) => $q->where('it.plant_id', $plantId))
|
||||
->whereNotNull('it.lr_bl_aw_date')
|
||||
->whereRaw('
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER) > 0
|
||||
')
|
||||
->distinct('it.invoice_number')
|
||||
->get();
|
||||
|
||||
|
||||
if ($results->isEmpty()) {
|
||||
$this->info('No invoice transit records found for today.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,25 +103,24 @@ class SendInvoiceTransitReport extends Command
|
||||
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);
|
||||
//$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;
|
||||
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';
|
||||
: "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,
|
||||
@@ -134,10 +132,9 @@ class SendInvoiceTransitReport extends Command
|
||||
'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',
|
||||
'status' => $item->delayed_days . ' Days',
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
}
|
||||
|
||||
$mail = new InvoiceTransitMail($scheduleType, $tableData, $mailSubject);
|
||||
@@ -158,14 +155,13 @@ class SendInvoiceTransitReport extends Command
|
||||
|
||||
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)
|
||||
"Mail sent → Rule {$rule->id} | Invoice Master ID: {$rule->invoice_master_id} | To: " . implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class TriggerPendingApprovalMails extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:trigger-pending-approval-mails';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $description = 'Command description';
|
||||
|
||||
// /**
|
||||
// * Execute the console command.
|
||||
// */
|
||||
// public function handle()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
protected $signature = 'approval:trigger-mails';
|
||||
protected $description = 'Trigger approval mail manually';
|
||||
|
||||
public $pdfPath;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Approval mail job started');
|
||||
|
||||
$records = RequestCharacteristic::whereNull('approver_status1')
|
||||
->whereNull('approver_status2')
|
||||
->whereNull('approver_status3')
|
||||
->get();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No pending approvals');
|
||||
return;
|
||||
}
|
||||
|
||||
$grouped = $records->groupBy(function ($item) {
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
|
||||
$first = $groupRecords->first();
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$characteristics = $groupRecords->map(fn ($r) => [
|
||||
'work_flow_id' => $r->work_flow_id,
|
||||
'characteristic_name' => $r->characteristic_name,
|
||||
'current_value' => $r->current_value,
|
||||
'update_value' => $r->update_value,
|
||||
])->toArray();
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
// $updateData['trigger_at'] = $approver->duration1 > 0
|
||||
// ? $now->copy()->addMinutes($approver->duration1 * 10)
|
||||
// : null;
|
||||
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- SECOND MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent' &&
|
||||
is_null($first->approver_status1) &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
// $first->trigger_at <= $now
|
||||
) {
|
||||
$level = 2;
|
||||
$mail = $approver->mail2;
|
||||
$name = $approver->name2;
|
||||
// $updateData['trigger_at'] = $approver->duration2 > 0
|
||||
// ? $now->copy()->addMinutes($approver->duration2 * 10)
|
||||
// : null;
|
||||
|
||||
// $updateData['mail_status'] = 'Sent-Mail2';
|
||||
|
||||
if ($approver->duration2 > 0) {
|
||||
|
||||
$duration = number_format((float)$approver->duration2, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
// IMPORTANT: use NOW, not old trigger
|
||||
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
|
||||
} else {
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
|
||||
$updateData['mail_status'] = 'Sent-Mail2';
|
||||
}
|
||||
|
||||
// --- THIRD MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent-Mail2' &&
|
||||
is_null($first->approver_status1) &&
|
||||
is_null($first->approver_status2) &&
|
||||
$first->trigger_at &&
|
||||
// $first->trigger_at <= $now
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 3;
|
||||
$mail = $approver->mail3;
|
||||
$name = $approver->name3;
|
||||
|
||||
$updateData['trigger_at'] = null;
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pdfPath,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
}
|
||||
|
||||
$this->table(
|
||||
['ID', 'Plant', 'Machine', 'Level', 'Mail', 'Status'],
|
||||
$rows
|
||||
);
|
||||
|
||||
$this->info('Approval mail job completed');
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class InvoicePendingReasonExport implements FromArray, WithHeadings, WithMapping
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected array $data;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Plant Code',
|
||||
'Document Number',
|
||||
'Remark',
|
||||
'Customer Trade Name',
|
||||
'Location',
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
return [
|
||||
$row['plant_id'] ?? '',
|
||||
$row['document_number'] ?? '',
|
||||
$row['remark'] ?? '',
|
||||
$row['customer_trade_name'] ?? '',
|
||||
$row['location'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Support\Facades\View as FacadesView;
|
||||
use Illuminate\View\View as ViewView;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
// use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStartRow;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Events\BeforeExport;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
// {
|
||||
// public function __construct(
|
||||
// public $records,
|
||||
// ) {}
|
||||
|
||||
// // public function view(): View
|
||||
// // {
|
||||
// // return view('exports.export-isi-pdf', [
|
||||
// // 'records' => $this->records,
|
||||
// // ]);
|
||||
// // }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// // Top two rows (Company info + Motor KW/HP)
|
||||
// return [
|
||||
// ['C.R.I. Pumps Private Limited', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Unit: MOTOR FREE RUN TEST REGISTER'],
|
||||
// ['Motor KW/HP : - / -', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Phase : -'],
|
||||
// // Column headers
|
||||
// [
|
||||
// 'Date', 'Motor SNo', 'Item Code', 'Motor Type',
|
||||
// 'Voltage', 'Current', 'Power', 'IR.Hot', 'IR.Cool', 'Frequency', 'Speed', 'Leakage Current', // AFTER FREE RUN
|
||||
// 'Voltage', 'Current', 'Power', // LOCKED ROTOR TEST
|
||||
// 'No Load Pickup Voltage', 'Room Temp.', 'High Voltage Test', 'Result', 'Remark'
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
|
||||
// public function registerEvents(): array
|
||||
// {
|
||||
// return [
|
||||
// AfterSheet::class => function (AfterSheet $event) {
|
||||
// $sheet = $event->sheet->getDelegate();
|
||||
|
||||
// // Merge top rows for company info
|
||||
// $sheet->mergeCells('A1:S1'); // Company Name
|
||||
// $sheet->mergeCells('T1:T1'); // Unit/Register info
|
||||
// $sheet->mergeCells('A2:S2'); // Motor KW/HP row
|
||||
// $sheet->mergeCells('T2:T2'); // Phase
|
||||
|
||||
// // Merge headers for grouped columns (AFTER FREE RUN & LOCKED ROTOR TEST)
|
||||
// $sheet->mergeCells('E3:L3'); // AFTER FREE RUN
|
||||
// $sheet->mergeCells('M3:O3'); // LOCKED ROTOR TEST
|
||||
|
||||
// // Optional: style headers
|
||||
// $sheet->getStyle('A1:T3')->getFont()->setBold(true);
|
||||
// $sheet->getStyle('A1:T3')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
// $sheet->getStyle('A1:T3')->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// // Set column widths (optional for better visibility)
|
||||
// $columns = range('A', 'T');
|
||||
// foreach ($columns as $col) {
|
||||
// $sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
// }
|
||||
// },
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// class MotorFreeRunExport implements FromCollection, WithMapping, WithStartRow
|
||||
// {
|
||||
// protected Collection $records;
|
||||
|
||||
// public function __construct(Collection $records)
|
||||
// {
|
||||
// $this->records = $records;
|
||||
// }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function startRow(): int
|
||||
// {
|
||||
// return 3; // insert data starting from row 3
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// return [
|
||||
// $record['Date'] ?? '',
|
||||
// $record['Output'] ?? '',
|
||||
// $record['Motor SNo'] ?? '',
|
||||
// $record['Item Code'] ?? '',
|
||||
// $record['Motor Type'] ?? '',
|
||||
// $record['kw'] ?? '',
|
||||
// $record['hp'] ?? '',
|
||||
// $record['phase'] ?? '',
|
||||
// $record['isi_model'] ?? '',
|
||||
// $record['Voltage_Before'] ?? '',
|
||||
// $record['Current_Before'] ?? '',
|
||||
// $record['Power_Before'] ?? '',
|
||||
// $record['Resistance_RY'] ?? '',
|
||||
// $record['Resistance_YB'] ?? '',
|
||||
// $record['Resistance_BR'] ?? '',
|
||||
// $record['Insulation_Resistance'] ?? '',
|
||||
// $record['Frequency_Before'] ?? '',
|
||||
// $record['Speed_Before'] ?? '',
|
||||
// $record['Voltage_After'] ?? '',
|
||||
// $record['Current_After'] ?? '',
|
||||
// $record['Power_After'] ?? '',
|
||||
// $record['IR_Hot'] ?? '',
|
||||
// $record['IR_Cool'] ?? '',
|
||||
// $record['Leakage_Current'] ?? '',
|
||||
// $record['Frequency_After'] ?? '',
|
||||
// $record['Speed_After'] ?? '',
|
||||
// $record['Voltage_Locked'] ?? '',
|
||||
// $record['Current_Locked'] ?? '',
|
||||
// $record['Power_Locked'] ?? '',
|
||||
// $record['No_Load_Pickup_Voltage'] ?? '',
|
||||
// $record['Room_Temp'] ?? '',
|
||||
// $record['High_Voltage_Test'] ?? '',
|
||||
// $record['Batch_Number'] ?? '',
|
||||
// $record['Batch_Count'] ?? '',
|
||||
// $record['Result'] ?? '',
|
||||
// $record['Remark'] ?? '',
|
||||
// $record['Tested_By'] ?? '',
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
class MotorFreeRunExport implements WithCustomStartCell, WithMapping, WithStartRow, WithChunkReading
|
||||
{
|
||||
protected $records;
|
||||
protected $templatePath;
|
||||
|
||||
public function __construct($records)
|
||||
{
|
||||
$this->records = $records;
|
||||
// dd($this->records);
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->records;
|
||||
}
|
||||
|
||||
public function startRow(): int
|
||||
{
|
||||
return 7; // Start inserting data from row 7
|
||||
}
|
||||
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7'; // Start inserting data from row 7 column A
|
||||
}
|
||||
|
||||
public function map($record): array
|
||||
{
|
||||
return [
|
||||
$record['Date'] ?? '',
|
||||
$record['Output'] ?? '',
|
||||
$record['Motor SNo'] ?? '',
|
||||
$record['Item Code'] ?? '',
|
||||
$record['Motor Type'] ?? '',
|
||||
$record['kw'] ?? '',
|
||||
$record['hp'] ?? '',
|
||||
$record['phase'] ?? '',
|
||||
$record['isi_model'] ?? '',
|
||||
$record['Voltage_Before'] ?? '',
|
||||
$record['Current_Before'] ?? '',
|
||||
$record['Power_Before'] ?? '',
|
||||
$record['Resistance_RY'] ?? '',
|
||||
$record['Resistance_YB'] ?? '',
|
||||
$record['Resistance_BR'] ?? '',
|
||||
$record['Insulation_Resistance'] ?? '',
|
||||
$record['Frequency_Before'] ?? '',
|
||||
$record['Speed_Before'] ?? '',
|
||||
$record['Voltage_After'] ?? '',
|
||||
$record['Current_After'] ?? '',
|
||||
$record['Power_After'] ?? '',
|
||||
$record['IR_Hot'] ?? '',
|
||||
$record['IR_Cool'] ?? '',
|
||||
$record['Leakage_Current'] ?? '',
|
||||
$record['Frequency_After'] ?? '',
|
||||
$record['Speed_After'] ?? '',
|
||||
$record['Voltage_Locked'] ?? '',
|
||||
$record['Current_Locked'] ?? '',
|
||||
$record['Power_Locked'] ?? '',
|
||||
$record['No_Load_Pickup_Voltage'] ?? '',
|
||||
$record['Room_Temp'] ?? '',
|
||||
$record['High_Voltage_Test'] ?? '',
|
||||
$record['Batch_Number'] ?? '',
|
||||
$record['Batch_Count'] ?? '',
|
||||
$record['Result'] ?? '',
|
||||
$record['Remark'] ?? '',
|
||||
$record['Tested_By'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
public function chunkSize(): int
|
||||
{
|
||||
return 1000; // load 1000 records at a time
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\TestingPanelReading;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
// use Maatwebsite\Excel\Concerns\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
// class TestingPanelReadingExport implements FromCollection
|
||||
// {
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
// return TestingPanelReading::all();
|
||||
// }
|
||||
// }
|
||||
|
||||
// class TestingPanelReadingExport implements FromQuery, WithChunkReading, ShouldQueue, WithHeadings
|
||||
// {
|
||||
// protected array $ids;
|
||||
// protected int $counter = 0;
|
||||
|
||||
// public function __construct(array $ids)
|
||||
// {
|
||||
// $this->ids = $ids;
|
||||
// }
|
||||
// public function query()
|
||||
// {
|
||||
// return TestingPanelReading::query()
|
||||
// ->whereIn('id', $this->ids)
|
||||
// ->select('id', 'plant_id', 'line_id', 'motor_testing_master_id', 'machine_id', 'output', 'serial_number', 'winded_serial_number', 'before_fr_volt', 'before_fr_cur', 'before_fr_pow', 'before_fr_res_ry', 'before_fr_res_yb', 'before_fr_res_br', 'before_fr_ir', 'before_fr_ir_r', 'before_fr_ir_y', 'before_fr_ir_b', 'before_fr_freq', 'before_fr_speed', 'after_fr_vol', 'after_fr_cur', 'after_fr_pow', 'after_fr_ir_hot','after_fr_ir_hot_r', 'after_fr_ir_hot_y', 'after_fr_ir_hot_b', 'after_fr_ir_cool', 'after_fr_ir_cool_r', 'after_fr_ir_cool_y', 'after_fr_ir_cool_b', 'after_fr_freq', 'after_fr_speed', 'after_fr_leak_cur', 'locked_rt_volt', 'locked_rt_cur', 'locked_rt_pow', 'no_load_pickup_volt', 'room_temperature', 'hv_test', 'batch_number', 'batch_count', 'result', 'remark', 'rework_count', 'update_count', 'output_flag', 'tested_by', 'updated_by', 'created_at', 'updated_at', 'scanned_at', 'created_at');
|
||||
// }
|
||||
|
||||
// public function chunkSize(): int
|
||||
// {
|
||||
// return 1000; // process 1000 rows at a time
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// return ['NO', 'PLANT', 'LINE', 'MOTORTESTINGMASTER', 'MACHINE', 'OUTPUT', 'SERIAL NUMBER', 'WINDED SERIAL NUMBER', 'BEFORE FR VOLT', 'BEFORE FR CUR', 'BEFORE FR POW', 'BEFORE FR RES RY', 'BEFORE FR RES YB', 'BEFORE FR RES BR', 'BEFORE FR IR', 'BEFORE FR IR R', 'BEFORE FR IR Y', 'BEFORE FR IR B', 'BEFORE FR FREQ', 'BEFORE FR SPEED', 'AFTER FR VOL', 'AFTER FR CUR', 'AFTER FR POW', 'AFTER FR IR HOT', 'AFTER FR IR HOT R', 'AFTER FR IR HOT Y', 'AFTER FR IR HOT B', 'AFTER FR IR COOL', 'AFTER FR IR COOL R', 'AFTER FR IR COOL Y', 'AFTER FR IR COOL B', 'AFTER FR FREQ', 'AFTER FR SPEED', 'AFTER FR LEAK CUR', 'LOCKED RT VOLT', 'LOCKED RT CUR', 'LOCKED RT POW', 'NO LOAD PICKUP VOLT', 'ROOM TEMPERATURE', 'HV TEST', 'BATCH NUMBER', 'BATCH COUNT', 'RESULT', 'REMARK', 'REWORK COUNT', 'UPDATE COUNT', 'OUTPUT FLAG', 'TETSED BY', 'UPDATED BY', 'CREATED AT', 'UPDATED AT', 'SCANNED AT', 'CREATED AT'];
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// $this->counter++;
|
||||
// return [
|
||||
// $this->counter, // No.
|
||||
// $record->plant_id,
|
||||
// $record->line_id,
|
||||
// $record->motor_testing_master_id,
|
||||
// $record->machine_id,
|
||||
// $record->output,
|
||||
// $record->serial_number,
|
||||
// $record->winded_serial_number,
|
||||
// $record->before_fr_volt,
|
||||
// $record->before_fr_cur,
|
||||
// $record->before_fr_pow,
|
||||
// $record->before_fr_res_ry,
|
||||
// $record->before_fr_res_yb,
|
||||
// $record->before_fr_res_br,
|
||||
// $record->before_fr_ir,
|
||||
// $record->before_fr_ir_r,
|
||||
// $record->before_fr_ir_y,
|
||||
// $record->before_fr_ir_b,
|
||||
// $record->before_fr_freq,
|
||||
// $record->before_fr_speed,
|
||||
// $record->after_fr_vol,
|
||||
// $record->after_fr_cur,
|
||||
// $record->after_fr_pow,
|
||||
// $record->after_fr_ir_hot,
|
||||
// $record->after_fr_ir_hot_r,
|
||||
// $record->after_fr_ir_hot_y,
|
||||
// $record->after_fr_ir_hot_b,
|
||||
// $record->after_fr_ir_cool,
|
||||
// $record->after_fr_ir_cool_r,
|
||||
// $record->after_fr_ir_cool_y,
|
||||
// $record->after_fr_ir_cool_b,
|
||||
// $record->after_fr_freq,
|
||||
// $record->after_fr_speed,
|
||||
// $record->after_fr_leak_cur,
|
||||
// $record->locked_rt_volt,
|
||||
// $record->locked_rt_cur,
|
||||
// $record->locked_rt_pow,
|
||||
// $record->no_load_pickup_volt,
|
||||
// $record->room_temperature,
|
||||
// $record->hv_test,
|
||||
// $record->batch_number,
|
||||
// $record->batch_count,
|
||||
// $record->result,
|
||||
// $record->remark,
|
||||
// $record->rework_count,
|
||||
// $record->update_count,
|
||||
// $record->output_flag,
|
||||
// $record->tested_by,
|
||||
// $record->updated_by,
|
||||
// // $record->created_at,
|
||||
// $record->updated_at,
|
||||
// $record->scanned_at,
|
||||
// $record->created_at,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
class TestingPanelReadingExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $records;
|
||||
protected $isAllStarDelta;
|
||||
|
||||
public function __construct($records, $isAllStarDelta)
|
||||
{
|
||||
$this->records = $records;
|
||||
$this->isAllStarDelta = $isAllStarDelta;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->records)->map(function ($record) {
|
||||
if (!$this->isAllStarDelta) {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return array_keys($this->collection()->first() ?? []);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CharacteristicApproverMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD 1'),
|
||||
ExportColumn::make('name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('mail1')
|
||||
->label('APPROVER MAIL 1'),
|
||||
ExportColumn::make('duration1')
|
||||
->label('DURATION 1'),
|
||||
ExportColumn::make('name2')
|
||||
->label('APPROVER NAME 2'),
|
||||
ExportColumn::make('mail2')
|
||||
->label('APPROVER MAIL 2'),
|
||||
ExportColumn::make('duration2')
|
||||
->label('DURATION 2'),
|
||||
ExportColumn::make('name3')
|
||||
->label('APPROVER NAME 3'),
|
||||
ExportColumn::make('mail3')
|
||||
->label('APPROVER MAIL 3'),
|
||||
ExportColumn::make('duration3')
|
||||
->label('DURATION 3'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your characteristic approver master export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,335 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ClassCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ClassCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ClassCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('class')
|
||||
->label('CLASS'),
|
||||
ExportColumn::make('arbid')
|
||||
->label('ARBID'),
|
||||
ExportColumn::make('gamng')
|
||||
->label('GAMNG'),
|
||||
ExportColumn::make('lmnga')
|
||||
->label('LMNGA'),
|
||||
ExportColumn::make('gernr')
|
||||
->label('GERNR'),
|
||||
ExportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD'),
|
||||
ExportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPSTEXT'),
|
||||
ExportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND'),
|
||||
ExportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREEOFPROTECTION'),
|
||||
ExportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY'),
|
||||
ExportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIR ROT'),
|
||||
ExportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE'),
|
||||
ExportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX'),
|
||||
ExportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN'),
|
||||
ExportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY'),
|
||||
ExportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR'),
|
||||
ExportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP'),
|
||||
ExportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY'),
|
||||
ExportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD'),
|
||||
ExportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING'),
|
||||
ExportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX'),
|
||||
ExportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM'),
|
||||
ExportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR'),
|
||||
ExportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP'),
|
||||
ExportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE'),
|
||||
ExportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMBTEMP'),
|
||||
ExportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MINCOOLING FLOW'),
|
||||
ExportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTORSERIES'),
|
||||
ExportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL'),
|
||||
ExportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET'),
|
||||
ExportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE'),
|
||||
ExportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE'),
|
||||
ExportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMPFLOWTYPE'),
|
||||
ExportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMPSERIES'),
|
||||
ExportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL'),
|
||||
ExportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER'),
|
||||
ExportColumn::make('zmm_region')
|
||||
->label('ZMM REGION'),
|
||||
ExportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICEFACTOR'),
|
||||
ExportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICEFACTORMAXIMUMAMPS'),
|
||||
ExportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED'),
|
||||
ExportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION'),
|
||||
ExportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTIONXDELIVERY'),
|
||||
ExportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLYSOURCE'),
|
||||
ExportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE'),
|
||||
ExportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUSTLOAD'),
|
||||
ExportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS'),
|
||||
ExportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE'),
|
||||
ExportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE'),
|
||||
ExportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PVARRAYRATING'),
|
||||
ExportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI'),
|
||||
ExportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISIMOTOR'),
|
||||
ExportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISIPUMP'),
|
||||
ExportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISIPUMPSET'),
|
||||
ExportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL'),
|
||||
ExportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES'),
|
||||
ExportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEADRANGE'),
|
||||
ExportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY'),
|
||||
ExportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION'),
|
||||
ExportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE'),
|
||||
ExportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISIREFERENCE'),
|
||||
ExportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY'),
|
||||
ExportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE'),
|
||||
ExportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITORSTART'),
|
||||
ExportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITORRUN'),
|
||||
ExportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH'),
|
||||
ExportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE'),
|
||||
ExportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION'),
|
||||
ExportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVRALL'),
|
||||
ExportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODYMOC'),
|
||||
ExportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTORMOC'),
|
||||
ExportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL'),
|
||||
ExportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUTPOWER'),
|
||||
ExportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD'),
|
||||
ExportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP'),
|
||||
ExportColumn::make('zmm_de')
|
||||
->label('ZMM DE'),
|
||||
ExportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGERANGE'),
|
||||
ExportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS'),
|
||||
ExportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAMESIZE'),
|
||||
ExportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLERDIAMETER'),
|
||||
ExportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATIONCLASS'),
|
||||
ExportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAXFLOW'),
|
||||
ExportColumn::make('zmm_minhead')
|
||||
->label('ZMM MINHEAD'),
|
||||
ExportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTRLOFCONST'),
|
||||
ExportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE'),
|
||||
ExportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR'),
|
||||
ExportColumn::make('zmm_tagno')
|
||||
->label('ZMM TANGO'),
|
||||
ExportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME'),
|
||||
ExportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE'),
|
||||
ExportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER'),
|
||||
ExportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR'),
|
||||
ExportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS'),
|
||||
ExportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE'),
|
||||
ExportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET'),
|
||||
ExportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE'),
|
||||
ExportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR'),
|
||||
ExportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF'),
|
||||
ExportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP'),
|
||||
ExportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISIVALVE'),
|
||||
ExportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC'),
|
||||
ExportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABELPERIOD'),
|
||||
ExportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH'),
|
||||
ExportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO'),
|
||||
ExportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFGMONYR'),
|
||||
ExportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODELYEAR'),
|
||||
ExportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTORIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET'),
|
||||
ExportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE'),
|
||||
ExportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR'),
|
||||
ExportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF'),
|
||||
ExportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP'),
|
||||
ExportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACKTYPE'),
|
||||
ExportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL'),
|
||||
ExportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR'),
|
||||
ExportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMPIDENTIFICATION'),
|
||||
ExportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSETTYPE'),
|
||||
ExportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE'),
|
||||
ExportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL'),
|
||||
ExportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE'),
|
||||
ExportColumn::make('zmm_usp')
|
||||
->label('ZMM USP'),
|
||||
ExportColumn::make('mark_status')
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME'),
|
||||
ExportColumn::make('marked_by')
|
||||
->label('MARKED BY'),
|
||||
ExportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED STATUS'),
|
||||
ExportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME'),
|
||||
ExportColumn::make('man_marked_by')
|
||||
->label('MANUAL MARKED BY'),
|
||||
ExportColumn::make('motor_marked_status')
|
||||
->label('MOTOR MARKED STATUS'),
|
||||
ExportColumn::make('pump_marked_status')
|
||||
->label('PUMP MARKED STATUS'),
|
||||
ExportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS'),
|
||||
ExportColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation_2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('samlight_logged_name')
|
||||
->label('SAMLIGHT LOGGED NAME'),
|
||||
ExportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS'),
|
||||
ExportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME'),
|
||||
ExportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your class characteristic export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class RequestCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = RequestCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('work_flow_id')
|
||||
->label('WORK FLOW ID'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('characteristicApproverMaster.machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('characteristicApproverMaster.characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('characteristic_name')
|
||||
->label('CHARACTERISTIC NAME'),
|
||||
ExportColumn::make('current_value')
|
||||
->label('CURRENT VALUE'),
|
||||
ExportColumn::make('update_value')
|
||||
->label('UPDATE VALUE'),
|
||||
ExportColumn::make('characteristicApproverMaster.name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('approver_status1')
|
||||
->label('APPROVER STATUS 1'),
|
||||
ExportColumn::make('approver_remark1')
|
||||
->label('APPROVER REMARK 1'),
|
||||
ExportColumn::make('approved1_at')
|
||||
->label('APPROVED AT 1'),
|
||||
ExportColumn::make('characteristicApproverMaster.name2')
|
||||
->label('APPROVER NAME 2'),
|
||||
ExportColumn::make('approver_status2')
|
||||
->label('APPROVER STATUS 2'),
|
||||
ExportColumn::make('approver_remark2')
|
||||
->label('APPROVER REMARK 2'),
|
||||
ExportColumn::make('approved2_at')
|
||||
->label('APPROVED AT 2'),
|
||||
ExportColumn::make('characteristicApproverMaster.name3')
|
||||
->label('APPROVER NAME 3'),
|
||||
ExportColumn::make('approver_status3')
|
||||
->label('APPROVER STATUS 3'),
|
||||
ExportColumn::make('approver_remark3')
|
||||
->label('APPROVER REMARK 3'),
|
||||
ExportColumn::make('approved3_at')
|
||||
->label('APPROVED AT 1'),
|
||||
ExportColumn::make('mail_status')
|
||||
->label('MAIL STATUS'),
|
||||
ExportColumn::make('trigger_at')
|
||||
->label('TRIGGERED AT'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your request characteristic export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,651 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ClassCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ClassCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ClassCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->exampleHeader('Aufnr')
|
||||
->example(''),
|
||||
ImportColumn::make('class')
|
||||
->label('Class')
|
||||
->exampleHeader('Class')
|
||||
->example(''),
|
||||
ImportColumn::make('arbid')
|
||||
->label('Arbid')
|
||||
->exampleHeader('Arbid')
|
||||
->example(''),
|
||||
ImportColumn::make('gamng')
|
||||
->label('Gamng')
|
||||
->exampleHeader('Gamng')
|
||||
->example(''),
|
||||
ImportColumn::make('lmnga')
|
||||
->label('Lmnga')
|
||||
->exampleHeader('Lmnga')
|
||||
->example(''),
|
||||
ImportColumn::make('gernr')
|
||||
->label('Gernr')
|
||||
->exampleHeader('Gernr')
|
||||
->example(''),
|
||||
ImportColumn::make('zz1_cn_bill_ord')
|
||||
->label('zz1 ccn bill ord')
|
||||
->exampleHeader('zz1 ccn bill ord')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_amps')
|
||||
->label('zmm amps')
|
||||
->exampleHeader('zmm amps')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_brand')
|
||||
->label('zmm brand')
|
||||
->exampleHeader('zmm brand')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_degreeofprotection')
|
||||
->label('zmm degreeofprotection')
|
||||
->exampleHeader('zmm degreeofprotection')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_delivery')
|
||||
->label('zmm delivery')
|
||||
->exampleHeader('zmm delivery')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dir_rot')
|
||||
->label('zmm dir rot')
|
||||
->exampleHeader('zmm dir rot')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge')
|
||||
->label('zmm discharge')
|
||||
->exampleHeader('zmm discharge')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge_max')
|
||||
->label('zmm discharge max')
|
||||
->exampleHeader('zmm discharge max')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_discharge_min')
|
||||
->label('zmm discharge min')
|
||||
->exampleHeader('zmm discharge min')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_duty')
|
||||
->label('zmm duty')
|
||||
->exampleHeader('zmm duty')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_motor')
|
||||
->label('zmm eff motor')
|
||||
->exampleHeader('zmm eff motor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_pump')
|
||||
->label('zmm eff pump')
|
||||
->exampleHeader('zmm eff pump')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_frequency')
|
||||
->label('zmm frequency')
|
||||
->exampleHeader('zmm frequency')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_head')
|
||||
->label('zmm head')
|
||||
->exampleHeader('zmm head')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_heading')
|
||||
->label('zmm heading')
|
||||
->exampleHeader('zmm heading')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_head_max')
|
||||
->label('zmm head max')
|
||||
->exampleHeader('zmm head max')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_head_minimum')
|
||||
->label('zmm head minimum')
|
||||
->exampleHeader('zmm head minimum')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('zmm idx eff mtr')
|
||||
->exampleHeader('zmm idx eff mtr')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_idx_eff_pump')
|
||||
->label('zmm idx eff pump')
|
||||
->exampleHeader('zmm idx eff pump')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_kvacode')
|
||||
->label('zmm kvacode')
|
||||
->exampleHeader('zmm kvacode')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_maxambtemp')
|
||||
->label('zmm maxambtemp')
|
||||
->exampleHeader('zmm maxambtemp')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mincoolingflow')
|
||||
->label('zmm mincoolingflow')
|
||||
->exampleHeader('zmm mincoolingflow')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motorseries')
|
||||
->label('zmm motorseries')
|
||||
->exampleHeader('zmm motorseries')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_model')
|
||||
->label('zmm motor model')
|
||||
->exampleHeader('zmm motor model')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_outlet')
|
||||
->label('zmm outlet')
|
||||
->exampleHeader('zmm outlet')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_phase')
|
||||
->label('zmm phase')
|
||||
->exampleHeader('zmm phase')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pressure')
|
||||
->label('zmm pressure')
|
||||
->exampleHeader('zmm pressure')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpflowtype')
|
||||
->label('zmm pumpflowtype')
|
||||
->exampleHeader('zmm pumpflowtype')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpseries')
|
||||
->label('zmm pumpseries')
|
||||
->exampleHeader('zmm pumpseries')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pump_model')
|
||||
->label('zmm pump model')
|
||||
->exampleHeader('zmm pump model')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_ratedpower')
|
||||
->label('zmm ratedpower')
|
||||
->exampleHeader('zmm ratedpower')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_region')
|
||||
->label('zmm region')
|
||||
->exampleHeader('zmm region')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactor')
|
||||
->label('zmm servicefactor')
|
||||
->exampleHeader('zmm servicefactor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('zmm servicefactormaximumamps')
|
||||
->exampleHeader('zmm servicefactormaximumamps')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_speed')
|
||||
->label('zmm speed')
|
||||
->exampleHeader('zmm speed')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_suction')
|
||||
->label('zmm suction')
|
||||
->exampleHeader('zmm suction')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_suctionxdelivery')
|
||||
->label('zmm suctionxdelivery')
|
||||
->exampleHeader('zmm suctionxdelivery')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_supplysource')
|
||||
->label('zmm supplysource')
|
||||
->exampleHeader('zmm supplysource')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_temperature')
|
||||
->label('zmm temperature')
|
||||
->exampleHeader('zmm temperature')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_thrustload')
|
||||
->label('zmm thrustload')
|
||||
->exampleHeader('zmm thrustload')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_volts')
|
||||
->label('zmm volts')
|
||||
->exampleHeader('zmm volts')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_wire')
|
||||
->label('zmm wire')
|
||||
->exampleHeader('zmm wire')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_package')
|
||||
->label('zmm package')
|
||||
->exampleHeader('zmm package')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pvarrayrating')
|
||||
->label('zmm pvarrayrating')
|
||||
->exampleHeader('zmm pvarrayrating')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi')
|
||||
->label('zmm isi')
|
||||
->exampleHeader('zmm isi')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isimotor')
|
||||
->label('zmm isimotor')
|
||||
->exampleHeader('zmm isimotor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isipump')
|
||||
->label('zmm isipump')
|
||||
->exampleHeader('zmm isipump')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isipumpset')
|
||||
->label('zmm isipumpset')
|
||||
->exampleHeader('zmm isipumpset')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpset_model')
|
||||
->label('zmm pumpset model')
|
||||
->exampleHeader('zmm pumpset model')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_stages')
|
||||
->label('zmm stages')
|
||||
->exampleHeader('zmm stages')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_headrange')
|
||||
->label('zmm headrange')
|
||||
->exampleHeader('zmm headrange')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_overall_efficiency')
|
||||
->label('zmm overall efficiency')
|
||||
->exampleHeader('zmm overall efficiency')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_connection')
|
||||
->label('zmm connection')
|
||||
->exampleHeader('zmm connection')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_min_bore_size')
|
||||
->label('zmm min bore size')
|
||||
->exampleHeader('zmm min bore size')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isireference')
|
||||
->label('zmm isireference')
|
||||
->exampleHeader('zmm isireference')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_category')
|
||||
->label('zmm category')
|
||||
->exampleHeader('zmm category')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_submergence')
|
||||
->label('zmm submergence')
|
||||
->exampleHeader('zmm submergence')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorstart')
|
||||
->label('zmm capacitorstart')
|
||||
->exampleHeader('zmm capacitorstart')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_capacitorrun')
|
||||
->label('zmm capacitorrun')
|
||||
->exampleHeader('zmm capacitorrun')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inch')
|
||||
->label('zmm inch')
|
||||
->exampleHeader('zmm inch')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motor_type')
|
||||
->label('zmm motor type')
|
||||
->exampleHeader('zmm motor type')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dismantle_direction')
|
||||
->label('zmm dismantle direction')
|
||||
->exampleHeader('zmm dismantle direction')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ovrall')
|
||||
->label('zmm eff ovrall')
|
||||
->exampleHeader('zmm eff ovrall')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_bodymoc')
|
||||
->label('zmm bodymoc')
|
||||
->exampleHeader('zmm bodymoc')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_rotormoc')
|
||||
->label('zmm rotormoc')
|
||||
->exampleHeader('zmm rotormoc')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dlwl')
|
||||
->label('zmm dlwl')
|
||||
->exampleHeader('zmm dlwl')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_inputpower')
|
||||
->label('zmm inputpower')
|
||||
->exampleHeader('zmm inputpower')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_imp_od')
|
||||
->label('zmm imp od')
|
||||
->exampleHeader('zmm imp od')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_ambtemp')
|
||||
->label('zmm ambtemp')
|
||||
->exampleHeader('zmm ambtemp')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_de')
|
||||
->label('zmm de')
|
||||
->exampleHeader('zmm de')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_dischargerange')
|
||||
->label('zmm dischargerange')
|
||||
->exampleHeader('zmm dischargerange')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_efficiency_class')
|
||||
->label('zmm efficiency class')
|
||||
->exampleHeader('zmm efficiency class')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_framesize')
|
||||
->label('zmm framesize')
|
||||
->exampleHeader('zmm framesize')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_impellerdiameter')
|
||||
->label('zmm impellerdiameter')
|
||||
->exampleHeader('zmm impellerdiameter')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_insulationclass')
|
||||
->label('zmm insulationclass')
|
||||
->exampleHeader('zmm insulationclass')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_maxflow')
|
||||
->label('zmm maxflow')
|
||||
->exampleHeader('zmm maxflow')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_minhead')
|
||||
->label('zmm minhead')
|
||||
->exampleHeader('zmm minhead')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mtrlofconst')
|
||||
->label('zmm mtrlofconst')
|
||||
->exampleHeader('zmm mtrlofconst')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_nde')
|
||||
->label('zmm nde')
|
||||
->exampleHeader('zmm nde')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_powerfactor')
|
||||
->label('zmm powerfactor')
|
||||
->exampleHeader('zmm powerfactor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_tagno')
|
||||
->label('zmm tagno')
|
||||
->exampleHeader('zmm tagno')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_year')
|
||||
->label('zmm year')
|
||||
->exampleHeader('zmm year')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_laser_name')
|
||||
->label('zmm laser name')
|
||||
->exampleHeader('zmm laser name')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenote')
|
||||
->label('zmm beenote')
|
||||
->exampleHeader('zmm beenote')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beenumber')
|
||||
->label('zmm beenumber')
|
||||
->exampleHeader('zmm beenumber')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_beestar')
|
||||
->label('zmm beenumber')
|
||||
->exampleHeader('zmm beenumber')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_codeclass')
|
||||
->label('zmm codeclass')
|
||||
->exampleHeader('zmm codeclass')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_colour')
|
||||
->label('zmm colour')
|
||||
->exampleHeader('zmm colour')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_cp')
|
||||
->label('zmm logo cp')
|
||||
->exampleHeader('zmm logo cp')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_ce')
|
||||
->label('zmm logo ce')
|
||||
->exampleHeader('zmm logo ce')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_logo_nsf')
|
||||
->label('zmm logo nsf')
|
||||
->exampleHeader('zmm logo nsf')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grade')
|
||||
->label('zmm grade')
|
||||
->exampleHeader('zmm grade')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pset')
|
||||
->label('zmm grwt pset')
|
||||
->exampleHeader('zmm grwt pset')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_cable')
|
||||
->label('zmm grwt cable')
|
||||
->exampleHeader('zmm grwt cable')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_motor')
|
||||
->label('zmm grwt motor')
|
||||
->exampleHeader('zmm grwt motor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pf')
|
||||
->label('zmm grwt pf')
|
||||
->exampleHeader('zmm grwt pf')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_grwt_pump')
|
||||
->label('zmm grwt pump')
|
||||
->exampleHeader('zmm grwt pump')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isivalve')
|
||||
->label('zmm isivalve')
|
||||
->exampleHeader('zmm isivalve')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_isi_wc')
|
||||
->label('zmm isi wc')
|
||||
->exampleHeader('zmm isi wc')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_labelperiod')
|
||||
->label('zmm labelperiod')
|
||||
->exampleHeader('zmm labelperiod')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_length')
|
||||
->label('zmm length')
|
||||
->exampleHeader('zmm length')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_license_cml_no')
|
||||
->label('zmm license cml no')
|
||||
->exampleHeader('zmm license cml no')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_mfgmonyr')
|
||||
->label('zmm mfgmonyr')
|
||||
->exampleHeader('zmm mfgmonyr')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_modelyear')
|
||||
->label('zmm modelyear')
|
||||
->exampleHeader('zmm modelyear')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_motoridentification')
|
||||
->label('zmm motoridentification')
|
||||
->exampleHeader('zmm motoridentification')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pset')
|
||||
->label('zmm newt pset')
|
||||
->exampleHeader('zmm newt pset')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_cable')
|
||||
->label('zmm newt cable')
|
||||
->exampleHeader('zmm newt cable')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_motor')
|
||||
->label('zmm newt motor')
|
||||
->exampleHeader('zmm newt motor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pf')
|
||||
->label('zmm newt pf')
|
||||
->exampleHeader('zmm newt pf')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_newt_pump')
|
||||
->label('zmm newt pump')
|
||||
->exampleHeader('zmm newt pump')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_packtype')
|
||||
->label('zmm packtype')
|
||||
->exampleHeader('zmm packtype')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_panel')
|
||||
->label('zmm panel')
|
||||
->exampleHeader('zmm panel')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_performance_factor')
|
||||
->label('zmm performance factor')
|
||||
->exampleHeader('zmm performance factor')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_pumpidentification')
|
||||
->label('zmm pumpidentification')
|
||||
->exampleHeader('zmm pumpidentification')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_psettype')
|
||||
->label('zmm psettype')
|
||||
->exampleHeader('zmm psettype')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_size')
|
||||
->label('zmm size')
|
||||
->exampleHeader('zmm size')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_eff_ttl')
|
||||
->label('zmm eff ttl')
|
||||
->exampleHeader('zmm eff ttl')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_type')
|
||||
->label('zmm type')
|
||||
->exampleHeader('zmm type')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_usp')
|
||||
->label('zmm usp')
|
||||
->exampleHeader('zmm usp')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->exampleHeader('MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->exampleHeader('MARKED DATETIME')
|
||||
->example(''),
|
||||
ImportColumn::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->exampleHeader('MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('man_marked_status')
|
||||
->label('MANUAL MARKED STATUS')
|
||||
->exampleHeader('MANUAL MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('man_marked_datetime')
|
||||
->label('MANUAL MARKED DATETIME')
|
||||
->exampleHeader('MANUAL MARKED DATETIME')
|
||||
->example(''),
|
||||
ImportColumn::make('man_marked_by')
|
||||
->label('MANUAL MARKED BY')
|
||||
->exampleHeader('MANUAL MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_marked_status')
|
||||
->label('MOTOR MARKED STATUS')
|
||||
->exampleHeader('MOTOR MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->exampleHeader('MOTOR MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_marked_status')
|
||||
->label('PUMP MARKED STATUS')
|
||||
->exampleHeader('PUMP MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->exampleHeader('PUMP MARKED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS')
|
||||
->exampleHeader('MOTOR PUMP PUMPSET STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->exampleHeader('MOTOR MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_machine_name')
|
||||
->label('PUMP MACHINE NAME')
|
||||
->exampleHeader('PUMP MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pumpset_machine_name')
|
||||
->label('PUMPSET MACHINE NAME')
|
||||
->exampleHeader('PUMPSET MACHINE NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1')
|
||||
->exampleHeader('PART VALIDATION 1')
|
||||
->example(''),
|
||||
ImportColumn::make('part_validation_2')
|
||||
->label('PART VALIDATION 2')
|
||||
->exampleHeader('PART VALIDATION 2')
|
||||
->example(''),
|
||||
ImportColumn::make('samlight_logged_name')
|
||||
->label('SAMLGHT LOGGED NAME')
|
||||
->exampleHeader('SAMLGHT LOGGED NAME')
|
||||
->example(''),
|
||||
ImportColumn::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS')
|
||||
->exampleHeader('PENDING RELEASED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->exampleHeader('MOTOR EXPECTED TIME')
|
||||
->example(''),
|
||||
ImportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->exampleHeader('PUMP EXPECTED TIME')
|
||||
->example(''),
|
||||
ImportColumn::make('created_at')
|
||||
->label('CREATED AT')
|
||||
->exampleHeader('CREATED AT')
|
||||
->example(''),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example(''),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example(''),
|
||||
// ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ClassCharacteristic
|
||||
{
|
||||
// return ClassCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ClassCharacteristic;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your class characteristic import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Imports\InvoicePendingReasonImport;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Storage;
|
||||
|
||||
class InvoicePendingReason extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-pending-reason';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
|
||||
public ?string $file = null;
|
||||
|
||||
public array $importErrors = [];
|
||||
|
||||
public array $invoicePending = [];
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->filtersForm->fill([
|
||||
'plant_id' => null,
|
||||
'document_number' => null,
|
||||
'remark' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get,$livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if($plantId){
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
}
|
||||
else{
|
||||
$this->dispatch('emptyData');
|
||||
}
|
||||
|
||||
$set('document_number', null);
|
||||
$set('customer_trade_name', null);
|
||||
$set('location', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Select::make('document_number')
|
||||
->label('Document Number')
|
||||
->required()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
||||
->distinct()
|
||||
->pluck('distribution_channel_desc')
|
||||
->filter(fn ($v) => trim($v) !== '')
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$distributions[] = '';
|
||||
|
||||
$pendingInvoices = collect();
|
||||
|
||||
foreach ($distributions as $distribution) {
|
||||
|
||||
$invoices = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('distribution_channel_desc', $distribution)
|
||||
->select('id', 'document_number')
|
||||
->get()
|
||||
->unique('document_number')
|
||||
->filter(fn ($inv) =>
|
||||
! empty($inv->document_number) &&
|
||||
! str_contains($inv->document_number, '-')
|
||||
);
|
||||
|
||||
if (trim($distribution) == '') {
|
||||
$invoices = $invoices->filter(fn ($inv) =>
|
||||
str_starts_with($inv->document_number, '7')
|
||||
);
|
||||
}
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceNumbers = $invoices->pluck('document_number')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$wentOut = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
->distinct()
|
||||
->pluck('qr_code')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$pending = $invoices->filter(function ($inv) use ($wentOut) {
|
||||
$doc = preg_replace('/\s+/', '', strtoupper($inv->document_number));
|
||||
return ! in_array($doc, $wentOut, true);
|
||||
});
|
||||
|
||||
$pendingInvoices = $pendingInvoices->merge($pending);
|
||||
}
|
||||
|
||||
return $pendingInvoices
|
||||
->unique('document_number')
|
||||
->pluck('document_number', 'document_number')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
$documentNumber = $get('document_number');
|
||||
|
||||
$customers = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->value('customer_trade_name');
|
||||
|
||||
$location = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->value('location');
|
||||
|
||||
$set('customer_trade_name', $customers);
|
||||
$set('location', $location);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pqBlockError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pqBlockError') ? $get('pqBlockError') : null)
|
||||
->hintColor('danger'),
|
||||
TextInput::make('customer_trade_name')
|
||||
->label('Customer Trade Name')
|
||||
->required()
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->columnSpan(1),
|
||||
TextInput::make('location')
|
||||
->label('Location')
|
||||
->required()
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->columnSpan(1),
|
||||
TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->reactive()
|
||||
->maxLength(40)
|
||||
->helperText('Max 40 characters allowed.')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter.prevent' => 'addRemark($event.target.value)',
|
||||
])
|
||||
->autofocus()
|
||||
->required(),
|
||||
FileUpload::make('file')
|
||||
->label('Upload Excel File')
|
||||
->required()
|
||||
->disk('local')
|
||||
->multiple(false)
|
||||
->directory('invoice-pending')
|
||||
->dehydrated(false)
|
||||
//->preserveFilenames()
|
||||
//->storeFiles()
|
||||
//storeFileNamesIn('original_name')
|
||||
// ->visibility('private')
|
||||
->acceptedFileTypes([
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-excel',
|
||||
'text/csv',
|
||||
])
|
||||
->rules(['mimes:xlsx,xls,csv'])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile) {
|
||||
$set('file', $state->store('invoice-pending'));
|
||||
}
|
||||
}),
|
||||
])
|
||||
->columns(3);
|
||||
}
|
||||
|
||||
public function addRemark(){
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$documentNumber = $this->filters['document_number'] ?? null;
|
||||
$remark = $this->filters['remark'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant first..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
if (! $documentNumber) {
|
||||
Notification::make()
|
||||
->title('Document Number')
|
||||
->body("please select document number..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
if ($remark == '') {
|
||||
Notification::make()
|
||||
->title('Remark')
|
||||
->body("Remark can't be empty..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->update([
|
||||
'remark' => $remark,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
'plant_id' => $plantId,
|
||||
'document_number' => $documentNumber,
|
||||
'remark' => null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Remark updated successfully')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
// public function importPendingReason()
|
||||
// {
|
||||
|
||||
// $file = $this->filters['file'] ?? null;
|
||||
|
||||
// $absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
// Excel::import(new InvoicePendingReasonImport, $absolutePath);
|
||||
|
||||
// $this->reset('filters.file');
|
||||
|
||||
// Notification::make()
|
||||
// ->title('File processed and database updated successfully')
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
public function importPendingReason()
|
||||
{
|
||||
$file = $this->filters['file'] ?? null;
|
||||
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (empty($file)) {
|
||||
Notification::make()
|
||||
->title('Please upload a file')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// if (
|
||||
// empty($fileFilter) ||
|
||||
// !is_array($fileFilter) ||
|
||||
// empty($fileFilter[0])
|
||||
// ) {
|
||||
// Notification::make()
|
||||
// ->title('Please upload a file')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// $filePath = $fileFilter[0];
|
||||
|
||||
// if (!is_string($filePath)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid file upload')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
$absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
$import = new InvoicePendingReasonImport();
|
||||
|
||||
try {
|
||||
|
||||
Excel::import(
|
||||
$import,
|
||||
$absolutePath
|
||||
);
|
||||
|
||||
if(!empty($import->plantCodeEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant code can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->docNoEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document number can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (! empty($import->duplicateExcelDocs)) {
|
||||
|
||||
$duplicates = collect($import->duplicateExcelDocs)
|
||||
->map(function ($rows, $key) {
|
||||
[$plant, $doc] = explode('|', $key);
|
||||
return "{$plant}-{$doc}";
|
||||
})
|
||||
->implode(', ');
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Duplicate Document Numbers found in Excel: {$duplicates}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingPlantCodes)) {
|
||||
$codes = implode(', ', array_keys($import->missingPlantCodes));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant codes not found: {$codes}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingDocNo)) {
|
||||
$docNo = implode(', ', array_keys($import->missingDocNo));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document numbers not found: {$docNo}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($import->validRows as $row) {
|
||||
InvoiceDataValidation::where('plant_id', $row['plant_id'])
|
||||
->where('document_number', $row['document_number'])
|
||||
->update([
|
||||
'remark' => $row['remark'],
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Import successful')
|
||||
->body('All records updated successfully.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import error')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function exportPendingReason()
|
||||
{
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId);
|
||||
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice pending reason');
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view welcome page');
|
||||
// }
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Machine;
|
||||
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;
|
||||
|
||||
class CharacteristicApproverMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->columnSpan(2)
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->columnSpan(2)
|
||||
// ->relationship('machine', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->machine_id ?? [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->default('NIL')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->machine_name ?? '';
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Section::make('Approver - 1')
|
||||
// ->description('Prevent abuse by limiting the number of requests per period')
|
||||
->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name1')
|
||||
->label('Name')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail1')
|
||||
->label('Mail')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration1')
|
||||
->label('Duration (HH.MM)')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 4]),
|
||||
Section::make('Approver - 2')
|
||||
->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name2')
|
||||
->label('Name')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail2')
|
||||
->label('Mail')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration2')
|
||||
->label('Duration (HH.MM)')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 4]),
|
||||
Section::make('Approver - 3')
|
||||
->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name3')
|
||||
->label('Name')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail3')
|
||||
->label('Mail')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration3')
|
||||
->label('Duration (HH.MM)')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 4]),
|
||||
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),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 4]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name1')
|
||||
->label('Approver Name 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail1')
|
||||
->label('Mail 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration1')
|
||||
->label('Duration 1 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name2')
|
||||
->label('Approver Name 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail2')
|
||||
->label('Mail 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration2')
|
||||
->label('Duration 2 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name3')
|
||||
->label('Approver Name 3')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail3')
|
||||
->label('Mail 3')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration3')
|
||||
->label('Duration 3 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->color('warning')
|
||||
// ->importer(CharacteristicApproverMasterImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import characteristic approver master');
|
||||
// }),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->color('warning')
|
||||
->exporter(CharacteristicApproverMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export characteristic approver master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCharacteristicApproverMasters::route('/'),
|
||||
'create' => Pages\CreateCharacteristicApproverMaster::route('/create'),
|
||||
'view' => Pages\ViewCharacteristicApproverMaster::route('/{record}'),
|
||||
'edit' => Pages\EditCharacteristicApproverMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCharacteristicApproverMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCharacteristicApproverMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::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\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCharacteristicApproverMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCharacteristicApproverMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateClassCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditClassCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::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\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListClassCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewClassCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -59,8 +59,6 @@ class InvoiceDataValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
@@ -125,11 +123,6 @@ class InvoiceDataValidationResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
@@ -398,104 +398,122 @@ class InvoiceOutValidationResource extends Resource
|
||||
// }
|
||||
|
||||
$successCount = 0;
|
||||
$updateCount = 0;
|
||||
$insertCount = 0;
|
||||
$failedRecords = [];
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
DB::beginTransaction();
|
||||
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
try {
|
||||
$qrcode = trim($row[1]);
|
||||
$plantCode = trim($row[2]);
|
||||
$scannedAt = trim($row[3]);
|
||||
$scannedBy = trim($row[4]);
|
||||
|
||||
if (empty($qrcode)) {
|
||||
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
||||
try {
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||
}
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
$formattedDate = null;
|
||||
if (! empty($scannedAt)) {
|
||||
try {
|
||||
// $formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||
// ->format('Y-m-d H:i:s');
|
||||
if (is_numeric($scannedAt)) {
|
||||
$formattedDate = ExcelDate::excelToDateTimeObject($scannedAt)
|
||||
->format('Y-m-d H:i:s');
|
||||
} else {
|
||||
// Or handle as manual string date (d-m-Y H:i:s)
|
||||
$formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||
->format('Y-m-d H:i:s');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Invalid date format : '{$scannedAt}'");
|
||||
try {
|
||||
$qrcode = trim($row[1]);
|
||||
$plantCode = trim($row[2]);
|
||||
$scannedAt = trim($row[3]);
|
||||
$scannedBy = trim($row[4]);
|
||||
|
||||
if (empty($qrcode)) {
|
||||
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||
}
|
||||
|
||||
$formattedDate = null;
|
||||
if (! empty($scannedAt)) {
|
||||
try {
|
||||
// $formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||
// ->format('Y-m-d H:i:s');
|
||||
if (is_numeric($scannedAt)) {
|
||||
$formattedDate = ExcelDate::excelToDateTimeObject($scannedAt)
|
||||
->format('Y-m-d H:i:s');
|
||||
} else {
|
||||
// Or handle as manual string date (d-m-Y H:i:s)
|
||||
$formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||
->format('Y-m-d H:i:s');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Invalid date format : '{$scannedAt}'");
|
||||
}
|
||||
}
|
||||
|
||||
$record = InvoiceOutValidation::where('plant_id', $plant->id)
|
||||
->where('qr_code', $qrcode)
|
||||
->first();
|
||||
|
||||
$curStat = $record ? 'Updation' : 'Insertion';
|
||||
|
||||
if ($record) {
|
||||
$record->update([
|
||||
'scanned_at' => $formattedDate,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted = $record;
|
||||
} else {
|
||||
// Record does not exist, create with 'created_by'
|
||||
$inserted = InvoiceOutValidation::create([
|
||||
'plant_id' => $plant->id,
|
||||
'qr_code' => $qrcode,
|
||||
'scanned_at' => $formattedDate,
|
||||
'scanned_by' => $scannedBy,
|
||||
'created_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
// $inserted = InvoiceOutValidation::create([
|
||||
// 'plant_id' => $plant->id,
|
||||
// 'qr_code' => $qrcode,
|
||||
// 'scanned_at' => $formattedDate,
|
||||
// 'scanned_by' => $scannedBy,
|
||||
// 'created_by' => $operatorName
|
||||
// ]);
|
||||
|
||||
if (! $inserted) {
|
||||
throw new \Exception("{$curStat} failed for QR : {$qrcode}");
|
||||
}
|
||||
|
||||
$successCount++;
|
||||
} catch (\Exception $e) {
|
||||
$failedRecords[] = [
|
||||
'row' => $rowNumber,
|
||||
'qrcode' => $qrcode ?? null,
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
$exists = InvoiceOutValidation::where('plant_id', $plant->id)
|
||||
->where('qr_code', $qrcode)
|
||||
->first();
|
||||
|
||||
InvoiceOutValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'qr_code' => $qrcode,
|
||||
],
|
||||
[
|
||||
'scanned_at' => $formattedDate,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
]
|
||||
);
|
||||
|
||||
$exists ? $updateCount++ : $insertCount++;
|
||||
$successCount++;
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$failedRecords[] = [
|
||||
'row' => $rowNumber,
|
||||
'qrcode' => $qrcode ?? null,
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($failedRecords) > 0) {
|
||||
DB::commit();
|
||||
|
||||
if (count($failedRecords) > 0) {
|
||||
$failedSummary = collect($failedRecords)
|
||||
->map(fn ($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
||||
->take(5)
|
||||
->take(5) // limit preview to first 5 errors
|
||||
->implode("\n");
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body(
|
||||
"Total Success: {$successCount}\n" .
|
||||
"Inserted: {$insertCount}\n" .
|
||||
"Updated: {$updateCount}\n" .
|
||||
"Failed: " . count($failedRecords) . "\n\n" .
|
||||
$failedSummary
|
||||
)
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body("'{$successCount}' records inserted. ".count($failedRecords)." failed.\n\n{$failedSummary}")
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Import Success')
|
||||
->body("Successfully imported '{$successCount}' records.")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Notification::make()
|
||||
->title('Import Success')
|
||||
->body("Successfully imported '{$successCount}' records.")
|
||||
->success()
|
||||
->title('Import Failed')
|
||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Attributes\On;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
@@ -53,7 +53,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
public $excel_file;
|
||||
|
||||
public $mInvoiceNo;
|
||||
|
||||
public function getFormActions(): array
|
||||
@@ -122,7 +121,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// ..GET SERIAL INVOICE API
|
||||
|
||||
if (strlen($invoiceNumber) > 15) {
|
||||
if(strlen($invoiceNumber) > 15)
|
||||
{
|
||||
|
||||
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
||||
|
||||
@@ -132,44 +132,41 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = json_decode($payloadJson, true);
|
||||
|
||||
if (! isset($payload['data'])) {
|
||||
|
||||
if (!isset($payload['data'])) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$documentData = $payload['data'];
|
||||
|
||||
if ($documentData == '' || $documentData == '') {
|
||||
if($documentData == '' || $documentData == ''){
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract DocNo
|
||||
// Extract DocNo
|
||||
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
||||
|
||||
if (! isset($matches[1])) {
|
||||
if (!isset($matches[1])) {
|
||||
Notification::make()
|
||||
->title('Invoice number not found.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +175,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
// dd($invoiceNumber);
|
||||
//dd($invoiceNumber);
|
||||
|
||||
// ..
|
||||
|
||||
@@ -1430,7 +1427,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$missingCodes = [];
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
@@ -1442,8 +1438,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if (Str::length($materialCode) < 6) {
|
||||
continue;
|
||||
} else {
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($plantId, $materialCode) {
|
||||
$query->where('plant_id', $plantId)->where('code', $materialCode); // $this->plantId >> Check if item.code matches Excel's materialCode
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
|
||||
$query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
|
||||
});
|
||||
if ($sticker->exists()) {
|
||||
if ($sticker->first()->material_type && ! empty($sticker->first()->material_type)) {
|
||||
@@ -1454,8 +1450,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$missingCodes[] = $materialCode;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1464,26 +1458,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
$uniqueCodes = array_unique($missingCodes);
|
||||
|
||||
if (! empty($uniqueCodes)) {
|
||||
$missingCount = count($uniqueCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:<br>'.implode(', ', $uniqueCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// if ($disk->exists($filePath)) {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
return;
|
||||
} elseif ($invoiceType == 'M') {
|
||||
if ($invoiceType == 'M') {
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
$missingQuantities = [];
|
||||
@@ -2899,7 +2874,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if ($dupRecord) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned Material QR : '{$serialNumber}' already completed the scanning process..!")
|
||||
->body("Scanned 'Material QR' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
@@ -2998,19 +2973,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
} else {
|
||||
if (str_contains($serialNumber, '|')) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned Material QR : '{$serialNumber}' already completed the scanning process..!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$itemCode = null;
|
||||
$this->currentItemCode = '';
|
||||
$batchNumber = null;
|
||||
$serNo = null;
|
||||
$serialNumber = null;
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned 'Material QR' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
@@ -3220,7 +3195,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'NotFoundInvoice')
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
@@ -3359,7 +3334,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadMotorQr == $hasMotorQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Motor QR')
|
||||
->body("Scanned Motor Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->body("Scanned 'Motor' serial number already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3476,7 +3451,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadPumpQr == $hasPumpQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump QR')
|
||||
->body("Scanned Pump Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->body("Scanned 'Pump' serial number already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3595,7 +3570,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadCapacitorQr == '1' && $hasCapacitorQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Capacitor QR')
|
||||
->body("Scanned Capacitor Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->body("Scanned 'Capacitor' serial number already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3657,7 +3632,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadPumpSetQr == $hasPumpSetQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump Set QR')
|
||||
->body("Scanned Pump Set Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->body("Scanned 'Pump Set' serial number already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
|
||||
@@ -197,7 +197,6 @@ class ItemResource extends Resource
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label('Category')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -218,7 +217,6 @@ class ItemResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -239,7 +237,6 @@ class ItemResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Item Code')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -259,7 +256,7 @@ class ItemResource extends Resource
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('code')
|
||||
->label('Search by Code')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('Plant');
|
||||
|
||||
@@ -156,9 +156,6 @@ class LineResource extends Resource
|
||||
'Base FG Line' => 'Base FG Line',
|
||||
'SFG Line' => 'SFG Line',
|
||||
'FG Line' => 'FG Line',
|
||||
'Process Base FG Line' => 'Process Base FG Line',
|
||||
'Process SFG Line' => 'Process SFG Line',
|
||||
'Process FG Line' => 'Process FG Line',
|
||||
'Machining Cell' => 'Machining Cell',
|
||||
'Blanking Cell' => 'Blanking Cell',
|
||||
'Forming Cell' => 'Forming Cell',
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Exports\ProcessOrderExporter;
|
||||
use App\Filament\Imports\ProcessOrderImporter;
|
||||
use App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -72,28 +71,6 @@ class ProcessOrderResource extends Resource
|
||||
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
|
||||
->hintColor('danger')
|
||||
->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 (callable $set, callable $get, ?string $state) {
|
||||
$set('item_id', null);
|
||||
$set('item_description', null);
|
||||
$set('item_uom', null);
|
||||
$set('process_order', null);
|
||||
$set('order_quantity', null);
|
||||
$set('received_quantity', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'id')
|
||||
@@ -154,7 +131,6 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
Forms\Components\TextInput::make('item_uom')
|
||||
->label('UOM')
|
||||
->readOnly()
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
@@ -269,8 +245,6 @@ class ProcessOrderResource extends Resource
|
||||
->label('Received Quantity')
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('scrap_quantity')
|
||||
->label('Scrap Quantity'),
|
||||
Forms\Components\TextInput::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->reactive()
|
||||
@@ -305,9 +279,6 @@ class ProcessOrderResource extends Resource
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine ID'),
|
||||
Forms\Components\TextInput::make('rework_status')
|
||||
->label('Rework Status')
|
||||
->default(0),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
@@ -517,11 +488,6 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->searchable()
|
||||
@@ -557,11 +523,6 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scrap_quantity')
|
||||
->label('Scrap Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->alignCenter()
|
||||
@@ -572,12 +533,6 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rework_status')
|
||||
->label('Rework Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => $state == 1 ? 'Yes' : 'No')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
@@ -1,890 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\RequestCharacteristicExporter;
|
||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RequestCharacteristicResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RequestCharacteristic::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
// $disableField = function ($get) {
|
||||
// $currentUser = Filament::auth()->user();
|
||||
// $approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
// if (!$approverId) return true; // disable if no approver selected
|
||||
|
||||
// $approver = CharacteristicApproverMaster::find($approverId);
|
||||
// if (!$approver) return true;
|
||||
|
||||
// // Enable if Super Admin
|
||||
// if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
// return false; // not disabled
|
||||
// }
|
||||
|
||||
// // Enable only if current user is one of the approvers
|
||||
// $userName = $currentUser?->name;
|
||||
|
||||
// return !in_array($userName, [
|
||||
// $approver->name1,
|
||||
// $approver->name2,
|
||||
// $approver->name3,
|
||||
// ]);
|
||||
// };
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$updRec = $get('id');
|
||||
$set('machine_id', null);
|
||||
$set('item_id', null);
|
||||
$set('aufnr', null);
|
||||
$set('machine_name', null);
|
||||
$set('characteristic_approver_master_id', null);
|
||||
if (! $updRec && $plantId) {
|
||||
$set('work_flow_id', self::isNewWorkFlow($get));
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->machine_id ?? [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_id', null);
|
||||
$set('aufnr', null);
|
||||
$set('machine_name', null);
|
||||
$set('characteristic_approver_master_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->default(function ($state, callable $set, callable $get) {
|
||||
$updRec = $get('id');
|
||||
if (! $updRec) {
|
||||
return self::isNewWorkFlow($get);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('request_characteristics', 'work_flow_id')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item')
|
||||
// ->relationship('item', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('aufnr', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->item_id ?? [];
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->aufnr ?? '';
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('machine_name')
|
||||
->label('Machines')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$machineId = $get('machine_id');
|
||||
|
||||
if (! $plantId || ! $machineId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'machine_name')->unique();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('characteristic_approver_master_id', null);
|
||||
// dd($get('characteristic_approver_master_id'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
$machineName = '';
|
||||
$reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||
if ($reqId) {
|
||||
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||
if ($reqMac) {
|
||||
$machineName = $reqMac;
|
||||
} else {
|
||||
$machineName = null;
|
||||
}
|
||||
} else {
|
||||
$machineName = null;
|
||||
}
|
||||
|
||||
// return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
||||
return $machineName ?? [];
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
$reqId = RequestCharacteristic::where('id', $get('id'))->first()?->characteristic_approver_master_id;
|
||||
if ($reqId) {
|
||||
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||
if ($reqMac) {
|
||||
$set('machine_name', $reqMac);
|
||||
} else {
|
||||
$set('machine_name', null);
|
||||
}
|
||||
} else {
|
||||
$set('machine_name', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||
->label('Master Characteristic Field')
|
||||
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$machineId = $get('machine_id');
|
||||
$machineName = $get('machine_name');
|
||||
|
||||
if (! $plantId || ! $machineId || ! $machineName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->pluck('characteristic_field', 'id');
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
||||
Section::make('Request Characteristic')
|
||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->reactive()
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('current_value')
|
||||
->label('Current Value')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled(get: $get)),
|
||||
Forms\Components\TextInput::make('update_value')
|
||||
->label('Update Value')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
])
|
||||
->collapsible()
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
Section::make(function ($get): string {
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
$approverName = $approverId ? CharacteristicApproverMaster::find($approverId)?->name1 : null;
|
||||
|
||||
return 'Approver - 1'.($approverName ? " ( {$approverName} )" : '');
|
||||
})
|
||||
->reactive()
|
||||
// ->description(fn (Get $get) => CharacteristicApproverMaster::find($get('characteristic_approver_master_id'))?->name1 ?? 'Select approver above'
|
||||
// )
|
||||
->schema([
|
||||
Forms\Components\Select::make('approver_status1')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->live()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state && empty($get('approved1_at'))) {
|
||||
$set('approved1_at', now());
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Super Admin can edit any
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false; // field enabled
|
||||
}
|
||||
|
||||
// Otherwise, enable only if the user's name matches
|
||||
return $approver->name1 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark1')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$updId = $get('id');
|
||||
|
||||
if (! $updId) {
|
||||
return true;
|
||||
} elseif ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('approved1_at')
|
||||
// ->label('Approved At')
|
||||
->label(fn (callable $get): string => match ($get('approver_status1')) {
|
||||
'Approved' => 'Approved At',
|
||||
'Hold' => 'Hold At',
|
||||
'Rejected' => 'Rejected At',
|
||||
default => 'Updated At',
|
||||
})
|
||||
->reactive()
|
||||
->live()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name1 != $currentUser?->name;
|
||||
}),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
Section::make(function ($get): string {
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
$approverName = $approverId ? CharacteristicApproverMaster::find($approverId)?->name2 : null;
|
||||
|
||||
return 'Approver - 2'.($approverName ? " ( {$approverName} )" : '');
|
||||
})
|
||||
->reactive()
|
||||
->schema([
|
||||
Forms\Components\Select::make('approver_status2')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state && empty($get('approved2_at'))) {
|
||||
$set('approved2_at', now());
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // get the User object
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Super Admin can always edit
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false; // ENABLE field
|
||||
}
|
||||
|
||||
// Otherwise, enable only if the user's name matches
|
||||
return $approver->name2 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark2')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$updId = $get('id');
|
||||
|
||||
if (! $updId) {
|
||||
return true;
|
||||
} elseif ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('approved2_at')
|
||||
->label(fn (callable $get): string => match ($get('approver_status2')) {
|
||||
'Approved' => 'Approved At',
|
||||
'Hold' => 'Hold At',
|
||||
'Rejected' => 'Rejected At',
|
||||
default => 'Updated At',
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name2 != $currentUser?->name;
|
||||
}),
|
||||
// ->dehydrated(true),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
Section::make(function ($get): string {
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
$approverName = $approverId ? CharacteristicApproverMaster::find($approverId)?->name3 : null;
|
||||
|
||||
return 'Approver - 3'.($approverName ? " ( {$approverName} )" : '');
|
||||
})
|
||||
->reactive()
|
||||
->schema([
|
||||
Forms\Components\Select::make('approver_status3')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state && empty($get('approved3_at'))) {
|
||||
$set('approved3_at', now());
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
} else {
|
||||
return $approver->name3 != $currentUser?->name;
|
||||
}
|
||||
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark3')
|
||||
->label('Approver Remark')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$updId = $get('id');
|
||||
|
||||
if (! $updId) {
|
||||
return true;
|
||||
} elseif ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('approved3_at')
|
||||
->label(fn (callable $get): string => match ($get('approver_status3')) {
|
||||
'Approved' => 'Approved At',
|
||||
'Hold' => 'Hold At',
|
||||
'Rejected' => 'Rejected At',
|
||||
default => 'Updated At',
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name3 != $currentUser?->name;
|
||||
}),
|
||||
])
|
||||
->collapsed()// collapsible()
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
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),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function isFieldDisabled($get): bool
|
||||
{
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userName = $currentUser?->name;
|
||||
|
||||
return in_array($userName, [
|
||||
$approver->name1,
|
||||
$approver->name2,
|
||||
$approver->name3,
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function isNewWorkFlow($get): string
|
||||
{
|
||||
$year = now()->format('y');
|
||||
$month = now()->format('m');
|
||||
$date = now()->format('d');
|
||||
$prefix = "WF-{$year}{$month}{$date}-";
|
||||
|
||||
$lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%")
|
||||
// ->where('machine_id', $MachineId)
|
||||
->where('work_flow_id', 'like', "{$prefix}%")
|
||||
->orderByDesc('work_flow_id')
|
||||
->first();
|
||||
|
||||
if ($lastWorkflow) {
|
||||
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
|
||||
$nextSerial = str_pad(
|
||||
intval($lastSerial) + 1,
|
||||
3,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
);
|
||||
} else {
|
||||
$nextSerial = '001';
|
||||
}
|
||||
|
||||
$workFlowId = "{$prefix}{$nextSerial}";
|
||||
|
||||
return $workFlowId;
|
||||
}
|
||||
|
||||
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('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->alignCenter()
|
||||
->searchable(), // isIndividual: true
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.machine_name')
|
||||
->label('Machine')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.characteristic_field')
|
||||
->label('Master Characteristic')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_value')
|
||||
->label('Current Value')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('update_value')
|
||||
->label('Update Value')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name1')
|
||||
->label('Approver Name 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status1')
|
||||
->label('Approver Status 1')
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Approved' => 'success',
|
||||
'Hold' => 'warning',
|
||||
'Rejected' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark1')
|
||||
->label('Approver Remark 1')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved1_at')
|
||||
->label('Approver At 1')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name2')
|
||||
->label('Approver Name 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status2')
|
||||
->label('Approver Status 2')
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Approved' => 'success',
|
||||
'Hold' => 'warning',
|
||||
'Rejected' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark2')
|
||||
->label('Approver Remark 2')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved2_at')
|
||||
->label('Approver At 2')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name3')
|
||||
->label('Approver Name 3')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status3')
|
||||
->label('Approver Status 3')
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Approved' => 'success',
|
||||
'Hold' => 'warning',
|
||||
'Rejected' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark3')
|
||||
->label('Approver Remark 3')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved3_at')
|
||||
->label('Approver At 3')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Work Flow ID')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->color('warning')
|
||||
// ->importer(RequestCharacteristicImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import request characteristic');
|
||||
// }),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->color('warning')
|
||||
->exporter(RequestCharacteristicExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export request characteristic');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRequestCharacteristics::route('/'),
|
||||
'create' => Pages\CreateRequestCharacteristic::route('/create'),
|
||||
'view' => Pages\ViewRequestCharacteristic::route('/{record}'),
|
||||
'edit' => Pages\EditRequestCharacteristic::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRequestCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRequestCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::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\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRequestCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewRequestCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,6 @@ use Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Livewire\Livewire;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
use App\Services\SmbService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateSerialValidation extends CreateRecord
|
||||
{
|
||||
@@ -64,13 +61,10 @@ class CreateSerialValidation extends CreateRecord
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
|
||||
public function processInvoice($invoiceNumber)
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
|
||||
$fileName = $invoiceNumber . '.txt';
|
||||
|
||||
$this->showCapacitorInput = false;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
@@ -94,187 +88,6 @@ class CreateSerialValidation extends CreateRecord
|
||||
|
||||
//..GET SERIAL INVOICE API
|
||||
|
||||
$content = SmbService::readTextFile($fileName);
|
||||
|
||||
if ($content == '') {
|
||||
Notification::make()
|
||||
->title('File Not Found')
|
||||
->body("Unable to locate file: {$fileName}")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$lines = preg_split("/\r\n|\n|\r/", trim($content));
|
||||
|
||||
$insertData = [];
|
||||
$missingItemCodes = [];
|
||||
$InvalidLenSno = [];
|
||||
$InvalidSno = [];
|
||||
$InvalidLenItem = [];
|
||||
$InvalidItem = [];
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$line = trim($line);
|
||||
if ($line == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parts = array_map('trim', explode(',', $line));
|
||||
|
||||
if (count($parts) != 2) {
|
||||
Notification::make()
|
||||
->title("Invalid data found inside the file.")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
[$itemCode, $serialNumber] = $parts;
|
||||
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)
|
||||
->whereHas('item', function ($query) use ($itemCode, $plantId) {
|
||||
$query->where('plant_id', $plantId)
|
||||
->where('code', $itemCode);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (Str::length($itemCode) < 6)
|
||||
{
|
||||
$InvalidLenItem [] = $itemCode;
|
||||
continue;
|
||||
}
|
||||
else if(!is_numeric($itemCode)){
|
||||
$InvalidItem [] = $itemCode;
|
||||
continue;
|
||||
}
|
||||
if (Str::length($serialNumber) < 9)
|
||||
{
|
||||
$InvalidLenSno [] = $serialNumber;
|
||||
continue;
|
||||
}
|
||||
else if(!ctype_alnum($serialNumber)){
|
||||
$InvalidSno [] = $serialNumber;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$sticker) {
|
||||
$missingItemCodes[] = $itemCode;
|
||||
continue;
|
||||
}
|
||||
|
||||
$insertData[] = [
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $serialNumber,
|
||||
'created_at' => now(),
|
||||
'operator_id' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($InvalidLenItem))
|
||||
{
|
||||
$count = count($InvalidLenItem);
|
||||
|
||||
if ($count <= 10) {
|
||||
$body = 'Item Code should contain minimum 6 digits: ' . implode(', ', $InvalidLenItem);
|
||||
} else {
|
||||
$body = "{$count} item codes contain minimum 6 digits.";
|
||||
}
|
||||
Notification::make()
|
||||
->title("Invalid Item Code.")
|
||||
->body("$body")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!empty($InvalidItem))
|
||||
{
|
||||
$count = count($InvalidItem);
|
||||
|
||||
if ($count <= 10) {
|
||||
$body = 'Item code must be in numeric values: ' . implode(', ', $InvalidSno);
|
||||
} else {
|
||||
$body = "{$count} item codes must be in numeric values.";
|
||||
}
|
||||
Notification::make()
|
||||
->title("Invalid Item Code.")
|
||||
->body("$body")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!empty($InvalidLenSno))
|
||||
{
|
||||
$count = count($InvalidLenSno);
|
||||
|
||||
if ($count <= 10) {
|
||||
$body = 'Serial number should be minimum 9 digits: ' . implode(', ', $InvalidLenSno);
|
||||
} else {
|
||||
$body = "{$count} serial number should be minimum 9 digits.";
|
||||
}
|
||||
Notification::make()
|
||||
->title("Invalid Serial Number.")
|
||||
->body("$body")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!empty($InvalidSno))
|
||||
{
|
||||
$count = count($InvalidSno);
|
||||
|
||||
if ($count <= 10) {
|
||||
$body = 'Serial number should be conatin alpha numeric values: ' . implode(', ', $InvalidSno);
|
||||
} else {
|
||||
$body = "{$count} serial number should be conatin alpha numeric values.";
|
||||
}
|
||||
Notification::make()
|
||||
->title("Invalid Serial Number.")
|
||||
->body("$body")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!empty($missingItemCodes))
|
||||
{
|
||||
$count = count($missingItemCodes);
|
||||
|
||||
if ($count <= 10) {
|
||||
$body = 'Item codes not found in sticker master: ' . implode(', ', $missingItemCodes);
|
||||
} else {
|
||||
$body = "{$count} item codes not found in sticker master table.";
|
||||
}
|
||||
Notification::make()
|
||||
->title("Unknown Item Code.")
|
||||
->body("$body")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($insertData)) {
|
||||
SerialValidation::insert($insertData);
|
||||
}
|
||||
else{
|
||||
Notification::make()
|
||||
->title("Insert Failed.")
|
||||
->body("Data insertion failed")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
//..
|
||||
|
||||
@@ -2498,9 +2311,8 @@ class CreateSerialValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function processSer($serNo)
|
||||
public function processSerialNumber($serNo)
|
||||
{
|
||||
|
||||
$serNo = trim($serNo);
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $user->name;
|
||||
@@ -2983,28 +2795,24 @@ class CreateSerialValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
// $this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId);
|
||||
//$this->dispatch('focusCapacitor', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId);
|
||||
|
||||
$this->dispatch('focusCapacitor', itemCode: $itemCode);
|
||||
$scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
$totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '')
|
||||
$scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
//$scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
// $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
// $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
// $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '')
|
||||
// $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $plantId,
|
||||
// 'invoice_number' => $invoiceNumber,
|
||||
// 'serial_number' => $serNo,
|
||||
// 'total_quantity' => $totQuan,
|
||||
// 'update_invoice' => false,
|
||||
// 'scanned_quantity'=> $scanSQuan,
|
||||
// ]);
|
||||
// $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
else if ($isMarkPs)
|
||||
@@ -3150,173 +2958,6 @@ class CreateSerialValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
#[On('process-scan')]
|
||||
public function processSerial($serial)
|
||||
{
|
||||
$this->processSer($serial);
|
||||
}
|
||||
|
||||
public function processCapacitor($serial, $itemCode)
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
$operatorName = $user->name;
|
||||
|
||||
$this->currentItemCode = $itemCode;
|
||||
|
||||
if (!$serial) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preg_match('/^[^\/]+\/[^\/]+\/.+$/', $serial)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
->danger()
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$parts = explode('/', $serial);
|
||||
|
||||
$supplier = $parts[0];
|
||||
$itemCode = $parts[1];
|
||||
$serialNumber = implode('/', array_slice($parts, 2)); // Keep rest of the string
|
||||
|
||||
$existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
})
|
||||
->exists();
|
||||
|
||||
if (!$existsInStickerMaster) {
|
||||
Notification::make()
|
||||
->title('Unknown: Panel Box Code')
|
||||
->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
|
||||
->danger()
|
||||
// ->duration(4000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (
|
||||
($row['code'] ?? '') === $this->currentItemCode &&
|
||||
($row['serial_number'] ?? '') === $this->currentSerialNumber
|
||||
) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
$row['capacitor_scanned_status'] = 1;
|
||||
// $row['scanned_status_set'] = true;
|
||||
|
||||
$matchingValidation = SerialValidation::with('stickerMaster.item')
|
||||
->where('serial_number', $this->currentSerialNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->get()
|
||||
->first(function ($validation) {
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
});
|
||||
|
||||
if ($matchingValidation) {
|
||||
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $matchingValidation->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
// $hasCapacitorQr = $matchingValidation->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
$hadMotorQr = $matchingValidation->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $matchingValidation->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $matchingValidation->scanned_status_set ?? null;
|
||||
// $hadCapacitorQr = $matchingValidation->capacitor_scanned_status ?? null;
|
||||
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
if($hasMotorQr || $hasPumpQr || $hasPumpSetQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
|
||||
$scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt === $scanCnt)
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Success: Capacitor QR')
|
||||
// // ->title("Panel box code scanned: $itemCode")
|
||||
// ->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
// ->success() // commented
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
$totalQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
// $this->form->fill([
|
||||
// 'plant_id' => $matchingValidation->plant_id,
|
||||
// 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// 'serial_number' => null,
|
||||
// 'total_quantity' => $totalQuantity,
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
|
||||
if($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->showCapacitorInput = false;
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Scan Serial Validation';
|
||||
|
||||
@@ -30,7 +30,6 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
// use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -94,33 +93,21 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
return Item::where('plant_id', $plantId)->whereDoesntHave('stickerMasters')->pluck('code', 'id');
|
||||
} else {
|
||||
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||
|
||||
return Item::where('plant_id', $plantId)
|
||||
->where(function ($query) use ($itemId) {
|
||||
$query->whereDoesntHave('stickerMasters')
|
||||
->orWhere('id', $itemId);
|
||||
})
|
||||
->pluck('code', 'id');
|
||||
}
|
||||
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('sticker_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
return \App\Models\Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('items', 'code')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id')); // Ignore current record during updates
|
||||
// })
|
||||
->required()
|
||||
// ->nullable()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||
@@ -145,7 +132,7 @@ class StickerMasterResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$availableItems = Item::where('plant_id', $plantId)->exists();
|
||||
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
|
||||
if (! $availableItems) {
|
||||
$set('item_error', null);
|
||||
|
||||
@@ -160,7 +147,7 @@ class StickerMasterResource extends Resource
|
||||
}
|
||||
|
||||
// Check if item exists for the selected plant
|
||||
$item = Item::where('plant_id', $plantId)
|
||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||
->where('id', $itemId)
|
||||
->first();
|
||||
|
||||
@@ -174,8 +161,7 @@ class StickerMasterResource extends Resource
|
||||
->where('item_id', $itemId)
|
||||
->exists();
|
||||
if (! $get('id')) {
|
||||
// $set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
||||
$set('item_error', null);
|
||||
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
@@ -191,7 +177,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('id')) {
|
||||
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||
if ($itemId) {
|
||||
$item = Item::where('id', $itemId)->first()?->description;
|
||||
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
||||
if ($item) {
|
||||
$set('item_description', $item);
|
||||
} else {
|
||||
@@ -539,35 +525,27 @@ class StickerMasterResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation1')
|
||||
->label('Part Validation 1')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation5')
|
||||
->label('Part Validation 5')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('load_rate')
|
||||
->label('Load Rate')
|
||||
@@ -575,22 +553,20 @@ class StickerMasterResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('material_type')
|
||||
->label('Material Type')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->formatStateUsing(function ($state) {
|
||||
if (is_null($state) || $state == '') {
|
||||
return '-';
|
||||
if (is_null($state) || $state === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
default => '-',
|
||||
default => '',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -611,7 +587,9 @@ class StickerMasterResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Item Code')
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -657,7 +635,7 @@ class StickerMasterResource extends Resource
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('material_type')
|
||||
->label('Select Material Type')
|
||||
->label('Material Type')
|
||||
->options([
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
@@ -666,7 +644,7 @@ class StickerMasterResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
TextInput::make('panel_box_code')
|
||||
->label('Search by Panel Box Code')
|
||||
->label('Panel Box Code')
|
||||
->placeholder(placeholder: 'Enter Panel Box Code'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
|
||||
@@ -24,8 +24,6 @@ class TestingTempResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'IIOT Temp';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -52,7 +50,6 @@ class TestingTempResource extends Resource
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->maxSize(20480)
|
||||
->reactive(),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
|
||||
@@ -80,7 +80,7 @@ class InvoiceChart extends ChartWidget
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
@@ -99,7 +99,7 @@ class InvoiceChart extends ChartWidget
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
@@ -142,7 +142,7 @@ class InvoiceChart extends ChartWidget
|
||||
$query->where('quantity', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||
|
||||
$completedQuery->where('quantity', 1)
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
@@ -153,7 +153,7 @@ class InvoiceChart extends ChartWidget
|
||||
$query->whereNull('quantity')->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||
|
||||
$completedQuery->whereNull('quantity')
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
@@ -164,7 +164,7 @@ class InvoiceChart extends ChartWidget
|
||||
$query->where('quantity', '>', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||
|
||||
$completedQuery->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
@@ -193,31 +193,22 @@ class InvoiceChart extends ChartWidget
|
||||
}
|
||||
elseif ($activeFilter == 'this_month') {
|
||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(8, 0, 0); // include full last day
|
||||
$monthName = $startOfMonth->format('M');
|
||||
|
||||
// Prepare weekly labels like "May(1-7)", "May(8-14)", etc.
|
||||
$labels = [];
|
||||
$weekStart = $startOfMonth->copy();
|
||||
$importedInvoicesPerWeek = [];
|
||||
$completedInvoicesPerWeek = [];
|
||||
|
||||
$weekIndex = 0;
|
||||
while ($weekStart <= $endOfMonth) {
|
||||
// $weekEnd = $weekStart->copy()->addDays(6);
|
||||
$weekEnd = $weekStart->copy()->addDays(6)->endOfDay();
|
||||
|
||||
// If week end exceeds end of month, limit it
|
||||
if ($weekEnd->greaterThan($endOfMonth)) {
|
||||
$weekEnd = $endOfMonth->copy()->endOfDay();
|
||||
}
|
||||
|
||||
while ($weekStart < $endOfMonth) {
|
||||
$weekEnd = $weekStart->copy()->addDays(7);
|
||||
$startDay = $weekStart->format('j');
|
||||
$endDay = $weekEnd->format('j');
|
||||
|
||||
// $startDay = $weekStart->format('j');
|
||||
// $weekEndLimit = $weekEnd->copy()->subDay();
|
||||
// $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
||||
// $endDay = $actualEnd->format('j');
|
||||
$weekEndLimit = $weekEnd->copy()->subDay();
|
||||
$actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
||||
$endDay = $actualEnd->format('j');
|
||||
|
||||
$labels[] = "{$monthName}({$startDay}-{$endDay})";
|
||||
|
||||
@@ -242,7 +233,7 @@ class InvoiceChart extends ChartWidget
|
||||
// --- Completed ---
|
||||
$queryCompleted = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||
->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
||||
|
||||
if ($selectedInvoice == 'individual_material') {
|
||||
$queryCompleted->where('quantity', 1)
|
||||
@@ -261,8 +252,7 @@ class InvoiceChart extends ChartWidget
|
||||
$completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count();
|
||||
|
||||
// Move to next week
|
||||
// $weekStart = $weekEnd;
|
||||
$weekStart = $weekEnd->copy()->addDay(1);
|
||||
$weekStart = $weekEnd;
|
||||
$weekIndex++;
|
||||
}
|
||||
|
||||
@@ -308,7 +298,6 @@ class InvoiceChart extends ChartWidget
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
public static function getDefaultName(): string
|
||||
{
|
||||
return 'invoice-chart';
|
||||
|
||||
@@ -1,327 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CharacteristicApprovalController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function approve(Request $request)
|
||||
{
|
||||
return $this->updateStatus($request, 'Approved');
|
||||
}
|
||||
|
||||
/**
|
||||
* HOLD
|
||||
*/
|
||||
// public function hold(Request $request)
|
||||
// {
|
||||
// return $this->updateStatus($request, 'Hold');
|
||||
// }
|
||||
|
||||
/**
|
||||
* REJECT
|
||||
*/
|
||||
public function reject(Request $request)
|
||||
{
|
||||
return $this->updateStatus($request, 'Rejected');
|
||||
}
|
||||
|
||||
public function holdForm(Request $request)
|
||||
{
|
||||
$id = $request->query('id');
|
||||
// $level = $request->query('level');
|
||||
|
||||
$level = (int) $request->query('level');
|
||||
|
||||
$record = RequestCharacteristic::findOrFail($id);
|
||||
|
||||
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$currentStatus = $record->$statusColumn;
|
||||
|
||||
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $currentStatus,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('approval.hold-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
public function rejectForm(Request $request)
|
||||
{
|
||||
$id = $request->query('id');
|
||||
// $level = $request->query('level');
|
||||
$level = (int) $request->query('level');
|
||||
|
||||
$record = RequestCharacteristic::findOrFail($id);
|
||||
|
||||
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$currentStatus = $record->$statusColumn;
|
||||
|
||||
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $currentStatus,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('approval.reject-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
public function holdSave(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'id' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'remark' => 'required|string',
|
||||
]);
|
||||
|
||||
return $this->updateStatus($request, 'Hold', false);
|
||||
}
|
||||
|
||||
public function rejectSave(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'id' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'remark' => 'required|string',
|
||||
]);
|
||||
|
||||
return $this->updateStatus($request, 'Rejected', false);
|
||||
}
|
||||
|
||||
// protected function updateStatus(Request $request, string $status)
|
||||
// {
|
||||
// $requestId = $request->query('id');
|
||||
// $level = (int) $request->query('level');
|
||||
|
||||
// $record = RequestCharacteristic::findOrFail($requestId);
|
||||
|
||||
// $column = match ($level) {
|
||||
// 1 => 'approver_status1',
|
||||
// 2 => 'approver_status2',
|
||||
// 3 => 'approver_status3',
|
||||
// default => abort(403, 'Invalid approver level'),
|
||||
// };
|
||||
|
||||
// $pendingRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
// ->where('machine_id', $record->machine_id)
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->whereNull('approver_status1')
|
||||
// ->whereNull('approver_status2')
|
||||
// ->whereNull('approver_status3')
|
||||
// ->get();
|
||||
|
||||
// if ($pendingRecords->isEmpty()) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => 'No pending records for this group'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($pendingRecords->first()->$column != null) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => $pendingRecords->first()->$column
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // Update all records in the group for this approver level
|
||||
// foreach ($pendingRecords as $rec) {
|
||||
// $rec->update([$column => $status]);
|
||||
// }
|
||||
|
||||
// return match ($status) {
|
||||
// 'Approved' => view('approval.success'),
|
||||
// 'Hold' => view('approval.hold-success'),
|
||||
// 'Rejected' => view('approval.reject-success'),
|
||||
// default => abort(500),
|
||||
// };
|
||||
// }
|
||||
|
||||
// protected function updateStatus(Request $request, string $status)
|
||||
// {
|
||||
// $requestId = $request->query('id');
|
||||
// $level = (int) $request->query('level');
|
||||
|
||||
// $record = RequestCharacteristic::findOrFail($requestId);
|
||||
|
||||
// [$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
// 1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
// 2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
// 3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
// default => abort(403, 'Invalid approver level'),
|
||||
// };
|
||||
|
||||
// $pendingRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
// ->where('machine_id', $record->machine_id)
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->where('work_flow_id', $record->work_flow_id)
|
||||
// ->whereNull('approver_status1')
|
||||
// ->whereNull('approver_status2')
|
||||
// ->whereNull('approver_status3')
|
||||
// ->get();
|
||||
|
||||
// if ($pendingRecords->isEmpty()) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => 'No pending records for this group',
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($pendingRecords->first()->$statusColumn !== null) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => $pendingRecords->first()->$statusColumn,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// $updateData = [
|
||||
// $statusColumn => $status,
|
||||
// $remarkColumn => $request->input('remark')
|
||||
// ];
|
||||
|
||||
// if ($status == 'Approved') {
|
||||
// $updateData[$approvedAtColumn] = Carbon::now();
|
||||
// }
|
||||
|
||||
// foreach ($pendingRecords as $rec) {
|
||||
// $rec->update($updateData);
|
||||
// }
|
||||
|
||||
// return match ($status) {
|
||||
// 'Approved' => view('approval.success'),
|
||||
// 'Hold' => view('approval.hold-success'),
|
||||
// 'Rejected' => view('approval.reject-success'),
|
||||
// default => abort(500),
|
||||
// };
|
||||
// }
|
||||
|
||||
protected function updateStatus(Request $request, string $status, bool $returnView = true)
|
||||
{
|
||||
$requestId = $request->input('id');
|
||||
$level = (int) $request->input('level');
|
||||
|
||||
$record = RequestCharacteristic::findOrFail($requestId);
|
||||
|
||||
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$pendingRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
->where('machine_id', $record->machine_id)
|
||||
->where('aufnr', $record->aufnr)
|
||||
->where('work_flow_id', $record->work_flow_id)
|
||||
->whereNull('approver_status1')
|
||||
->whereNull('approver_status2')
|
||||
->whereNull('approver_status3')
|
||||
->get();
|
||||
|
||||
$processRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
->where('machine_id', $record->machine_id)
|
||||
->where('aufnr', $record->aufnr)
|
||||
->where('work_flow_id', $record->work_flow_id)
|
||||
->where(function ($query) {
|
||||
$query->whereNotNull('approver_status1')
|
||||
->orWhereNotNull('approver_status2')
|
||||
->orWhereNotNull('approver_status3');
|
||||
})
|
||||
->get();
|
||||
|
||||
$alreadyProcessed = RequestCharacteristic::whereIn($statusColumn, ['Approved', 'Rejected'])->exists();
|
||||
|
||||
if ($alreadyProcessed) {
|
||||
if ($returnView) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'Already processed',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'This request has already been processed.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
$statusColumn => $status,
|
||||
$remarkColumn => $request->input('remark'),
|
||||
];
|
||||
|
||||
if ($status == 'Approved') {
|
||||
$updateData[$approvedAtColumn] = Carbon::now();
|
||||
}
|
||||
|
||||
foreach ($pendingRecords as $rec) {
|
||||
$rec->update($updateData);
|
||||
}
|
||||
|
||||
foreach ($processRecords as $recd) {
|
||||
$recd->update($updateData);
|
||||
}
|
||||
|
||||
if ($returnView) {
|
||||
return match ($status) {
|
||||
'Approved' => view('approval.success'),
|
||||
'Hold' => view('approval.hold-success'),
|
||||
'Rejected' => view('approval.reject-success'),
|
||||
default => abort(500),
|
||||
};
|
||||
}
|
||||
|
||||
return response()->json(['status' => true, 'message' => 'Status updated successfully']);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -808,29 +808,4 @@ class InvoiceValidationController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// public function handle(Request $request)
|
||||
// {
|
||||
// $invoice = InvoiceValidation::withCount([
|
||||
// 'serialNumbers as scanned_count' => function ($q) {
|
||||
// $q->where('is_scanned', 1);
|
||||
// }
|
||||
// ])->find($request->invoice_id);
|
||||
|
||||
// if (!$invoice) {
|
||||
// return response()->json(['error' => 'Invoice not found'], 404);
|
||||
// }
|
||||
|
||||
// if ($invoice->scanned_count < $invoice->total_serials) {
|
||||
|
||||
// Mail::to('alerts@example.com')->send(
|
||||
// new \App\Mail\IncompleteInvoiceMail(
|
||||
// $invoice,
|
||||
// $invoice->scanned_count,
|
||||
// $invoice->total_serials
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// return response()->json(['status' => 'ok']);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -33,28 +33,29 @@ class MachineController extends Controller
|
||||
public function get_all_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
|
||||
$machinesData = $machines->map(function ($machine) {
|
||||
$machinesData = $machines->map(function($machine) {
|
||||
return [
|
||||
'plant_code' => $machine->plant ? (string) $machine->plant->code : '',
|
||||
'group_work_center' => $machine->workGroupMaster ? (string) $machine->workGroupMaster->name : '',
|
||||
'work_center' => $machine->work_center ?? '',
|
||||
'plant_code' => $machine->plant ? (String)$machine->plant->code : "",
|
||||
'group_work_center' => $machine->workGroupMaster ? (String)$machine->workGroupMaster->name : "",
|
||||
'work_center' => $machine->work_center ?? "",
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'machines' => $machinesData,
|
||||
'machines' => $machinesData
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -64,70 +65,80 @@ class MachineController extends Controller
|
||||
public function get_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$lineName = $request->header('line-name');
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
}
|
||||
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
} elseif ($lineName == null || $lineName == '' || Str::length($lineName) <= 0) {
|
||||
}
|
||||
else if ($lineName == null || $lineName == '' || Str::length($lineName) <= 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name can't be empty!",
|
||||
'status_description' => "Line name can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!",
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
if (! $line) {
|
||||
if (!$line)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line Name '{$lineName}' not found!",
|
||||
'status_description' => "Line Name '{$lineName}' not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
|
||||
if (! $line) {
|
||||
if (!$line)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line Name '{$lineName}' not found for the plant!",
|
||||
'status_description' => "Line Name '{$lineName}' not found for the plant!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$lineId = $line->id; // no_of_operation
|
||||
$lineId = $line->id;//no_of_operation
|
||||
$lineWorkGroup1Id = $line->work_group1_id;
|
||||
$lineWorkGroup2Id = $line->work_group2_id;
|
||||
if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || ! is_numeric($line->no_of_operation)) {
|
||||
if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || !is_numeric($line->no_of_operation))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Group work center not found for the plant & line!',
|
||||
'status_description' => "Group work center not found for the plant & line!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -135,22 +146,26 @@ class MachineController extends Controller
|
||||
$lineWorkGroupIds = [];
|
||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
||||
$curWorkGroupId = $line->{"work_group{$i}_id"};
|
||||
if (in_array($curWorkGroupId, $lineWorkGroupIds)) {
|
||||
if (in_array($curWorkGroupId, $lineWorkGroupIds))
|
||||
{
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineWorkGroupIds[] = $curWorkGroupId;
|
||||
}
|
||||
|
||||
$test[] = [
|
||||
'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? '',
|
||||
'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? '',
|
||||
'work_centers' => Machine::where('plant_id', $plantId)->where('work_group_master_id', $curWorkGroupId)->orderBy('work_center')->pluck('work_center')->toArray() ?? [],
|
||||
'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? "",
|
||||
'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? "",
|
||||
'work_centers' => Machine::where('plant_id', $plantId)->where('work_group_master_id', $curWorkGroupId)->orderBy('work_center')->pluck('work_center')->toArray() ?? [],
|
||||
];
|
||||
}
|
||||
|
||||
if ($lineWorkGroupIds) {
|
||||
if($lineWorkGroupIds)
|
||||
{
|
||||
return response()->json([
|
||||
'machines' => $test,
|
||||
'machines' => $test
|
||||
]);
|
||||
}
|
||||
// $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Mpdf;
|
||||
use Mpdf\QrCode\Output;
|
||||
@@ -21,11 +20,11 @@ class PalletController extends Controller
|
||||
public function downloadReprintQrPdf($palletNo)
|
||||
{
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png;
|
||||
$output = new Output\Png();
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
return '
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@@ -40,10 +39,10 @@ class PalletController extends Controller
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
|
||||
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
</td>
|
||||
<td class="text-cell">
|
||||
'.htmlspecialchars($palletNo).'
|
||||
' . htmlspecialchars($palletNo) . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -74,182 +73,26 @@ class PalletController extends Controller
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
}
|
||||
|
||||
public function downloadReprintProcess($plant, $item, $process_order, $coil_number, $name)
|
||||
{
|
||||
// dd($plant,$item,$process_order,$coil_number);
|
||||
|
||||
$processOrder = \App\Models\ProcessOrder::where('plant_id', $plant)
|
||||
->where('item_id', $item)
|
||||
->where('process_order', $process_order)
|
||||
->where('coil_number', $coil_number)
|
||||
->first();
|
||||
|
||||
if (! $processOrder) {
|
||||
return response()->json(['error' => 'Process order not found'], 404);
|
||||
}
|
||||
|
||||
$receivedQuantity = $processOrder->received_quantity;
|
||||
$machineName = $processOrder->machine_name;
|
||||
$user = $processOrder->created_by;
|
||||
|
||||
$icode = \App\Models\Item::find($item);
|
||||
|
||||
$pCode = \App\Models\Plant::find($plant);
|
||||
|
||||
$plCode = $pCode->code;
|
||||
|
||||
if (! $plCode) {
|
||||
Notification::make()
|
||||
->title('Unknown Plant')
|
||||
->body('Plant not found.')
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
|
||||
if (! $icode) {
|
||||
Notification::make()
|
||||
->title('Unknown Item')
|
||||
->body('Item not found.')
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
|
||||
$itCode = $icode->code;
|
||||
|
||||
$itemAgaPlant = \App\Models\Item::where('code', $itCode)
|
||||
->where('plant_id', $plant)
|
||||
->first();
|
||||
|
||||
if (! $itemAgaPlant) {
|
||||
Notification::make()
|
||||
->title('Unknown Item')
|
||||
->body("Item not found against plant code $plCode.")
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
$itemDescription = $itemAgaPlant->description;
|
||||
}
|
||||
|
||||
$nowDT = now()->format('d-m-Y H:i:s');
|
||||
|
||||
// Build QR content
|
||||
$qrContent = "{$receivedQuantity}|{$itCode}|{$process_order}-{$coil_number}";
|
||||
|
||||
$qrCode = new QrCode($qrContent);
|
||||
$output = new Output\Png;
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@page {
|
||||
size: 60mm 30mm;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 60mm;
|
||||
font-size: 9pt;
|
||||
font-family: "DejaVu Sans Condensed", "FreeSans", sans-serif;
|
||||
}
|
||||
|
||||
.sticker-table {
|
||||
width: 60mm;
|
||||
border-collapse: collapse;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
.text-cell {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
font-size: 9pt;
|
||||
padding-left: 2mm;
|
||||
padding-top: 2mm; /* was 6mm ❌ */
|
||||
font-weight: bold;
|
||||
line-height: 1.1; /* IMPORTANT */
|
||||
white-space: nowrap;
|
||||
width: 40mm;
|
||||
}
|
||||
|
||||
.qr-cell {
|
||||
width: 20mm;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.lbl {
|
||||
display: inline-block;
|
||||
width: 11mm;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.text-cell b {
|
||||
font-size: 10pt; /* was 12pt ❌ */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.qr {
|
||||
width: 12mm;
|
||||
height: 12mm;
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="text-cell">
|
||||
<span class="lbl">D/T</span>: '.htmlspecialchars($nowDT).'<br>
|
||||
<span class="lbl">OP ID</span>: '.htmlspecialchars($user).'<br>
|
||||
<span class="lbl">PO NO</span>: '.htmlspecialchars($process_order).'<br>
|
||||
<span class="lbl">M/C</span>: '.htmlspecialchars($itCode).'<br>
|
||||
<span class="lbl">DES</span>: '.htmlspecialchars($itemDescription).'<br>
|
||||
<span class="lbl">WGT</span>: <b>'.htmlspecialchars($receivedQuantity).' KGS</b><br>
|
||||
<span class="lbl">MAC</span>: '.htmlspecialchars($machineName).'
|
||||
</td>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
setTimeout(function () { window.close(); }, 500);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png;
|
||||
$output = new Output\Png();
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$htmlBlock = '
|
||||
$htmlBlock = '
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
|
||||
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
</td>
|
||||
<td class="text-cell">
|
||||
'.htmlspecialchars($palletNo).'
|
||||
' . htmlspecialchars($palletNo) . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
return '
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@@ -261,7 +104,7 @@ class PalletController extends Controller
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
'.$htmlBlock.$htmlBlock.'
|
||||
' . $htmlBlock . $htmlBlock . '
|
||||
<script>
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\User;
|
||||
@@ -668,14 +667,11 @@ class PdfController extends Controller
|
||||
$plantId = $plant->id;
|
||||
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$lineName = $data['line_name'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
$receivedQty = $data['received_quantity'] ?? 0;
|
||||
$scrapQty = $data['scrap_quantity'] ?? 0;
|
||||
$sfgNo = $data['sfg_number'] ?? '';
|
||||
$machineId = $data['machine_id'] ?? '';
|
||||
$rework = $data['rework'] ?? '';
|
||||
$createdBy = $data['created_by'] ?? '';
|
||||
|
||||
// $validated = $request->validate([
|
||||
@@ -705,35 +701,6 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($lineName == null || $lineName == '' || ! $lineName) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
|
||||
if (! $line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name '{$lineName}' not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineNamePlant = Line::where('name', $lineName)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (! $lineNamePlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name '{$lineName}' not found for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineNamePlantId = $lineNamePlant->id;
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -839,6 +806,18 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
@@ -860,98 +839,25 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
try {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineId,
|
||||
'created_by' => $createdBy,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if($rework != 'Yes' && $rework != 'No'){
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value should be either 'Yes' or 'No'!",
|
||||
], 404);
|
||||
}
|
||||
else if ($rework == 'No')
|
||||
{
|
||||
if($scrapQty != 0){
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Scrap Quanity value should be '0'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ($rework == 'Yes')
|
||||
{
|
||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => 1,
|
||||
'updated_by' => $createdBy,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if ($updated == 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No matching record found for rework coil number!',
|
||||
], 404);
|
||||
}
|
||||
else
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Updated Successfully (Rework)',
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineNamePlantId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineId,
|
||||
'rework_status' => 0,
|
||||
'created_by' => $createdBy,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Inserted Successfully',
|
||||
]);
|
||||
}
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Inserted Successfully',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -960,65 +866,6 @@ class PdfController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function storeLaserPdf(Request $request){
|
||||
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$workflowId = $request->header('work_flow_id');
|
||||
|
||||
if (!$workflowId) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "work_flow_id can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (! $request->hasFile('pdf_file')) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No PDF file provided!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $file = $request->file('pdf_file');
|
||||
// $filename = $file->getClientOriginalName();
|
||||
|
||||
// $filePath = $file->storeAs(
|
||||
// 'uploads/LaserDocs',
|
||||
// $filename,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
$filename = $workflowId . '.pdf';
|
||||
|
||||
$filePath = 'uploads/LaserDocs/' . $filename;
|
||||
|
||||
if (Storage::disk('local')->exists($filePath)) {
|
||||
Storage::disk('local')->delete($filePath);
|
||||
}
|
||||
|
||||
Storage::disk('local')->putFileAs(
|
||||
'uploads/LaserDocs',
|
||||
$filename,
|
||||
'local'
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Laser document pdf file replaced successfully!',
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
@@ -70,10 +70,6 @@ class ProductionStickerReprintController extends Controller
|
||||
{
|
||||
$copies = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$copies = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DriverMaster;
|
||||
use App\Models\VehicleMaster;
|
||||
use Illuminate\Http\Request;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -21,21 +19,10 @@ class SapFileController extends Controller
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string',
|
||||
'identification1' => 'nullable|string',
|
||||
'identification2' => 'nullable|string',
|
||||
'identification3' => 'nullable|string',
|
||||
'contact_number' => 'nullable|string',
|
||||
'alternate_number' => 'nullable|string',
|
||||
]);
|
||||
|
||||
DriverMaster::create($request->all());
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
// public function store(Request $request)
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public function getSapData(Request $request)
|
||||
{
|
||||
@@ -158,6 +145,40 @@ class SapFileController extends Controller
|
||||
], 500);
|
||||
}
|
||||
|
||||
// $table = 'class_characteristics';
|
||||
// $columns = Schema::getColumnListing($table); // returns lowercase column names
|
||||
|
||||
// $rows = [];
|
||||
// foreach ($lines as $line) {
|
||||
// $values = str_getcsv($line); // split by comma
|
||||
|
||||
// $row = [];
|
||||
// foreach ($columns as $index => $column) {
|
||||
// $value = $values[$index] ?? null; // if missing, set null
|
||||
// if ($value === '') $value = null; // empty string -> null
|
||||
// $row[$column] = $value;
|
||||
// }
|
||||
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'DEBUG_ROWS',
|
||||
// 'rows_sample' => array_slice($rows, 0, 5),
|
||||
// ]);
|
||||
|
||||
|
||||
// Insert into database
|
||||
// foreach ($rows as $row) {
|
||||
// \App\Models\ClassCharacteristic::create($row);
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'SUCCESS',
|
||||
// 'rows_imported' => count($rows),
|
||||
// ]);
|
||||
|
||||
|
||||
// Prepare arrays
|
||||
// $serialNumbers = [];
|
||||
// $remainingRows = [];
|
||||
@@ -230,7 +251,7 @@ class SapFileController extends Controller
|
||||
if (!empty($invalidSerials)) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => 'serial numbers are invalid (less than 13 characters)',
|
||||
'status_description' => 'Some serial numbers are invalid (less than 13 characters)',
|
||||
'invalid_serials' => $invalidSerials
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
// use Carbon\Carbon;
|
||||
//use Carbon\Carbon;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -29,65 +29,72 @@ class UserController extends Controller
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
// show(string $id)
|
||||
//show(string $id)
|
||||
public function get_testing_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$header_user = $request->header('User-Name');
|
||||
$header_pass = $request->header('User-Pass');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$header_user = $request->header('User-Name');
|
||||
$header_pass = $request->header('User-Pass');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
if (! $header_user) {
|
||||
if (!$header_user)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid user name found!',
|
||||
'status_description' => 'Invalid user name found!'
|
||||
], 400);
|
||||
} elseif (! $header_pass) {
|
||||
}
|
||||
else if (!$header_pass)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid password found!',
|
||||
'status_description' => 'Invalid password found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$existUser = User::where('name', $header_user)->first();
|
||||
$existPlant = 'All Plants';
|
||||
$existPlant = "All Plants";
|
||||
|
||||
if (! $existUser) {
|
||||
if (!$existUser)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Unknown user name found!',
|
||||
'status_description' => 'Unknown user name found!'
|
||||
], 400);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$codeExist = Plant::where('id', $existUser->plant_id)->first();
|
||||
if ($codeExist) {
|
||||
$existPlant = $codeExist->code;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Retrieve the user by email
|
||||
// $user = User::where('email', $email)->first();
|
||||
//$user = User::where('email', $email)->first();
|
||||
if (Hash::check($header_pass, $existUser->password)) {
|
||||
return response()->json([
|
||||
'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? '',
|
||||
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? '',
|
||||
'requested_at' => now()->format('Y-m-d H:i:s') ?? '', // Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "",
|
||||
'plant' => (string) $existPlant ?? '',
|
||||
'email' => $existUser->email ?? '',
|
||||
'roles' => $existUser->roles()->pluck('name')->toArray(),
|
||||
'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "",
|
||||
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? "",
|
||||
'requested_at' => now()->format('Y-m-d H:i:s') ?? "", //Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "",
|
||||
'plant' => (String)$existPlant ?? "",
|
||||
'email' => $existUser->email ?? "",
|
||||
'roles' => $existUser->roles()->pluck('name')->toArray()
|
||||
], 200);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Password does not match!',
|
||||
'status_description' => 'Password does not match!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports;
|
||||
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
|
||||
class InvoicePendingReasonImport implements ToCollection
|
||||
{
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
|
||||
public array $errors = [];
|
||||
|
||||
public array $missingPlantCodes = [];
|
||||
public array $missingDocNo = [];
|
||||
public array $plantCodeEmpty = [];
|
||||
public array $docNoEmpty = [];
|
||||
public array $remarkEmpty = [];
|
||||
|
||||
public array $duplicateExcelDocs = [];
|
||||
|
||||
private array $seenExcelKeys = [];
|
||||
|
||||
public array $validRows = [];
|
||||
|
||||
public function collection(Collection $collection)
|
||||
{
|
||||
$rows = $collection;
|
||||
// foreach ($rows->skip(1) as $row) {
|
||||
|
||||
// $plantCode = trim($row[0] ?? '');
|
||||
// $documentNumber = trim($row[1] ?? '');
|
||||
// $remark = trim($row[2] ?? '');
|
||||
|
||||
// if (! $plantCode || ! $documentNumber || ! $remark) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// $plantId = Plant::where('code', $plantCode)->value('id');
|
||||
|
||||
// InvoiceDataValidation::where('plant_id', $plantId)
|
||||
// ->where('document_number', $documentNumber)
|
||||
// ->update([
|
||||
// 'remark' => $remark,
|
||||
// 'updated_at' => now(),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
foreach ($rows->skip(1) as $index => $row) {
|
||||
|
||||
$rowNo = $index + 2;
|
||||
|
||||
$plantCode = trim($row[0] ?? '');
|
||||
$documentNumber = trim($row[1] ?? '');
|
||||
$remark = trim($row[2] ?? '');
|
||||
|
||||
if (! $plantCode) {
|
||||
$this->plantCodeEmpty[] = [
|
||||
'row' => $rowNo,
|
||||
'reason' => "Plant Code can't be empty!",
|
||||
];
|
||||
continue;
|
||||
}
|
||||
else if (! $documentNumber) {
|
||||
$this->docNoEmpty[] = [
|
||||
'row' => $rowNo,
|
||||
'reason' => "Document number can't be empty!",
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
//Excel-level duplicate check
|
||||
$key = $plantCode . '|' . $documentNumber;
|
||||
|
||||
if (isset($this->seenExcelKeys[$key])) {
|
||||
$this->duplicateExcelDocs[$key][] = $rowNo;
|
||||
|
||||
$this->errors[] = [
|
||||
'row' => $rowNo,
|
||||
'reason' => "Duplicate Document Number in Excel ({$plantCode} - {$documentNumber})",
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->seenExcelKeys[$key] = true;
|
||||
|
||||
$plantId = Plant::where('code', $plantCode)->value('id');
|
||||
|
||||
if (! $plantId) {
|
||||
$this->missingPlantCodes[$plantCode] = true;
|
||||
|
||||
$this->errors[] = [
|
||||
'row' => $rowNo,
|
||||
'reason' => "Plant code not found: {$plantCode}",
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceExists = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('document_number', $documentNumber)
|
||||
->first();
|
||||
|
||||
if (! $invoiceExists) {
|
||||
$this->missingDocNo[$documentNumber] = true;
|
||||
|
||||
$this->errors[] = [
|
||||
'row' => $rowNo,
|
||||
'reason' => "Document number not found: {$documentNumber}",
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
// dd($row['document_number'], bin2hex($row['document_number']));
|
||||
|
||||
$this->validRows[] = [
|
||||
'plant_id' => $plantId,
|
||||
'document_number' => $documentNumber,
|
||||
'remark' => $remark,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendApprover1MailJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(public RequestCharacteristic $request) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Already approved? stop
|
||||
if (!is_null($this->request->approver_status1)) return;
|
||||
|
||||
if ($this->request->approver1_mail_sent) return;
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id)
|
||||
->where('machine_id', $this->request->machine_id)
|
||||
->first();
|
||||
|
||||
if (! $approver || ! $approver->mail1) return;
|
||||
|
||||
Mail::to($approver->mail1)
|
||||
->queue(new CharacteristicApprovalMail(
|
||||
$this->request,
|
||||
$approver->name1,
|
||||
1
|
||||
));
|
||||
|
||||
$this->request->update(['approver1_mail_sent' => 1]);
|
||||
|
||||
SendApprover2MailJob::dispatch($this->request)
|
||||
->delay(now()->addMinutes(5));
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendApprover2MailJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
// public function __construct()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function __construct(public RequestCharacteristic $request) {}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// If approver-1 approved → STOP
|
||||
if (!is_null($this->request->approver_status1)) return;
|
||||
|
||||
// If approver-2 already approved → STOP
|
||||
if (!is_null($this->request->approver_status2)) return;
|
||||
|
||||
if ($this->request->approver2_mail_sent) return;
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id)
|
||||
->where('machine_id', $this->request->machine_id)
|
||||
->first();
|
||||
|
||||
if (! $approver || ! $approver->mail2) return;
|
||||
|
||||
Mail::to($approver->mail2)
|
||||
->queue(new CharacteristicApprovalMail(
|
||||
$this->request,
|
||||
$approver->name2,
|
||||
2
|
||||
));
|
||||
|
||||
$this->request->update(['approver2_mail_sent' => 1]);
|
||||
|
||||
// Schedule Approver-3 after 5 minutes
|
||||
SendApprover3MailJob::dispatch($this->request)
|
||||
->delay(now()->addMinutes(5));
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendApprover3MailJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
// public function __construct()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function __construct(public RequestCharacteristic $request) {}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (
|
||||
!is_null($this->request->approver_status1) ||
|
||||
!is_null($this->request->approver_status2) ||
|
||||
!is_null($this->request->approver_status3)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->request->approver3_mail_sent) return;
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id)
|
||||
->where('machine_id', $this->request->machine_id)
|
||||
->first();
|
||||
|
||||
if (! $approver || ! $approver->mail3) return;
|
||||
|
||||
Mail::to($approver->mail3)
|
||||
->queue(new CharacteristicApprovalMail(
|
||||
$this->request,
|
||||
$approver->name3,
|
||||
3
|
||||
));
|
||||
|
||||
$this->request->update(['approver3_mail_sent' => 1]);
|
||||
}
|
||||
}
|
||||
@@ -13,41 +13,23 @@ class GuardPatrolEntryDataTable extends Component
|
||||
// public $date;
|
||||
|
||||
public $newNameFound;
|
||||
|
||||
public $guardName;
|
||||
|
||||
public $checkPointName;
|
||||
|
||||
public $startTime;
|
||||
|
||||
public $endTime;
|
||||
|
||||
public $start;
|
||||
|
||||
public $finish;
|
||||
|
||||
public $begin;
|
||||
|
||||
public $end;
|
||||
|
||||
public $labTime;
|
||||
|
||||
public $minDiff;
|
||||
|
||||
public $seqNoCnt = 0;
|
||||
|
||||
public $seqNo = 0;
|
||||
|
||||
public $isSequenced = true;
|
||||
|
||||
public $sequences = [];
|
||||
|
||||
public $seqTime;
|
||||
|
||||
public $seqTimes = [];
|
||||
|
||||
public $startSeqCheckPoints = [];
|
||||
|
||||
public $records = [];
|
||||
|
||||
protected $listeners = [
|
||||
@@ -79,9 +61,9 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->seqTimes = [];
|
||||
$this->startSeqCheckPoints = [];
|
||||
|
||||
if (! $plantId || ! $date) {
|
||||
if (!$plantId || !$date)
|
||||
{
|
||||
$this->records = [];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,19 +73,20 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->startSeqCheckPoints[$i] = CheckPointTime::with('checkPointNames1')->with('checkPointNames2')->where('sequence_number', $i)->where('plant_id', $plantId)->first();
|
||||
}
|
||||
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, 'X');
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
$this->seqTimes = array_fill(1, $this->seqNoCnt, null);
|
||||
|
||||
$hasSingleGuard = GuardPatrolEntry::whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get();
|
||||
|
||||
$checking = 0;
|
||||
$records = GuardPatrolEntry::with('guardNames')->with('checkPointNames')->whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); // desc Carbon::parse($record->patrol_time)->toTimeString()
|
||||
foreach ($records as $index => $record) { // foreach ($startSeqCheckPoints as $seq => $checkpoint)
|
||||
$records = GuardPatrolEntry::with('guardNames')->with('checkPointNames')->whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); //desc Carbon::parse($record->patrol_time)->toTimeString()
|
||||
foreach ($records as $index => $record) { //foreach ($startSeqCheckPoints as $seq => $checkpoint)
|
||||
$checking++;
|
||||
$guardName = $record->guardNames ? $record->guardNames->name : null;
|
||||
$checkPointName = $record->checkPointNames ? $record->checkPointNames->name : null;
|
||||
if ($this->guardName != $guardName || $this->newNameFound) {// if ($this->newNameFound) {
|
||||
if ($this->guardName) {
|
||||
if ($this->guardName != $guardName || $this->newNameFound) {//if ($this->newNameFound) {
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
@@ -122,25 +105,27 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->seqTimes = array_fill(1, $this->seqNoCnt, null);
|
||||
|
||||
$this->guardName = $guardName;
|
||||
$this->startTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
|
||||
$this->startTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->start = Carbon::parse($record->patrol_time);
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->finish = Carbon::parse($record->patrol_time);
|
||||
$this->begin = Carbon::parse($record->patrol_time);
|
||||
$this->end = Carbon::parse($record->patrol_time);
|
||||
$this->labTime = (int) $this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int) $this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString().' - '.$this->end->toTimeString();
|
||||
$this->labTime = (int)$this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int)$this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString();
|
||||
$this->seqNo = 0;
|
||||
$this->newNameFound = false;
|
||||
$this->isSequenced = true;
|
||||
} elseif ($this->guardName == $guardName && $this->start && $this->begin) {
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
|
||||
}
|
||||
else if ($this->guardName == $guardName && $this->start && $this->begin)
|
||||
{
|
||||
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
|
||||
$this->finish = Carbon::parse($record->patrol_time);
|
||||
$this->end = Carbon::parse($record->patrol_time);
|
||||
$this->labTime = (int) $this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int) $this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString().' - '.$this->end->toTimeString();
|
||||
$this->labTime = (int)$this->start->diffInMinutes($this->finish);
|
||||
$this->minDiff = (int)$this->begin->diffInMinutes($this->end);
|
||||
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString();
|
||||
$this->begin = Carbon::parse($record->patrol_time);
|
||||
// $this->seqNo = 0;
|
||||
}
|
||||
@@ -148,16 +133,19 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->seqNo++;
|
||||
|
||||
if ($this->seqNo == 1) {
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {// "STP BACKSIDE"
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"STP BACKSIDE"
|
||||
$this->isSequenced = true;
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, 'X');
|
||||
} else {
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, 'X');
|
||||
$this->sequences = array_fill(1, $this->seqNoCnt, "X");
|
||||
}
|
||||
|
||||
if (($index + 1) == count($hasSingleGuard)) {
|
||||
if ($this->guardName) {
|
||||
if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
@@ -173,37 +161,26 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
} elseif ($this->seqNo >= ($this->seqNoCnt + 1)) {
|
||||
$this->seqTimes[$this->seqNo - 1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo - 1]->checkPointNames2->name) {// "D 72 END"
|
||||
}
|
||||
else if ($this->seqNo >= ($this->seqNoCnt+1)) {
|
||||
$this->seqTimes[$this->seqNo-1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo-1]->checkPointNames2->name) {//"D 72 END"
|
||||
if ($this->isSequenced) {
|
||||
$this->sequences[$this->seqNo - 1] = $this->minDiff;
|
||||
$this->sequences[$this->seqNo-1] = $this->minDiff;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
}
|
||||
$this->newNameFound = true;
|
||||
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1) {
|
||||
if (($this->seqNoCnt + 1) == count($hasSingleGuard)) {
|
||||
// dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName) {
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
} elseif (($index + 1) == count($hasSingleGuard)) {
|
||||
if ($this->guardName) {
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1)
|
||||
{
|
||||
if (($this->seqNoCnt+1) == count($hasSingleGuard))
|
||||
{
|
||||
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
@@ -219,8 +196,30 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
} elseif (($index + 1) == count($hasSingleGuard)) {
|
||||
if ($this->guardName) {
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
@@ -236,36 +235,26 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
} else { // if ($this->seqNo >= 2) {
|
||||
$this->seqTimes[$this->seqNo - 1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {// "CANTEEN"
|
||||
}
|
||||
else // if ($this->seqNo >= 2) {
|
||||
{
|
||||
$this->seqTimes[$this->seqNo-1] = $this->seqTime;
|
||||
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"CANTEEN"
|
||||
if ($this->isSequenced) {
|
||||
$this->sequences[$this->seqNo - 1] = $this->minDiff;
|
||||
$this->sequences[$this->seqNo-1] = $this->minDiff;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$this->isSequenced = false;
|
||||
}
|
||||
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1) {
|
||||
if ($this->seqNo == count($hasSingleGuard)) {
|
||||
// dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName) {
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
} elseif (($index + 1) == count($hasSingleGuard)) {
|
||||
if ($this->guardName) {
|
||||
if ($hasSingleGuard->unique('guard_name_id')->count() == 1)
|
||||
{
|
||||
if ($this->seqNo == count($hasSingleGuard))
|
||||
{
|
||||
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
@@ -281,8 +270,30 @@ class GuardPatrolEntryDataTable extends Component
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
} elseif (($index + 1) == count($hasSingleGuard)) {
|
||||
if ($this->guardName) {
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
'end_time' => $this->endTime,
|
||||
'lap_time' => $this->labTime,
|
||||
];
|
||||
|
||||
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
|
||||
$recordData["Sequence_$i"] = $this->sequences[$i];
|
||||
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
|
||||
}
|
||||
|
||||
$this->records[] = $recordData;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (($index+1) == count($hasSingleGuard))
|
||||
{
|
||||
if ($this->guardName)
|
||||
{
|
||||
$recordData = [
|
||||
'guard_name' => $this->guardName,
|
||||
'start_time' => $this->startTime,
|
||||
|
||||
@@ -8,24 +8,13 @@ use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Component;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class InvoiceDataTable extends Component
|
||||
{
|
||||
|
||||
use WithPagination;
|
||||
|
||||
protected $paginationTheme = 'tailwind';
|
||||
public $invoiceData = [];
|
||||
|
||||
// public $invoiceRecords;
|
||||
|
||||
public $plantId = 0;
|
||||
|
||||
public $package = [];
|
||||
|
||||
|
||||
public $packageCount = 0;
|
||||
|
||||
public string $invoiceNumber = '';
|
||||
@@ -187,131 +176,10 @@ class InvoiceDataTable extends Component
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
// {
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->plantId = $plantId;
|
||||
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
|
||||
// $this->resetPage();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// // IMPORTANT: keep scanned rows, otherwise count will not update
|
||||
// $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation')
|
||||
// ->where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->get();
|
||||
|
||||
// foreach ($this->invoiceRecords as &$row) {
|
||||
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// // Get item code
|
||||
// $row['code'] = StickerMaster::with('item')
|
||||
// ->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
|
||||
// $curStick = StickerMaster::find($row['sticker_master_id']);
|
||||
|
||||
// if ($curStick) {
|
||||
|
||||
// /** ---------------- REQUIRED STICKERS ---------------- */
|
||||
|
||||
// // PANEL BOX (capacitor)
|
||||
// if (!empty($curStick->panel_box_code)) {
|
||||
// $stickCount++;
|
||||
|
||||
// // Panel box scan = capacitor_scanned_status
|
||||
// if ($row['capacitor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Tube stickers
|
||||
// if (
|
||||
// $curStick->tube_sticker_motor == 1 ||
|
||||
// $curStick->tube_sticker_pump == 1 ||
|
||||
// $curStick->tube_sticker_pumpset == 1
|
||||
// ) {
|
||||
// if ($curStick->tube_sticker_motor == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (
|
||||
// $curStick->tube_sticker_pump == 1 ||
|
||||
// ($curStick->tube_sticker_pumpset != 1 &&
|
||||
// $curStick->tube_sticker_pump != 1 &&
|
||||
// $curStick->pack_slip_pump == 1)
|
||||
// ) {
|
||||
// $stickCount++;
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->tube_sticker_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Pack slips (only if no tube stickers)
|
||||
// elseif (
|
||||
// $curStick->pack_slip_motor == 1 ||
|
||||
// $curStick->pack_slip_pump == 1 ||
|
||||
// $curStick->pack_slip_pumpset == 1
|
||||
// ) {
|
||||
// if ($curStick->pack_slip_motor == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->pack_slip_pump == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->pack_slip_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // SAFETY: never go negative
|
||||
// $this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
// }
|
||||
|
||||
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
|
||||
// }
|
||||
|
||||
|
||||
// #[On('refreshInvoiceData')]
|
||||
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
{
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->onCapFocus = $onCapFocus;
|
||||
@@ -319,166 +187,78 @@ class InvoiceDataTable extends Component
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
|
||||
$this->resetPage();
|
||||
// Eager load stickerMasterRelation and item
|
||||
$invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
|
||||
$this->invoiceData = [];
|
||||
$this->packageCount = 0;
|
||||
|
||||
$this->packageCount = InvoiceValidation::with('stickerMasterRelation')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get()
|
||||
->sum(function ($record) {
|
||||
$sm = $record->stickerMasterRelation;
|
||||
foreach ($invoiceRecords as $record) {
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
// Compute code
|
||||
$rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
if ($sm) {
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
// if (strlen($sm->panel_box_code) > 0) $stickCount++;
|
||||
|
||||
if (!empty($sm->panel_box_code)) {
|
||||
$stickCount++;
|
||||
if (!empty($record->panel_box_serial_number)) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Tube stickers
|
||||
if ($sm->tube_sticker_motor || $sm->tube_sticker_pump || $sm->tube_sticker_pumpset) {
|
||||
$stickCount += $sm->tube_sticker_motor ? 1 : 0;
|
||||
$stickCount += ($sm->tube_sticker_pump || ($sm->tube_sticker_pumpset != 1 && !$sm->tube_sticker_pump && $sm->pack_slip_pump)) ? 1 : 0;
|
||||
$stickCount += $sm->tube_sticker_pumpset ? 1 : 0;
|
||||
}
|
||||
// Pack slips (only if tube stickers not applied)
|
||||
elseif ($sm->pack_slip_motor || $sm->pack_slip_pump || $sm->pack_slip_pumpset) {
|
||||
$stickCount += $sm->pack_slip_motor ? 1 : 0;
|
||||
$stickCount += $sm->pack_slip_pump ? 1 : 0;
|
||||
$stickCount += $sm->pack_slip_pumpset ? 1 : 0;
|
||||
}
|
||||
if ($sm) {
|
||||
// Panel box code
|
||||
if (Str::length($sm->panel_box_code) > 0) {
|
||||
$stickCount++;
|
||||
}
|
||||
|
||||
// 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;
|
||||
// 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 (!empty($record->panel_box_serial_number)) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
return max($stickCount - $scannedCount, 0);
|
||||
});
|
||||
// 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;
|
||||
|
||||
$this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
|
||||
// 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,
|
||||
];
|
||||
}
|
||||
|
||||
if ($onCapFocus) {
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
} else {
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
}
|
||||
|
||||
public function getInvoiceRecordsProperty()
|
||||
{
|
||||
return InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->when(! $this->hasSearched, fn ($q) => $q->whereRaw('1 = 0'))
|
||||
->when($this->hasSearched, fn ($q) =>
|
||||
$q->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->whereNull('scanned_status')
|
||||
)
|
||||
->paginate(7);
|
||||
}
|
||||
|
||||
// public function getInvoiceRecordsProperty()
|
||||
// {
|
||||
// return InvoiceValidation::with('stickerMasterRelation.item')
|
||||
// ->where('invoice_number', $this->hasSearched ? $this->invoiceNumber : null)
|
||||
// ->where('plant_id', $this->hasSearched ? $this->plantId : null)
|
||||
// ->whereNull('scanned_status')
|
||||
// ->paginate(7);
|
||||
// }
|
||||
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
|
||||
// // Eager load stickerMasterRelation and item
|
||||
// $invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
// ->where('invoice_number', $invoiceNumber)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('scanned_status')
|
||||
// ->get();
|
||||
|
||||
// $this->invoiceData = [];
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// foreach ($invoiceRecords as $record) {
|
||||
// $sm = $record->stickerMasterRelation;
|
||||
|
||||
// // Compute code
|
||||
// $rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// if ($sm) {
|
||||
// // Panel box code
|
||||
// if (Str::length($sm->panel_box_code) > 0) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// // Tube stickers logic
|
||||
// if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
// if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
// if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
// if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
// }
|
||||
// // Pack slip logic (only if tube sticker block didn't apply)
|
||||
// elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
// if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
// if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
// if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Count already scanned
|
||||
// $scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
|
||||
// // Increment packageCount
|
||||
// $this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
// $this->invoiceData[] = [
|
||||
// 'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'serial_number' => $record->serial_number,
|
||||
// 'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
// '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,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// if ($onCapFocus) {
|
||||
// $this->dispatch('focus-capacitor-input');
|
||||
// } else {
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function loadMaterialData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
@@ -559,13 +339,12 @@ class InvoiceDataTable extends Component
|
||||
if (! preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body("Scan the valid panel box QR '$this->capacitorInput' to proceed!")
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
->danger()
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->capacitorInput = '';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -592,20 +371,8 @@ class InvoiceDataTable extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$this->package = InvoiceValidation::with('stickerMasterRelation')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
|
||||
foreach ($this->package as &$row) {
|
||||
|
||||
// if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
// if ($row->stickerMasterRelation?->item?->code == $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
$stickerCode = $row->stickerMasterRelation?->item?->code ?? null;
|
||||
$serialNumber = $row->serial_number ?? null;
|
||||
|
||||
if ($stickerCode === $this->currentItemCode && $serialNumber === $this->currentSerialNumber) {
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
@@ -620,8 +387,6 @@ class InvoiceDataTable extends Component
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
});
|
||||
|
||||
// dd($matchingValidation);
|
||||
|
||||
if ($matchingValidation) {
|
||||
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
@@ -715,15 +480,8 @@ class InvoiceDataTable extends Component
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
// public function render()
|
||||
// {
|
||||
// return view('livewire.invoice-data-table');
|
||||
// }
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-data-table', [
|
||||
'records' => $this->invoiceRecords,
|
||||
]);
|
||||
return view('livewire.invoice-data-table');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use Livewire\Component;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\InvoicePendingReasonExport;
|
||||
use App\Models\Plant;
|
||||
|
||||
class InvoicePending extends Component
|
||||
{
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $invoicePending = [];
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadInvoiceData',
|
||||
'emptyData' => 'loadInvoiceEmptyData',
|
||||
'loadData1' => 'exportPendingReason',
|
||||
];
|
||||
|
||||
public function loadInvoiceEmptyData()
|
||||
{
|
||||
$this->invoicePending = [];
|
||||
}
|
||||
|
||||
public function loadInvoiceData($plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
||||
->distinct()
|
||||
->pluck('distribution_channel_desc')
|
||||
->filter(fn ($v) => trim($v) != '')
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$distributions[] = '';
|
||||
|
||||
$pendingInvoices = collect();
|
||||
|
||||
foreach ($distributions as $distribution) {
|
||||
|
||||
$invoices = InvoiceDataValidation::where('plant_id', $plantId)
|
||||
->where('distribution_channel_desc', $distribution)
|
||||
->select(
|
||||
'id',
|
||||
'document_number',
|
||||
'customer_trade_name',
|
||||
'location',
|
||||
'remark',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by'
|
||||
)
|
||||
->get()
|
||||
->unique('document_number')
|
||||
->filter(fn ($inv) =>
|
||||
!empty($inv->document_number) &&
|
||||
!str_contains($inv->document_number, '-')
|
||||
);
|
||||
|
||||
if (trim($distribution) == '') {
|
||||
$invoices = $invoices->filter(fn ($inv) =>
|
||||
str_starts_with($inv->document_number, '7')
|
||||
);
|
||||
}
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceNumbers = $invoices->pluck('document_number')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$wentOut = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
->distinct()
|
||||
->pluck('qr_code')
|
||||
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||
->toArray();
|
||||
|
||||
$pending = $invoices->filter(function ($inv) use ($wentOut) {
|
||||
$doc = preg_replace('/\s+/', '', strtoupper($inv->document_number));
|
||||
return !in_array($doc, $wentOut, true);
|
||||
});
|
||||
|
||||
$pendingInvoices = $pendingInvoices->merge($pending);
|
||||
}
|
||||
|
||||
$plantCode = Plant::find($this->plantId)->code ?? '';
|
||||
|
||||
$this->invoicePending = $pendingInvoices
|
||||
->unique('document_number')
|
||||
->map(function ($record) use ($plantCode) {
|
||||
return [
|
||||
'plant_id' => $plantCode ?? '',
|
||||
'document_number' => $record->document_number ?? '',
|
||||
'customer_trade_name' => $record->customer_trade_name ?? '',
|
||||
'location' => $record->location ?? '',
|
||||
'remark' => $record->remark ?? '',
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function exportPendingReason()
|
||||
{
|
||||
return Excel::download(
|
||||
new InvoicePendingReasonExport($this->invoicePending),
|
||||
'invoice_pending_reason.xlsx'
|
||||
);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-pending');
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,7 @@ class SerialValidationData extends Component
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshMaterialInvoiceData' => 'loadMaterialData',
|
||||
'focusCapacitor' => 'focusCapacitorInput'
|
||||
//'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
];
|
||||
|
||||
public $capacitorInput = '';
|
||||
@@ -49,8 +48,6 @@ class SerialValidationData extends Component
|
||||
|
||||
public $panel_box_serial_number;
|
||||
|
||||
public $itemcode;
|
||||
|
||||
public string $currentItemCode = '';
|
||||
|
||||
public string $currentSerialNumber = '';
|
||||
@@ -67,11 +64,6 @@ class SerialValidationData extends Component
|
||||
// // $this->showCapacitorInput = false;
|
||||
// }
|
||||
|
||||
public function focusCapacitorInput($itemCode)
|
||||
{
|
||||
$this->dispatch('focus-capacitor-input', itemCode: $itemCode);
|
||||
}
|
||||
|
||||
public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
|
||||
{
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Storage;
|
||||
|
||||
class CharacteristicApprovalMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $request;
|
||||
public $approverName;
|
||||
public $level;
|
||||
|
||||
public $pdfPath;
|
||||
public $tableData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($request, $approverName, $level, $pdfPath = null, $characteristics = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->approverName = $approverName;
|
||||
$this->level = $level;
|
||||
$this->pdfPath = $pdfPath;
|
||||
$this->tableData = $characteristics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Characteristic Approval Mail',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.characteristic-approval',
|
||||
with: [
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => 'Dear ' . $this->approverName . ',',
|
||||
'request' => $this->request,
|
||||
'tableData' => $this->tableData,
|
||||
'approveUrl' => $this->approveUrl(),
|
||||
'holdUrl' => $this->holdUrl(),
|
||||
'rejectUrl' => $this->rejectUrl(),
|
||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function approveUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.approve', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
protected function holdUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.hold', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function rejectUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.reject', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
if (! $this->pdfPath) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! Storage::disk('local')->exists($this->pdfPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
Attachment::fromStorageDisk(
|
||||
'local',
|
||||
$this->pdfPath
|
||||
)->as(basename($this->pdfPath)),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CharacteristicApproverMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'machine_name',
|
||||
'characteristic_field',
|
||||
'name1',
|
||||
'mail1',
|
||||
'name2',
|
||||
'mail2',
|
||||
'name3',
|
||||
'mail3',
|
||||
'duration1',
|
||||
'duration2',
|
||||
'duration3',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ClassCharacteristic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_id',
|
||||
'machine_id',
|
||||
'aufnr',
|
||||
'class',
|
||||
'arbid',
|
||||
'gamng',
|
||||
'lmnga',
|
||||
'gernr',
|
||||
'zz1_cn_bill_ord',
|
||||
'zmm_amps',
|
||||
'zmm_brand',
|
||||
'zmm_degreeofprotection',
|
||||
'zmm_delivery',
|
||||
'zmm_dir_rot',
|
||||
'zmm_discharge',
|
||||
'zmm_discharge_max',
|
||||
'zmm_discharge_min',
|
||||
'zmm_duty',
|
||||
'zmm_eff_motor',
|
||||
'zmm_eff_pump',
|
||||
'zmm_frequency',
|
||||
'zmm_head',
|
||||
'zmm_heading',
|
||||
'zmm_head_max',
|
||||
'zmm_head_minimum',
|
||||
'zmm_idx_eff_mtr',
|
||||
'zmm_idx_eff_pump',
|
||||
'zmm_kvacode',
|
||||
'zmm_maxambtemp',
|
||||
'zmm_mincoolingflow',
|
||||
'zmm_motorseries',
|
||||
'zmm_motor_model',
|
||||
'zmm_outlet',
|
||||
'zmm_phase',
|
||||
'zmm_pressure',
|
||||
'zmm_pumpflowtype',
|
||||
'zmm_pumpseries',
|
||||
'zmm_pump_model',
|
||||
'zmm_ratedpower',
|
||||
'zmm_region',
|
||||
'zmm_servicefactor',
|
||||
'zmm_servicefactormaximumamps',
|
||||
'zmm_speed',
|
||||
'zmm_suction',
|
||||
'zmm_suctionxdelivery',
|
||||
'zmm_supplysource',
|
||||
'zmm_temperature',
|
||||
'zmm_thrustload',
|
||||
'zmm_volts',
|
||||
'zmm_wire',
|
||||
'zmm_package',
|
||||
'zmm_pvarrayrating',
|
||||
'zmm_isi',
|
||||
'zmm_isimotor',
|
||||
'zmm_isipump',
|
||||
'zmm_isipumpset',
|
||||
'zmm_pumpset_model',
|
||||
'zmm_stages',
|
||||
'zmm_headrange',
|
||||
'zmm_overall_efficiency',
|
||||
'zmm_connection',
|
||||
'zmm_min_bore_size',
|
||||
'zmm_isireference',
|
||||
'zmm_category',
|
||||
'zmm_submergence',
|
||||
'zmm_capacitorstart',
|
||||
'zmm_capacitorrun',
|
||||
'zmm_inch',
|
||||
'zmm_motor_type',
|
||||
'zmm_dismantle_direction',
|
||||
'zmm_eff_ovrall',
|
||||
'zmm_bodymoc',
|
||||
'zmm_rotormoc',
|
||||
'zmm_dlwl',
|
||||
'zmm_inputpower',
|
||||
'zmm_imp_od',
|
||||
'zmm_ambtemp',
|
||||
'zmm_de',
|
||||
'zmm_dischargerange',
|
||||
'zmm_efficiency_class',
|
||||
'zmm_framesize',
|
||||
'zmm_impellerdiameter',
|
||||
'zmm_insulationclass',
|
||||
'zmm_maxflow',
|
||||
'zmm_minhead',
|
||||
'zmm_mtrlofconst',
|
||||
'zmm_nde',
|
||||
'zmm_powerfactor',
|
||||
'zmm_tagno',
|
||||
'zmm_year',
|
||||
'zmm_laser_name',
|
||||
'zmm_beenote',
|
||||
'zmm_beenumber',
|
||||
'zmm_beestar',
|
||||
'zmm_codeclass',
|
||||
'zmm_colour',
|
||||
'zmm_logo_cp',
|
||||
'zmm_logo_ce',
|
||||
'zmm_logo_nsf',
|
||||
'zmm_grade',
|
||||
'zmm_grwt_pset',
|
||||
'zmm_grwt_cable',
|
||||
'zmm_grwt_motor',
|
||||
'zmm_grwt_pf',
|
||||
'zmm_grwt_pump',
|
||||
'zmm_isivalve',
|
||||
'zmm_isi_wc',
|
||||
'zmm_labelperiod',
|
||||
'zmm_length',
|
||||
'zmm_license_cml_no',
|
||||
'zmm_mfgmonyr',
|
||||
'zmm_modelyear',
|
||||
'zmm_motoridentification',
|
||||
'zmm_newt_pset',
|
||||
'zmm_newt_cable',
|
||||
'zmm_newt_motor',
|
||||
'zmm_newt_pf',
|
||||
'zmm_newt_pump',
|
||||
'zmm_packtype',
|
||||
'zmm_panel',
|
||||
'zmm_performance_factor',
|
||||
'zmm_pumpidentification',
|
||||
'zmm_psettype',
|
||||
'zmm_size',
|
||||
'zmm_eff_ttl',
|
||||
'zmm_type',
|
||||
'zmm_usp',
|
||||
'mark_status',
|
||||
'marked_datetime',
|
||||
'marked_by',
|
||||
'man_marked_status',
|
||||
'man_marked_datetime',
|
||||
'man_marked_by',
|
||||
'motor_marked_status',
|
||||
'motor_marked_by',
|
||||
'pump_marked_status',
|
||||
'pump_marked_by',
|
||||
'motor_pump_pumpset_status',
|
||||
'motor_machine_name',
|
||||
'pump_machine_name',
|
||||
'pumpset_machine_name',
|
||||
'part_validation_1',
|
||||
'part_validation_2',
|
||||
'samlight_logged_name',
|
||||
'pending_released_status',
|
||||
'motor_expected_time',
|
||||
'pump_expected_time',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class GuardPatrolEntry extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -30,24 +27,13 @@ class GuardPatrolEntry extends Model
|
||||
|
||||
public function guardNames(): BelongsTo
|
||||
{
|
||||
// return $this->belongsTo(CheckPointName::class);
|
||||
//return $this->belongsTo(CheckPointName::class);
|
||||
return $this->belongsTo(GuardName::class, 'guard_name_id');
|
||||
}
|
||||
|
||||
public function checkPointNames(): BelongsTo
|
||||
{
|
||||
// return $this->belongsTo(CheckPointName::class);
|
||||
//return $this->belongsTo(CheckPointName::class);
|
||||
return $this->belongsTo(CheckPointName::class, 'check_point_name_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
// // Start of two months ago (first day of that month)
|
||||
// $startOfTwoMonthsAgo = now()->subMonthsNoOverflow(6)->startOfMonth();
|
||||
// // End of previous month (last day of last month)
|
||||
// $endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
|
||||
|
||||
// return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,27 +9,26 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class InvoiceDataValidation extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'distribution_channel_desc',
|
||||
'customer_code',
|
||||
'document_number',
|
||||
'document_date',
|
||||
'customer_trade_name',
|
||||
'customer_location',
|
||||
'location',
|
||||
'remark',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
"plant_id",
|
||||
"distribution_channel_desc",
|
||||
"customer_code",
|
||||
"document_number",
|
||||
"document_date",
|
||||
"customer_trade_name",
|
||||
"customer_location",
|
||||
"location",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,17 +10,15 @@ class InvoiceOutValidation extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
// protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'qr_code',
|
||||
'scanned_at',
|
||||
'scanned_by',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
"plant_id",
|
||||
"qr_code",
|
||||
"scanned_at",
|
||||
"scanned_by",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
|
||||
@@ -12,7 +12,6 @@ class ProcessOrder extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'process_order',
|
||||
'coil_number',
|
||||
@@ -20,8 +19,6 @@ class ProcessOrder extends Model
|
||||
'received_quantity',
|
||||
'sfg_number',
|
||||
'machine_name',
|
||||
'scrap_quantity',
|
||||
'rework_status',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
@@ -33,12 +30,7 @@ class ProcessOrder extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'item_id');
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestCharacteristic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'item_id',
|
||||
'characteristic_approver_master_id',
|
||||
'aufnr',
|
||||
'characteristic_name',
|
||||
'current_value',
|
||||
'update_value',
|
||||
'approver_status1',
|
||||
'approver_status2',
|
||||
'approver_status3',
|
||||
'approver_remark1',
|
||||
'approver_remark2',
|
||||
'approver_remark3',
|
||||
'approved1_at',
|
||||
'approved2_at',
|
||||
'approved3_at',
|
||||
'mail_status',
|
||||
'trigger_at',
|
||||
'work_flow_id',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
|
||||
public function characteristicApproverMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CharacteristicApproverMaster::class);
|
||||
}
|
||||
|
||||
// public function approverName1()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
// public function approverName2()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
// public function approverName3()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
public function approver()
|
||||
{
|
||||
return $this->belongsTo(
|
||||
CharacteristicApproverMaster::class,
|
||||
'characteristic_approver_master_id'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class WeightValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -25,8 +22,6 @@ class WeightValidation extends Model
|
||||
'bundle_number',
|
||||
'picked_weight',
|
||||
'scanned_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -38,13 +33,4 @@ class WeightValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
// $startOfTwoMonthsAgo = now()->subMonthsNoOverflow(3)->startOfMonth();
|
||||
// $endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
|
||||
|
||||
// return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\SendApprover1MailJob;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class RequestCharacteristicObserver
|
||||
{
|
||||
/**
|
||||
* Handle the RequestCharacteristic "created" event.
|
||||
*/
|
||||
public function created(RequestCharacteristic $request): void
|
||||
{
|
||||
// Only if all statuses are NULL
|
||||
if (
|
||||
!is_null($request->approver_status1) ||
|
||||
!is_null($request->approver_status2) ||
|
||||
!is_null($request->approver_status3)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
SendApprover1MailJob::dispatch($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "updated" event.
|
||||
*/
|
||||
public function updated(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "deleted" event.
|
||||
*/
|
||||
public function deleted(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "restored" event.
|
||||
*/
|
||||
public function restored(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class CharacteristicApproverMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any CharacteristicApproverMaster');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\User;
|
||||
|
||||
class ClassCharacteristicPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ClassCharacteristic');
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\User;
|
||||
|
||||
class RequestCharacteristicPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any RequestCharacteristic');
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"league/flysystem-sftp-v3": "^3.30",
|
||||
"livewire/livewire": "^3.6",
|
||||
"livewire/livewire": "^4.0",
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"mike42/escpos-php": "^4.0",
|
||||
"mpdf/mpdf": "^8.2",
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Class Namespace
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| This value sets the root class namespace for Livewire component classes in
|
||||
| your application. This value will change where component auto-discovery
|
||||
| finds components. It's also referenced by the file creation commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'class_namespace' => 'App\\Livewire',
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| View Path
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| This value is used to specify where Livewire component Blade templates are
|
||||
| stored when running file creation commands like `artisan make:livewire`.
|
||||
| It is also used if you choose to omit a component's render() method.
|
||||
|
|
||||
*/
|
||||
|
||||
'view_path' => resource_path('views/livewire'),
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Layout
|
||||
|---------------------------------------------------------------------------
|
||||
| The view that will be used as the layout when rendering a single component
|
||||
| as an entire page via `Route::get('/post/create', CreatePost::class);`.
|
||||
| In this case, the view returned by CreatePost will render into $slot.
|
||||
|
|
||||
*/
|
||||
|
||||
'layout' => 'components.layouts.app',
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Lazy Loading Placeholder
|
||||
|---------------------------------------------------------------------------
|
||||
| Livewire allows you to lazy load components that would otherwise slow down
|
||||
| the initial page load. Every component can have a custom placeholder or
|
||||
| you can define the default placeholder view for all components below.
|
||||
|
|
||||
*/
|
||||
|
||||
'lazy_placeholder' => null,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Temporary File Uploads
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| Livewire handles file uploads by storing uploads in a temporary directory
|
||||
| before the file is stored permanently. All file uploads are directed to
|
||||
| a global endpoint for temporary storage. You may configure this below:
|
||||
|
|
||||
*/
|
||||
|
||||
// 'temporary_file_upload' => [
|
||||
// 'disk' => null, // Example: 'local', 's3' | Default: 'default'
|
||||
// 'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
|
||||
// 'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp'
|
||||
// 'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
|
||||
// 'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
|
||||
// 'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
|
||||
// 'mov', 'avi', 'wmv', 'mp3', 'm4a',
|
||||
// 'jpg', 'jpeg', 'mpga', 'webp', 'wma',
|
||||
// ],
|
||||
// 'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
|
||||
// 'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
|
||||
// ],
|
||||
|
||||
|
||||
|
||||
'temporary_file_upload' => [
|
||||
'max_upload_file_size' => 20480, // 20 MB
|
||||
],
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Render On Redirect
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines if Livewire will run a component's `render()` method
|
||||
| after a redirect has been triggered using something like `redirect(...)`
|
||||
| Setting this to true will render the view once more before redirecting
|
||||
|
|
||||
*/
|
||||
|
||||
'render_on_redirect' => false,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Eloquent Model Binding
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| Previous versions of Livewire supported binding directly to eloquent model
|
||||
| properties using wire:model by default. However, this behavior has been
|
||||
| deemed too "magical" and has therefore been put under a feature flag.
|
||||
|
|
||||
*/
|
||||
|
||||
'legacy_model_binding' => false,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Auto-inject Frontend Assets
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| By default, Livewire automatically injects its JavaScript and CSS into the
|
||||
| <head> and <body> of pages containing Livewire components. By disabling
|
||||
| this behavior, you need to use @livewireStyles and @livewireScripts.
|
||||
|
|
||||
*/
|
||||
|
||||
'inject_assets' => true,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Navigate (SPA mode)
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| By adding `wire:navigate` to links in your Livewire application, Livewire
|
||||
| will prevent the default link handling and instead request those pages
|
||||
| via AJAX, creating an SPA-like effect. Configure this behavior here.
|
||||
|
|
||||
*/
|
||||
|
||||
'navigate' => [
|
||||
'show_progress_bar' => true,
|
||||
'progress_bar_color' => '#2299dd',
|
||||
],
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| HTML Morph Markers
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| Livewire intelligently "morphs" existing HTML into the newly rendered HTML
|
||||
| after each update. To make this process more reliable, Livewire injects
|
||||
| "markers" into the rendered Blade surrounding @if, @class & @foreach.
|
||||
|
|
||||
*/
|
||||
|
||||
'inject_morph_markers' => true,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Smart Wire Keys
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| Livewire uses loops and keys used within loops to generate smart keys that
|
||||
| are applied to nested components that don't have them. This makes using
|
||||
| nested components more reliable by ensuring that they all have keys.
|
||||
|
|
||||
*/
|
||||
|
||||
'smart_wire_keys' => false,
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Pagination Theme
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| When enabling Livewire's pagination feature by using the `WithPagination`
|
||||
| trait, Livewire will use Tailwind templates to render pagination views
|
||||
| on the page. If you want Bootstrap CSS, you can specify: "bootstrap"
|
||||
|
|
||||
*/
|
||||
|
||||
'pagination_theme' => 'tailwind',
|
||||
|
||||
/*
|
||||
|---------------------------------------------------------------------------
|
||||
| Release Token
|
||||
|---------------------------------------------------------------------------
|
||||
|
|
||||
| This token is stored client-side and sent along with each request to check
|
||||
| a users session to see if a new release has invalidated it. If there is
|
||||
| a mismatch it will throw an error and prompt for a browser refresh.
|
||||
|
|
||||
*/
|
||||
|
||||
'release_token' => 'a',
|
||||
];
|
||||
@@ -1,186 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE class_characteristics (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
aufnr TEXT DEFAULT NULL,
|
||||
class TEXT DEFAULT NULL,
|
||||
arbid TEXT DEFAULT NULL,
|
||||
gamng TEXT DEFAULT NULL,
|
||||
lmnga TEXT DEFAULT NULL,
|
||||
gernr TEXT DEFAULT NULL,
|
||||
zz1_cn_bill_ord TEXT DEFAULT NULL,
|
||||
zmm_amps TEXT DEFAULT NULL,
|
||||
zmm_brand TEXT DEFAULT NULL,
|
||||
zmm_degreeofprotection TEXT DEFAULT NULL,
|
||||
zmm_delivery TEXT DEFAULT NULL,
|
||||
zmm_dir_rot TEXT DEFAULT NULL,
|
||||
zmm_discharge TEXT DEFAULT NULL,
|
||||
zmm_discharge_max TEXT DEFAULT NULL,
|
||||
zmm_discharge_min TEXT DEFAULT NULL,
|
||||
zmm_duty TEXT DEFAULT NULL,
|
||||
zmm_eff_motor TEXT DEFAULT NULL,
|
||||
zmm_eff_pump TEXT DEFAULT NULL,
|
||||
zmm_frequency TEXT DEFAULT NULL,
|
||||
zmm_head TEXT DEFAULT NULL,
|
||||
zmm_heading TEXT DEFAULT NULL,
|
||||
zmm_head_max TEXT DEFAULT NULL,
|
||||
zmm_head_minimum TEXT DEFAULT NULL,
|
||||
zmm_idx_eff_mtr TEXT DEFAULT NULL,
|
||||
zmm_idx_eff_pump TEXT DEFAULT NULL,
|
||||
zmm_kvacode TEXT DEFAULT NULL,
|
||||
zmm_maxambtemp TEXT DEFAULT NULL,
|
||||
zmm_mincoolingflow TEXT DEFAULT NULL,
|
||||
zmm_motorseries TEXT DEFAULT NULL,
|
||||
zmm_motor_model TEXT DEFAULT NULL,
|
||||
zmm_outlet TEXT DEFAULT NULL,
|
||||
zmm_phase TEXT DEFAULT NULL,
|
||||
zmm_pressure TEXT DEFAULT NULL,
|
||||
zmm_pumpflowtype TEXT DEFAULT NULL,
|
||||
zmm_pumpseries TEXT DEFAULT NULL,
|
||||
zmm_pump_model TEXT DEFAULT NULL,
|
||||
zmm_ratedpower TEXT DEFAULT NULL,
|
||||
zmm_region TEXT DEFAULT NULL,
|
||||
zmm_servicefactor TEXT DEFAULT NULL,
|
||||
zmm_servicefactormaximumamps TEXT DEFAULT NULL,
|
||||
zmm_speed TEXT DEFAULT NULL,
|
||||
zmm_suction TEXT DEFAULT NULL,
|
||||
zmm_suctionxdelivery TEXT DEFAULT NULL,
|
||||
zmm_supplysource TEXT DEFAULT NULL,
|
||||
zmm_temperature TEXT DEFAULT NULL,
|
||||
zmm_thrustload TEXT DEFAULT NULL,
|
||||
zmm_volts TEXT DEFAULT NULL,
|
||||
zmm_wire TEXT DEFAULT NULL,
|
||||
zmm_package TEXT DEFAULT NULL,
|
||||
zmm_pvarrayrating TEXT DEFAULT NULL,
|
||||
zmm_isi TEXT DEFAULT NULL,
|
||||
zmm_isimotor TEXT DEFAULT NULL,
|
||||
zmm_isipump TEXT DEFAULT NULL,
|
||||
zmm_isipumpset TEXT DEFAULT NULL,
|
||||
zmm_pumpset_model TEXT DEFAULT NULL,
|
||||
zmm_stages TEXT DEFAULT NULL,
|
||||
zmm_headrange TEXT DEFAULT NULL,
|
||||
zmm_overall_efficiency TEXT DEFAULT NULL,
|
||||
zmm_connection TEXT DEFAULT NULL,
|
||||
zmm_min_bore_size TEXT DEFAULT NULL,
|
||||
zmm_isireference TEXT DEFAULT NULL,
|
||||
zmm_category TEXT DEFAULT NULL,
|
||||
zmm_submergence TEXT DEFAULT NULL,
|
||||
zmm_capacitorstart TEXT DEFAULT NULL,
|
||||
zmm_capacitorrun TEXT DEFAULT NULL,
|
||||
zmm_inch TEXT DEFAULT NULL,
|
||||
zmm_motor_type TEXT DEFAULT NULL,
|
||||
zmm_dismantle_direction TEXT DEFAULT NULL,
|
||||
zmm_eff_ovrall TEXT DEFAULT NULL,
|
||||
zmm_bodymoc TEXT DEFAULT NULL,
|
||||
zmm_rotormoc TEXT DEFAULT NULL,
|
||||
zmm_dlwl TEXT DEFAULT NULL,
|
||||
zmm_inputpower TEXT DEFAULT NULL,
|
||||
zmm_imp_od TEXT DEFAULT NULL,
|
||||
zmm_ambtemp TEXT DEFAULT NULL,
|
||||
zmm_de TEXT DEFAULT NULL,
|
||||
zmm_dischargerange TEXT DEFAULT NULL,
|
||||
zmm_efficiency_class TEXT DEFAULT NULL,
|
||||
zmm_framesize TEXT DEFAULT NULL,
|
||||
zmm_impellerdiameter TEXT DEFAULT NULL,
|
||||
zmm_insulationclass TEXT DEFAULT NULL,
|
||||
zmm_maxflow TEXT DEFAULT NULL,
|
||||
zmm_minhead TEXT DEFAULT NULL,
|
||||
zmm_mtrlofconst TEXT DEFAULT NULL,
|
||||
zmm_nde TEXT DEFAULT NULL,
|
||||
zmm_powerfactor TEXT DEFAULT NULL,
|
||||
zmm_tagno TEXT DEFAULT NULL,
|
||||
zmm_year TEXT DEFAULT NULL,
|
||||
zmm_laser_name TEXT DEFAULT NULL,
|
||||
zmm_beenote TEXT DEFAULT NULL,
|
||||
zmm_beenumber TEXT DEFAULT NULL,
|
||||
zmm_beestar TEXT DEFAULT NULL,
|
||||
zmm_codeclass TEXT DEFAULT NULL,
|
||||
zmm_colour TEXT DEFAULT NULL,
|
||||
zmm_grade TEXT DEFAULT NULL,
|
||||
zmm_grwt_pset TEXT DEFAULT NULL,
|
||||
zmm_grwt_cable TEXT DEFAULT NULL,
|
||||
zmm_grwt_motor TEXT DEFAULT NULL,
|
||||
zmm_grwt_pf TEXT DEFAULT NULL,
|
||||
zmm_grwt_pump TEXT DEFAULT NULL,
|
||||
zmm_isivalve TEXT DEFAULT NULL,
|
||||
zmm_isi_wc TEXT DEFAULT NULL,
|
||||
zmm_labelperiod TEXT DEFAULT NULL,
|
||||
zmm_length TEXT DEFAULT NULL,
|
||||
zmm_license_cml_no TEXT DEFAULT NULL,
|
||||
zmm_mfgmonyr TEXT DEFAULT NULL,
|
||||
zmm_modelyear TEXT DEFAULT NULL,
|
||||
zmm_motoridentification TEXT DEFAULT NULL,
|
||||
zmm_newt_pset TEXT DEFAULT NULL,
|
||||
zmm_newt_cable TEXT DEFAULT NULL,
|
||||
zmm_newt_motor TEXT DEFAULT NULL,
|
||||
zmm_newt_pf TEXT DEFAULT NULL,
|
||||
zmm_newt_pump TEXT DEFAULT NULL,
|
||||
zmm_logo_cp TEXT DEFAULT NULL,
|
||||
zmm_logo_ce TEXT DEFAULT NULL,
|
||||
zmm_logo_nsf TEXT DEFAULT NULL,
|
||||
zmm_packtype TEXT DEFAULT NULL,
|
||||
zmm_panel TEXT DEFAULT NULL,
|
||||
zmm_performance_factor TEXT DEFAULT NULL,
|
||||
zmm_pumpidentification TEXT DEFAULT NULL,
|
||||
zmm_psettype TEXT DEFAULT NULL,
|
||||
zmm_size TEXT DEFAULT NULL,
|
||||
zmm_eff_ttl TEXT DEFAULT NULL,
|
||||
zmm_type TEXT DEFAULT NULL,
|
||||
zmm_usp TEXT DEFAULT NULL,
|
||||
mark_status TEXT DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
marked_by TEXT DEFAULT NULL,
|
||||
man_marked_status TEXT DEFAULT '0',
|
||||
man_marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
man_marked_by TEXT DEFAULT NULL,
|
||||
motor_marked_status TEXT DEFAULT NULL,
|
||||
motor_marked_by TEXT DEFAULT NULL,
|
||||
pump_marked_status TEXT DEFAULT NULL,
|
||||
pump_marked_by TEXT DEFAULT NULL,
|
||||
motor_pump_pumpset_status TEXT DEFAULT NULL,
|
||||
motor_machine_name TEXT DEFAULT NULL,
|
||||
pump_machine_name TEXT DEFAULT NULL,
|
||||
pumpset_machine_name TEXT DEFAULT NULL,
|
||||
part_validation_1 TEXT DEFAULT NULL,
|
||||
part_validation_2 TEXT DEFAULT NULL,
|
||||
samlight_logged_name TEXT DEFAULT NULL,
|
||||
pending_released_status INTEGER DEFAULT 0,
|
||||
motor_expected_time TEXT DEFAULT '0',
|
||||
pump_expected_time TEXT DEFAULT '0',
|
||||
|
||||
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 (machine_id) REFERENCES machines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('class_characteristics');
|
||||
}
|
||||
};
|
||||
@@ -1,65 +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 request_characteristics (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
characteristic_approver_master_id BIGINT NOT NULL,
|
||||
aufnr TEXT DEFAULT NULL,
|
||||
characteristic_name TEXT DEFAULT NULL,
|
||||
current_value TEXT DEFAULT NULL,
|
||||
update_value TEXT DEFAULT NULL,
|
||||
|
||||
approver_status1 TEXT DEFAULT NULL,
|
||||
approver_status2 TEXT DEFAULT NULL,
|
||||
approver_status3 TEXT DEFAULT NULL,
|
||||
|
||||
approver_remark1 TEXT DEFAULT NULL,
|
||||
approver_remark2 TEXT DEFAULT NULL,
|
||||
approver_remark3 TEXT DEFAULT NULL,
|
||||
|
||||
work_flow_id TEXT DEFAULT NULL,
|
||||
mail_status TEXT DEFAULT NULL,
|
||||
trigger_at TIMESTAMP,
|
||||
|
||||
approved1_at TIMESTAMP,
|
||||
approved2_at TIMESTAMP,
|
||||
approved3_at TIMESTAMP,
|
||||
|
||||
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 (machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (item_id) REFERENCES items(id),
|
||||
FOREIGN KEY (characteristic_approver_master_id) REFERENCES characteristic_approver_masters(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('request_characteristics');
|
||||
}
|
||||
};
|
||||
@@ -1,49 +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_approver_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
machine_name TEXT DEFAULT NULL,
|
||||
characteristic_field TEXT DEFAULT NULL,
|
||||
name1 TEXT DEFAULT NULL,
|
||||
mail1 TEXT DEFAULT NULL,
|
||||
name2 TEXT DEFAULT NULL,
|
||||
mail2 TEXT DEFAULT NULL,
|
||||
name3 TEXT DEFAULT NULL,
|
||||
mail3 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 (machine_id) REFERENCES machines(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('characteristic_approver_masters');
|
||||
}
|
||||
};
|
||||
@@ -1,45 +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
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN duration1 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN duration2 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
|
||||
$sql3 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN duration3 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('characteristic_approver_masters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,31 +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
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE invoice_data_validations
|
||||
ADD COLUMN remark TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('invoice_data_validations', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -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 process_orders
|
||||
ADD COLUMN line_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT process_orders_line_id_fkey
|
||||
FOREIGN KEY (line_id) REFERENCES lines(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($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("
|
||||
ALTER TABLE process_orders
|
||||
ADD COLUMN scrap_quantity NUMERIC(10,3)
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,31 +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
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE process_orders
|
||||
ADD COLUMN rework_status INT NOT NULL DEFAULT (0)
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -161,9 +161,6 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view production data send to sap']);
|
||||
Permission::updateOrCreate(['name' => 'create production sticker reject reason page']);
|
||||
Permission::updateOrCreate(['name' => 'create web capture page']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view invoice pending reason']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import invoice out validation']);
|
||||
Permission::updateOrCreate(['name' => 'view export invoice out validation']);
|
||||
Permission::updateOrCreate(['name' => 'view import invoice data validation']);
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Action Already Taken</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f6f8;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #ffffff;
|
||||
width: 420px;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
box-shadow: 0 6px 20px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 50px;
|
||||
margin-bottom: 10px;
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 10px 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-top: 15px;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.status.Approved {
|
||||
background-color: #e8f5e9;
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
.status.Hold {
|
||||
background-color: #fff3e0;
|
||||
color: #ef6c00;
|
||||
}
|
||||
|
||||
.status.Rejected {
|
||||
background-color: #fdecea;
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.note {
|
||||
margin-top: 15px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="icon">⚠️</div>
|
||||
<h2>Action Already Taken</h2>
|
||||
|
||||
<div class="status {{ $status }}">
|
||||
Status: {{ $status }}
|
||||
</div>
|
||||
|
||||
<p class="note">
|
||||
This request has already been processed.<br>
|
||||
No further action is required.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,98 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Request On Hold</title>
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="padding: 20px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<!-- Card container -->
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); border: 1px solid #e0e0e0;">
|
||||
<tr>
|
||||
<td style="padding: 30px; text-align: center;">
|
||||
<!-- Header -->
|
||||
<div style="font-size: 40px;">🟠</div>
|
||||
<h2 style="color: #FF8800; margin: 10px 0 20px; font-size: 24px;">Request On Hold</h2>
|
||||
|
||||
<!-- Message -->
|
||||
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
|
||||
Your request has been temporarily put on hold.
|
||||
</p>
|
||||
|
||||
<!-- Remark Textbox -->
|
||||
<div style="margin-top: 20px; text-align: left;">
|
||||
<label for="remark" style="font-size: 14px; color: #333;">Remark <span style="color:red;">*</span></label>
|
||||
<textarea id="remark" style="width:100%; height:100px; padding:10px; margin-top:5px; border:1px solid #ddd; border-radius:5px;"></textarea>
|
||||
<div id="remarkError" style="color:red; font-size:12px; display:none; margin-top:5px;">
|
||||
Remark is mandatory.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Buttons -->
|
||||
<div style="margin-top: 20px;">
|
||||
{{-- <button onclick="holdRequest()" style="padding: 10px 20px; margin-right: 10px; background-color:#FF8800; color:#fff; border:none; border-radius:5px; cursor:pointer;">
|
||||
Hold
|
||||
</button> --}}
|
||||
<input type="hidden" id="requestId" value="{{ request()->query('id') }}">
|
||||
<input type="hidden" id="level" value="{{ request()->query('level') }}">
|
||||
|
||||
<button onclick="saveRemark()" style="padding: 10px 20px; background-color:#4CAF50; color:#fff; border:none; border-radius:5px; cursor:pointer;">
|
||||
Save Remark
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="padding: 15px; text-align: center; font-size: 12px; color: #999999;">
|
||||
CRI Digital Manufacturing Solutions<br>
|
||||
© 2026 All Rights Reserved
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
|
||||
function saveRemark() {
|
||||
const remark = document.getElementById("remark").value.trim();
|
||||
const id = document.getElementById("requestId").value;
|
||||
const level = document.getElementById("level").value;
|
||||
|
||||
fetch('/characteristic/hold-save', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: id,
|
||||
level: level,
|
||||
remark: remark
|
||||
})
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error("HTTP error " + res.status);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
alert('Hold saved successfully!');
|
||||
window.location.href = "/approval/hold-success";
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
alert('Error saving hold!');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,36 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Request On Hold</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="padding: 20px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<!-- Card container -->
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); border: 1px solid #e0e0e0;">
|
||||
<tr>
|
||||
<td style="padding: 30px; text-align: center;">
|
||||
<!-- Header -->
|
||||
<div style="font-size: 40px;">🟠</div>
|
||||
<h2 style="color: #FF8800; margin: 10px 0 20px; font-size: 24px;">Request On Hold</h2>
|
||||
<!-- Message -->
|
||||
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
|
||||
Your request has been temporarily put on hold.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="padding: 15px; text-align: center; font-size: 12px; color: #999999;">
|
||||
CRI Digital Manufacturing Solutions<br>
|
||||
© 2026 All Rights Reserved
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Request On Reject</title>
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="padding: 20px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<!-- Card container -->
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); border: 1px solid #e0e0e0;">
|
||||
<tr>
|
||||
<td style="padding: 30px; text-align: center;">
|
||||
<!-- Header -->
|
||||
<div style="font-size: 40px;">🟠</div>
|
||||
<h2 style="color: #FF0000; margin: 10px 0 20px; font-size: 24px;">Request On Reject</h2>
|
||||
|
||||
<!-- Message -->
|
||||
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
|
||||
Your request has been temporarily put on reject.
|
||||
</p>
|
||||
|
||||
<!-- Remark Textbox -->
|
||||
<div style="margin-top: 20px; text-align: left;">
|
||||
<label for="remark" style="font-size: 14px; color: #333;">Remark <span style="color:red;">*</span></label>
|
||||
<textarea id="remark" style="width:100%; height:100px; padding:10px; margin-top:5px; border:1px solid #ddd; border-radius:5px;"></textarea>
|
||||
<div id="remarkError" style="color:red; font-size:12px; display:none; margin-top:5px;">
|
||||
Remark is mandatory.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Buttons -->
|
||||
<div style="margin-top: 20px;">
|
||||
{{-- <button onclick="holdRequest()" style="padding: 10px 20px; margin-right: 10px; background-color:#FF8800; color:#fff; border:none; border-radius:5px; cursor:pointer;">
|
||||
Hold
|
||||
</button> --}}
|
||||
<input type="hidden" id="requestId" value="{{ request()->query('id') }}">
|
||||
<input type="hidden" id="level" value="{{ request()->query('level') }}">
|
||||
|
||||
<button onclick="saveRemark()" style="padding: 10px 20px; background-color:#4CAF50; color:#fff; border:none; border-radius:5px; cursor:pointer;">
|
||||
Save Remark
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="padding: 15px; text-align: center; font-size: 12px; color: #999999;">
|
||||
CRI Digital Manufacturing Solutions<br>
|
||||
© 2026 All Rights Reserved
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
|
||||
function saveRemark() {
|
||||
const remark = document.getElementById("remark").value.trim();
|
||||
const id = document.getElementById("requestId").value;
|
||||
const level = document.getElementById("level").value;
|
||||
|
||||
fetch('/characteristic/reject-save', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: id,
|
||||
level: level,
|
||||
remark: remark
|
||||
})
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error("HTTP error " + res.status);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
alert('Reject saved successfully!');
|
||||
window.location.href = "/approval/reject-success";
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
alert('Error saving reject!');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Rejected</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f6f6f6;
|
||||
padding: 20px;
|
||||
}
|
||||
.card {
|
||||
background: #ffffff;
|
||||
padding: 20px;
|
||||
max-width: 500px;
|
||||
margin: 50px auto;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,.1);
|
||||
}
|
||||
.rejected {
|
||||
color: red;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.footer {
|
||||
font-size: 12px;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
a.button {
|
||||
display: inline-block;
|
||||
margin-top: 15px;
|
||||
padding: 10px 20px;
|
||||
background-color: red;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="card">
|
||||
<div class="rejected">❌ Rejected Successfully</div>
|
||||
<p>The rejection has been recorded.</p>
|
||||
<p>You may now close this tab.</p>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="footer">
|
||||
CRI Digital Manufacturing Solutions<br>
|
||||
© 2026 All Rights Reserved
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Approval Recorded</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f6f6f6;
|
||||
padding: 20px;
|
||||
}
|
||||
.card {
|
||||
background: #ffffff;
|
||||
padding: 20px;
|
||||
max-width: 500px;
|
||||
margin: 50px auto;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,.1);
|
||||
}
|
||||
.success {
|
||||
color: green;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.footer {
|
||||
font-size: 12px;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="card">
|
||||
<div class="success">✔ Approval Successful</div>
|
||||
<p>Your action has been recorded.</p>
|
||||
<p>You may now close this tab.</p>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="footer">
|
||||
CRI Digital Manufacturing Solutions<br>
|
||||
© 2026 All Rights Reserved
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
</div>
|
||||
<div class="flex-row gap-2 mt-4">
|
||||
<x-filament::button
|
||||
{{-- type="button" --}}
|
||||
{{-- wire:click="addRemark"
|
||||
class="px-3 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm" --}}
|
||||
wire:click="addRemark"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Save
|
||||
</x-filament::button>
|
||||
|
||||
<x-filament::button
|
||||
wire:click="importPendingReason"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Import
|
||||
</x-filament::button>
|
||||
<x-filament::button
|
||||
wire:click="exportPendingReason"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Export
|
||||
</x-filament::button>
|
||||
<div class="bg-white shadow rounded-xl p-4 mt-6">
|
||||
<livewire:invoice-pending />
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
@@ -1,19 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<h1 class="text-3xl font-bold mb-6">Welcome to CRI Digital Manufacturing IIOT</h1>
|
||||
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-64 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<p class="text-lg text-gray-600 mb-6">
|
||||
This dashboard provides real-time visibility into your manufacturing operations,
|
||||
enabling you to monitor production, track performance, and make data-driven decisions
|
||||
across plants and lines—all from one centralized platform.
|
||||
</p>
|
||||
|
||||
</x-filament-panels::page>
|
||||
@@ -18,29 +18,9 @@
|
||||
@endif
|
||||
@endif
|
||||
</h2>
|
||||
|
||||
<!-- Serial Number Search Bar -->
|
||||
|
||||
{{-- <div class="flex items-center space-x-2">
|
||||
<input
|
||||
type="text"
|
||||
wire:model.debounce.500ms="serialSearch"
|
||||
placeholder="Check Serial Number..."
|
||||
class="border border-gray-300 rounded px-3 py-1 focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500"
|
||||
/>
|
||||
<button
|
||||
wire:click="checkSerialNumber"
|
||||
class="bg-indigo-600 text-white px-3 py-1 rounded hover:bg-indigo-700"
|
||||
>
|
||||
Search
|
||||
</button>
|
||||
</div> --}}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<div class="mt-2">
|
||||
<hr class="border-t-2 border-gray-300">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Modal for completed invoice--}}
|
||||
@@ -64,11 +44,11 @@
|
||||
@endif
|
||||
|
||||
{{-- Modal for serial invoice--}}
|
||||
{{-- @if ($hasSearched)
|
||||
@if ($hasSearched)
|
||||
<div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
|
||||
<table class="min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
{{-- <table class="min-w-[1500px] text-sm text-center border border-gray-300"> --}}
|
||||
{{-- <table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300"> --}}
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
@@ -111,60 +91,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif --}}
|
||||
|
||||
|
||||
@if ($hasSearched)
|
||||
<div class="overflow-x-auto" style="height: 385px;">
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Material Code</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Motor Scanned Status</th>
|
||||
<th class="border px-4 py-2">Pump Scanned Status</th>
|
||||
<th class="border px-4 py-2">Capacitor Scanned Status</th>
|
||||
<th class="border px-4 py-2">Scanned Status Set</th>
|
||||
<th class="border px-4 py-2">Scanned Status</th>
|
||||
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
<th class="border px-4 py-2">Panel Box Supplier</th>
|
||||
<th class="border px-4 py-2">Panel Box Serial Number</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@forelse ($records as $index => $record)
|
||||
<tr wire:key="inv-{{ $record->id }}" class="border-t">
|
||||
<td class="border px-2 py-2">{{ $records->firstItem() + $index }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->stickerMasterRelation?->item?->code ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->serial_number ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->motor_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->pump_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->capacitor_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status_set ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status ?? '' }}</td>
|
||||
<td class="border px-2 py-2 whitespace-nowrap">{{ optional($record->created_at)->format('d-m-Y H:i:s') }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->operator_id ?? '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->panel_box_supplier ?? '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->panel_box_serial_number ?? '' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="12" class="py-4 text-gray-500">
|
||||
No data found for invoice <strong>{{ $invoiceNumber }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mt-3 flex justify-center">
|
||||
{{ $records->onEachSide(3)->links() }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
{{-- Modal for Capacitor Input --}}
|
||||
@@ -199,18 +125,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{{-- Add this script to focus on the input --}}
|
||||
{{-- <script>
|
||||
document.getElementById('capacitorInput').focus();
|
||||
</script> --}}
|
||||
<script>
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
@this.on('focus-capacitor-input', () => {
|
||||
setTimeout(() => {
|
||||
const el = document.getElementById('capacitorInput');
|
||||
if (el) el.focus();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
document.getElementById('capacitorInput').focus();
|
||||
</script>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<div class="p-4">
|
||||
<h2 class="text-lg font-bold mb-4 text-gray-700 uppercase tracking-wider">
|
||||
PENDING INVOICE DATA TABLE:
|
||||
</h2>
|
||||
<div class="overflow-x-auto rounded-lg shadow">
|
||||
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
||||
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Plant Code</th>
|
||||
<th class="border px-4 py-2">Document Number</th>
|
||||
<th class="border px-4 py-2">Customer Trade Location</th>
|
||||
<th class="border px-4 py-2">Location</th>
|
||||
<th class="border px-4 py-2">Remark</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@if (empty($invoicePending))
|
||||
<tr>
|
||||
<td colspan="6" class="px-4 py-4 text-center text-gray-500">
|
||||
Please select plant to load pending invoice.
|
||||
</td>
|
||||
</tr>
|
||||
@else
|
||||
@forelse ($invoicePending as $index => $locator)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['plant_id'] ?? '-' }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['document_number'] ?? '-' }}</td>
|
||||
<td class="border px-4 py-2">{{ $locator['customer_trade_name'] ?? '-' }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['location'] ?? '-' }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['remark'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="9" class="px-4 py-4 text-center text-gray-500">
|
||||
No invoice pending records found.
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,88 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{{-- <title>Invoice Data Report</title> --}}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="text-align: center; font-weight: bold;">
|
||||
{{ $company }}
|
||||
</div>
|
||||
<br>
|
||||
<p>{!! $greeting !!}</p>
|
||||
|
||||
<table border="1" width="50%" cellpadding="6" cellspacing="0">
|
||||
|
||||
<tr>
|
||||
<th width="30%">Title</th>
|
||||
<th width="40%">Details</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Requested DateTime</td>
|
||||
<td>{{ $request->created_at->format('d-m-Y H:i:s') }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Plant</td>
|
||||
<td>{{ $request->plant->name ?? $request->plant_id }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Item Code</td>
|
||||
<td>{{ $request->item->code ?? $request->code }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Job Number</td>
|
||||
<td>{{ $request->aufnr }}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<table border="1" width="50%" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<th>Characteristics Name</th>
|
||||
<th>SAP Value</th>
|
||||
<th>Update Value</th>
|
||||
<th>WorkFlow ID</th>
|
||||
</tr>
|
||||
|
||||
@forelse ($tableData as $char)
|
||||
<tr>
|
||||
{{-- <td>{{ $char['characteristic_name'] ?? '-' }}</td> --}}
|
||||
<td>{{ strtoupper($char['characteristic_name'] ?? '-') }}</td>
|
||||
<td>{{ $char['current_value'] ?? '-' }}</td>
|
||||
<td>{{ $char['update_value'] ?? '-' }}</td>
|
||||
<td>{{ $char['work_flow_id'] ?? '-' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="4">No Characteristics Found</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</table>
|
||||
<br>
|
||||
<table border="1" width="50%" cellpadding="6" cellspacing="0">
|
||||
<tr>
|
||||
<th>Approver Name</th>
|
||||
<th>Approve Status</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ $approverName }}</td>
|
||||
<td style="text-align: center;">
|
||||
<a href="{{ $approveUrl }}">Approve</a> |
|
||||
<a href="{{ $holdUrl }}">Hold</a> |
|
||||
<a href="{{ $rejectUrl }}">Reject</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>{!! $wishes !!}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -88,7 +88,6 @@
|
||||
<th>Location</th>
|
||||
<th>Pending Days</th>
|
||||
<th>Status</th>
|
||||
<th>Remark</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -118,7 +117,6 @@
|
||||
<td class="{{ $row['status_class'] ?? '' }}">
|
||||
{{ $row['status'] }}
|
||||
</td>
|
||||
<td>{{ $row['remark'] ?? '-'}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CharacteristicApprovalController;
|
||||
use App\Http\Controllers\CharacteristicsController;
|
||||
use App\Http\Controllers\EquipmentMasterController;
|
||||
use App\Http\Controllers\InvoiceValidationController;
|
||||
@@ -46,6 +45,7 @@ use Illuminate\Support\Facades\Route;
|
||||
|
||||
// Route::post('/user/update', function (Request $request) {
|
||||
// // Return the request data as JSON
|
||||
|
||||
// // dd($request);
|
||||
// return response()->json([
|
||||
// 'message' => 'User updated successfully',
|
||||
@@ -75,9 +75,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-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'])->where('palletNo', '.*')->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');
|
||||
|
||||
@@ -155,37 +155,29 @@ Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
||||
|
||||
Route::get('sap/files', [SapFileController::class, 'readFiles']);
|
||||
|
||||
Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
|
||||
// ..Part Validation - Characteristics
|
||||
// ..Laser Marking - Characteristics
|
||||
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
// ..Laser Route to SAP
|
||||
|
||||
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
|
||||
|
||||
// ..Job or Serial - Characteristics
|
||||
// ..Part Validation - Characteristics
|
||||
|
||||
Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
// Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
|
||||
Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
// ..Serial or job
|
||||
|
||||
// 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']);
|
||||
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// ..serial (auto or manual)
|
||||
// ..serial auto or manual
|
||||
|
||||
Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
// ..Request Characteristics
|
||||
|
||||
Route::post('laser/characteristics/change', [CharacteristicsController::class, 'storeLaserRequestChar']);
|
||||
|
||||
Route::get('laser/characteristics/request', [CharacteristicsController::class, 'getLaserRequestChar']);
|
||||
|
||||
Route::post('laser-doc-pdf', [PdfController::class, 'storeLaserPdf']);
|
||||
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
// ..Product Characteristics
|
||||
|
||||
@@ -203,13 +195,6 @@ Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']);
|
||||
|
||||
Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
|
||||
|
||||
// routes/api.php
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave']);
|
||||
|
||||
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']);
|
||||
|
||||
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
||||
|
||||
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave'])
|
||||
// ->name('characteristic.hold.save');
|
||||
|
||||
247
routes/web.php
247
routes/web.php
@@ -1,116 +1,76 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CharacteristicApprovalController;
|
||||
use App\Http\Controllers\FileUploadController;
|
||||
use App\Mail\test;
|
||||
use App\Models\EquipmentMaster;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
});
|
||||
|
||||
// Route::get('/admin', function () {
|
||||
// return redirect('/admin/welcome');
|
||||
// });
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
});
|
||||
|
||||
// ..Characteristic Approval Routes..//
|
||||
// routes/web.php
|
||||
Route::post('/save-serials-to-session', function (Request $request) {
|
||||
session(['serial_numbers' => $request->serial_numbers]);
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'serial_numbers' => session('serial_numbers'),
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/characteristic/hold', [CharacteristicApprovalController::class, 'holdForm'])
|
||||
->name('characteristic.hold')
|
||||
->middleware('signed');
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
|
||||
Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave'])
|
||||
->name('characteristic.hold.save');
|
||||
if (!file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
}
|
||||
|
||||
Route::get('/approval/hold-success', function () {
|
||||
return view('approval.hold-success');
|
||||
})->name('approval.hold.success');
|
||||
return response()->file($path);
|
||||
})->name('part.validation.image');
|
||||
|
||||
Route::get('/characteristic/reject', [CharacteristicApprovalController::class, 'rejectForm'])
|
||||
->name('characteristic.reject')
|
||||
->middleware('signed');
|
||||
// web.php
|
||||
Route::post('/temp-upload', function (Request $request) {
|
||||
if (!$request->hasFile('photo')) {
|
||||
return response()->json(['success' => false], 400);
|
||||
}
|
||||
|
||||
Route::post('/characteristic/reject-save', [CharacteristicApprovalController::class, 'rejectSave'])
|
||||
->name('characteristic.reject.save');
|
||||
$file = $request->file('photo');
|
||||
$filename = 'capture_' . time() . '.jpeg';
|
||||
$path = $file->storeAs('temp', $filename, 'local'); // storage/app/temp
|
||||
|
||||
Route::get('/approval/reject-success', function () {
|
||||
return view('approval.reject-success');
|
||||
})->name('approval.reject.success');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
||||
->name('characteristic.approve')
|
||||
->middleware('signed');
|
||||
Route::post('/verify-ocr', function (Request $request) {
|
||||
|
||||
Route::post('/file-upload', [FileUploadController::class, 'upload'])->name('file.upload');
|
||||
if (!$request->has('path')) {
|
||||
return response()->json(['success' => false, 'error' => 'No file path provided']);
|
||||
}
|
||||
|
||||
// Route::get('/characteristic/hold', [CharacteristicApprovalController::class, 'hold'])
|
||||
// ->name('characteristic.hold')
|
||||
// ->middleware('signed');
|
||||
$filePath = storage_path('app/private/temp/' . basename($request->path));
|
||||
|
||||
// Route::get('/characteristic/reject', [CharacteristicApprovalController::class, 'reject'])
|
||||
// ->name('characteristic.reject')
|
||||
// ->middleware('signed');
|
||||
if (!file_exists($filePath)) {
|
||||
return response()->json(['success' => false, 'error' => 'File not found']);
|
||||
}
|
||||
|
||||
// routes/web.php
|
||||
Route::post('/save-serials-to-session', function (Request $request) {
|
||||
session(['serial_numbers' => $request->serial_numbers]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'serial_numbers' => session('serial_numbers'),
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
|
||||
if (! file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
}
|
||||
|
||||
return response()->file($path);
|
||||
})->name('part.validation.image');
|
||||
|
||||
// web.php
|
||||
Route::post('/temp-upload', function (Request $request) {
|
||||
if (! $request->hasFile('photo')) {
|
||||
return response()->json(['success' => false], 400);
|
||||
}
|
||||
|
||||
$file = $request->file('photo');
|
||||
$filename = 'capture_'.time().'.jpeg';
|
||||
$path = $file->storeAs('temp', $filename, 'local'); // storage/app/temp
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
});
|
||||
|
||||
Route::post('/verify-ocr', function (Request $request) {
|
||||
|
||||
if (! $request->has('path')) {
|
||||
return response()->json(['success' => false, 'error' => 'No file path provided']);
|
||||
}
|
||||
|
||||
$filePath = storage_path('app/private/temp/'.basename($request->path));
|
||||
|
||||
if (! file_exists($filePath)) {
|
||||
return response()->json(['success' => false, 'error' => 'File not found']);
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
// $text = (new TesseractOCR($filePath))->lang('eng')->run();
|
||||
$text = (new TesseractOCR($filePath))
|
||||
->executable('/usr/bin/tesseract')
|
||||
->lang('eng')
|
||||
->psm(6) // treats the image as a block of text
|
||||
->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
|
||||
->run();
|
||||
->executable('/usr/bin/tesseract')
|
||||
->lang('eng')
|
||||
->psm(6) // treats the image as a block of text
|
||||
->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
|
||||
->run();
|
||||
|
||||
$text = trim($text); // remove whitespace
|
||||
|
||||
@@ -119,19 +79,19 @@ Route::post('/verify-ocr', function (Request $request) {
|
||||
return response()->json(['success' => true, 'text' => 'Text not found']);
|
||||
}
|
||||
|
||||
// return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn ($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||
//return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'text' => array_values($serials), // reindex array
|
||||
]);
|
||||
}
|
||||
// catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||
// }
|
||||
catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'text' => array_values($serials) // reindex array
|
||||
]);
|
||||
}
|
||||
//catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||
// }
|
||||
catch (\Exception $e) {
|
||||
// Log the full exception class and message
|
||||
\Log::error('Tesseract OCR failed', [
|
||||
'exception_class' => get_class($e),
|
||||
@@ -151,61 +111,62 @@ Route::post('/verify-ocr', function (Request $request) {
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/download/{equipmentNumber}', function ($equipmentNumber) {
|
||||
Route::get('/download/{equipmentNumber}', function ($equipmentNumber) {
|
||||
$model = EquipmentMaster::where('equipment_number', $equipmentNumber)->firstOrFail();
|
||||
|
||||
if (! $model->attachment || ! Storage::disk('local')->exists($model->attachment)) {
|
||||
abort(404, 'File not found.');
|
||||
}
|
||||
return Storage::disk('local')->download($model->attachment);
|
||||
})->name('download.attachment');
|
||||
|
||||
return Storage::disk('local')->download($model->attachment);
|
||||
})->name('download.attachment');
|
||||
// Route::get('/admin/forgot-password', function () {
|
||||
// return view('auth.forgot-password');
|
||||
// })->name('filament.admin.forgot-password');
|
||||
|
||||
// Route::get('/admin/forgot-password', function () {
|
||||
// return view('auth.forgot-password');
|
||||
// })->name('filament.admin.forgot-password');
|
||||
|
||||
// Route::post('/admin/forgot-password', function(Request $request){
|
||||
// Route::post('/admin/forgot-password', function(Request $request){
|
||||
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'email'=>'required|email',
|
||||
// 'old_password'=>'required',
|
||||
// 'password'=>'required',
|
||||
// 'password_confirmation'=>'required'
|
||||
// ]);
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'email'=>'required|email',
|
||||
// 'old_password'=>'required',
|
||||
// 'password'=>'required',
|
||||
// 'password_confirmation'=>'required'
|
||||
// ]);
|
||||
|
||||
// if($validator->fails()){
|
||||
// return response()->json([
|
||||
// 'emailError' => $validator->errors()->first('email'),
|
||||
// 'oldPasswordError' => $validator->errors()->first('old_password'),
|
||||
// 'newPasswordError' => $validator->errors()->first('password'),
|
||||
// 'confirmPasswordError' => $validator->errors()->first('password_confirmation')
|
||||
// ]);
|
||||
// }
|
||||
// if($validator->fails()){
|
||||
// return response()->json([
|
||||
// 'emailError' => $validator->errors()->first('email'),
|
||||
// 'oldPasswordError' => $validator->errors()->first('old_password'),
|
||||
// 'newPasswordError' => $validator->errors()->first('password'),
|
||||
// 'confirmPasswordError' => $validator->errors()->first('password_confirmation')
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// $user = User::where('email',$request->email)->first();
|
||||
// if(!$user){
|
||||
// return response()->json(['passwordError'=>'No user found with this email.']);
|
||||
// }
|
||||
// $user = User::where('email',$request->email)->first();
|
||||
// if(!$user){
|
||||
// return response()->json(['passwordError'=>'No user found with this email.']);
|
||||
// }
|
||||
|
||||
// if(!Hash::check($request->old_password, $user->password)){
|
||||
// return response()->json(['oldPasswordError'=>'Old password does not match']);
|
||||
// }
|
||||
// if(!Hash::check($request->old_password, $user->password)){
|
||||
// return response()->json(['oldPasswordError'=>'Old password does not match']);
|
||||
// }
|
||||
|
||||
// if($request->password != $request->password_confirmation){
|
||||
// return response()->json(['newPasswordError'=>'New password and confirm password do not match']);
|
||||
// }
|
||||
// if($request->password != $request->password_confirmation){
|
||||
// return response()->json(['newPasswordError'=>'New password and confirm password do not match']);
|
||||
// }
|
||||
|
||||
// $user->password = Hash::make($request->password);
|
||||
// $user->save();
|
||||
// $user->password = Hash::make($request->password);
|
||||
// $user->save();
|
||||
|
||||
// return response()->json(['success'=>'Password changed successfully!']);
|
||||
// })->name('filament.admin.forgot-password.otp');
|
||||
// return response()->json(['success'=>'Password changed successfully!']);
|
||||
// })->name('filament.admin.forgot-password.otp');
|
||||
|
||||
// Route::post('/admin/check-email', function(Request $request){
|
||||
// $request->validate(['email' => 'required|email']);
|
||||
// $exists = User::where('email', $request->email)->first();
|
||||
// return response()->json(['exists' => $exists]);
|
||||
// })->name('admin.check-email');
|
||||
|
||||
// Route::post('/admin/check-email', function(Request $request){
|
||||
// $request->validate(['email' => 'required|email']);
|
||||
// $exists = User::where('email', $request->email)->first();
|
||||
// return response()->json(['exists' => $exists]);
|
||||
// })->name('admin.check-email');
|
||||
|
||||
Reference in New Issue
Block a user