Compare commits
1 Commits
39a2fed9a8
...
gha-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfed40f535 |
30
.github/workflows/pint.yaml
vendored
Normal file
30
.github/workflows/pint.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Laravel Pint
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Reinstall system libraries to ensure compatibility
|
||||||
|
- name: Ensure system libraries are up-to-date
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install --reinstall --yes git libc6
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: "8.3"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-interaction --prefer-dist --no-progress
|
||||||
|
|
||||||
|
# Run pint in test mode, check only files different from master branch
|
||||||
|
- name: Run Laravel Pint in test mode
|
||||||
|
run: vendor/bin/pint --test --diff=master
|
||||||
@@ -1,249 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'send:invoice-data-report {schedule_type} {plant}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Command description';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
// ini_set('max_execution_time', 0); // disable limit
|
|
||||||
// set_time_limit(0);
|
|
||||||
|
|
||||||
$scheduleType = $this->argument('schedule_type');
|
|
||||||
$plantId = (int) $this->argument('plant');
|
|
||||||
|
|
||||||
$mailRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
|
||||||
->where('rule_name', 'InvoiceDataMail')
|
|
||||||
->where('schedule_type', $scheduleType)
|
|
||||||
->where('plant', $plantId)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
|
||||||
|
|
||||||
if ($plants->isEmpty()) {
|
|
||||||
$this->error("No valid plant(s) found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (strtolower($scheduleType) == 'daily') {
|
|
||||||
// $startDate = now()->subDay()->setTime(10, 0, 0);//8:00
|
|
||||||
// $endDate = now()->setTime(10, 0, 0);//8
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (strtolower($scheduleType) == 'daily')
|
|
||||||
{
|
|
||||||
$firstRecord = InvoiceDataValidation::orderBy('document_date', 'asc')->first();
|
|
||||||
$lastRecord = InvoiceDataValidation::orderBy('document_date', 'desc')->first();
|
|
||||||
|
|
||||||
if ($firstRecord && $lastRecord) {
|
|
||||||
$startDate = \Carbon\Carbon::parse($firstRecord->document_date)->startOfDay();
|
|
||||||
//$endDate = \Carbon\Carbon::parse($lastRecord->document_date)->endOfDay();
|
|
||||||
$endDate = \Carbon\Carbon::parse($lastRecord->document_date)
|
|
||||||
->addDay()
|
|
||||||
->setTime(10, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$startDate = now()->startOfDay();
|
|
||||||
$endDate = now()->endOfDay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$startDate = now()->setTime(8, 0, 0);
|
|
||||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//..
|
|
||||||
|
|
||||||
foreach ($plants as $plant)
|
|
||||||
{
|
|
||||||
$tableData = [];
|
|
||||||
|
|
||||||
// $distributions = ['Direct Sale', 'Branch Sale', 'Internal Transfer', 'WOS', ''];
|
|
||||||
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
|
||||||
->distinct()
|
|
||||||
->pluck('distribution_channel_desc')
|
|
||||||
->filter(fn($val) => trim($val) != '')
|
|
||||||
->values()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$distributions[] = '';
|
|
||||||
|
|
||||||
foreach ($distributions as $selectedDistribution)
|
|
||||||
{
|
|
||||||
//where('plant_id', $plant->id)
|
|
||||||
$invoices = InvoiceDataValidation::where('plant_id', $plant->id)
|
|
||||||
->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')
|
|
||||||
->get()
|
|
||||||
->unique('document_number')
|
|
||||||
->values();
|
|
||||||
|
|
||||||
if ($invoices->isEmpty()) {
|
|
||||||
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, '-');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (trim($selectedDistribution) == '' || $selectedDistribution == null) {
|
|
||||||
$invoices = $invoices->filter(function ($inv) {
|
|
||||||
return str_starts_with($inv->document_number, '7');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($invoices->isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoiceNumbers = $invoices
|
|
||||||
->pluck('document_number')
|
|
||||||
->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')
|
|
||||||
->pluck('qr_code')
|
|
||||||
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
// if (!empty($wentOutInvoices)) {
|
|
||||||
// $deletedValidations = InvoiceDataValidation::whereIn('document_number', $wentOutInvoices)
|
|
||||||
// ->delete();
|
|
||||||
|
|
||||||
// $deletedOuts = InvoiceOutValidation::whereIn('qr_code', $wentOutInvoices)
|
|
||||||
// ->delete();
|
|
||||||
|
|
||||||
// $this->info("Deleted {$deletedValidations} from invoice_data_validations and {$deletedOuts} from invoice_out_validations for plant {$plant->name} ({$selectedDistribution}).");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $pendingInvoices = $invoices->filter(function ($inv) use ($wentOutInvoices) {
|
|
||||||
// return !in_array($inv->document_number, $wentOutInvoices);
|
|
||||||
// });
|
|
||||||
// $pendingInvoices = $invoices->filter(function ($inv) use ($wentOutInvoices) {
|
|
||||||
// return !in_array(strtoupper(trim($inv->document_number)), $wentOutInvoices);
|
|
||||||
// });
|
|
||||||
|
|
||||||
$pendingInvoices = $invoices->filter(function ($inv) use ($wentOutInvoices) {
|
|
||||||
$doc = preg_replace('/\s+/', '', strtoupper((string) $inv->document_number));
|
|
||||||
return !in_array($doc, $wentOutInvoices, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if ($pendingInvoices->isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($pendingInvoices as $inv)
|
|
||||||
{
|
|
||||||
$yesterday = now()->subDay()->toDateString();
|
|
||||||
$today = now()->toDateString();
|
|
||||||
$documentDate = \Carbon\Carbon::parse($inv->document_date);
|
|
||||||
|
|
||||||
if (in_array($documentDate->toDateString(), [$today, $yesterday])) {
|
|
||||||
$statusColor = 'status-pending-yellow';
|
|
||||||
} else {
|
|
||||||
$statusColor = 'status-pending-red';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tableData[] = [
|
|
||||||
//'no' => $no++,
|
|
||||||
'plant' => $plant->name,
|
|
||||||
// 'distribution_type' => $selectedDistribution,
|
|
||||||
'customer_code' => $inv->customer_code,
|
|
||||||
'document_number' => $inv->document_number,
|
|
||||||
'document_date' => $inv->document_date,
|
|
||||||
'customer_trade_name' => $inv->customer_trade_name,
|
|
||||||
'customer_location' => $inv->customer_location,
|
|
||||||
'location' => $inv->location,
|
|
||||||
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
|
||||||
'status' => 'Pending',
|
|
||||||
'status_class' => $statusColor,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$tableData = collect($tableData)
|
|
||||||
->sortBy('document_date')
|
|
||||||
->values()
|
|
||||||
->map(function ($item, $index) {
|
|
||||||
$item['no'] = $index + 1;
|
|
||||||
return $item;
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$mailSubject = "Despatch Pending Sale Invoice & STO Invoice as on Date ({$plant->name})";
|
|
||||||
|
|
||||||
$mail = new InvoiceDataMail($scheduleType, $tableData, $mailSubject);
|
|
||||||
$contentVars = $mail->content()->with;
|
|
||||||
|
|
||||||
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
|
||||||
$this->table(
|
|
||||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type'
|
|
||||||
$tableData
|
|
||||||
);
|
|
||||||
$this->info($contentVars['wishes'] ?? '');
|
|
||||||
|
|
||||||
foreach ($mailRules as $rule)
|
|
||||||
{
|
|
||||||
$toEmails = collect(explode(',', $rule->email))
|
|
||||||
->map(fn($e) => trim($e))
|
|
||||||
->filter()
|
|
||||||
->unique()
|
|
||||||
->values()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
$ccEmails = collect(explode(',', $rule->cc_emails))
|
|
||||||
->map(fn($e) => trim($e))
|
|
||||||
->filter()
|
|
||||||
->unique()
|
|
||||||
->values()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
if (empty($toEmails)) {
|
|
||||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
|
||||||
|
|
||||||
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : ''));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,17 +30,258 @@ class SendInvoiceReport extends Command
|
|||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// public function handle()
|
||||||
|
// {
|
||||||
|
|
||||||
|
// $schedule = $this->argument('schedule_type');
|
||||||
|
// $plantid = $this->argument('plant');
|
||||||
|
|
||||||
|
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||||
|
|
||||||
|
// $startDate = now()->setTime(8, 0, 0);
|
||||||
|
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
|
||||||
|
|
||||||
|
// $serialTableData = [];
|
||||||
|
// $materialTableData = [];
|
||||||
|
// $bundleTableData = [];
|
||||||
|
// $noSerial = 1;
|
||||||
|
// $noMaterial = 1;
|
||||||
|
// $noBundle = 1;
|
||||||
|
|
||||||
|
// foreach ($plants as $plantId) {
|
||||||
|
// $plant = Plant::find($plantId);
|
||||||
|
// $plantName = $plant ? $plant->name : $plantId;
|
||||||
|
|
||||||
|
// //..Serial Invoice
|
||||||
|
|
||||||
|
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->whereNull('quantity')
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->whereNull('quantity')
|
||||||
|
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||||
|
// ->groupBy('invoice_number')
|
||||||
|
// ->havingRaw(
|
||||||
|
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||||
|
// )
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
// $serialTableData[] = [
|
||||||
|
// 'no' => $noSerial++,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $totalSerialCount,
|
||||||
|
// 'scannedInvoice' => $scannedSerialCount,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// //..Individual Invoice
|
||||||
|
|
||||||
|
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', 1)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', 1)
|
||||||
|
// ->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();
|
||||||
|
|
||||||
|
// $materialTableData[] = [
|
||||||
|
// 'no' => $noMaterial++,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $TotalMatCount,
|
||||||
|
// 'scannedInvoice' => $scannedMatCount,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// //..BUndle Invoice
|
||||||
|
|
||||||
|
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', '>', 1)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', '>', 1)
|
||||||
|
// ->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();
|
||||||
|
|
||||||
|
// $bundleTableData[] = [
|
||||||
|
// 'no' => $noBundle++,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $totalBundleCount,
|
||||||
|
// 'scannedInvoice' => $scannedBundleCount,
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 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, [], []));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //$this->info(json_encode($materialTableData));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function handle()
|
||||||
|
// {
|
||||||
|
// $schedule = $this->argument('schedule_type');
|
||||||
|
// $plantId = $this->argument('plant');
|
||||||
|
|
||||||
|
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||||
|
|
||||||
|
// $startDate = now()->setTime(8, 0, 0);
|
||||||
|
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
|
||||||
|
// $serialTableData = [];
|
||||||
|
// $materialTableData = [];
|
||||||
|
// $bundleTableData = [];
|
||||||
|
|
||||||
|
// $plant = Plant::find($plantId);
|
||||||
|
// $plantName = $plant ? $plant->name : $plantId;
|
||||||
|
|
||||||
|
// // Serial Invoice
|
||||||
|
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->whereNull('quantity')
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->whereNull('quantity')
|
||||||
|
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||||
|
// ->groupBy('invoice_number')
|
||||||
|
// ->havingRaw(
|
||||||
|
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||||
|
// )
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
// $serialTableData[] = [
|
||||||
|
// 'no' => 1,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $totalSerialCount,
|
||||||
|
// 'scannedInvoice' => $scannedSerialCount,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// // Individual Material Invoice
|
||||||
|
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', 1)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', 1)
|
||||||
|
// ->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();
|
||||||
|
|
||||||
|
// $materialTableData[] = [
|
||||||
|
// 'no' => 1,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $TotalMatCount,
|
||||||
|
// 'scannedInvoice' => $scannedMatCount,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// // Bundle Invoice
|
||||||
|
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', '>', 1)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->distinct('invoice_number')
|
||||||
|
// ->count('invoice_number');
|
||||||
|
|
||||||
|
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('quantity', '>', 1)
|
||||||
|
// ->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();
|
||||||
|
|
||||||
|
// $bundleTableData[] = [
|
||||||
|
// 'no' => 1,
|
||||||
|
// 'plant' => $plantName,
|
||||||
|
// 'totalInvoice' => $totalBundleCount,
|
||||||
|
// 'scannedInvoice' => $scannedBundleCount,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// // 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, [], []));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // $this->table(
|
||||||
|
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
|
||||||
|
// // $serialTableData
|
||||||
|
// // );
|
||||||
|
// }
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$schedule = $this->argument('schedule_type');
|
$schedule = $this->argument('schedule_type');
|
||||||
//$scheduleType = $this->argument('scheduleType');
|
|
||||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||||
|
|
||||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||||
|
|
||||||
// $startDate = now()->setTime(8, 0, 0);
|
$startDate = now()->setTime(8, 0, 0);
|
||||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
|
||||||
$serialTableData = [];
|
$serialTableData = [];
|
||||||
$materialTableData = [];
|
$materialTableData = [];
|
||||||
@@ -52,18 +293,7 @@ class SendInvoiceReport extends Command
|
|||||||
: [$plantIdArg];
|
: [$plantIdArg];
|
||||||
|
|
||||||
$no = 1;
|
$no = 1;
|
||||||
if (strtolower($schedule) == 'daily')
|
foreach ($plantIds as $plantId) {
|
||||||
{
|
|
||||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
|
||||||
$endDate = now()->setTime(8, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$startDate = now()->setTime(8, 0, 0);
|
|
||||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
|
||||||
}
|
|
||||||
foreach ($plantIds as $plantId)
|
|
||||||
{
|
|
||||||
$plant = Plant::find($plantId);
|
$plant = Plant::find($plantId);
|
||||||
$plantName = $plant ? $plant->name : $plantId;
|
$plantName = $plant ? $plant->name : $plantId;
|
||||||
|
|
||||||
@@ -82,27 +312,11 @@ class SendInvoiceReport extends Command
|
|||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$serialInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('quantity', null)
|
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('scanned_status', 'Scanned')
|
|
||||||
->where(function($query) {
|
|
||||||
$query->whereNull('quantity')
|
|
||||||
->orWhere('quantity', 0);
|
|
||||||
})
|
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$serialTableData[] = [
|
$serialTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalSerialCount,
|
'totalInvoice' => $totalSerialCount,
|
||||||
'scannedInvoice' => $scannedSerialCount,
|
'scannedInvoice' => $scannedSerialCount,
|
||||||
'totalInvoiceQuan' => $serialInvoiceQuan,
|
|
||||||
'scannedInvoiceQuan' => $scannedInvoiceQuan,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Material Invoice
|
// Material Invoice
|
||||||
@@ -120,25 +334,11 @@ class SendInvoiceReport extends Command
|
|||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$totalMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('quantity', 1)
|
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('quantity', 1)
|
|
||||||
->whereNotNull('serial_number')
|
|
||||||
->where('serial_number','!=', '')
|
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$materialTableData[] = [
|
$materialTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalMatCount,
|
'totalInvoice' => $totalMatCount,
|
||||||
'scannedInvoice' => $scannedMatCount,
|
'scannedInvoice' => $scannedMatCount,
|
||||||
'totalInvoiceQuan' => $totalMatInvoiceQuan,
|
|
||||||
'scannedInvoiceQuan' => $scannedMatInvoiceQuan,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Bundle Invoice
|
// Bundle Invoice
|
||||||
@@ -156,49 +356,29 @@ class SendInvoiceReport extends Command
|
|||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$totalBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('quantity', '>', 1)
|
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
|
||||||
->where('quantity', '>', 1)
|
|
||||||
->whereNotNull('serial_number')
|
|
||||||
->where('serial_number','!=', '')
|
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
|
||||||
->count();
|
|
||||||
|
|
||||||
$bundleTableData[] = [
|
$bundleTableData[] = [
|
||||||
'no' => $no,
|
'no' => $no,
|
||||||
'plant' => $plantName,
|
'plant' => $plantName,
|
||||||
'totalInvoice' => $totalBundleCount,
|
'totalInvoice' => $totalBundleCount,
|
||||||
'scannedInvoice' => $scannedBundleCount,
|
'scannedInvoice' => $scannedBundleCount,
|
||||||
'totalInvoiceQuan' => $totalBundleInvoiceQuan,
|
|
||||||
'scannedInvoiceQuan' => $scannedBundleInvoiceQuan,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$no++;
|
$no++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
|
|
||||||
$contentVars = $mail->content()->with;
|
|
||||||
|
|
||||||
$this->info($contentVars['greeting'] ?? 'Invoice Report');
|
|
||||||
|
|
||||||
// Send to SerialInvoiceMail recipients
|
// Send to SerialInvoiceMail recipients
|
||||||
if ($mailRules->has('SerialInvoiceMail')) {
|
if ($mailRules->has('SerialInvoiceMail')) {
|
||||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
Mail::to($email)->send(new test($serialTableData, [], []));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,21 +386,19 @@ class SendInvoiceReport extends Command
|
|||||||
if ($mailRules->has('InvoiceMail')) {
|
if ($mailRules->has('InvoiceMail')) {
|
||||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show preview in console
|
// Show preview in console
|
||||||
$this->info('--- Serial Invoice Table ---');
|
$this->info('--- Serial Invoice Table ---');
|
||||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
|
||||||
|
|
||||||
$this->info('--- Material Invoice Table ---');
|
$this->info('--- Material Invoice Table ---');
|
||||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
|
||||||
|
|
||||||
$this->info('--- Bundle Invoice Table ---');
|
$this->info('--- Bundle Invoice Table ---');
|
||||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
|
||||||
|
|
||||||
$this->info($contentVars['wishes'] ?? '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,79 @@ class SendProductionReport extends Command
|
|||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// public function handle()
|
||||||
|
// {
|
||||||
|
// $scheduleType = $this->argument('schedule_type');
|
||||||
|
// $plantId = $this->argument('plant');
|
||||||
|
|
||||||
|
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
|
// ->where('rule_name', 'ProductionMail')
|
||||||
|
// ->where('plant', $plantId)
|
||||||
|
// ->where('schedule_type', $scheduleType)
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// $emails = $mailRules->pluck('email')->unique()->toArray();
|
||||||
|
|
||||||
|
// $plant = Plant::find($plantId);
|
||||||
|
|
||||||
|
// if (!$plant) {
|
||||||
|
// $this->error("Invalid plant ID: $plantId");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $lines = Line::where('plant_id', $plantId)->get();
|
||||||
|
|
||||||
|
// $startDate = now()->setTime(8, 0, 0);
|
||||||
|
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||||
|
|
||||||
|
// $PlanstartDate = now()->setTime(8, 0, 0);
|
||||||
|
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
|
||||||
|
|
||||||
|
// $tableData = [];
|
||||||
|
// $no = 1;
|
||||||
|
|
||||||
|
// foreach ($lines as $line) {
|
||||||
|
// $lineId = $line->id;
|
||||||
|
// $lineName = $line->name;
|
||||||
|
|
||||||
|
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
|
||||||
|
// ->where('line_id', $lineId)
|
||||||
|
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||||
|
// ->sum('plan_quantity');
|
||||||
|
|
||||||
|
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
|
||||||
|
// ->where('line_id', $lineId)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
// $tableData[] = [
|
||||||
|
// 'no' => $no++,
|
||||||
|
// 'plant' => $plant->name,
|
||||||
|
// 'line' => $lineName,
|
||||||
|
// 'targetQuantity' => $targetQuantity,
|
||||||
|
// 'productionQuantity' => $productionQuantity,
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // $this->table(
|
||||||
|
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
|
||||||
|
// // $tableData
|
||||||
|
// // );
|
||||||
|
|
||||||
|
// if (!empty($emails)) {
|
||||||
|
// foreach ($emails as $email) {
|
||||||
|
// Mail::to($email)->send(new ProductionMail($tableData));
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// $this->info('No recipients found for ProductionMailAlert.');
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
ini_set('max_execution_time', 0); // disable limit
|
|
||||||
set_time_limit(0);
|
|
||||||
|
|
||||||
$scheduleType = $this->argument('schedule_type');
|
$scheduleType = $this->argument('schedule_type');
|
||||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
||||||
|
|
||||||
@@ -78,7 +146,53 @@ class SendProductionReport extends Command
|
|||||||
$tableData = [];
|
$tableData = [];
|
||||||
$no = 1;
|
$no = 1;
|
||||||
|
|
||||||
//.
|
// foreach ($plants as $plant) {
|
||||||
|
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||||
|
|
||||||
|
// foreach ($lines as $line) {
|
||||||
|
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||||
|
// ->where('line_id', $line->id)
|
||||||
|
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||||
|
// ->sum('plan_quantity');
|
||||||
|
|
||||||
|
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||||
|
// ->where('line_id', $line->id)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
// $tableData[] = [
|
||||||
|
// 'no' => $no++,
|
||||||
|
// 'plant' => $plant->name,
|
||||||
|
// 'line' => $line->name,
|
||||||
|
// 'targetQuantity' => $targetQuantity,
|
||||||
|
// 'productionQuantity' => $productionQuantity,
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $fgTableData = []; // store FG Line related data
|
||||||
|
|
||||||
|
// foreach ($plants as $plant) {
|
||||||
|
// // ✅ Only get FG Lines
|
||||||
|
// $fgLines = Line::where('plant_id', $plant->id)
|
||||||
|
// ->where('type', 'FG Line')
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// foreach ($fgLines as $line) {
|
||||||
|
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||||
|
// ->where('line_id', $line->id)
|
||||||
|
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||||
|
// ->count();
|
||||||
|
|
||||||
|
// $fgTableData[] = [
|
||||||
|
// 'no' => $no++,
|
||||||
|
// 'plant' => $plant->name,
|
||||||
|
// 'line' => $line->name,
|
||||||
|
// 'targetQuantity' => $targetQuantity,
|
||||||
|
// 'productionQuantity' => $validationCount,
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
foreach ($plants as $plant)
|
foreach ($plants as $plant)
|
||||||
{
|
{
|
||||||
@@ -90,7 +204,7 @@ class SendProductionReport extends Command
|
|||||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||||
->sum('plan_quantity');
|
->sum('plan_quantity');
|
||||||
|
|
||||||
if (strtolower($line->type) == 'fg line') {
|
if (strtolower($line->type) === 'fg line') {
|
||||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||||
->where('line_id', $line->id)
|
->where('line_id', $line->id)
|
||||||
->whereBetween('created_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
@@ -106,7 +220,6 @@ class SendProductionReport extends Command
|
|||||||
'no' => $no++,
|
'no' => $no++,
|
||||||
'plant' => $plant->name,
|
'plant' => $plant->name,
|
||||||
'line' => $line->name,
|
'line' => $line->name,
|
||||||
'type' => $line->type,
|
|
||||||
'targetQuantity' => $targetQuantity,
|
'targetQuantity' => $targetQuantity,
|
||||||
'productionQuantity' => $productionQuantity,
|
'productionQuantity' => $productionQuantity,
|
||||||
];
|
];
|
||||||
@@ -115,38 +228,20 @@ class SendProductionReport extends Command
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||||
|
|
||||||
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||||
|
|
||||||
// if (!empty($emails)) {
|
|
||||||
// foreach ($emails as $email) {
|
|
||||||
// Mail::to($email)->send(new ProductionMail($tableData));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// $this->info('No recipients found for ProductionMailAlert.');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
|
||||||
// Preview in console
|
|
||||||
$mail = new ProductionMail($scheduleType, $tableData);
|
|
||||||
$contentVars = $mail->content()->with;
|
|
||||||
|
|
||||||
$this->info($contentVars['greeting'] ?? 'Production Report');
|
|
||||||
$this->table(
|
|
||||||
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
|
|
||||||
$tableData
|
|
||||||
);
|
|
||||||
$this->info($contentVars['wishes'] ?? '');
|
|
||||||
|
|
||||||
// Send mails
|
|
||||||
if (!empty($emails)) {
|
if (!empty($emails)) {
|
||||||
foreach ($emails as $email) {
|
foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
|
Mail::to($email)->send(new ProductionMail($tableData));
|
||||||
}
|
}
|
||||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
|
||||||
} else {
|
} else {
|
||||||
$this->warn('No recipients found for ProductionMailAlert.');
|
$this->info('No recipients found for ProductionMailAlert.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ConfigurationExporter extends Exporter
|
|||||||
// Increment and return the row number
|
// Increment and return the row number
|
||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.code')
|
ExportColumn::make('plant.name')
|
||||||
->label('PLANT'),
|
->label('PLANT'),
|
||||||
ExportColumn::make('line.name')
|
ExportColumn::make('line.name')
|
||||||
->label('LINE'),
|
->label('LINE'),
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\DeviceMaster;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class DeviceMasterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = DeviceMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('name')
|
|
||||||
->label('DEVICE NAME'),
|
|
||||||
ExportColumn::make('mac_address')
|
|
||||||
->label('MAC ADDRESS'),
|
|
||||||
ExportColumn::make('ip_address')
|
|
||||||
->label('IP ADDRESS'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your device 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,140 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\EbReading;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class EbReadingExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = EbReading::class;
|
|
||||||
static $rowNumber = 0;
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('lcd_segment_check')
|
|
||||||
->label('LCD SEGMENT CHECK'),
|
|
||||||
ExportColumn::make('meter_serial_no')
|
|
||||||
->label('METER SERIAL NO'),
|
|
||||||
ExportColumn::make('eb_date_time')
|
|
||||||
->label('EB DATE TIME'),
|
|
||||||
ExportColumn::make('ph_seq_of_volt')
|
|
||||||
->label('PH SEQ OF VOLT'),
|
|
||||||
ExportColumn::make('ph_assoc_conn_check')
|
|
||||||
->label('PH ASSOC CONN CHECK'),
|
|
||||||
ExportColumn::make('instantaneous_ph_volt')
|
|
||||||
->label('INSTANTANEOUS PH VOLT'),
|
|
||||||
ExportColumn::make('instantaneous_curr')
|
|
||||||
->label('INSTANTANEOUS CURR'),
|
|
||||||
ExportColumn::make('instantaneous_freq')
|
|
||||||
->label('INSTANTANEOUS FREQ'),
|
|
||||||
ExportColumn::make('instantaneous_kw_with_sign')
|
|
||||||
->label('INSTANTANEOUS KW WITH SIGN'),
|
|
||||||
ExportColumn::make('instantaneous_kva')
|
|
||||||
->label('INSTANTANEOUS KVA'),
|
|
||||||
ExportColumn::make('instantaneous_kv_ar')
|
|
||||||
->label('INSTANTANEOUS KV AR'),
|
|
||||||
ExportColumn::make('instantaneous_pf_with_sign')
|
|
||||||
->label('INSTANTANEOUS PF WITH SIGN'),
|
|
||||||
ExportColumn::make('rd_with_elapsed_time_kva')
|
|
||||||
->label('RD WITH ELAPSED TIME KVA'),
|
|
||||||
ExportColumn::make('cum_active_import_energy')
|
|
||||||
->label('CUM ACTIVE IMPORT ENERGY'),
|
|
||||||
ExportColumn::make('tod1_active_energy_6_9')
|
|
||||||
->label('TOD1 ACTIVE ENERGY 6-9'),
|
|
||||||
ExportColumn::make('tod2_active_energy_18_21')
|
|
||||||
->label('TOD2 ACTIVE ENERGY 18-21'),
|
|
||||||
ExportColumn::make('tod3_active_energy_21_22')
|
|
||||||
->label('TOD3 ACTIVE ENERGY 21-22'),
|
|
||||||
ExportColumn::make('tod4_active_energy_5_6_9_18')
|
|
||||||
->label('TOD4 ACTIVE ENERGY 5-6-9-18'),
|
|
||||||
ExportColumn::make('tod5_active_energy_22_5')
|
|
||||||
->label('TOD5 ACTIVE ENERGY 22-5'),
|
|
||||||
ExportColumn::make('cum_reac_lag_energy')
|
|
||||||
->label('CUM REAC LAG ENERGY'),
|
|
||||||
ExportColumn::make('cum_reac_lead_energy')
|
|
||||||
->label('CUM REAC LEAD ENERGY'),
|
|
||||||
ExportColumn::make('cum_appar_energy')
|
|
||||||
->label('CUM APPAR ENERGY'),
|
|
||||||
ExportColumn::make('tod1_appar_energy_6_9')
|
|
||||||
->label('TOD1 APPAR ENERGY 6-9'),
|
|
||||||
ExportColumn::make('tod2_appar_energy_18_21')
|
|
||||||
->label('TOD2 APPAR ENERGY 18-21'),
|
|
||||||
ExportColumn::make('tod3_appar_energy_21_22')
|
|
||||||
->label('TOD3 APPAR ENERGY 21-22'),
|
|
||||||
ExportColumn::make('tod4_appar_energy_5_6_9_18')
|
|
||||||
->label('TOD4 APPAR ENERGY 5-6-9-18'),
|
|
||||||
ExportColumn::make('tod5_appar_energy_22_5')
|
|
||||||
->label('TOD5 APPAR ENERGY 22-5'),
|
|
||||||
ExportColumn::make('avg_pow_factor')
|
|
||||||
->label('AVG POW FACTOR'),
|
|
||||||
ExportColumn::make('avg_freq_15min_last_ip')
|
|
||||||
->label('AVG FREQ 15MIN LAST IP'),
|
|
||||||
ExportColumn::make('net_kv_arh_high')
|
|
||||||
->label('NET KV ARH HIGH'),
|
|
||||||
ExportColumn::make('net_kv_arh_low')
|
|
||||||
->label('NET KV ARH LOW'),
|
|
||||||
ExportColumn::make('cum_md_kva')
|
|
||||||
->label('CUM MD KVA'),
|
|
||||||
ExportColumn::make('present_md_kva')
|
|
||||||
->label('PRESENT MD KVA'),
|
|
||||||
ExportColumn::make('present_md_kva_date_time')
|
|
||||||
->label('PRESENT MD KVA DATE TIME'),
|
|
||||||
ExportColumn::make('tod1_md_kva_6_9')
|
|
||||||
->label('TOD1 MD KVA 6-9'),
|
|
||||||
ExportColumn::make('tod2_md_kva_18_21')
|
|
||||||
->label('TOD2 MD KVA 18-21'),
|
|
||||||
ExportColumn::make('tod3_md_kva_21_22')
|
|
||||||
->label('TOD3 MD KVA 21-22'),
|
|
||||||
ExportColumn::make('tod4_md_kva_5_6_9_18')
|
|
||||||
->label('TOD4 MD KVA 5-6-9-18'),
|
|
||||||
ExportColumn::make('tod5_md_kva_22_5')
|
|
||||||
->label('TOD5 MD KVA 22-5'),
|
|
||||||
ExportColumn::make('total_pow_off_hours')
|
|
||||||
->label('TOTAL POW OFF HOURS'),
|
|
||||||
ExportColumn::make('programming_count')
|
|
||||||
->label('PROGRAMMING COUNT'),
|
|
||||||
ExportColumn::make('last_occ_res_event_type')
|
|
||||||
->label('LAST OCC RES EVENT TYPE'),
|
|
||||||
ExportColumn::make('last_occ_res_event_date_time')
|
|
||||||
->label('LAST OCC RES EVENT DATE TIME'),
|
|
||||||
ExportColumn::make('tamper_count')
|
|
||||||
->label('TAMPER COUNT'),
|
|
||||||
ExportColumn::make('reset_count')
|
|
||||||
->label('RESET COUNT'),
|
|
||||||
ExportColumn::make('last_md_reset_date_time')
|
|
||||||
->label('LAST MD RESET DATE TIME'),
|
|
||||||
ExportColumn::make('electrician_sign')
|
|
||||||
->label('ELECTRICIAN SIGN'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your eb reading 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,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\EquipmentMaster;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class EquipmentMasterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = EquipmentMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('machine.name')
|
|
||||||
->label('MACHINE NAME'),
|
|
||||||
ExportColumn::make('name')
|
|
||||||
->label('NAME'),
|
|
||||||
ExportColumn::make('description')
|
|
||||||
->label('DESCRIPTION'),
|
|
||||||
ExportColumn::make('make')
|
|
||||||
->label('MAKE'),
|
|
||||||
ExportColumn::make('model')
|
|
||||||
->label('MODEL'),
|
|
||||||
ExportColumn::make('equipment_number')
|
|
||||||
->label('EQUIPMENT NUMBER'),
|
|
||||||
ExportColumn::make('instrument_serial_number')
|
|
||||||
->label('INSTRUMENT SERIAL NUMBER'),
|
|
||||||
ExportColumn::make('calibrated_on')
|
|
||||||
->label('CALIBRATED ON'),
|
|
||||||
ExportColumn::make('frequency')
|
|
||||||
->label('FREQUENCY'),
|
|
||||||
ExportColumn::make('next_calibration_date')
|
|
||||||
->label('NEXT CALIBRATION DATE'),
|
|
||||||
ExportColumn::make('calibrated_by')
|
|
||||||
->label('CALIBRATED BY'),
|
|
||||||
ExportColumn::make('calibration_certificate')
|
|
||||||
->label('CALIBRATION CERTIFICATE'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your equipment 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,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\GrMaster;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class GrMasterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = GrMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('item.code')
|
|
||||||
->label('ITEM'),
|
|
||||||
ExportColumn::make('serial_number')
|
|
||||||
->label('SERIAL NUMBER'),
|
|
||||||
ExportColumn::make('gr_number')
|
|
||||||
->label('GR NUMBER'),
|
|
||||||
ExportColumn::make('status')
|
|
||||||
->label('STATUS'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your gr 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,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\InvoiceDataValidation;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class InvoiceDataValidationExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = InvoiceDataValidation::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.code')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('distribution_channel_desc')
|
|
||||||
->label('DISTRIBUTION CHANNEL DESC'),
|
|
||||||
ExportColumn::make('customer_code')
|
|
||||||
->label('CUSTOMER CODE'),
|
|
||||||
ExportColumn::make('document_number')
|
|
||||||
->label('DOCUMENT NUMBER'),
|
|
||||||
ExportColumn::make('document_date')
|
|
||||||
->label('DOCUMENT DATE'),
|
|
||||||
ExportColumn::make('customer_trade_name')
|
|
||||||
->label('CUSTOMER TRADE NAME'),
|
|
||||||
ExportColumn::make('customer_location')
|
|
||||||
->label('CUSTOMER LOCATION'),
|
|
||||||
ExportColumn::make('location')
|
|
||||||
->label('LOCATION'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your invoice data validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\InvoiceOutValidation;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class InvoiceOutValidationExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = InvoiceOutValidation::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.code')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('qr_code')
|
|
||||||
->label('QR CODE'),
|
|
||||||
ExportColumn::make('scanned_at')
|
|
||||||
->label('SCANNED AT'),
|
|
||||||
ExportColumn::make('scanned_by')
|
|
||||||
->label('SCANNED BY'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your invoice out validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,48 +30,8 @@ class LineExporter extends Exporter
|
|||||||
->label('NAME'),
|
->label('NAME'),
|
||||||
ExportColumn::make('type')
|
ExportColumn::make('type')
|
||||||
->label('TYPE'),
|
->label('TYPE'),
|
||||||
ExportColumn::make('no_of_operation')
|
ExportColumn::make('group_work_center')
|
||||||
->label('NO OF OPERATION'),
|
->label('GROUP WORK CENTER'),
|
||||||
ExportColumn::make('workGroup1.name')
|
|
||||||
->label('WORK GROUP CENTER 1'),
|
|
||||||
ExportColumn::make('workGroup1.operation_number')
|
|
||||||
->label('OPERATION NUMBER 1'),
|
|
||||||
ExportColumn::make('workGroup2.name')
|
|
||||||
->label('WORK GROUP CENTER 2'),
|
|
||||||
ExportColumn::make('workGroup2.operation_number')
|
|
||||||
->label('OPERATION NUMBER 2'),
|
|
||||||
ExportColumn::make('workGroup3.name')
|
|
||||||
->label('WORK GROUP CENTER 3'),
|
|
||||||
ExportColumn::make('workGroup3.operation_number')
|
|
||||||
->label('OPERATION NUMBER 3'),
|
|
||||||
ExportColumn::make('workGroup4.name')
|
|
||||||
->label('WORK GROUP CENTER 4'),
|
|
||||||
ExportColumn::make('workGroup4.operation_number')
|
|
||||||
->label('OPERATION NUMBER 4'),
|
|
||||||
ExportColumn::make('workGroup5.name')
|
|
||||||
->label('WORK GROUP CENTER 5'),
|
|
||||||
ExportColumn::make('workGroup5.operation_number')
|
|
||||||
->label('OPERATION NUMBER 5'),
|
|
||||||
ExportColumn::make('workGroup6.name')
|
|
||||||
->label('WORK GROUP CENTER 6'),
|
|
||||||
ExportColumn::make('workGroup6.operation_number')
|
|
||||||
->label('OPERATION NUMBER 6'),
|
|
||||||
ExportColumn::make('workGroup7.name')
|
|
||||||
->label('WORK GROUP CENTER 7'),
|
|
||||||
ExportColumn::make('workGroup7.operation_number')
|
|
||||||
->label('OPERATION NUMBER 7'),
|
|
||||||
ExportColumn::make('workGroup8.name')
|
|
||||||
->label('WORK GROUP CENTER 8'),
|
|
||||||
ExportColumn::make('workGroup8.operation_number')
|
|
||||||
->label('OPERATION NUMBER 8'),
|
|
||||||
ExportColumn::make('workGroup9.name')
|
|
||||||
->label('WORK GROUP CENTER 9'),
|
|
||||||
ExportColumn::make('workGroup9.operation_number')
|
|
||||||
->label('OPERATION NUMBER 9'),
|
|
||||||
ExportColumn::make('workGroup10.name')
|
|
||||||
->label('WORK GROUP CENTER 10'),
|
|
||||||
ExportColumn::make('workGroup10.operation_number')
|
|
||||||
->label('OPERATION NUMBER 10'),
|
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
->label('CREATED AT'),
|
->label('CREATED AT'),
|
||||||
ExportColumn::make('updated_at')
|
ExportColumn::make('updated_at')
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ class MachineExporter extends Exporter
|
|||||||
->label('MACHINE'),
|
->label('MACHINE'),
|
||||||
ExportColumn::make('work_center')
|
ExportColumn::make('work_center')
|
||||||
->label('WORK CENTER'),
|
->label('WORK CENTER'),
|
||||||
ExportColumn::make('workGroupMaster.name')
|
|
||||||
->label('WORK GROUP CENTER'),
|
|
||||||
ExportColumn::make('created_at')
|
ExportColumn::make('created_at')
|
||||||
->label('CREATED AT'),
|
->label('CREATED AT'),
|
||||||
ExportColumn::make('updated_at')
|
ExportColumn::make('updated_at')
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\MfmMeter;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class MfmMeterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = MfmMeter::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('device.name')
|
|
||||||
->label('DEVICE NAME'),
|
|
||||||
ExportColumn::make('sequence')
|
|
||||||
->label('SEQUENCE'),
|
|
||||||
ExportColumn::make('name')
|
|
||||||
->label('NAME'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your mfm meter 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,40 +13,20 @@ class MfmParameterExporter extends Exporter
|
|||||||
|
|
||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
return [
|
||||||
ExportColumn::make('no')
|
ExportColumn::make('id')
|
||||||
->label('NO')
|
->label('ID'),
|
||||||
->state(function ($record) use (&$rowNumber) {
|
ExportColumn::make('plant.name'),
|
||||||
// Increment and return the row number
|
ExportColumn::make('name'),
|
||||||
return ++$rowNumber;
|
ExportColumn::make('register_id'),
|
||||||
}),
|
ExportColumn::make('identifier'),
|
||||||
ExportColumn::make('plant.name')
|
ExportColumn::make('byte_to_convert'),
|
||||||
->label('PLANT'),
|
ExportColumn::make('type_to_convert'),
|
||||||
ExportColumn::make('deviceName.name')
|
ExportColumn::make('decimal_to_display'),
|
||||||
->label('Device Name'),
|
ExportColumn::make('created_at'),
|
||||||
ExportColumn::make('name')
|
ExportColumn::make('updated_at'),
|
||||||
->label('NAME'),
|
ExportColumn::make('deleted_at'),
|
||||||
ExportColumn::make('mfmMeter.name')
|
ExportColumn::make('mfmMeter.name'),
|
||||||
->label('MFM METER'),
|
|
||||||
ExportColumn::make('register_id')
|
|
||||||
->label('REGISTER ID'),
|
|
||||||
ExportColumn::make('identifier')
|
|
||||||
->label('IDENTIFIER'),
|
|
||||||
ExportColumn::make('byte_to_convert')
|
|
||||||
->label('BYTE TO CONVERT'),
|
|
||||||
ExportColumn::make('type_to_convert')
|
|
||||||
->label('TYPE TO CONVERT'),
|
|
||||||
ExportColumn::make('decimal_to_display')
|
|
||||||
->label('DECIMAL TO DISPLAY'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,12 @@ class MotorTestingMasterExporter extends Exporter
|
|||||||
// Increment and return the row number
|
// Increment and return the row number
|
||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.code')
|
ExportColumn::make('plant.name')
|
||||||
->label('PLANT'),
|
->label('PLANT'),
|
||||||
ExportColumn::make('item.category')
|
ExportColumn::make('item.category')
|
||||||
->label('CATEGORY'),
|
->label('CATEGORY'),
|
||||||
ExportColumn::make('item.code')
|
ExportColumn::make('item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
ExportColumn::make('subassembly_code')
|
|
||||||
->label('SUBASSEMBLY CODE'),
|
|
||||||
ExportColumn::make('item.description')
|
ExportColumn::make('item.description')
|
||||||
->label('DESCRIPTION'),
|
->label('DESCRIPTION'),
|
||||||
ExportColumn::make('isi_model')
|
ExportColumn::make('isi_model')
|
||||||
@@ -71,9 +69,9 @@ class MotorTestingMasterExporter extends Exporter
|
|||||||
ExportColumn::make('res_br_ul')
|
ExportColumn::make('res_br_ul')
|
||||||
->label('RESISTANCE BR UL'),
|
->label('RESISTANCE BR UL'),
|
||||||
ExportColumn::make('lock_volt_limit')
|
ExportColumn::make('lock_volt_limit')
|
||||||
->label('LOCK VOLT LIMIT'),
|
->label('LOCK VOLT Limit'),
|
||||||
ExportColumn::make('leak_cur_limit')
|
ExportColumn::make('leak_cur_limit')
|
||||||
->label('LEAK CURRENT LIMIT'),
|
->label('Leak CURRENT Limit'),
|
||||||
ExportColumn::make('lock_cur_ll')
|
ExportColumn::make('lock_cur_ll')
|
||||||
->label('LOCK CURRENT LL'),
|
->label('LOCK CURRENT LL'),
|
||||||
ExportColumn::make('lock_cur_ul')
|
ExportColumn::make('lock_cur_ul')
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\ProcessOrder;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class ProcessOrderExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = ProcessOrder::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT NAME'),
|
|
||||||
ExportColumn::make('item.code')
|
|
||||||
->label('ITEM CODE'),
|
|
||||||
ExportColumn::make('process_order')
|
|
||||||
->label('PROCESS ORDER'),
|
|
||||||
ExportColumn::make('coil_number')
|
|
||||||
->label('COIL NUMBER'),
|
|
||||||
ExportColumn::make('order_quantity')
|
|
||||||
->label('ORDER QUANTITY'),
|
|
||||||
ExportColumn::make('received_quantity')
|
|
||||||
->label('RECEIVED QUANTITY'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your process order 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,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\SerialValidation;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class SerialValidationExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = SerialValidation::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('invoice_number')
|
|
||||||
->label('INVOICE NUMBER'),
|
|
||||||
ExportColumn::make('serial_number')
|
|
||||||
->label('SERIAL NUMBER'),
|
|
||||||
ExportColumn::make('stickerMaster.item.code')
|
|
||||||
->label('ITEM CODE'),
|
|
||||||
ExportColumn::make('motor_scanned_status')
|
|
||||||
->label('MOTOR SCANNED STATUS'),
|
|
||||||
ExportColumn::make('pump_scanned_status')
|
|
||||||
->label('PUMP SCANNED STATUS'),
|
|
||||||
ExportColumn::make('scanned_status_set')
|
|
||||||
->label('PUMPSET SCANNED STATUS'),
|
|
||||||
ExportColumn::make('capacitor_scanned_status')
|
|
||||||
->label('CAPACITOR SCANNED STATUS'),
|
|
||||||
ExportColumn::make('scanned_status')
|
|
||||||
->label('SCANNED STATUS'),
|
|
||||||
ExportColumn::make('panel_box_supplier')
|
|
||||||
->label('PANEL BOX SUPPLIER'),
|
|
||||||
ExportColumn::make('panel_box_serial_number')
|
|
||||||
->label('PANEL BOX SERIAL NUMBER'),
|
|
||||||
ExportColumn::make('load_rate')
|
|
||||||
->label('LOAD RATE'),
|
|
||||||
ExportColumn::make('upload_status')
|
|
||||||
->label('UPLOAD STATUS'),
|
|
||||||
ExportColumn::make('batch_number')
|
|
||||||
->label('BATCH NUMBER'),
|
|
||||||
ExportColumn::make('quantity')
|
|
||||||
->label('QUANTITY'),
|
|
||||||
ExportColumn::make('operator_id')
|
|
||||||
->label('OPERATOR ID'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your serial validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@ class StickerMasterExporter extends Exporter
|
|||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.name')
|
ExportColumn::make('plant.name')
|
||||||
->label('PLANT NAME'),
|
->label('PLANT'),
|
||||||
ExportColumn::make('item.code')
|
ExportColumn::make('item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
ExportColumn::make('serial_number_motor')
|
ExportColumn::make('serial_number_motor')
|
||||||
|
|||||||
@@ -30,25 +30,23 @@ class TestingPanelReadingExporter extends Exporter
|
|||||||
->label('LINE'),
|
->label('LINE'),
|
||||||
ExportColumn::make('machine.name')
|
ExportColumn::make('machine.name')
|
||||||
->label('MACHINE'),
|
->label('MACHINE'),
|
||||||
ExportColumn::make('motorTestingMaster.item.code')
|
ExportColumn::make('item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
ExportColumn::make('motorTestingMaster.item.description')
|
ExportColumn::make('item.description')
|
||||||
->label('MODEL'),
|
->label('MODEL'),
|
||||||
ExportColumn::make('output')
|
ExportColumn::make('output')
|
||||||
->label('OUTPUT'),
|
->label('OUTPUT'),
|
||||||
ExportColumn::make('serial_number')
|
ExportColumn::make('serial_number')
|
||||||
->label('SERIAL NUMBER'),
|
->label('SERIAL NUMBER'),
|
||||||
ExportColumn::make('winded_serial_number')
|
ExportColumn::make('item.kw')
|
||||||
->label('WINDED SERIAL NUMBER'),
|
|
||||||
ExportColumn::make('motorTestingMaster.kw')
|
|
||||||
->label('KW'),
|
->label('KW'),
|
||||||
ExportColumn::make('motorTestingMaster.hp')
|
ExportColumn::make('item.hp')
|
||||||
->label('HP'),
|
->label('HP'),
|
||||||
ExportColumn::make('motorTestingMaster.phase')
|
ExportColumn::make('item.phase')
|
||||||
->label('PHASE'),
|
->label('PHASE'),
|
||||||
ExportColumn::make('motorTestingMaster.connection')
|
ExportColumn::make('item.connection')
|
||||||
->label('CONNECTION'),
|
->label('CONNECTION'),
|
||||||
ExportColumn::make('motorTestingMaster.isi_model')
|
ExportColumn::make('item.isi_model')
|
||||||
->label('ISI MODEL'),
|
->label('ISI MODEL'),
|
||||||
ExportColumn::make('before_fr_volt')
|
ExportColumn::make('before_fr_volt')
|
||||||
->label('BEFORE FR VOLT'),
|
->label('BEFORE FR VOLT'),
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class UserExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = User::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('name')
|
|
||||||
->label('NAME'),
|
|
||||||
ExportColumn::make('email')
|
|
||||||
->label('E-MAIL'),
|
|
||||||
ExportColumn::make('password')
|
|
||||||
->label('PASSWORD'),
|
|
||||||
ExportColumn::make('roles')
|
|
||||||
->label('ROLES')
|
|
||||||
->state(function ($record) {
|
|
||||||
// Assuming Spatie\Permission: roles() relationship
|
|
||||||
return $record->roles->pluck('name')->join(', ');
|
|
||||||
}),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->enabledByDefault(false)
|
|
||||||
->label('DELETED AT'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your user 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,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\WorkGroupMaster;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class WorkGroupMasterExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = WorkGroupMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('plant.name')
|
|
||||||
->label('PLANT'),
|
|
||||||
ExportColumn::make('name')
|
|
||||||
->label('NAME'),
|
|
||||||
ExportColumn::make('description')
|
|
||||||
->label('DESCRIPTION'),
|
|
||||||
ExportColumn::make('operation_number')
|
|
||||||
->label('OPERATION NUMBER'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your work group 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -41,15 +41,15 @@ class ConfigurationImporter extends Importer
|
|||||||
ImportColumn::make('line')
|
ImportColumn::make('line')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship(resolveUsing: 'name')
|
->relationship(resolveUsing: 'name')
|
||||||
->exampleHeader('Line')
|
->exampleHeader('Plant')
|
||||||
->example(['4 inch pump line'])
|
->example(['4 inch pump line'])
|
||||||
->label('Line')
|
->label('Line')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'name')
|
||||||
->exampleHeader('Plant')
|
->exampleHeader('Plant')
|
||||||
->example(['1000'])
|
->example(['Ransar Industries-I'])
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\DeviceMaster;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
|
|
||||||
class DeviceMasterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = DeviceMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Device Name')
|
|
||||||
->label('Device Name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('mac_address')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('MAC Address')
|
|
||||||
->example('00:1A:2B:3C:4D:5E')
|
|
||||||
->label('MAC Address')
|
|
||||||
->rules(['required', 'mac_address']),
|
|
||||||
ImportColumn::make('ip_address')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('IP Address')
|
|
||||||
->label('IP Address')
|
|
||||||
->rules(['required', 'ip']),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Created By')
|
|
||||||
->example('Admin')
|
|
||||||
->label('Created By')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?DeviceMaster
|
|
||||||
{
|
|
||||||
// return DeviceMaster::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new DeviceMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your device master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\EbReading;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
|
|
||||||
class EbReadingImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = EbReading::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('lcd_segment_check')
|
|
||||||
->label('LCD Segment Check')
|
|
||||||
->example('Ok')
|
|
||||||
->exampleHeader('LCD Segment Check'),
|
|
||||||
ImportColumn::make('meter_serial_no')
|
|
||||||
->label('Meter Serial No')
|
|
||||||
->example('572880')
|
|
||||||
->exampleHeader('Meter Serial No'),
|
|
||||||
ImportColumn::make('eb_date_time')
|
|
||||||
->label('EB Date Time')
|
|
||||||
->example('2025-08-05 08:32:58')
|
|
||||||
->exampleHeader('EB Date Time')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('ph_seq_of_volt')
|
|
||||||
->label('Phase Sequence of Volt')
|
|
||||||
->example('RYB')
|
|
||||||
->exampleHeader('Phase Sequence of Volt'),
|
|
||||||
ImportColumn::make('ph_assoc_conn_check')
|
|
||||||
->example('GOOD')
|
|
||||||
->exampleHeader('Phase Associated Connection Check')
|
|
||||||
->label('Phase Associated Connection Check'),
|
|
||||||
ImportColumn::make('instantaneous_ph_volt')
|
|
||||||
->exampleHeader('Instantaneous Phase Volt')
|
|
||||||
->example('64.35,64.91,64.93')
|
|
||||||
->label('Instantaneous Phase Volt'),
|
|
||||||
ImportColumn::make('instantaneous_curr')
|
|
||||||
->exampleHeader('Instantaneous Current')
|
|
||||||
->example('1.02,1.00,0.94')
|
|
||||||
->label('Instantaneous Current'),
|
|
||||||
ImportColumn::make('instantaneous_freq')
|
|
||||||
->exampleHeader('Instantaneous Frequency')
|
|
||||||
->example('50.07')
|
|
||||||
->label('Instantaneous Frequency'),
|
|
||||||
ImportColumn::make('instantaneous_kw_with_sign')
|
|
||||||
->exampleHeader('Instantaneous KW with Sign')
|
|
||||||
->example('0.176')
|
|
||||||
->label('Instantaneous KW with Sign'),
|
|
||||||
ImportColumn::make('instantaneous_kva')
|
|
||||||
->exampleHeader('Instantaneous KVA')
|
|
||||||
->example('0.176')
|
|
||||||
->label('Instantaneous KVA'),
|
|
||||||
ImportColumn::make('instantaneous_kv_ar')
|
|
||||||
->exampleHeader('Instantaneous KV AR')
|
|
||||||
->example('0.02')
|
|
||||||
->label('Instantaneous KV AR'),
|
|
||||||
ImportColumn::make('instantaneous_pf_with_sign')
|
|
||||||
->exampleHeader('Instantaneous PF with Sign')
|
|
||||||
->example('0.99')
|
|
||||||
->label('Instantaneous PF with Sign'),
|
|
||||||
ImportColumn::make('rd_with_elapsed_time_kva')
|
|
||||||
->exampleHeader('RD with Elapsed Time KVA')
|
|
||||||
->example('0.047')
|
|
||||||
->label('RD with Elapsed Time KVA'),
|
|
||||||
ImportColumn::make('cum_active_import_energy')
|
|
||||||
->exampleHeader('Cumulative Active Import Energy')
|
|
||||||
->example('13246.46')
|
|
||||||
->label('Cumulative Active Import Energy'),
|
|
||||||
ImportColumn::make('tod1_active_energy_6_9')
|
|
||||||
->exampleHeader('TOD1 Active Energy 6-9')
|
|
||||||
->example('1367.75')
|
|
||||||
->label('TOD1 Active Energy 6-9'),
|
|
||||||
ImportColumn::make('tod2_active_energy_18_21')
|
|
||||||
->exampleHeader('TOD2 Active Energy 18-21')
|
|
||||||
->example('1759.08')
|
|
||||||
->label('TOD2 Active Energy 18-21'),
|
|
||||||
ImportColumn::make('tod3_active_energy_21_22')
|
|
||||||
->exampleHeader('TOD3 Active Energy 21-22')
|
|
||||||
->example('457.67')
|
|
||||||
->label('TOD3 Active Energy 21-22'),
|
|
||||||
ImportColumn::make('tod4_active_energy_5_6_9_18')
|
|
||||||
->exampleHeader('TOD4 Active Energy 5-6-9-18')
|
|
||||||
->example('6253.85')
|
|
||||||
->label('TOD4 Active Energy 5-6-9-18'),
|
|
||||||
ImportColumn::make('tod5_active_energy_22_5')
|
|
||||||
->exampleHeader('TOD5 Active Energy 22-5')
|
|
||||||
->example('3408.11')
|
|
||||||
->label('TOD5 Active Energy 22-5'),
|
|
||||||
ImportColumn::make('cum_reac_lag_energy')
|
|
||||||
->exampleHeader('Cumulative Reactive Lag Energy')
|
|
||||||
->example('685.11')
|
|
||||||
->label('Cumulative Reactive Lag Energy'),
|
|
||||||
ImportColumn::make('cum_reac_lead_energy')
|
|
||||||
->exampleHeader('Cumulative Reactive Lead Energy')
|
|
||||||
->example('426.1')
|
|
||||||
->label('Cumulative Reactive Lead Energy'),
|
|
||||||
ImportColumn::make('cum_appar_energy')
|
|
||||||
->exampleHeader('Cumulative Apparent Energy')
|
|
||||||
->example('13306.57')
|
|
||||||
->label('Cumulative Apparent Energy'),
|
|
||||||
ImportColumn::make('tod1_appar_energy_6_9')
|
|
||||||
->exampleHeader('TOD1 Apparent Energy 6-9')
|
|
||||||
->example('1374.63')
|
|
||||||
->label('TOD1 Apparent Energy 6-9'),
|
|
||||||
ImportColumn::make('tod2_appar_energy_18_21')
|
|
||||||
->exampleHeader('TOD2 Apparent Energy 18-21')
|
|
||||||
->example('1766.61')
|
|
||||||
->label('TOD2 Apparent Energy 18-21'),
|
|
||||||
ImportColumn::make('tod3_appar_energy_21_22')
|
|
||||||
->exampleHeader('TOD3 Apparent Energy 21-22')
|
|
||||||
->example('459.47')
|
|
||||||
->label('TOD3 Apparent Energy 21-22'),
|
|
||||||
ImportColumn::make('tod4_appar_energy_5_6_9_18')
|
|
||||||
->exampleHeader('TOD4 Apparent Energy 5-6-9-18')
|
|
||||||
->example('6283.28')
|
|
||||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
|
||||||
ImportColumn::make('tod5_appar_energy_22_5')
|
|
||||||
->exampleHeader('TOD5 Apparent Energy 22-5')
|
|
||||||
->example('3422.56')
|
|
||||||
->label('TOD5 Apparent Energy 22-5'),
|
|
||||||
ImportColumn::make('avg_pow_factor')
|
|
||||||
->exampleHeader('Average Power Factor')
|
|
||||||
->example('0.98')
|
|
||||||
->label('Average Power Factor'),
|
|
||||||
ImportColumn::make('avg_freq_15min_last_ip')
|
|
||||||
->exampleHeader('Average Frequency 15min Last IP')
|
|
||||||
->example('50')
|
|
||||||
->label('Average Frequency 15min Last IP'),
|
|
||||||
ImportColumn::make('net_kv_arh_high')
|
|
||||||
->exampleHeader('Net KV ARH High')
|
|
||||||
->example('2.99')
|
|
||||||
->label('Net KV ARH High'),
|
|
||||||
ImportColumn::make('net_kv_arh_low')
|
|
||||||
->exampleHeader('Net KV ARH Low')
|
|
||||||
->example('143.14')
|
|
||||||
->label('Net KV ARH Low'),
|
|
||||||
ImportColumn::make('cum_md_kva')
|
|
||||||
->exampleHeader('Cumulative MD KVA')
|
|
||||||
->example('43.816')
|
|
||||||
->label('Cumulative MD KVA'),
|
|
||||||
ImportColumn::make('present_md_kva')
|
|
||||||
->exampleHeader('Present MD KVA')
|
|
||||||
->example('0.379')
|
|
||||||
->label('Present MD KVA'),
|
|
||||||
ImportColumn::make('present_md_kva_date_time')
|
|
||||||
->label('Present MD KVA Date Time')
|
|
||||||
->exampleHeader('Present MD KVA Date Time')
|
|
||||||
->example('2025-08-05 08:32:58')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('tod1_md_kva_6_9')
|
|
||||||
->exampleHeader('TOD1 MD KVA 6-9')
|
|
||||||
->example('0.282')
|
|
||||||
->label('TOD1 MD KVA 6-9'),
|
|
||||||
ImportColumn::make('tod2_md_kva_18_21')
|
|
||||||
->exampleHeader('TOD2 MD KVA 18-21')
|
|
||||||
->example('0.268')
|
|
||||||
->label('TOD2 MD KVA 18-21'),
|
|
||||||
ImportColumn::make('tod3_md_kva_21_22')
|
|
||||||
->exampleHeader('TOD3 MD KVA 21-22')
|
|
||||||
->example('0')
|
|
||||||
->label('TOD3 MD KVA 21-22'),
|
|
||||||
ImportColumn::make('tod4_md_kva_5_6_9_18')
|
|
||||||
->exampleHeader('TOD4 MD KVA 5-6-9-18')
|
|
||||||
->example('0.379')
|
|
||||||
->label('TOD4 MD KVA 5-6-9-18'),
|
|
||||||
ImportColumn::make('tod5_md_kva_22_5')
|
|
||||||
->exampleHeader('TOD5 MD KVA 22-5')
|
|
||||||
->example('0.379')
|
|
||||||
->label('TOD5 MD KVA 22-5'),
|
|
||||||
ImportColumn::make('total_pow_off_hours')
|
|
||||||
->exampleHeader('Total Power Off Hours')
|
|
||||||
->example('6480.56')
|
|
||||||
->label('Total Power Off Hours'),
|
|
||||||
ImportColumn::make('programming_count')
|
|
||||||
->exampleHeader('Programming Count')
|
|
||||||
->example('3')
|
|
||||||
->label('Programming Count'),
|
|
||||||
ImportColumn::make('last_occ_res_event_type')
|
|
||||||
->exampleHeader('Last Occurrence/Reset Event Type')
|
|
||||||
->example('-')
|
|
||||||
->label('Last Occurrence/Reset Event Type'),
|
|
||||||
ImportColumn::make('last_occ_res_event_date_time')
|
|
||||||
->label('Last Occurrence/Reset Event Date Time')
|
|
||||||
->example('2025-08-05 08:32:58')
|
|
||||||
->exampleHeader('Last Occurrence/Reset Event Date Time')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('tamper_count')
|
|
||||||
->exampleHeader('Tamper Count')
|
|
||||||
->example('24')
|
|
||||||
->label('Tamper Count'),
|
|
||||||
ImportColumn::make('reset_count')
|
|
||||||
->exampleHeader('Reset Count')
|
|
||||||
->example('108')
|
|
||||||
->label('Reset Count'),
|
|
||||||
ImportColumn::make('last_md_reset_date_time')
|
|
||||||
->exampleHeader('Last MD Reset Date Time')
|
|
||||||
->example('2025-08-05 08:32:58')
|
|
||||||
->label('Last MD Reset Date Time')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('electrician_sign')
|
|
||||||
->exampleHeader('Electrician Sign')
|
|
||||||
->example('Admin')
|
|
||||||
->label('Electrician Sign'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?EbReading
|
|
||||||
{
|
|
||||||
// return EbReading::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new EbReading();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your eb reading 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,109 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\EquipmentMaster;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
|
|
||||||
class EquipmentMasterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = EquipmentMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('machine')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Machine Name')
|
|
||||||
->example('1006378')
|
|
||||||
->label('Machine Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->label('Name')
|
|
||||||
->exampleHeader('Name')
|
|
||||||
->example('463605 E-E-078'),
|
|
||||||
ImportColumn::make('description')
|
|
||||||
->label('Description')
|
|
||||||
->exampleHeader('Description')
|
|
||||||
->example('FIN.6INCH.HOUSING LOWER 150R3+ CI RUN-OUT CHECKING FIXTURE'),
|
|
||||||
ImportColumn::make('make')
|
|
||||||
->label('Make')
|
|
||||||
->exampleHeader('Make')
|
|
||||||
->example('Ok'),
|
|
||||||
ImportColumn::make('model')
|
|
||||||
->label('Model')
|
|
||||||
->exampleHeader('Model')
|
|
||||||
->example('Ok'),
|
|
||||||
ImportColumn::make('equipment_number')
|
|
||||||
->label('Equipment Number')
|
|
||||||
->exampleHeader('Equipment Number')
|
|
||||||
->example('463605 E-E-078'),
|
|
||||||
ImportColumn::make('instrument_serial_number')
|
|
||||||
->label('Instrument Serial Number')
|
|
||||||
->exampleHeader('Instrument Serial Number')
|
|
||||||
->example('131548498'),
|
|
||||||
ImportColumn::make('calibrated_on')
|
|
||||||
->label('Calibrated On')
|
|
||||||
->exampleHeader('Calibrated On')
|
|
||||||
->example('01-09-2025 08:00:00')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('frequency')
|
|
||||||
->label('Frequency')
|
|
||||||
->exampleHeader('Frequency')
|
|
||||||
->example('15')
|
|
||||||
->requiredMapping()
|
|
||||||
->numeric()
|
|
||||||
->rules(['required', 'integer']),
|
|
||||||
ImportColumn::make('next_calibration_date')
|
|
||||||
->label('Next Calibration Date')
|
|
||||||
->exampleHeader('Next Calibration Date')
|
|
||||||
->requiredMapping()
|
|
||||||
->example('16-09-2025 08:00:00')
|
|
||||||
->rules(['required', 'datetime']),
|
|
||||||
ImportColumn::make('calibrated_by')
|
|
||||||
->label('Calibration By')
|
|
||||||
->example('Sri Venkateswara Tools')
|
|
||||||
->exampleHeader('Calibration By'),
|
|
||||||
ImportColumn::make('calibration_certificate')
|
|
||||||
->label('Calibration Certificate')
|
|
||||||
->example('1231CRI651')
|
|
||||||
->exampleHeader('Calibration Certificate'),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->example('RAS00296')
|
|
||||||
->exampleHeader('Created By'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?EquipmentMaster
|
|
||||||
{
|
|
||||||
// return EquipmentMaster::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new EquipmentMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your equipment master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\GrMaster;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\Item;
|
|
||||||
use Str;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class GrMasterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = GrMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('item')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Item Code')
|
|
||||||
->example('630214')
|
|
||||||
->label('Item Code')
|
|
||||||
->relationship(resolveUsing:'code')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('serial_number')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Serial Number')
|
|
||||||
->example('11023567567567')
|
|
||||||
->label('Serial Number')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('gr_number')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('GR Number')
|
|
||||||
->example('67345237')
|
|
||||||
->label('GR Number')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Created By')
|
|
||||||
->example('Admin')
|
|
||||||
->label('Created By')
|
|
||||||
->rules(['required']),
|
|
||||||
//ImportColumn::make('updated_by'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?GrMaster
|
|
||||||
{
|
|
||||||
// return GrMaster::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
$warnMsg = [];
|
|
||||||
|
|
||||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
|
||||||
|
|
||||||
if (!$plant) {
|
|
||||||
$warnMsg[] = "Plant not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
$item = null;
|
|
||||||
if ($plant) {
|
|
||||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
|
||||||
}
|
|
||||||
if (!$item) {
|
|
||||||
$warnMsg[] = "Item not found";
|
|
||||||
}
|
|
||||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
|
||||||
$warnMsg[] = "Invalid serial number found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($this->data['gr_number'])) {
|
|
||||||
$warnMsg[] = "GR Number cannot be empty.";
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = User::where('name', $this->data['created_by'])->first();
|
|
||||||
if (!$user) {
|
|
||||||
$warnMsg[] = "User not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
else { //if (empty($warnMsg))
|
|
||||||
$grMaster = GrMaster::where('plant_id', $plant->id)
|
|
||||||
->where('serial_number', $this->data['serial_number'])
|
|
||||||
->latest()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($grMaster) {
|
|
||||||
throw new RowImportFailedException("Serial number already exist!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GrMaster::updateOrCreate([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'item_id' => $item->id,
|
|
||||||
'serial_number' => $this->data['serial_number'],
|
|
||||||
'gr_number' => $this->data['gr_number'] ?? null,
|
|
||||||
'created_by' => $this->data['created_by'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
//return new GrMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your gr master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ namespace App\Filament\Imports;
|
|||||||
|
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
@@ -30,61 +29,11 @@ class LineImporter extends Importer
|
|||||||
->example('Domestic Assembly')
|
->example('Domestic Assembly')
|
||||||
->label('Line Type')
|
->label('Line Type')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('no_of_operation')
|
ImportColumn::make('group_work_center')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('No of Operation')
|
->exampleHeader('Group Work Center')
|
||||||
->example('10')
|
->example('RMGCEABC')
|
||||||
->label('No of Operation'),
|
->label('Group Work Center'),
|
||||||
ImportColumn::make('work_group1_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 1')
|
|
||||||
->example('RMGCGABC')
|
|
||||||
->label('Work Group Center 1'),
|
|
||||||
ImportColumn::make('work_group2_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 2')
|
|
||||||
->example('RMGCGABC1')
|
|
||||||
->label('Work Group Center 2'),
|
|
||||||
ImportColumn::make('work_group3_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 3')
|
|
||||||
->example('RMGCGABC2')
|
|
||||||
->label('Work Group Center 3'),
|
|
||||||
ImportColumn::make('work_group4_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 4')
|
|
||||||
->example('RMGCGABC1')
|
|
||||||
->label('Work Group Center 4'),
|
|
||||||
ImportColumn::make('work_group5_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 5')
|
|
||||||
->example('RMGCGABC5')
|
|
||||||
->label('Work Group Center 5'),
|
|
||||||
ImportColumn::make('work_group6_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 6')
|
|
||||||
->example('RMGCGABC6')
|
|
||||||
->label('Work Group Center 6'),
|
|
||||||
ImportColumn::make('work_group7_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 7')
|
|
||||||
->example('RMGCGABC7')
|
|
||||||
->label('Work Group Center 7'),
|
|
||||||
ImportColumn::make('work_group8_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 8')
|
|
||||||
->example('RMGCGABC8')
|
|
||||||
->label('Work Group Center 8'),
|
|
||||||
ImportColumn::make('work_group9_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 9')
|
|
||||||
->example('RMGCGABC9')
|
|
||||||
->label('Work Group Center 9'),
|
|
||||||
ImportColumn::make('work_group10_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Work Group Center 10')
|
|
||||||
->example('RMGCGABC10')
|
|
||||||
->label('Work Group Center 10'),
|
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
@@ -98,110 +47,34 @@ class LineImporter extends Importer
|
|||||||
public function resolveRecord(): ?Line
|
public function resolveRecord(): ?Line
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
|
|
||||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||||
if (!$plant) {
|
if (!$plant) {
|
||||||
throw new RowImportFailedException("Plant '{$this->data['plant']}' not found");
|
$warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
|
||||||
}
|
}
|
||||||
|
if (Str::length($this->data['name']) < 0) {
|
||||||
if (Str::length($this->data['name'] ?? '') <= 0) {
|
$warnMsg[] = "Line name not found";
|
||||||
throw new RowImportFailedException("Line name not found");
|
|
||||||
}
|
}
|
||||||
|
if (Str::length($this->data['type']) < 0) {
|
||||||
if (Str::length($this->data['type'] ?? '') <= 0) {
|
$warnMsg[] = "Line type not found";
|
||||||
throw new RowImportFailedException("Line type not found");
|
|
||||||
}
|
}
|
||||||
|
if (!empty($warnMsg)) {
|
||||||
$noOfOps = (int) ($this->data['no_of_operation'] ?? 0);
|
|
||||||
|
|
||||||
if (($noOfOps == null || $noOfOps == '' || !is_numeric($noOfOps)) && $noOfOps != 0) {
|
|
||||||
throw new RowImportFailedException("'No of Operation' is required and must be a number $noOfOps");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($noOfOps > 10)
|
|
||||||
{
|
|
||||||
throw new RowImportFailedException("Invalid 'No Of Operation' value: {$noOfOps}, maximum allowed is 10");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate required work groups
|
|
||||||
$missingGroups = [];
|
|
||||||
for ($i = 1; $i <= $noOfOps; $i++) {
|
|
||||||
if (empty($this->data["work_group{$i}_id"])) {
|
|
||||||
$missingGroups[] = "work_group{$i}_id";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($missingGroups)) {
|
|
||||||
throw new RowImportFailedException(
|
|
||||||
"Invalid data: Required work groups missing values in: " . implode(', ', $missingGroups)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure no extra work groups are filled
|
|
||||||
$invalidGroups = [];
|
|
||||||
for ($i = $noOfOps + 1; $i <= 10; $i++) {
|
|
||||||
if (!empty($this->data["work_group{$i}_id"])) {
|
|
||||||
$invalidGroups[] = "work_group{$i}_id";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($invalidGroups)) {
|
|
||||||
throw new RowImportFailedException(
|
|
||||||
"Invalid data: Only first {$noOfOps} work groups should be filled, but values found in: " . implode(', ', $invalidGroups)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 1; $i <= 10; $i++) {
|
|
||||||
$workGroupName = $this->data["work_group{$i}_id"] ?? null;
|
|
||||||
if (!$workGroupName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$workGroupRecord = WorkGroupMaster::where('name', $workGroupName)
|
|
||||||
->where('plant_id', $plant->id)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (!$workGroupRecord) {
|
|
||||||
throw new RowImportFailedException("Work group '{$workGroupName}' not found in plant '{$this->data['plant']}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
$existsInLines = Line::where('plant_id', $plant->id)
|
|
||||||
->where('name', '!=', $this->data['name'])
|
|
||||||
->where("work_group{$i}_id", $workGroupRecord->id)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($existsInLines) {
|
|
||||||
$warnMsg[] = "Work group '{$workGroupName}' is already assigned to another line in plant '{$this->data['plant']}'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data["work_group{$i}_id"] = $workGroupRecord->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg))
|
|
||||||
{
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
}
|
}
|
||||||
|
return Line::updateOrCreate([
|
||||||
Line::updateOrCreate(
|
|
||||||
[
|
|
||||||
'name' => $this->data['name'],
|
'name' => $this->data['name'],
|
||||||
'plant_id' => $plant->id
|
'plant_id' => $plant->id
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'type' => $this->data['type'],
|
'type' => $this->data['type'],
|
||||||
'no_of_operation' => $noOfOps,
|
'group_work_center' => $this->data['group_work_center']
|
||||||
'work_group1_id' => $this->data['work_group1_id'] ?? null,
|
|
||||||
'work_group2_id' => $this->data['work_group2_id'] ?? null,
|
|
||||||
'work_group3_id' => $this->data['work_group3_id'] ?? null,
|
|
||||||
'work_group4_id' => $this->data['work_group4_id'] ?? null,
|
|
||||||
'work_group5_id' => $this->data['work_group5_id'] ?? null,
|
|
||||||
'work_group6_id' => $this->data['work_group6_id'] ?? null,
|
|
||||||
'work_group7_id' => $this->data['work_group7_id'] ?? null,
|
|
||||||
'work_group8_id' => $this->data['work_group8_id'] ?? null,
|
|
||||||
'work_group9_id' => $this->data['work_group9_id'] ?? null,
|
|
||||||
'work_group10_id' => $this->data['work_group10_id'] ?? null,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
// return Line::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
return null;
|
// return new Line();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class LineStopImporter extends Importer
|
|||||||
public function resolveRecord(): ?LineStop
|
public function resolveRecord(): ?LineStop
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
if (Str::length($this->data['code']) < 3 || !ctype_alnum($this->data['code'])) {
|
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||||
$warnMsg[] = "Invalid line stop code found";
|
$warnMsg[] = "Invalid line stop code found";
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['reason']) < 5) {
|
if (Str::length($this->data['reason']) < 5) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Imports;
|
|||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
@@ -29,15 +28,7 @@ class MachineImporter extends Importer
|
|||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Work Center')
|
->exampleHeader('Work Center')
|
||||||
->example('RMGCE001')
|
->example('RMGCE001')
|
||||||
->label('Work Center')
|
->label('Work Center'),
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('workGroupMaster')
|
|
||||||
->requiredMapping()
|
|
||||||
->relationship(resolveUsing: 'name')
|
|
||||||
->exampleHeader('Work Group Center')
|
|
||||||
->example(['RMGCGABC'])
|
|
||||||
->label('Work Group Center')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('line')
|
ImportColumn::make('line')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship(resolveUsing: 'name')
|
->relationship(resolveUsing: 'name')
|
||||||
@@ -62,53 +53,26 @@ class MachineImporter extends Importer
|
|||||||
$line = null;
|
$line = null;
|
||||||
$machine = $this->data['name'];
|
$machine = $this->data['name'];
|
||||||
$workCenter = $this->data['work_center'];
|
$workCenter = $this->data['work_center'];
|
||||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->first();
|
|
||||||
if (!$plant) {
|
if (!$plant) {
|
||||||
$warnMsg[] = "Plant not found!";
|
$warnMsg[] = "Plant not found";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->where('plant_id', $plant->id)->first();
|
|
||||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||||
if ($line) {
|
if ($line) {
|
||||||
$grpWrkCnr = $line->no_of_operation;
|
$grpWrkCnr = $line->group_work_center;
|
||||||
if (!$grpWrkCnr || $grpWrkCnr < 1)//Str::length($grpWrkCnr) < 1)
|
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||||
{
|
{
|
||||||
$warnMsg[] = "Group work center line not found!";
|
$warnMsg[] = "Group work center line not found";
|
||||||
}
|
|
||||||
else if (!$groupWorkCenter) {
|
|
||||||
$warnMsg[] = "Group work center not found!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$dupMachine = Machine::where('plant_id', $plant->id)->where('work_center', '!=', $workCenter)->where('name', $machine)->first();
|
|
||||||
if ($dupMachine) {
|
|
||||||
$warnMsg[] = "Duplicate machine name found!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$isValidGroupWork = false;
|
|
||||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
|
||||||
$column = "work_group{$i}_id";
|
|
||||||
if (!empty($line->$column)) {
|
|
||||||
if ($line->$column == $groupWorkCenter->id) {
|
|
||||||
$isValidGroupWork = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$isValidGroupWork) {
|
|
||||||
$warnMsg[] = "Group work center does not match with line!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$warnMsg[] = "Line not found!";
|
$warnMsg[] = "Line not found";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::length($machine) <= 0) {
|
if (Str::length($machine) <= 0) {
|
||||||
$warnMsg[] = "Machine name not found!";
|
$warnMsg[] = "Machine name not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
if (!empty($warnMsg)) {
|
||||||
@@ -117,13 +81,12 @@ class MachineImporter extends Importer
|
|||||||
|
|
||||||
Machine::updateOrCreate(
|
Machine::updateOrCreate(
|
||||||
[
|
[
|
||||||
|
'name' => $machine,
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'work_center' => $workCenter
|
'line_id' => $line->id
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'line_id' => $line->id,
|
'work_center' => $workCenter
|
||||||
'name' => $machine,
|
|
||||||
'work_group_master_id' => $groupWorkCenter->id
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\MfmMeter;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
|
|
||||||
class MfmMeterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = MfmMeter::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('Device Name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Device Name')
|
|
||||||
->example('REG001')
|
|
||||||
->label('Device Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('sequence')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Sequence')
|
|
||||||
->example('1')
|
|
||||||
->label('Sequence')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Meter Name')
|
|
||||||
->example('Display SSB')
|
|
||||||
->label('Meter Name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Created By')
|
|
||||||
->example('Admin')
|
|
||||||
->label('Created By')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?MfmMeter
|
|
||||||
{
|
|
||||||
// return MfmMeter::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
return new MfmMeter();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your mfm meter 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,13 +21,6 @@ class MfmParameterImporter extends Importer
|
|||||||
->label('Plant Name')
|
->label('Plant Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing:'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('deviceName')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Device Name')
|
|
||||||
->example('REG001')
|
|
||||||
->label('Device Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('mfmMeter')
|
ImportColumn::make('mfmMeter')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Mfm Meter Sequence')
|
->exampleHeader('Mfm Meter Sequence')
|
||||||
|
|||||||
@@ -2,17 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Imports;
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
use App\Models\Item;
|
|
||||||
use App\Models\MotorTestingMaster;
|
use App\Models\MotorTestingMaster;
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\User;
|
|
||||||
use DateTime;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Str;
|
|
||||||
|
|
||||||
class MotorTestingMasterImporter extends Importer
|
class MotorTestingMasterImporter extends Importer
|
||||||
{
|
{
|
||||||
@@ -28,14 +22,7 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('subassembly_code')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('SubAssembly Code')
|
|
||||||
->example(['123456'])
|
|
||||||
->label('SubAssembly Code')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('isi_model')
|
ImportColumn::make('isi_model')
|
||||||
->requiredMapping()
|
|
||||||
->boolean()
|
->boolean()
|
||||||
->exampleHeader('ISI Model')
|
->exampleHeader('ISI Model')
|
||||||
->example(['Y','N','Y'])
|
->example(['Y','N','Y'])
|
||||||
@@ -157,8 +144,8 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('leak_cur_limit')
|
ImportColumn::make('leak_cur_limit')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Leak Current Limit')
|
->exampleHeader('Leakage Current Limit')
|
||||||
->label('Leak Current Limit')
|
->label('Leakage Current Limit')
|
||||||
->example(['50','50','50'])
|
->example(['50','50','50'])
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('lock_cur_ll')
|
ImportColumn::make('lock_cur_ll')
|
||||||
@@ -212,9 +199,9 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant')
|
->exampleHeader('Plant')
|
||||||
->example(['1000','1010','1020'])
|
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('created_by')
|
ImportColumn::make('created_by')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -233,245 +220,12 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
|
|
||||||
public function resolveRecord(): ?MotorTestingMaster
|
public function resolveRecord(): ?MotorTestingMaster
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
// return MotorTestingMaster::firstOrNew([
|
||||||
$plantCod = trim($this->data['plant']);
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
$iCode = trim($this->data['item']);
|
// 'email' => $this->data['email'],
|
||||||
$sCode = trim($this->data['subassembly_code']);
|
// ]);
|
||||||
$isiModel = (trim($this->data['isi_model']) == "1") ? true : false;
|
|
||||||
$phase = trim($this->data['phase']);
|
|
||||||
$kw = trim($this->data['kw']);
|
|
||||||
$hp = trim($this->data['hp']);
|
|
||||||
$volt = trim($this->data['volt']);
|
|
||||||
$current = trim($this->data['current']);
|
|
||||||
$rpm = trim($this->data['rpm']);
|
|
||||||
$torque = trim($this->data['torque']);
|
|
||||||
$frequency = trim($this->data['frequency']);
|
|
||||||
$connection = trim($this->data['connection']);
|
|
||||||
$insResType = trim($this->data['ins_res_type']);
|
|
||||||
$insResLimit = trim($this->data['ins_res_limit']);
|
|
||||||
$routineTestTime = trim($this->data['routine_test_time']);
|
|
||||||
$resRyLl = trim($this->data['res_ry_ll']);
|
|
||||||
$resRyUl = trim($this->data['res_ry_ul']);
|
|
||||||
$resYbLl = trim($this->data['res_yb_ll']);
|
|
||||||
$resYbUl = trim($this->data['res_yb_ul']);
|
|
||||||
$resBrLl = trim($this->data['res_br_ll']);
|
|
||||||
$resBrUl = trim($this->data['res_br_ul']);
|
|
||||||
$lockVoltLimit = trim($this->data['lock_volt_limit']);
|
|
||||||
$leakCurLimit = trim($this->data['leak_cur_limit']);
|
|
||||||
$lockCurLl = trim($this->data['lock_cur_ll']);
|
|
||||||
$lockCurUl = trim($this->data['lock_cur_ul']);
|
|
||||||
$noloadCurLl = trim($this->data['noload_cur_ll']);
|
|
||||||
$noloadCurUl = trim($this->data['noload_cur_ul']);
|
|
||||||
$noloadPowLl = trim($this->data['noload_pow_ll']);
|
|
||||||
$noloadPowUl = trim($this->data['noload_pow_ul']);
|
|
||||||
$noloadSpdLl = trim($this->data['noload_spd_ll']);
|
|
||||||
$noloadSpdUl = trim($this->data['noload_spd_ul']);
|
|
||||||
$createdBy = trim($this->data['created_by']);
|
|
||||||
$updatedBy = trim($this->data['updated_by']);
|
|
||||||
|
|
||||||
$plant = null;
|
return new MotorTestingMaster();
|
||||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod))
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Invalid plant code found";
|
|
||||||
}
|
|
||||||
else if (Str::length($iCode) < 6 || !ctype_alnum($iCode))
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Invalid item code found";
|
|
||||||
}
|
|
||||||
else if (Str::length($sCode) < 6 || !ctype_alnum($sCode))
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Invalid sub-assembly code found";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$plant = Plant::where('code', $plantCod)->first();
|
|
||||||
$codeExist = Item::where('code', $iCode)->first();
|
|
||||||
if ($plant)
|
|
||||||
{
|
|
||||||
$iCode = Item::where('code', $iCode)->where('plant_id', $plant->id)->first();
|
|
||||||
}
|
|
||||||
if (!$plant)
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Plant not found";
|
|
||||||
}
|
|
||||||
else if (!$codeExist)
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Item code not found";
|
|
||||||
}
|
|
||||||
else if (!$iCode)
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Item code not found for choosed plant";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if (Str::length($isiModel) <= 0 || $isiModel == "0" || $isiModel == "1") {
|
|
||||||
// $warnMsg[] = "Invalid ISI Model found";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// $isiModel = ($isiModel == "1");
|
|
||||||
// }
|
|
||||||
if (Str::length($phase) <= 0 || ($phase != "Single" && $phase != "Three")) {//!is_string($phase) ||
|
|
||||||
$warnMsg[] = "Invalid phase found";
|
|
||||||
}
|
|
||||||
if (Str::length($hp) <= 0 || !is_numeric($hp)) {
|
|
||||||
$warnMsg[] = "Invalid HP found";
|
|
||||||
}
|
|
||||||
if (Str::length($kw) <= 0 || !is_numeric($kw)) {
|
|
||||||
$warnMsg[] = "Invalid KW found";
|
|
||||||
}
|
|
||||||
if (Str::length($volt) <= 0 || !is_numeric($volt)) {
|
|
||||||
$warnMsg[] = "Invalid volt found";
|
|
||||||
}
|
|
||||||
if (Str::length($current) <= 0 || !is_numeric($current)) {
|
|
||||||
$warnMsg[] = "Invalid current found";
|
|
||||||
}
|
|
||||||
if (Str::length($rpm) <= 0 || !is_numeric($rpm)) {
|
|
||||||
$warnMsg[] = "Invalid RPM found";
|
|
||||||
}
|
|
||||||
if (Str::length($torque) <= 0 || !is_numeric($torque)) {
|
|
||||||
$warnMsg[] = "Invalid torque found";
|
|
||||||
}
|
|
||||||
if (Str::length($frequency) <= 0 || !is_numeric($frequency)) {
|
|
||||||
$warnMsg[] = "Invalid frequency found";
|
|
||||||
}
|
|
||||||
if (Str::length($connection) <= 0 || ($connection != "Star-Delta" && $connection != "Star" && $connection != "Delta")) {
|
|
||||||
$warnMsg[] = "Invalid connection found";
|
|
||||||
}
|
|
||||||
if (Str::length($insResLimit) <= 0 || !is_numeric($insResLimit)) {
|
|
||||||
$warnMsg[] = "Invalid insulation resistance limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($insResType) <= 0 || ($insResType != "O" && $insResType != "M" && $insResType != "G")) {
|
|
||||||
$warnMsg[] = "Invalid insulation resistance type found";
|
|
||||||
}
|
|
||||||
if (Str::length($routineTestTime) <= 0 || !isValidTimeFormat($routineTestTime)) {
|
|
||||||
$warnMsg[] = "Invalid routine test time found";
|
|
||||||
}
|
|
||||||
if (Str::length($resRyLl) <= 0 || !is_numeric($resRyLl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance RY lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($resRyUl) <= 0 || !is_numeric($resRyUl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance RY upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($resYbLl) <= 0 || !is_numeric($resYbLl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance YB lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($resYbUl) <= 0 || !is_numeric($resYbUl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance YB upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($resBrLl) <= 0 || !is_numeric($resBrLl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance BR lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($resBrUl) <= 0 || !is_numeric($resBrUl)) {
|
|
||||||
$warnMsg[] = "Invalid resistance BR upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($lockVoltLimit) <= 0 || !is_numeric($lockVoltLimit)) {
|
|
||||||
$warnMsg[] = "Invalid locked volt limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($leakCurLimit) <= 0 || !is_numeric($leakCurLimit)) {
|
|
||||||
$warnMsg[] = "Invalid leakage current limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($lockCurLl) <= 0 || !is_numeric($lockCurLl)) {
|
|
||||||
$warnMsg[] = "Invalid locked current lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($lockCurUl) <= 0 || !is_numeric($lockCurUl)) {
|
|
||||||
$warnMsg[] = "Invalid locked current upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadCurLl) <= 0 || !is_numeric($noloadCurLl)) {
|
|
||||||
$warnMsg[] = "Invalid no load current lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadCurUl) <= 0 || !is_numeric($noloadCurUl)) {
|
|
||||||
$warnMsg[] = "Invalid no load current upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadPowLl) <= 0 || !is_numeric($noloadPowLl)) {
|
|
||||||
$warnMsg[] = "Invalid no load power lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadPowUl) <= 0 || !is_numeric($noloadPowUl)) {
|
|
||||||
$warnMsg[] = "Invalid no load power upper limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadSpdLl) <= 0 || !is_numeric($noloadSpdLl)) {
|
|
||||||
$warnMsg[] = "Invalid no load speed lower limit found";
|
|
||||||
}
|
|
||||||
if (Str::length($noloadSpdUl) <= 0 || !is_numeric($noloadSpdUl)) {
|
|
||||||
$warnMsg[] = "Invalid no load speed upper limit found";
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldCode = MotorTestingMaster::where('item_id', $iCode->id)->where('plant_id', $plant->id)->first();
|
|
||||||
|
|
||||||
if ($oldCode) {
|
|
||||||
$created = $oldCode->created_by ? User::where('name', $oldCode->created_by)->first() : null;
|
|
||||||
if (!$created) {
|
|
||||||
$warnMsg[] = "Created by not found on update";
|
|
||||||
}
|
|
||||||
$updated = User::where('name', $updatedBy)->first();
|
|
||||||
if (!$updated) {
|
|
||||||
$warnMsg[] = "Updated by not found on update";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$created = User::where('name', $createdBy)->first();
|
|
||||||
if (!$created) {
|
|
||||||
$warnMsg[] = "Created by not found";
|
|
||||||
}
|
|
||||||
$updated = User::where('name', $updatedBy)->first();
|
|
||||||
if (!$updated) {
|
|
||||||
$warnMsg[] = "Updated by not found";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
MotorTestingMaster::updateOrCreate([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'item_id' => $iCode->id
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'subassembly_code' => $sCode,
|
|
||||||
'isi_model' => $isiModel,
|
|
||||||
'phase' => $phase,
|
|
||||||
'kw' => $kw,
|
|
||||||
'hp' => $hp,
|
|
||||||
'volt' => $volt,
|
|
||||||
'current' => $current,
|
|
||||||
'rpm' => $rpm,
|
|
||||||
'torque' => $torque,
|
|
||||||
'frequency' => $frequency,
|
|
||||||
'connection' => $connection,
|
|
||||||
'ins_res_limit' => $insResLimit,
|
|
||||||
'ins_res_type' => $insResType,
|
|
||||||
'routine_test_time' => $routineTestTime,
|
|
||||||
'res_ry_ll' => $resRyLl,
|
|
||||||
'res_ry_ul' => $resRyUl,
|
|
||||||
'res_yb_ll' => $resYbLl,
|
|
||||||
'res_yb_ul' => $resYbUl,
|
|
||||||
'res_br_ll' => $resBrLl,
|
|
||||||
'res_br_ul' => $resBrUl,
|
|
||||||
'lock_volt_limit' => $lockVoltLimit,
|
|
||||||
'leak_cur_limit' => $leakCurLimit,
|
|
||||||
'lock_cur_ll' => $lockCurLl,
|
|
||||||
'lock_cur_ul' => $lockCurUl,
|
|
||||||
'noload_cur_ll' => $noloadCurLl,
|
|
||||||
'noload_cur_ul' => $noloadCurUl,
|
|
||||||
'noload_pow_ll' => $noloadPowLl,
|
|
||||||
'noload_pow_ul' => $noloadPowUl,
|
|
||||||
'noload_spd_ll' => $noloadSpdLl,
|
|
||||||
'noload_spd_ul' => $noloadSpdUl,
|
|
||||||
'created_by' => $created->name,
|
|
||||||
'updated_by' => $updated->name,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
// // return MotorTestingMaster::firstOrNew([
|
|
||||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// // 'email' => $this->data['email'],
|
|
||||||
// // ]);
|
|
||||||
|
|
||||||
// return new MotorTestingMaster();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
@@ -485,13 +239,3 @@ class MotorTestingMasterImporter extends Importer
|
|||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidTimeFormat($time) {
|
|
||||||
// If time starts with a single digit hour without leading zero, pad it
|
|
||||||
if (preg_match('/^\d(:\d{2}:\d{2})$/', $time, $matches)) {
|
|
||||||
$time = '0' . $time;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dateTime = DateTime::createFromFormat('H:i:s', $time);
|
|
||||||
return $dateTime && $dateTime->format('H:i:s') === $time;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,21 +12,10 @@ use Filament\Actions\Imports\Importer;
|
|||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
|
|
||||||
class PalletValidationImporter extends Importer
|
class PalletValidationImporter extends Importer
|
||||||
{
|
{
|
||||||
protected static ?string $model = PalletValidation::class;
|
protected static ?string $model = PalletValidation::class;
|
||||||
|
|
||||||
// public static function canQueue(): bool
|
|
||||||
// {
|
|
||||||
// return true; // allows this importer to be queued
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public static function getChunkSize(): ?int
|
|
||||||
// {
|
|
||||||
// return 1000;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\Item;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\ProcessOrder;
|
|
||||||
use App\Models\User;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
use Str;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
|
|
||||||
class ProcessOrderImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = ProcessOrder::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('123456')
|
|
||||||
->label('Item Code')
|
|
||||||
->relationship(resolveUsing: 'code')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('process_order')
|
|
||||||
->exampleHeader('Process Order')
|
|
||||||
->example('200000166843')
|
|
||||||
->label('Process Order')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->exampleHeader('Created By')
|
|
||||||
->example('RAW01234')
|
|
||||||
->label('Created By'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?ProcessOrder
|
|
||||||
{
|
|
||||||
$warnMsg = [];
|
|
||||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
|
||||||
$itemCode = Item::where('code', $this->data['item'])->first();
|
|
||||||
$iCode = trim($this->data['item']);
|
|
||||||
|
|
||||||
if (!$plant) {
|
|
||||||
$warnMsg[] = "Plant not found";
|
|
||||||
}
|
|
||||||
else if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
|
||||||
$warnMsg[] = "Invalid item code found";
|
|
||||||
}
|
|
||||||
else if(!$itemCode)
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Item Code not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
$processOrder = trim($this->data['process_order'] ?? '');
|
|
||||||
|
|
||||||
if ($processOrder == '') {
|
|
||||||
$warnMsg[] = "Process Order cannot be empty";
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = User::where('name', $this->data['created_by'])->first();
|
|
||||||
if (!$user) {
|
|
||||||
$warnMsg[] = "User not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($plant && $processOrder != '') {
|
|
||||||
|
|
||||||
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
|
|
||||||
->where('process_order', $processOrder)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
|
|
||||||
$warnMsg[] = "Same Process Order already exists for this Plant with a different Item Code";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ProcessOrder::create([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'item_id' => $itemCode->id,
|
|
||||||
'process_order' => trim($this->data['process_order']),
|
|
||||||
'coil_number' => "0",
|
|
||||||
'order_quantity' => 0,
|
|
||||||
'received_quantity' => 0,
|
|
||||||
'created_by' => $user->name,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//return new ProcessOrder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your process order 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -59,9 +59,9 @@ class ProductionQuantityImporter extends Importer
|
|||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('block_reference')
|
ImportColumn::make('block_reference')
|
||||||
->requiredMapping() // Or optionalMapping() if not always present
|
->requiredMapping() // Or optionalMapping() if not always present
|
||||||
->exampleHeader('Block')
|
->exampleHeader('Block Name')
|
||||||
->example(['Block A', 'Block A'])
|
->example(['Block A', 'Block A'])
|
||||||
->label('Block')
|
->label('Block Name')
|
||||||
->rules(['required']), // Or remove if not required
|
->rules(['required']), // Or remove if not required
|
||||||
ImportColumn::make('shift')
|
ImportColumn::make('shift')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -130,7 +130,7 @@ class ProductionQuantityImporter extends Importer
|
|||||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
||||||
$warnMsg[] = "Invalid serial number found";
|
$warnMsg[] = "Invalid serial number found";
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14 || !is_numeric($this->data['production_order']))) {
|
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || !is_numeric($this->data['production_order']))) {
|
||||||
$warnMsg[] = "Invalid production order found";
|
$warnMsg[] = "Invalid production order found";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class QualityValidationImporter extends Importer
|
|||||||
$warnMsg[] = "Sticker item code not found";
|
$warnMsg[] = "Sticker item code not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
|
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7) {
|
||||||
$warnMsg[] = "Invalid production order found";
|
$warnMsg[] = "Invalid production order found";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,13 +281,11 @@ class QualityValidationImporter extends Importer
|
|||||||
|
|
||||||
QualityValidation::updateOrCreate([
|
QualityValidation::updateOrCreate([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'sticker_master_id' => $stickMaster,//->id
|
|
||||||
'serial_number' => $this->data['serial_number']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'line_id' => $line->id,
|
'line_id' => $line->id,
|
||||||
|
'sticker_master_id' => $stickMaster,//->id
|
||||||
'uom' => $this->data['uom'],
|
'uom' => $this->data['uom'],
|
||||||
'production_order' => $this->data['production_order'],
|
'production_order' => $this->data['production_order'],
|
||||||
|
'serial_number' => $this->data['serial_number'],
|
||||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||||
|
|||||||
@@ -26,107 +26,107 @@ class StickerMasterImporter extends Importer
|
|||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('serial_number_motor')
|
ImportColumn::make('serial_number_motor')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Serial Number Motor')
|
->exampleHeader('Serial Number Motor')
|
||||||
->label('SERIAL NUMBER MOTOR')
|
->label('SERIAL NUMBER MOTOR')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('serial_number_pump')
|
ImportColumn::make('serial_number_pump')
|
||||||
->requiredMapping()
|
//->requiredMapping()
|
||||||
->exampleHeader('Serial Number Pump')
|
->exampleHeader('Serial Number Pump')
|
||||||
->label('SERIAL NUMBER PUMP')
|
->label('SERIAL NUMBER PUMP')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('serial_number_pumpset')
|
ImportColumn::make('serial_number_pumpset')
|
||||||
->requiredMapping()
|
//->requiredMapping()
|
||||||
->exampleHeader('Serial Number PumpSet')
|
->exampleHeader('Serial Number PumpSet')
|
||||||
->label('SERIAL NUMBER PUMPSET')
|
->label('SERIAL NUMBER PUMPSET')
|
||||||
->example(''),
|
->example(''),
|
||||||
ImportColumn::make('pack_slip_motor')
|
ImportColumn::make('pack_slip_motor')
|
||||||
->requiredMapping()
|
//->requiredMapping()
|
||||||
->exampleHeader('Pack Slip Motor')
|
->exampleHeader('Pack Slip Motor')
|
||||||
->label('PACK SLIP MOTOR')
|
->label('PACK SLIP MOTOR')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('pack_slip_pump')
|
ImportColumn::make('pack_slip_pump')
|
||||||
->requiredMapping()
|
//->requiredMapping()
|
||||||
->exampleHeader('Pack Slip Pump')
|
->exampleHeader('Pack Slip Pump')
|
||||||
->label('PACK SLIP PUMP')
|
->label('PACK SLIP PUMP')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('pack_slip_pumpset')
|
ImportColumn::make('pack_slip_pumpset')
|
||||||
->requiredMapping()
|
//->requiredMapping()
|
||||||
->exampleHeader('Pack Slip PumpSet')
|
->exampleHeader('Pack Slip PumpSet')
|
||||||
->label('PACK SLIP PUMPSET')
|
->label('PACK SLIP PUMPSET')
|
||||||
->example(''),
|
->example(''),
|
||||||
ImportColumn::make('name_plate_motor')
|
ImportColumn::make('name_plate_motor')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Name Plate Motor')
|
->exampleHeader('Name Plate Motor')
|
||||||
->label('NAME PLATE MOTOR')
|
->label('NAME PLATE MOTOR')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('name_plate_pump')
|
ImportColumn::make('name_plate_pump')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Name Plate Pump')
|
->exampleHeader('Name Plate Pump')
|
||||||
->label('NAME PLATE PUMP')
|
->label('NAME PLATE PUMP')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('name_plate_pumpset')
|
ImportColumn::make('name_plate_pumpset')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Name Plate PumpSet')
|
->exampleHeader('Name Plate PumpSet')
|
||||||
->label('NAME PLATE PUMPSET')
|
->label('NAME PLATE PUMPSET')
|
||||||
->example(''),
|
->example(''),
|
||||||
ImportColumn::make('tube_sticker_motor')
|
ImportColumn::make('tube_sticker_motor')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Tube Sticker Motor')
|
->exampleHeader('Tube Sticker Motor')
|
||||||
->label('TUBE STICKER MOTOR')
|
->label('TUBE STICKER MOTOR')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('tube_sticker_pump')
|
ImportColumn::make('tube_sticker_pump')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Tube Sticker Pump')
|
->exampleHeader('Tube Sticker Pump')
|
||||||
->label('TUBE STICKER PUMP')
|
->label('TUBE STICKER PUMP')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('tube_sticker_pumpset')
|
ImportColumn::make('tube_sticker_pumpset')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Tube Sticker PumpSet')
|
->exampleHeader('Tube Sticker PumpSet')
|
||||||
->label('TUBE STICKER PUMPSET')
|
->label('TUBE STICKER PUMPSET')
|
||||||
->example(''),
|
->example(''),
|
||||||
ImportColumn::make('warranty_card')
|
ImportColumn::make('warranty_card')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Warranty Card')
|
->exampleHeader('Warranty Card')
|
||||||
->label('WARRANTY CARD')
|
->label('WARRANTY CARD')
|
||||||
->example('1'),
|
->example('1'),
|
||||||
ImportColumn::make('part_validation1')
|
ImportColumn::make('part_validation1')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Part Validation 1')
|
->exampleHeader('Part Validation 1')
|
||||||
->label('PART VALIDATION 1')
|
->label('PART VALIDATION 1')
|
||||||
->example('12345'),
|
->example('12345'),
|
||||||
ImportColumn::make('part_validation2')
|
ImportColumn::make('part_validation2')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Part Validation 2')
|
->exampleHeader('Part Validation 2')
|
||||||
->label('PART VALIDATION 2')
|
->label('PART VALIDATION 2')
|
||||||
->example('23456'),
|
->example('23456'),
|
||||||
ImportColumn::make('part_validation3')
|
ImportColumn::make('part_validation3')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Part Validation 3')
|
->exampleHeader('Part Validation 3')
|
||||||
->label('PART VALIDATION 3')
|
->label('PART VALIDATION 3')
|
||||||
->example('34567'),
|
->example('34567'),
|
||||||
ImportColumn::make('part_validation4')
|
ImportColumn::make('part_validation4')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Part Validation 4')
|
->exampleHeader('Part Validation 4')
|
||||||
->label('PART VALIDATION 4')
|
->label('PART VALIDATION 4')
|
||||||
->example('45678'),
|
->example('45678'),
|
||||||
ImportColumn::make('part_validation5')
|
ImportColumn::make('part_validation5')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Part Validation 5')
|
->exampleHeader('Part Validation 5')
|
||||||
->label('PART VALIDATION 5')
|
->label('PART VALIDATION 5')
|
||||||
->example('56789'),
|
->example('56789'),
|
||||||
ImportColumn::make('laser_part_validation1')
|
ImportColumn::make('laser_part_validation1')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Laser Part Validation 1')
|
->exampleHeader('Laser Part Validation 1')
|
||||||
->label('LASER PART VALIDATION 1')
|
->label('LASER PART VALIDATION 1')
|
||||||
->example('67890'),
|
->example('67890'),
|
||||||
ImportColumn::make('laser_part_validation2')
|
ImportColumn::make('laser_part_validation2')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Laser Part Validation 2')
|
->exampleHeader('Laser Part Validation 2')
|
||||||
->label('LASER PART VALIDATION 2')
|
->label('LASER PART VALIDATION 2')
|
||||||
->example('78901'),
|
->example('78901'),
|
||||||
ImportColumn::make('panel_box_code')
|
ImportColumn::make('panel_box_code')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Panel Box Code')
|
->exampleHeader('Panel Box Code')
|
||||||
->label('PANEL BOX CODE')
|
->label('PANEL BOX CODE')
|
||||||
->example('123456'),
|
->example('123456'),
|
||||||
@@ -138,13 +138,13 @@ class StickerMasterImporter extends Importer
|
|||||||
->example('0')
|
->example('0')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('material_type')
|
ImportColumn::make('material_type')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->integer()
|
->integer()
|
||||||
->exampleHeader('Material Type')
|
->exampleHeader('Material Type')
|
||||||
->label('MATERIAL TYPE')
|
->label('MATERIAL TYPE')
|
||||||
->example(''),
|
->example(''),
|
||||||
ImportColumn::make('bundle_quantity')
|
ImportColumn::make('bundle_quantity')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->integer()
|
->integer()
|
||||||
->exampleHeader('Bundle Quantity')
|
->exampleHeader('Bundle Quantity')
|
||||||
->label('BUNDLE QUANTITY')
|
->label('BUNDLE QUANTITY')
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ class TestingPanelReadingImporter extends Importer
|
|||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ImportColumn::make('machine')
|
ImportColumn::make('item')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship()
|
->relationship()
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('motorTestingMaster.item.code')
|
ImportColumn::make('machine')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->relationship()
|
->relationship()
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
@@ -28,9 +28,6 @@ class TestingPanelReadingImporter extends Importer
|
|||||||
ImportColumn::make('serial_number')
|
ImportColumn::make('serial_number')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('winded_serial_number')
|
|
||||||
->requiredMapping()
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('before_fr_volt'),
|
ImportColumn::make('before_fr_volt'),
|
||||||
ImportColumn::make('before_fr_cur'),
|
ImportColumn::make('before_fr_cur'),
|
||||||
ImportColumn::make('before_fr_pow'),
|
ImportColumn::make('before_fr_pow'),
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\User;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
use Spatie\Permission\Models\Role;
|
|
||||||
use Str;
|
|
||||||
|
|
||||||
class UserImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = User::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Code')
|
|
||||||
->example('1000')
|
|
||||||
->label('PLANT CODE')
|
|
||||||
->relationship(resolveUsing: 'code'),
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Name')
|
|
||||||
->example('RAW00001')
|
|
||||||
->label('Name')
|
|
||||||
->rules(['required']),//, 'max:255'
|
|
||||||
ImportColumn::make('email')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('E-Mail')
|
|
||||||
->example('RAW00001@cripumps.com')
|
|
||||||
->label('E-Mail')
|
|
||||||
->rules(['required', 'email']),//, 'max:255'
|
|
||||||
ImportColumn::make('password')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Password')
|
|
||||||
->example('RAW00001')
|
|
||||||
->label('Password')
|
|
||||||
->rules(['required']),//, 'max:255'
|
|
||||||
ImportColumn::make('roles')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Roles')
|
|
||||||
->example('Employee')
|
|
||||||
->label('Roles')
|
|
||||||
->rules(['nullable', 'string']), // Optional roles
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?User
|
|
||||||
{
|
|
||||||
$warnMsg = [];
|
|
||||||
$plant = null;
|
|
||||||
if (Str::length($this->data['plant']) > 0) {
|
|
||||||
if (Str::length($this->data['plant']) < 4 || !is_numeric($this->data['plant']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['plant'])) {
|
|
||||||
$warnMsg[] = "Invalid plant code found!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
|
||||||
if (!$plant) {
|
|
||||||
$warnMsg[] = "Plant not found";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$plant = $plant->id ?? null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::length($this->data['name']) < 1) {
|
|
||||||
$warnMsg[] = "User name not found!";
|
|
||||||
}
|
|
||||||
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
|
||||||
if (Str::length($this->data['email']) < 5) {
|
|
||||||
$warnMsg[] = "Invalid email found!";
|
|
||||||
}
|
|
||||||
if (Str::length($this->data['password']) < 3) {
|
|
||||||
$warnMsg[] = "Invalid password found!";
|
|
||||||
}
|
|
||||||
// Validate roles if provided
|
|
||||||
$roles = [];
|
|
||||||
if (!empty($this->data['roles'])) {
|
|
||||||
$roles = collect(explode(',', $this->data['roles']))
|
|
||||||
->map(fn($role) => trim($role))
|
|
||||||
->filter()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
foreach ($roles as $roleName) {
|
|
||||||
if (!Role::where('name', $roleName)->exists()) {
|
|
||||||
$warnMsg[] = "Role : '{$roleName}' does not exist!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$warnMsg[] = "User roles not found!";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = User::updateOrCreate([
|
|
||||||
'email' => $this->data['email'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => $this->data['name'],
|
|
||||||
'password' => $this->data['password'],
|
|
||||||
'plant_id' => $plant,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Assign roles
|
|
||||||
if (!empty($roles)) {
|
|
||||||
$user->syncRoles($roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
// return User::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
//return new User();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your user 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,154 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Models\WorkGroupMaster;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
use Str;
|
|
||||||
|
|
||||||
class WorkGroupMasterImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = WorkGroupMaster::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->example('Ransar Industries-I')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Name')
|
|
||||||
->example('RMGCEABC')
|
|
||||||
->label('Name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('description')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Description')
|
|
||||||
->example('Testing Model 1')
|
|
||||||
->label('Description')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('operation_number')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Operation Number')
|
|
||||||
->example('0020')
|
|
||||||
->label('Operation Number')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('created_by')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Created By')
|
|
||||||
->example('Admin')
|
|
||||||
->label('Created By')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function resolveRecord(): ?WorkGroupMaster
|
|
||||||
{
|
|
||||||
// return WorkGroupMaster::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
$warnMsg = [];
|
|
||||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
|
||||||
if (!$plant) {
|
|
||||||
$warnMsg[] = "Plant not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::length($this->data['name']) <= 0) { //|| !ctype_alnum($this->data['description'])
|
|
||||||
$warnMsg[] = "Invalid name found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::length(trim($this->data['description'])) <= 0) {
|
|
||||||
$warnMsg[] = "Invalid description found";
|
|
||||||
}
|
|
||||||
|
|
||||||
$desc = trim($this->data['description']);
|
|
||||||
|
|
||||||
if (Str::length($desc) > 44) {
|
|
||||||
$warnMsg[] = "Description should be less than 44 digits.";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::length($this->data['operation_number']) <= 0) {
|
|
||||||
$warnMsg[] = "Invalid operation number found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_numeric($this->data['operation_number']))
|
|
||||||
{
|
|
||||||
$warnMsg[] = "Invalid operation number found must be numeric";
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = User::where('name', $this->data['created_by'])->first();
|
|
||||||
if (!$user) {
|
|
||||||
$warnMsg[] = "Operator ID not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Check (plant_id, name)
|
|
||||||
$existingByName = WorkGroupMaster::where('plant_id', $plant->id)
|
|
||||||
->where('name', $this->data['name'])
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($existingByName) {
|
|
||||||
throw new RowImportFailedException("Work group name already exists for this plant!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check (plant_id, operation_number)
|
|
||||||
$existingByOpNum = WorkGroupMaster::where('plant_id', $plant->id)
|
|
||||||
->where('operation_number', $this->data['operation_number'])
|
|
||||||
->where('name', $this->data['name'])
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($existingByOpNum) {
|
|
||||||
throw new RowImportFailedException("Operation number already exists for this plant!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check (plant_id)
|
|
||||||
$existingByOperator = WorkGroupMaster::where('plant_id', $plant->id)
|
|
||||||
->where('name', $this->data['name'])
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($existingByOperator) {
|
|
||||||
throw new RowImportFailedException("Already work group name assigned to another plant!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkGroupMaster::updateOrCreate([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'name' => $this->data['name'],
|
|
||||||
'description' => $this->data['description'],
|
|
||||||
'operation_number' => $this->data['operation_number'],
|
|
||||||
'created_by' => $this->data['created_by'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
//return new WorkGroupMaster();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your work group master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -53,7 +53,6 @@ class Dashboard extends \Filament\Pages\Dashboard
|
|||||||
{
|
{
|
||||||
return 'Production Line Count';
|
return 'Production Line Count';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWidgets(): array
|
public function getWidgets(): array
|
||||||
{
|
{
|
||||||
$widgets = [];
|
$widgets = [];
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Models\Plant;
|
|||||||
use App\Models\ProductionQuantity;
|
use App\Models\ProductionQuantity;
|
||||||
use App\Models\QualityValidation;
|
use App\Models\QualityValidation;
|
||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Actions;
|
use Filament\Forms\Components\Actions;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -56,12 +55,8 @@ class DataSendToSap extends Page implements HasForms
|
|||||||
->statePath('data')
|
->statePath('data')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
// ->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Filament\Pages;
|
|||||||
|
|
||||||
use App\Filament\Widgets\GuardPatrolDayChart;
|
use App\Filament\Widgets\GuardPatrolDayChart;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -35,12 +34,8 @@ class GuardPatrolDayCount extends Page
|
|||||||
->statePath('filters')
|
->statePath('filters')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
// ->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state) {
|
->afterStateUpdated(function ($state) {
|
||||||
session(['selected_plant' => $state]);
|
session(['selected_plant' => $state]);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Pages;
|
|||||||
use App\Models\GuardPatrolEntry;
|
use App\Models\GuardPatrolEntry;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
@@ -39,12 +38,8 @@ class GuardPatrolEntryDashboard extends Page
|
|||||||
->statePath('filters') // Explicitly set where to store form data
|
->statePath('filters') // Explicitly set where to store form data
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
// ->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get){
|
->afterStateUpdated(function ($state, callable $set, callable $get){
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Models\CheckPointTime;
|
|||||||
use App\Models\GuardPatrolEntry;
|
use App\Models\GuardPatrolEntry;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -48,12 +47,8 @@ class GuardPatrolHourlyCount extends Page
|
|||||||
->statePath('filters')
|
->statePath('filters')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state,callable $set) {
|
->afterStateUpdated(function ($state,callable $set) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Filament\Pages;
|
|||||||
|
|
||||||
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -39,12 +38,8 @@ class InvoiceDashboard extends Page
|
|||||||
->statePath('filters') // Explicitly set where to store form data
|
->statePath('filters') // Explicitly set where to store form data
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state) {
|
->afterStateUpdated(function ($state) {
|
||||||
session(['selec_plant' => $state]);
|
session(['selec_plant' => $state]);
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Widgets\InvoiceDataChart;
|
|
||||||
use App\Models\InvoiceDataValidation;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Pages\Page;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
|
|
||||||
class InvoiceDataDashboard extends Page
|
|
||||||
{
|
|
||||||
use HasFiltersForm;
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
||||||
|
|
||||||
protected static string $view = 'filament.pages.invoice-data-dashboard';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Invoice Management';
|
|
||||||
|
|
||||||
public function mount(): void
|
|
||||||
{
|
|
||||||
session()->forget(['selected_plant','dist_channel']);
|
|
||||||
$this->filtersForm->fill([
|
|
||||||
'plant' => null,
|
|
||||||
'distribution_channel' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filtersForm(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->statePath('filters') // Store form state in 'filters'
|
|
||||||
->schema([
|
|
||||||
Section::make('')
|
|
||||||
->schema([
|
|
||||||
Select::make('plant')
|
|
||||||
->label('Select Plant')
|
|
||||||
->reactive()
|
|
||||||
// ->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function ($state,callable $set) {
|
|
||||||
session(['selected_plant' => $state]);
|
|
||||||
$set('distribution_channel', null);
|
|
||||||
session()->forget('distribution_channel');
|
|
||||||
}),
|
|
||||||
Select::make('distribution_channel')
|
|
||||||
->label('Distribution Channel')
|
|
||||||
// ->options(function (callable $get) {
|
|
||||||
// $plant = $get('plant');
|
|
||||||
|
|
||||||
// if (!$plant) {
|
|
||||||
// return [];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $options = InvoiceDataValidation::where('plant_id', $plant)
|
|
||||||
// ->whereNotNull('distribution_channel_desc')
|
|
||||||
// ->where('distribution_channel_desc', '!=', '')
|
|
||||||
// ->select('distribution_channel_desc')
|
|
||||||
// ->distinct()
|
|
||||||
// ->pluck('distribution_channel_desc', 'distribution_channel_desc')
|
|
||||||
// ->toArray();
|
|
||||||
|
|
||||||
// $hasEmpty = InvoiceDataValidation::where('plant_id', $plant)
|
|
||||||
// ->where(function ($q) {
|
|
||||||
// $q->whereNull('distribution_channel_desc')
|
|
||||||
// ->orWhere('distribution_channel_desc', '');
|
|
||||||
// })
|
|
||||||
// ->exists();
|
|
||||||
|
|
||||||
// if ($hasEmpty) {
|
|
||||||
// $options['Challan'] = 'Challan';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $options;
|
|
||||||
// })
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plant = $get('plant');
|
|
||||||
|
|
||||||
if (!$plant) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch unique, non-empty distribution_channel_desc values
|
|
||||||
return InvoiceDataValidation::where('plant_id', $plant)
|
|
||||||
->whereNotNull('distribution_channel_desc')
|
|
||||||
->where('distribution_channel_desc', '!=', '')
|
|
||||||
->distinct()
|
|
||||||
->pluck('distribution_channel_desc', 'distribution_channel_desc')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(callback: function ($state,callable $set) {
|
|
||||||
session(['dist_channel' => $state]);
|
|
||||||
})
|
|
||||||
->reactive(),
|
|
||||||
])
|
|
||||||
->columns(2),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function getNavigationLabel(): string
|
|
||||||
{
|
|
||||||
return 'Invoice Data Dashboard';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeading(): string
|
|
||||||
{
|
|
||||||
return 'Invoice Data Dashboard';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function canAccess(): bool
|
|
||||||
{
|
|
||||||
return Auth::check() && Auth::user()->can('view invoice data dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Pages;
|
|||||||
use App\Models\LocatorInvoiceValidation;
|
use App\Models\LocatorInvoiceValidation;
|
||||||
use App\Models\PalletValidation;
|
use App\Models\PalletValidation;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Filament\Forms\Contracts\HasForms;
|
use Filament\Forms\Contracts\HasForms;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
@@ -42,12 +41,8 @@ class InvoiceFinder extends Page implements HasForms
|
|||||||
Section::make('') // You can give your section a title or leave it blank
|
Section::make('') // You can give your section a title or leave it blank
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('scan_invoice')
|
TextInput::make('scan_invoice')
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -36,12 +35,8 @@ class InvoiceQuantityDashboard extends Page
|
|||||||
->statePath('filters') // Explicitly set where to store form data
|
->statePath('filters') // Explicitly set where to store form data
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state) {
|
->afterStateUpdated(function ($state) {
|
||||||
session(['selec_plant' => $state]);
|
session(['selec_plant' => $state]);
|
||||||
|
|||||||
@@ -69,11 +69,7 @@ class LocatorValidation extends Page implements HasForms
|
|||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
//->options(Plant::pluck('name', 'id'))
|
->options(Plant::pluck('name', 'id'))
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(),
|
->required(),
|
||||||
TextInput::make('scan_pallet_no')
|
TextInput::make('scan_pallet_no')
|
||||||
->label('Scan Pallet No')
|
->label('Scan Pallet No')
|
||||||
|
|||||||
@@ -64,15 +64,11 @@ class PalletFromLocator extends Page implements HasForms
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->disabled(fn (Get $get) => $get('plant_id'))
|
->disabled(fn (Get $get) => $get('plant_id'))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -730,27 +726,13 @@ class PalletFromLocator extends Page implements HasForms
|
|||||||
$month = now()->format('m');
|
$month = now()->format('m');
|
||||||
$prefix = "EP-{$year}{$month}";
|
$prefix = "EP-{$year}{$month}";
|
||||||
|
|
||||||
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||||
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
|
|
||||||
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
||||||
if ($lastPallet1 && $lastPallet2) {
|
if ($lastPallet) {
|
||||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
$serialPart = substr($lastPallet->pallet_number, strlen($prefix));
|
||||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
|
||||||
if (intval($serialPart1) > intval($serialPart2)) {
|
|
||||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
|
||||||
} else {
|
|
||||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($lastPallet1) {
|
|
||||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
|
||||||
// OR
|
// OR
|
||||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
$newNumber = str_pad(intval($serialPart) + 1, strlen($serialPart), '0', STR_PAD_LEFT);
|
||||||
}
|
|
||||||
else if ($lastPallet2) {
|
|
||||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
|
||||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Models\Plant;
|
|||||||
use App\Models\ProductionQuantity;
|
use App\Models\ProductionQuantity;
|
||||||
use App\Models\QualityValidation;
|
use App\Models\QualityValidation;
|
||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Actions;
|
use Filament\Forms\Components\Actions;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -56,14 +55,10 @@ class ProductionDataSap extends Page implements HasForms
|
|||||||
->statePath('data')
|
->statePath('data')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (!$plantId) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -39,12 +38,8 @@ class ProductionLineStopCount extends Page
|
|||||||
->schema([
|
->schema([
|
||||||
|
|
||||||
Select::make('plant')
|
Select::make('plant')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state) {
|
->afterStateUpdated(function ($state) {
|
||||||
session(['selected_plant' => $state]);
|
session(['selected_plant' => $state]);
|
||||||
|
|||||||
@@ -323,41 +323,20 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
->label('Production Order')
|
->label('Production Order')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->minLength(7)
|
|
||||||
->maxLength(14)
|
|
||||||
//->columnSpan(1)
|
//->columnSpan(1)
|
||||||
->columnSpan(['default' => 1, 'sm' => 1])
|
->columnSpan(['default' => 1, 'sm' => 1])
|
||||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
|
||||||
{
|
|
||||||
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
|
|
||||||
$set('production_order', null);
|
|
||||||
$set('item_code', null);
|
|
||||||
$set('item_id', null);
|
|
||||||
// $set('item_description', null);
|
|
||||||
$set('serial_number', null);
|
|
||||||
$set('validationError', null);
|
|
||||||
$this->prodOrder = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('productionError', null);
|
|
||||||
$set('production_order', $state);
|
|
||||||
$set('item_code', null);
|
$set('item_code', null);
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
// $set('item_description', null);
|
// $set('item_description', null);
|
||||||
$set('serial_number', null);
|
$set('serial_number', null);
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
$this->prodOrder = $state;
|
$this->prodOrder = $state;
|
||||||
|
|
||||||
|
return;
|
||||||
// if (empty($state)) {
|
// if (empty($state)) {
|
||||||
// }
|
// }
|
||||||
}
|
}),
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('productionError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
|
|
||||||
// TextInput::make('item_code')
|
// TextInput::make('item_code')
|
||||||
// ->label('Item Code')
|
// ->label('Item Code')
|
||||||
@@ -613,7 +592,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
|
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||||
{
|
{
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id'=> $this->pId,
|
'plant_id'=> $this->pId,
|
||||||
@@ -632,7 +611,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Production Order')
|
->title('Invalid Production Order')
|
||||||
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
|
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,133 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Widgets\TrendChartAnalysis;
|
|
||||||
use App\Models\MfmMeter;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Pages\Page;
|
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class TrendChartAnalys extends Page
|
|
||||||
{
|
|
||||||
use HasFiltersForm;
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
||||||
|
|
||||||
protected static string $view = 'filament.pages.trend-chart-analys';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
|
||||||
|
|
||||||
// use HasFiltersForm;
|
|
||||||
public function mount(): void
|
|
||||||
{
|
|
||||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
|
||||||
$this->filtersForm->fill([
|
|
||||||
'selected_plant' => null,
|
|
||||||
'selected_meter' => null,
|
|
||||||
'from_datetime' => null,
|
|
||||||
'to_datetime' => null,
|
|
||||||
'parameter' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function filtersForm(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->statePath('filters')
|
|
||||||
->schema([
|
|
||||||
DateTimePicker::make('from_datetime')
|
|
||||||
->label('From DateTime')
|
|
||||||
->required()
|
|
||||||
->before('to_datetime')
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
|
||||||
session(['from_datetime' => $formatted]);
|
|
||||||
}),
|
|
||||||
DateTimePicker::make('to_datetime')
|
|
||||||
->label('To DateTime')
|
|
||||||
->required()
|
|
||||||
->after('from_datetime')
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
|
||||||
session(['to_datetime' => $formatted]);
|
|
||||||
}),
|
|
||||||
Select::make('plant')
|
|
||||||
->label('Select Plant')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
|
||||||
session(['selected_plant' => $state]);
|
|
||||||
// When plant changes, also reset meter_name
|
|
||||||
$set('meter_name', null);
|
|
||||||
session(['selected_meter' => null]);
|
|
||||||
// dd($state);
|
|
||||||
}),
|
|
||||||
Select::make('meter_name')
|
|
||||||
->options(function ($get) {
|
|
||||||
$plantId = $get('plant');
|
|
||||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
|
||||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
|
||||||
})
|
|
||||||
->label('Select Meter')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
session(['selected_meter' => $state]);
|
|
||||||
}),
|
|
||||||
Select::make('parameter')
|
|
||||||
->options([
|
|
||||||
'Phase Voltage' => 'Phase Voltage',
|
|
||||||
'Line Voltage' => 'Line Voltage',
|
|
||||||
'Current' => 'Current',
|
|
||||||
'Active Power' => 'Active Power',
|
|
||||||
'Power Factor' => 'Power Factor',
|
|
||||||
'Units' => 'Units',
|
|
||||||
])
|
|
||||||
->label('Select Parameter')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
session(['parameter' => $state]);
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
->columns(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getNavigationLabel(): string
|
|
||||||
{
|
|
||||||
return 'Trend Chart Analysis';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeading(): string
|
|
||||||
{
|
|
||||||
return 'Trend Chart Analysis';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWidgets(): array
|
|
||||||
{
|
|
||||||
$widgets = [];
|
|
||||||
|
|
||||||
if (TrendChartAnalysis::canView()) {
|
|
||||||
$widgets[] = TrendChartAnalysis::class;
|
|
||||||
}
|
|
||||||
return $widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function canAccess(): bool
|
|
||||||
{
|
|
||||||
return Auth::check() && Auth::user()->can('view ems trend chart analysis dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Widgets\TrendLineChart;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Pages\Page;
|
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use App\Models\MfmMeter;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class TrendLineAnalysis extends Page
|
|
||||||
{
|
|
||||||
use HasFiltersForm;
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
||||||
|
|
||||||
protected static string $view = 'filament.pages.trend-line-analysis';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
|
||||||
|
|
||||||
public function mount(): void
|
|
||||||
{
|
|
||||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
|
||||||
$this->filtersForm->fill([
|
|
||||||
'selected_plant' => null,
|
|
||||||
'selected_meter' => null,
|
|
||||||
'from_datetime' => null,
|
|
||||||
'to_datetime' => null,
|
|
||||||
'parameter' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function filtersForm(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->statePath('filters')
|
|
||||||
->schema([
|
|
||||||
DateTimePicker::make('from_datetime')
|
|
||||||
->label('From DateTime')
|
|
||||||
->required()
|
|
||||||
->before('to_datetime')
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
|
||||||
session(['from_datetime' => $formatted]);
|
|
||||||
}),
|
|
||||||
DateTimePicker::make('to_datetime')
|
|
||||||
->label('To DateTime')
|
|
||||||
->required()
|
|
||||||
->after('from_datetime')
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
|
||||||
session(['to_datetime' => $formatted]);
|
|
||||||
}),
|
|
||||||
Select::make('plant')
|
|
||||||
->label('Select Plant')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
|
||||||
session(['selected_plant' => $state]);
|
|
||||||
// When plant changes, also reset meter_name
|
|
||||||
$set('meter_name', null);
|
|
||||||
session(['selected_meter' => null]);
|
|
||||||
// dd($state);
|
|
||||||
}),
|
|
||||||
Select::make('meter_name')
|
|
||||||
->options(function ($get) {
|
|
||||||
$plantId = $get('plant');
|
|
||||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
|
||||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
|
||||||
})
|
|
||||||
->label('Select Meter')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
session(['selected_meter' => $state]);
|
|
||||||
}),
|
|
||||||
Select::make('parameter')
|
|
||||||
->options([
|
|
||||||
'Phase Voltage' => 'Phase Voltage',
|
|
||||||
'Line Voltage' => 'Line Voltage',
|
|
||||||
'Current' => 'Current',
|
|
||||||
'Active Power' => 'Active Power',
|
|
||||||
'Power Factor' => 'Power Factor',
|
|
||||||
'Units' => 'Units',
|
|
||||||
])
|
|
||||||
->label('Select Parameter')
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->afterStateUpdated(function ($state) {
|
|
||||||
session(['parameter' => $state]);
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
->columns(5);
|
|
||||||
}
|
|
||||||
// public static function getNavigationLabel(): string
|
|
||||||
// {
|
|
||||||
// return 'Trend Chart Analysis';
|
|
||||||
// }
|
|
||||||
// public function getHeading(): string
|
|
||||||
// {
|
|
||||||
// return 'Trend Chart Analysis';
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public function getWidgets(): array
|
|
||||||
{
|
|
||||||
$widgets = [];
|
|
||||||
|
|
||||||
if (TrendLineChart::canView()) {
|
|
||||||
$widgets[] = TrendLineChart::class;
|
|
||||||
}
|
|
||||||
return $widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function canAccess(): bool
|
|
||||||
{
|
|
||||||
return Auth::check() && Auth::user()->can('view ems trend line analysis dashboard');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -54,14 +54,10 @@ class UploadSerialLocator extends Page implements HasForms
|
|||||||
Section::make('') // You can give your section a title or leave it blank
|
Section::make('') // You can give your section a title or leave it blank
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
|
->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
//->options(Plant::pluck('name', 'id'))
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->disabled(fn (Get $get) => $get('scan_serial_number') || $get('scan_locator')) //!empty($get('scan_serial_number'))
|
->disabled(fn (Get $get) => $get('scan_serial_number') || $get('scan_locator')) //!empty($get('scan_serial_number'))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('scan_serial_number', null);
|
$set('scan_serial_number', null);
|
||||||
|
|||||||
@@ -36,10 +36,7 @@ class AlertMailRuleResource extends Resource
|
|||||||
Forms\Components\Select::make('plant')
|
Forms\Components\Select::make('plant')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(fn () => Plant::pluck('name', 'id')->toArray())
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(fn ($get) => ! $get('is_active'))
|
->required(fn ($get) => ! $get('is_active'))
|
||||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||||
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
||||||
@@ -48,9 +45,7 @@ class AlertMailRuleResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->options([
|
->options([
|
||||||
'InvoiceValidation' => 'InvoiceValidation',
|
'InvoiceValidation' => 'InvoiceValidation',
|
||||||
'InvoiceDataReport' => 'InvoiceDataReport',
|
|
||||||
'ProductionQuantities' => 'ProductionQuantities',
|
'ProductionQuantities' => 'ProductionQuantities',
|
||||||
//'Calibration' => 'Calibration',
|
|
||||||
]),
|
]),
|
||||||
Forms\Components\Select::make('rule_name')
|
Forms\Components\Select::make('rule_name')
|
||||||
->label('Rule Name')
|
->label('Rule Name')
|
||||||
@@ -59,15 +54,11 @@ class AlertMailRuleResource extends Resource
|
|||||||
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
||||||
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
||||||
'ProductionMail' => 'Production Mail',
|
'ProductionMail' => 'Production Mail',
|
||||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
|
||||||
//'CalibrationMail' => 'Calibration Mail',
|
|
||||||
])
|
])
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('email')
|
Forms\Components\TextInput::make('email')
|
||||||
->label('Email')
|
->label('Email')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Textarea::make('cc_emails')
|
|
||||||
->label('CC Emails'),
|
|
||||||
Forms\Components\Select::make('schedule_type')
|
Forms\Components\Select::make('schedule_type')
|
||||||
->label('Schedule Type')
|
->label('Schedule Type')
|
||||||
->required()
|
->required()
|
||||||
@@ -85,7 +76,7 @@ class AlertMailRuleResource extends Resource
|
|||||||
Forms\Components\Hidden::make('updated_by')
|
Forms\Components\Hidden::make('updated_by')
|
||||||
->default(fn () => Filament::auth()->user()?->name),
|
->default(fn () => Filament::auth()->user()?->name),
|
||||||
])
|
])
|
||||||
->columns(6),
|
->columns(5),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,18 +94,12 @@ class AlertMailRuleResource extends Resource
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('No.')
|
Tables\Columns\TextColumn::make('id')
|
||||||
->label('No.')
|
->label('ID')
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
->numeric()
|
||||||
$paginator = $livewire->getTableRecords();
|
->sortable(),
|
||||||
$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')
|
Tables\Columns\TextColumn::make('plant')
|
||||||
->label('Plant Name')
|
->label('Plant')
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable()
|
->sortable()
|
||||||
->formatStateUsing(function ($state) {
|
->formatStateUsing(function ($state) {
|
||||||
static $plants;
|
static $plants;
|
||||||
@@ -124,54 +109,32 @@ class AlertMailRuleResource extends Resource
|
|||||||
return $plants[$state] ?? 'All Plants';
|
return $plants[$state] ?? 'All Plants';
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('module')
|
Tables\Columns\TextColumn::make('module')
|
||||||
->label('Module Name')
|
->label('Module')
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('rule_name')
|
Tables\Columns\TextColumn::make('rule_name')
|
||||||
->label('Rule Name')
|
->label('Rule Name')
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('email')
|
Tables\Columns\TextColumn::make('email')
|
||||||
->label('TO Emails')
|
->label('Email')
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('cc_emails')
|
|
||||||
->label('CC Emails')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('schedule_type')
|
Tables\Columns\TextColumn::make('schedule_type')
|
||||||
->label('Schedule Type')
|
->label('Schedule Type')
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: false),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
->label('Updated At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('updated_by')
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
->label('Updated By')
|
->label('Updated By')
|
||||||
->alignCenter()
|
->sortable(),
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
->label('Deleted At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|||||||
@@ -12,15 +12,11 @@ class CreateAlertMailRule extends CreateRecord
|
|||||||
|
|
||||||
protected function mutateFormDataBeforeCreate(array $data): array
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($data['is_active']) {
|
if ($data['is_active']) {
|
||||||
$data['plant'] = 0;
|
$data['plant'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use App\Filament\Exports\BlockExporter;
|
|||||||
use App\Filament\Imports\BlockImporter;
|
use App\Filament\Imports\BlockImporter;
|
||||||
use App\Filament\Resources\BlockResource\Pages;
|
use App\Filament\Resources\BlockResource\Pages;
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -70,10 +69,6 @@ class BlockResource extends Resource
|
|||||||
// ->unique(ignoreRecord: true)
|
// ->unique(ignoreRecord: true)
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Block::latest()->first())->plant_id;
|
return optional(Block::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -164,15 +159,11 @@ class BlockResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Blocks')
|
|
||||||
->color('warning')
|
|
||||||
->importer(BlockImporter::class)
|
->importer(BlockImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import block');
|
return Filament::auth()->user()->can('view import block');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Blocks')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(BlockExporter::class)
|
->exporter(BlockExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export block');
|
return Filament::auth()->user()->can('view export block');
|
||||||
|
|||||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
|||||||
class CreateBlock extends CreateRecord
|
class CreateBlock extends CreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = BlockResource::class;
|
protected static string $resource = BlockResource::class;
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Filament\Imports\CheckPointNameImporter;
|
|||||||
use App\Filament\Resources\CheckPointNameResource\Pages;
|
use App\Filament\Resources\CheckPointNameResource\Pages;
|
||||||
use App\Filament\Resources\CheckPointNameResource\RelationManagers;
|
use App\Filament\Resources\CheckPointNameResource\RelationManagers;
|
||||||
use App\Models\CheckPointName;
|
use App\Models\CheckPointName;
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -29,7 +28,7 @@ class CheckPointNameResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
protected static ?string $navigationGroup = 'Master Entries';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 15;
|
protected static ?int $navigationSort = 14;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
@@ -40,10 +39,6 @@ class CheckPointNameResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -153,15 +148,11 @@ class CheckPointNameResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Check Point Names')
|
|
||||||
->color('warning')
|
|
||||||
->importer(CheckPointNameImporter::class)
|
->importer(CheckPointNameImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import check point name');
|
return Filament::auth()->user()->can('view import check point name');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Check Point Names')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(CheckPointNameExporter::class)
|
->exporter(CheckPointNameExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export check point name');
|
return Filament::auth()->user()->can('view export check point name');
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Filament\Resources\CheckPointTimeResource\Pages;
|
|||||||
use App\Filament\Resources\CheckPointTimeResource\RelationManagers;
|
use App\Filament\Resources\CheckPointTimeResource\RelationManagers;
|
||||||
use App\Models\CheckPointName;
|
use App\Models\CheckPointName;
|
||||||
use App\Models\CheckPointTime;
|
use App\Models\CheckPointTime;
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -30,7 +29,7 @@ class CheckPointTimeResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
protected static ?string $navigationGroup = 'Master Entries';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 16;
|
protected static ?int $navigationSort = 15;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
@@ -41,10 +40,6 @@ class CheckPointTimeResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -384,15 +379,11 @@ class CheckPointTimeResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Check Point Times')
|
|
||||||
->color('warning')
|
|
||||||
->importer(CheckPointTimeImporter::class)
|
->importer(CheckPointTimeImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import check point time');
|
return Filament::auth()->user()->can('view import check point time');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Check Point Times')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(CheckPointTimeExporter::class)
|
->exporter(CheckPointTimeExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export check point time');
|
return Filament::auth()->user()->can('view export check point time');
|
||||||
|
|||||||
@@ -121,15 +121,11 @@ class CompanyResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Companies')
|
|
||||||
->color('warning')
|
|
||||||
->importer(CompanyImporter::class)
|
->importer(CompanyImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import company');
|
return Filament::auth()->user()->can('view import company');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Companies')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(CompanyExporter::class)
|
->exporter(CompanyExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export company');
|
return Filament::auth()->user()->can('view export company');
|
||||||
|
|||||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
|||||||
class CreateCompany extends CreateRecord
|
class CreateCompany extends CreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CompanyResource::class;
|
protected static string $resource = CompanyResource::class;
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Filament\Resources\ConfigurationResource\Pages;
|
|||||||
use App\Filament\Resources\ConfigurationResource\RelationManagers;
|
use App\Filament\Resources\ConfigurationResource\RelationManagers;
|
||||||
use App\Models\Configuration;
|
use App\Models\Configuration;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -38,10 +37,6 @@ class ConfigurationResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Configuration::latest()->first())->plant_id;
|
return optional(Configuration::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -183,15 +178,11 @@ class ConfigurationResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Configurations')
|
|
||||||
->color('warning')
|
|
||||||
->importer(ConfigurationImporter::class)
|
->importer(ConfigurationImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import configuration');
|
return Filament::auth()->user()->can('view import configuration');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Configurations')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(ConfigurationExporter::class)
|
->exporter(ConfigurationExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export configuration');
|
return Filament::auth()->user()->can('view export configuration');
|
||||||
|
|||||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
|||||||
class CreateConfiguration extends CreateRecord
|
class CreateConfiguration extends CreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = ConfigurationResource::class;
|
protected static string $resource = ConfigurationResource::class;
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,160 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\DeviceMasterExporter;
|
|
||||||
use App\Filament\Imports\DeviceMasterImporter;
|
|
||||||
use App\Filament\Resources\DeviceMasterResource\Pages;
|
|
||||||
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
|
|
||||||
use App\Models\DeviceMaster;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class DeviceMasterResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = DeviceMaster::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
protected static ?string $navigationGroup = 'Power House';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Section::make('')
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->label('Device Name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('mac_address')
|
|
||||||
->label('MAC Address'),
|
|
||||||
Forms\Components\TextInput::make('ip_address')
|
|
||||||
->label('IP Address'),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
])
|
|
||||||
->columns(4),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('No.')
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
}),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('name')
|
|
||||||
->label('Device Name')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('mac_address')
|
|
||||||
->label('MAC Address')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('ip_address')
|
|
||||||
->label('IP Address')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->label('Created At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->label('Updated At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->dateTime()
|
|
||||||
->alignCenter()
|
|
||||||
->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 Device Masters')
|
|
||||||
->color('warning')
|
|
||||||
->importer(DeviceMasterImporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import device master');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export Device Masters')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(DeviceMasterExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export device master');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListDeviceMasters::route('/'),
|
|
||||||
'create' => Pages\CreateDeviceMaster::route('/create'),
|
|
||||||
'view' => Pages\ViewDeviceMaster::route('/{record}'),
|
|
||||||
'edit' => Pages\EditDeviceMaster::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DeviceMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateDeviceMaster extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DeviceMasterResource::class;
|
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DeviceMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditDeviceMaster extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DeviceMasterResource::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\DeviceMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DeviceMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListDeviceMasters extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = DeviceMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DeviceMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewDeviceMaster extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DeviceMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,455 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\EbReadingExporter;
|
|
||||||
use App\Filament\Imports\EbReadingImporter;
|
|
||||||
use App\Filament\Resources\EbReadingResource\Pages;
|
|
||||||
use App\Filament\Resources\EbReadingResource\RelationManagers;
|
|
||||||
use App\Models\EbReading;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
|
|
||||||
class EbReadingResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = EbReading::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Power House';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('lcd_segment_check')
|
|
||||||
->label('LCD Segment Check'),
|
|
||||||
Forms\Components\TextInput::make('meter_serial_no')
|
|
||||||
->label('Meter Serial No'),
|
|
||||||
Forms\Components\DateTimePicker::make('eb_date_time')
|
|
||||||
->required()
|
|
||||||
->label('EB Date Time'),
|
|
||||||
Forms\Components\TextInput::make('ph_seq_of_volt')
|
|
||||||
->label('PH Sequence of Volt'),
|
|
||||||
Forms\Components\TextInput::make('ph_assoc_conn_check')
|
|
||||||
->label('PH Association Connection Check'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_ph_volt')
|
|
||||||
->label('Instantaneous PH Volt'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_curr')
|
|
||||||
->label('Instantaneous Current'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_freq')
|
|
||||||
->label('Instantaneous Frequency'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_kw_with_sign')
|
|
||||||
->label('Instantaneous KW with Sign'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_kva')
|
|
||||||
->label('Instantaneous KVA'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_kv_ar')
|
|
||||||
->label('Instantaneous KV AR'),
|
|
||||||
Forms\Components\TextInput::make('instantaneous_pf_with_sign')
|
|
||||||
->label('Instantaneous PF with Sign'),
|
|
||||||
Forms\Components\TextInput::make('rd_with_elapsed_time_kva')
|
|
||||||
->label('RD with Elapsed Time KVA'),
|
|
||||||
Forms\Components\TextInput::make('cum_active_import_energy')
|
|
||||||
->label('Cumulative Active Import Energy'),
|
|
||||||
Forms\Components\TextInput::make('tod1_active_energy_6_9')
|
|
||||||
->label('TOD1 Active Energy 6-9'),
|
|
||||||
Forms\Components\TextInput::make('tod2_active_energy_18_21')
|
|
||||||
->label('TOD2 Active Energy 18-21'),
|
|
||||||
Forms\Components\TextInput::make('tod3_active_energy_21_22')
|
|
||||||
->label('TOD3 Active Energy 21-22'),
|
|
||||||
Forms\Components\TextInput::make('tod4_active_energy_5_6_9_18')
|
|
||||||
->label('TOD4 Active Energy 5-6-9-18'),
|
|
||||||
Forms\Components\TextInput::make('tod5_active_energy_22_5')
|
|
||||||
->label('TOD5 Active Energy 22-5'),
|
|
||||||
Forms\Components\TextInput::make('cum_reac_lag_energy')
|
|
||||||
->label('Cumulative Reactive Lag Energy'),
|
|
||||||
Forms\Components\TextInput::make('cum_reac_lead_energy')
|
|
||||||
->label('Cumulative Reactive Lead Energy'),
|
|
||||||
Forms\Components\TextInput::make('cum_appar_energy')
|
|
||||||
->label('Cumulative Apparent Energy'),
|
|
||||||
Forms\Components\TextInput::make('tod1_appar_energy_6_9')
|
|
||||||
->label('TOD1 Apparent Energy 6-9'),
|
|
||||||
Forms\Components\TextInput::make('tod2_appar_energy_18_21')
|
|
||||||
->label('TOD2 Apparent Energy 18-21'),
|
|
||||||
Forms\Components\TextInput::make('tod3_appar_energy_21_22')
|
|
||||||
->label('TOD3 Apparent Energy 21-22'),
|
|
||||||
Forms\Components\TextInput::make('tod4_appar_energy_5_6_9_18')
|
|
||||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
|
||||||
Forms\Components\TextInput::make('tod5_appar_energy_22_5')
|
|
||||||
->label('TOD5 Apparent Energy 22-5'),
|
|
||||||
Forms\Components\TextInput::make('avg_pow_factor')
|
|
||||||
->label('Average Power Factor'),
|
|
||||||
Forms\Components\TextInput::make('avg_freq_15min_last_ip')
|
|
||||||
->label('Average Frequency 15min Last IP'),
|
|
||||||
Forms\Components\TextInput::make('net_kv_arh_high')
|
|
||||||
->label('Net KV ARH High'),
|
|
||||||
Forms\Components\TextInput::make('net_kv_arh_low')
|
|
||||||
->label('Net KV ARH Low'),
|
|
||||||
Forms\Components\TextInput::make('cum_md_kva')
|
|
||||||
->label('Cumulative MD KVA'),
|
|
||||||
Forms\Components\TextInput::make('present_md_kva')
|
|
||||||
->label('Present MD KVA'),
|
|
||||||
Forms\Components\DateTimePicker::make('present_md_kva_date_time')
|
|
||||||
->label('Present MD KVA Date Time')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('tod1_md_kva_6_9')
|
|
||||||
->label('TOD1 MD KVA 6-9'),
|
|
||||||
Forms\Components\TextInput::make('tod2_md_kva_18_21')
|
|
||||||
->label('TOD2 MD KVA 18-21'),
|
|
||||||
Forms\Components\TextInput::make('tod3_md_kva_21_22')
|
|
||||||
->label('TOD3 MD KVA 21-22'),
|
|
||||||
Forms\Components\TextInput::make('tod4_md_kva_5_6_9_18')
|
|
||||||
->label('TOD4 MD KVA 5-6-9-18'),
|
|
||||||
Forms\Components\TextInput::make('tod5_md_kva_22_5')
|
|
||||||
->label('TOD5 MD KVA 22-5'),
|
|
||||||
Forms\Components\TextInput::make('total_pow_off_hours')
|
|
||||||
->label('Total Power Off Hours'),
|
|
||||||
Forms\Components\TextInput::make('programming_count')
|
|
||||||
->label('Programming Count'),
|
|
||||||
Forms\Components\TextInput::make('last_occ_res_event_type')
|
|
||||||
->label('Last Occurrence/Reset Event Type'),
|
|
||||||
Forms\Components\DateTimePicker::make('last_occ_res_event_date_time')
|
|
||||||
->label('Last Occurrence/Reset Event Date Time')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('tamper_count')
|
|
||||||
->label('Tamper Count'),
|
|
||||||
Forms\Components\TextInput::make('reset_count')
|
|
||||||
->label('Reset Count'),
|
|
||||||
Forms\Components\DateTimePicker::make('last_md_reset_date_time')
|
|
||||||
->label('Last MD Reset Date Time')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Hidden::make('electrician_sign')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('No.')
|
|
||||||
->alignCenter()
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
}),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('lcd_segment_check')
|
|
||||||
->alignCenter()
|
|
||||||
->label('LCD Segment Check'),
|
|
||||||
Tables\Columns\TextColumn::make('meter_serial_no')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Meter Serial No'),
|
|
||||||
Tables\Columns\TextColumn::make('eb_date_time')
|
|
||||||
->alignCenter()
|
|
||||||
->label('EB Date Time'),
|
|
||||||
Tables\Columns\TextColumn::make('ph_seq_of_volt')
|
|
||||||
->alignCenter()
|
|
||||||
->label('PH Sequence of Volt'),
|
|
||||||
Tables\Columns\TextColumn::make('ph_assoc_conn_check')
|
|
||||||
->alignCenter()
|
|
||||||
->label('PH Association Connection Check'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_ph_volt')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous PH Volt'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_curr')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous Current'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_freq')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous Frequency'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_kw_with_sign')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous KW with Sign'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_kva')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous KVA'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_kv_ar')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous KV AR'),
|
|
||||||
Tables\Columns\TextColumn::make('instantaneous_pf_with_sign')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Instantaneous PF with Sign'),
|
|
||||||
Tables\Columns\TextColumn::make('rd_with_elapsed_time_kva')
|
|
||||||
->alignCenter()
|
|
||||||
->label('RD with Elapsed Time KVA'),
|
|
||||||
Tables\Columns\TextColumn::make('cum_active_import_energy')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Cumulative Active Import Energy'),
|
|
||||||
Tables\Columns\TextColumn::make('tod1_active_energy_6_9')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD1 Active Energy 6-9'),
|
|
||||||
Tables\Columns\TextColumn::make('tod2_active_energy_18_21')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD2 Active Energy 18-21'),
|
|
||||||
Tables\Columns\TextColumn::make('tod3_active_energy_21_22')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD3 Active Energy 21-22'),
|
|
||||||
Tables\Columns\TextColumn::make('tod4_active_energy_5_6_9_18')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD4 Active Energy 5-6-9-18'),
|
|
||||||
Tables\Columns\TextColumn::make('tod5_active_energy_22_5')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD5 Active Energy 22-5'),
|
|
||||||
Tables\Columns\TextColumn::make('cum_reac_lag_energy')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Cumulative Reactive Lag Energy'),
|
|
||||||
Tables\Columns\TextColumn::make('cum_reac_lead_energy')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Cumulative Reactive Lead Energy'),
|
|
||||||
Tables\Columns\TextColumn::make('cum_appar_energy')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Cumulative Apparent Energy'),
|
|
||||||
Tables\Columns\TextColumn::make('tod1_appar_energy_6_9')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD1 Apparent Energy 6-9'),
|
|
||||||
Tables\Columns\TextColumn::make('tod2_appar_energy_18_21')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD2 Apparent Energy 18-21'),
|
|
||||||
Tables\Columns\TextColumn::make('tod3_appar_energy_21_22')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD3 Apparent Energy 21-22'),
|
|
||||||
Tables\Columns\TextColumn::make('tod4_appar_energy_5_6_9_18')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
|
||||||
Tables\Columns\TextColumn::make('tod5_appar_energy_22_5')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD5 Apparent Energy 22-5'),
|
|
||||||
Tables\Columns\TextColumn::make('avg_pow_factor')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Average Power Factor'),
|
|
||||||
Tables\Columns\TextColumn::make('avg_freq_15min_last_ip')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Average Frequency 15min Last IP'),
|
|
||||||
Tables\Columns\TextColumn::make('net_kv_arh_high')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Net KV ARH High'),
|
|
||||||
Tables\Columns\TextColumn::make('net_kv_arh_low')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Net KV ARH Low'),
|
|
||||||
Tables\Columns\TextColumn::make('cum_md_kva')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Cumulative MD KVA'),
|
|
||||||
Tables\Columns\TextColumn::make('present_md_kva')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Present MD KVA'),
|
|
||||||
Tables\Columns\TextColumn::make('present_md_kva_date_time')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Present MD KVA Date Time'),
|
|
||||||
Tables\Columns\TextColumn::make('tod1_md_kva_6_9')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD1 MD KVA 6-9'),
|
|
||||||
Tables\Columns\TextColumn::make('tod2_md_kva_18_21')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD2 MD KVA 18-21'),
|
|
||||||
Tables\Columns\TextColumn::make('tod3_md_kva_21_22')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD3 MD KVA 21-22'),
|
|
||||||
Tables\Columns\TextColumn::make('tod4_md_kva_5_6_9_18')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD4 MD KVA 5-6-9-18'),
|
|
||||||
Tables\Columns\TextColumn::make('tod5_md_kva_22_5')
|
|
||||||
->alignCenter()
|
|
||||||
->label('TOD5 MD KVA 22-5'),
|
|
||||||
Tables\Columns\TextColumn::make('total_pow_off_hours')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Total Power Off Hours'),
|
|
||||||
Tables\Columns\TextColumn::make('programming_count')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Programming Count'),
|
|
||||||
Tables\Columns\TextColumn::make('last_occ_res_event_type')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Last Occurrence/Reset Event Type'),
|
|
||||||
Tables\Columns\TextColumn::make('last_occ_res_event_date_time')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Last Occurrence/Reset Event Date Time'),
|
|
||||||
Tables\Columns\TextColumn::make('tamper_count')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Tamper Count'),
|
|
||||||
Tables\Columns\TextColumn::make('reset_count')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Reset Count'),
|
|
||||||
Tables\Columns\TextColumn::make('last_md_reset_date_time')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Last MD Reset Date Time'),
|
|
||||||
Tables\Columns\TextColumn::make('electrician_sign')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Created By'),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->alignCenter()
|
|
||||||
->label('Created At')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->dateTime()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->dateTime()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
])
|
|
||||||
// ->filters([
|
|
||||||
// Tables\Filters\TrashedFilter::make(),
|
|
||||||
// ])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
Filter::make('advanced_filters')
|
|
||||||
->label('Advanced Filters')
|
|
||||||
->form([
|
|
||||||
Select::make('Plant')
|
|
||||||
->label('Select Plant')
|
|
||||||
->nullable()
|
|
||||||
// ->options(function () {
|
|
||||||
// return Plant::pluck('name', 'id');
|
|
||||||
// })
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$set('electrician_sign', null);
|
|
||||||
}),
|
|
||||||
TextInput::make('electrician_sign')
|
|
||||||
->label('Created By'),
|
|
||||||
DateTimePicker::make(name: 'created_from')
|
|
||||||
->label('Created From')
|
|
||||||
->placeholder(placeholder: 'Select From DateTime')
|
|
||||||
->reactive()
|
|
||||||
->native(false),
|
|
||||||
DateTimePicker::make('created_to')
|
|
||||||
->label('Created To')
|
|
||||||
->placeholder(placeholder: 'Select To DateTime')
|
|
||||||
->reactive()
|
|
||||||
->native(false),
|
|
||||||
])
|
|
||||||
->query(function ($query, array $data) {
|
|
||||||
// Hide all records initially if no filters are applied
|
|
||||||
if (empty($data['Plant']) && empty($data['electrician_sign'])) {
|
|
||||||
return $query->whereRaw('1 = 0');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['Plant'])) {
|
|
||||||
$query->where('plant_id', $data['Plant']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
|
||||||
$query->where('created_at', '<=', $data['created_to']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['electrician_sign'])) {
|
|
||||||
$query->where('electrician_sign', $data['electrician_sign']);
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
->indicateUsing(function (array $data) {
|
|
||||||
$indicators = [];
|
|
||||||
|
|
||||||
if (!empty($data['Plant'])) {
|
|
||||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['electrician_sign'])) {
|
|
||||||
$indicators[] = 'Created By: ' . $data['electrician_sign'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
|
||||||
$indicators[] = 'From: ' . $data['created_from'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
|
||||||
$indicators[] = 'To: ' . $data['created_to'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $indicators;
|
|
||||||
})
|
|
||||||
])
|
|
||||||
->filtersFormMaxHeight('280px')
|
|
||||||
->actions([
|
|
||||||
Tables\Actions\ViewAction::make(),
|
|
||||||
Tables\Actions\EditAction::make(),
|
|
||||||
])
|
|
||||||
->bulkActions([
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->headerActions([
|
|
||||||
ImportAction::make()
|
|
||||||
->label('Import EB Readings')
|
|
||||||
->color('warning')
|
|
||||||
->importer(EbReadingImporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import eb reading');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export EB Readings')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(EbReadingExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export eb reading');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListEbReadings::route('/'),
|
|
||||||
'create' => Pages\CreateEbReading::route('/create'),
|
|
||||||
'view' => Pages\ViewEbReading::route('/{record}'),
|
|
||||||
'edit' => Pages\EditEbReading::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EbReadingResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateEbReading extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EbReadingResource::class;
|
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EbReadingResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditEbReading extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EbReadingResource::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\EbReadingResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EbReadingResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListEbReadings extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = EbReadingResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EbReadingResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewEbReading extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EbReadingResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,514 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\EquipmentMasterExporter;
|
|
||||||
use App\Filament\Imports\EquipmentMasterImporter;
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource\Pages;
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource\RelationManagers;
|
|
||||||
use App\Models\EquipmentMaster;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
|
||||||
use Storage;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
|
|
||||||
class EquipmentMasterResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = EquipmentMaster::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Testing Panel';
|
|
||||||
|
|
||||||
protected static ?int $navigationSort = 2;
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->reactive()
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('machine_id')
|
|
||||||
//->relationship('machine', 'name')
|
|
||||||
->label('Work Center')
|
|
||||||
->reactive()
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
if (empty($plantId)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->label('Name'),
|
|
||||||
Forms\Components\TextInput::make('description')
|
|
||||||
->label('Description'),
|
|
||||||
Forms\Components\TextInput::make('make')
|
|
||||||
->label('Make'),
|
|
||||||
Forms\Components\TextInput::make('model')
|
|
||||||
->label('Model'),
|
|
||||||
Forms\Components\TextInput::make('equipment_number')
|
|
||||||
->label('Equipment Number')
|
|
||||||
->reactive()
|
|
||||||
->rules(function (callable $get) {
|
|
||||||
return [
|
|
||||||
Rule::unique('equipment_masters', 'equipment_number')
|
|
||||||
->where(function ($query) use ($get) {
|
|
||||||
return $query->where('plant_id', $get('plant_id'));
|
|
||||||
})
|
|
||||||
->ignore($get('id')),
|
|
||||||
];
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
|
||||||
if (! $state) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$model = EquipmentMaster::where('equipment_number', $state)->first();
|
|
||||||
|
|
||||||
if ($model?->attachment) {
|
|
||||||
$set('attachment', $model->attachment);
|
|
||||||
} else {
|
|
||||||
$set('attachment', null);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
//->afterStateUpdated(function ($state, callable $set) {
|
|
||||||
// if (! $state) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $model = EquipmentMaster::where('equipment_number', $state)->first();
|
|
||||||
|
|
||||||
// if ($model?->attachment) {
|
|
||||||
// $set('attachment', $model->attachment);
|
|
||||||
// } else {
|
|
||||||
// $set('attachment', null);
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
Forms\Components\TextInput::make('instrument_serial_number')
|
|
||||||
->label('Instrument Serial Number'),
|
|
||||||
// Forms\Components\DateTimePicker::make('calibrated_on')
|
|
||||||
// ->label('Calibrated On')
|
|
||||||
// ->required(),
|
|
||||||
// Forms\Components\TextInput::make('frequency')
|
|
||||||
// ->label('Frequency')
|
|
||||||
// ->required()
|
|
||||||
// ->numeric()
|
|
||||||
// ->default(1),
|
|
||||||
// Forms\Components\DateTimePicker::make('next_calibration_date')
|
|
||||||
// ->label('Next Calibration Date')
|
|
||||||
// ->required(),
|
|
||||||
Forms\Components\DateTimePicker::make('calibrated_on')
|
|
||||||
->label('Calibrated On')
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$frequency = $get('frequency') ?? '1';
|
|
||||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
|
||||||
$set('next_calibration_date', $nextDate);
|
|
||||||
}),
|
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
|
||||||
// $frequency = (int) $get('frequency');
|
|
||||||
|
|
||||||
// if ($state && $frequency != 0) {
|
|
||||||
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
|
|
||||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
|
||||||
// $set('next_calibration_date', $nextDate);
|
|
||||||
// } else {
|
|
||||||
// $set('next_calibration_date', null);
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('frequency')
|
|
||||||
->label('Frequency (days)')
|
|
||||||
->required()
|
|
||||||
->numeric()
|
|
||||||
->minValue(1)
|
|
||||||
->default(1)
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$calibratedOn = $get('calibrated_on');
|
|
||||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
|
||||||
$set('next_calibration_date', $nextDate);
|
|
||||||
}),
|
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
|
||||||
// $calibratedOn = $get('calibrated_on');
|
|
||||||
// $frequency = (int) $state;
|
|
||||||
|
|
||||||
// if ($calibratedOn && $frequency !== 0) {
|
|
||||||
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
|
|
||||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
|
||||||
// $set('next_calibration_date', $nextDate);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// $set('next_calibration_date', null);
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
|
|
||||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
|
||||||
->label('Next Calibration Date')
|
|
||||||
->readOnly()
|
|
||||||
->required(),
|
|
||||||
|
|
||||||
Forms\Components\TextInput::make('calibrated_by')
|
|
||||||
->label('Calibrated By'),
|
|
||||||
Forms\Components\Textarea::make('calibration_certificate')
|
|
||||||
->label('Calibration Certificate'),
|
|
||||||
|
|
||||||
Forms\Components\FileUpload::make('attachment')
|
|
||||||
->label('PDF Upload')
|
|
||||||
->acceptedFileTypes(['application/pdf'])
|
|
||||||
->storeFiles(false)
|
|
||||||
->disk('local')
|
|
||||||
->directory('uploads/temp')
|
|
||||||
->preserveFilenames()
|
|
||||||
->reactive(),
|
|
||||||
|
|
||||||
// Forms\Components\Actions::make([
|
|
||||||
// Action::make('uploadNow')
|
|
||||||
// ->label('Upload PDF Now')
|
|
||||||
// ->action(function ($get, callable $set) {
|
|
||||||
|
|
||||||
// $uploadedFiles = $get('attachment');
|
|
||||||
|
|
||||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
|
||||||
// $uploaded = reset($uploadedFiles);
|
|
||||||
|
|
||||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
|
||||||
// $originalName = $uploaded->getClientOriginalName();
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
|
||||||
// 'uploads/temp',
|
|
||||||
// $originalName,
|
|
||||||
// 'local'
|
|
||||||
// );
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }),
|
|
||||||
// ]),
|
|
||||||
// Forms\Components\Actions::make([
|
|
||||||
// Action::make('downloadAttachment')
|
|
||||||
// ->label('Download PDF')
|
|
||||||
// ->action(function ($get) {
|
|
||||||
// $uploadedFiles = $get('attachment');
|
|
||||||
|
|
||||||
// $equipmentNumber = $get('equipment_number');
|
|
||||||
|
|
||||||
// if (!$equipmentNumber) {
|
|
||||||
// Notification::make()
|
|
||||||
// ->title('No equipment number entered')
|
|
||||||
// ->danger()
|
|
||||||
// ->send();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $files = Storage::disk('local')->files('uploads/temp');
|
|
||||||
|
|
||||||
// $fileToDownload = null;
|
|
||||||
|
|
||||||
// foreach ($files as $file) {
|
|
||||||
// if (str_contains($file, $equipmentNumber)) {
|
|
||||||
// $fileToDownload = $file;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!$fileToDownload) {
|
|
||||||
// Notification::make()
|
|
||||||
// ->title('PDF not found for this equipment')
|
|
||||||
// ->danger()
|
|
||||||
// ->send();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return response()->download(Storage::disk('local')->path($fileToDownload));
|
|
||||||
// }),
|
|
||||||
// ]),
|
|
||||||
Forms\Components\Actions::make([
|
|
||||||
Action::make('uploadNow')
|
|
||||||
->label('Upload PDF Now')
|
|
||||||
// ->action(function ($get, callable $set) {
|
|
||||||
// $uploadedFiles = $get('attachment');
|
|
||||||
|
|
||||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
|
||||||
// $uploaded = reset($uploadedFiles);
|
|
||||||
|
|
||||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
|
||||||
// $originalName = $uploaded->getClientOriginalName();
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
|
||||||
// 'uploads/temp',
|
|
||||||
// $originalName,
|
|
||||||
// 'local'
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
->action(function ($get, callable $set) {
|
|
||||||
$uploadedFiles = $get('attachment');
|
|
||||||
|
|
||||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
|
||||||
$uploaded = reset($uploadedFiles);
|
|
||||||
|
|
||||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
|
||||||
$originalName = $uploaded->getClientOriginalName();
|
|
||||||
|
|
||||||
$storedPath = $uploaded->storeAs(
|
|
||||||
'uploads/temp',
|
|
||||||
$originalName,
|
|
||||||
'local'
|
|
||||||
);
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('PDF uploaded successfully')
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('No file selected to upload')
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
Action::make('downloadAttachment')
|
|
||||||
->label('Download PDF')
|
|
||||||
->action(function ($get) {
|
|
||||||
$equipmentNumber = $get('equipment_number');
|
|
||||||
|
|
||||||
if (!$equipmentNumber) {
|
|
||||||
Notification::make()
|
|
||||||
->title('No equipment number entered')
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = Storage::disk('local')->files('uploads/temp');
|
|
||||||
|
|
||||||
$fileToDownload = null;
|
|
||||||
foreach ($files as $file) {
|
|
||||||
if (str_contains($file, $equipmentNumber)) {
|
|
||||||
$fileToDownload = $file;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$fileToDownload) {
|
|
||||||
Notification::make()
|
|
||||||
->title('PDF not found for this equipment')
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
->columns(2),
|
|
||||||
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->label('Updated By'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('No.')
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
}),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('machine.work_center')
|
|
||||||
->label('Work Center')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('name')
|
|
||||||
->label('Name')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('description')
|
|
||||||
->label('Description')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('make')
|
|
||||||
->label('Make')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('model')
|
|
||||||
->label('Model')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('equipment_number')
|
|
||||||
->label('Equipment Number')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('instrument_serial_number')
|
|
||||||
->label('Instrument Serial Number')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('calibrated_on')
|
|
||||||
->label('Calibrated On')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('frequency')
|
|
||||||
->label('Frequency')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('next_calibration_date')
|
|
||||||
->label('Next Calibration Date')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('calibrated_by')
|
|
||||||
->label('Calibrated By')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('calibration_certificate')
|
|
||||||
->label('Calibration Certificate')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
|
||||||
->label('Created Bys')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_by')
|
|
||||||
->label('Updated By')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->label('Created At')
|
|
||||||
->dateTime()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->label('Updated At')
|
|
||||||
->dateTime()
|
|
||||||
->alignCenter()
|
|
||||||
->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 Equipment Masters')
|
|
||||||
->color('warning')
|
|
||||||
->importer(EquipmentMasterImporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import equipment master');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export Equipment Masters')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(EquipmentMasterExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export equipment master');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListEquipmentMasters::route('/'),
|
|
||||||
'create' => Pages\CreateEquipmentMaster::route('/create'),
|
|
||||||
'view' => Pages\ViewEquipmentMaster::route('/{record}'),
|
|
||||||
'edit' => Pages\EditEquipmentMaster::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
|
|
||||||
{
|
|
||||||
if (!$startDateTime || !$durationDays) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$startDateTimeCarbon = Carbon::parse($startDateTime);
|
|
||||||
$durationDays = str_replace(',', '.', $durationDays);
|
|
||||||
|
|
||||||
if(!is_numeric($durationDays))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
|
|
||||||
return $nextCalibrationDate->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateEquipmentMaster extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EquipmentMasterResource::class;
|
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
|
||||||
{
|
|
||||||
return $this->getResource()::getUrl('create');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditEquipmentMaster extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EquipmentMasterResource::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\EquipmentMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListEquipmentMasters extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = EquipmentMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\EquipmentMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewEquipmentMaster extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = EquipmentMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,546 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\GrMasterExporter;
|
|
||||||
use App\Filament\Imports\GrMasterImporter;
|
|
||||||
use App\Filament\Resources\GrMasterResource\Pages;
|
|
||||||
use App\Filament\Resources\GrMasterResource\RelationManagers;
|
|
||||||
use App\Models\GrMaster;
|
|
||||||
use App\Models\Item;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
use Storage;
|
|
||||||
use Smalot\PdfParser\Parser;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
|
||||||
use setasign\Fpdi\Fpdi;
|
|
||||||
use setasign\Fpdi\PdfReader;
|
|
||||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GrMasterResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = GrMaster::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->reactive()
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('item_id')
|
|
||||||
->label('Item Code')
|
|
||||||
//->relationship('item', 'id')
|
|
||||||
->reactive()
|
|
||||||
->searchable()
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
if (empty($plantId)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('gr_number')
|
|
||||||
->label('GR Number')
|
|
||||||
->minLength(7)
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('serial_number')
|
|
||||||
->label('Serial Number')
|
|
||||||
->rule(function (callable $get) {
|
|
||||||
return Rule::unique('gr_masters', 'serial_number')
|
|
||||||
->where('plant_id', $get('plant_id'))
|
|
||||||
->ignore($get('id')); // Ignore current record during updates
|
|
||||||
}),
|
|
||||||
|
|
||||||
Forms\Components\FileUpload::make('attachment')
|
|
||||||
->label('PDF Upload')
|
|
||||||
->acceptedFileTypes(['application/pdf'])
|
|
||||||
->storeFiles(false)
|
|
||||||
->disk('local')
|
|
||||||
->directory('uploads/temp')
|
|
||||||
->preserveFilenames()
|
|
||||||
->reactive(),
|
|
||||||
Forms\Components\Actions::make([
|
|
||||||
Action::make('uploadNow')
|
|
||||||
->label('Upload PDF Now')
|
|
||||||
->action(function ($get, callable $set) {
|
|
||||||
$uploadedFiles = $get('attachment');
|
|
||||||
|
|
||||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
|
||||||
{
|
|
||||||
$uploaded = reset($uploadedFiles);
|
|
||||||
|
|
||||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
|
||||||
$grNumber = $get('gr_number');
|
|
||||||
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
|
||||||
// $originalName = $uploaded->getClientOriginalName();
|
|
||||||
// $path = 'uploads/GRNumber/' . $originalName;
|
|
||||||
$finalFileName = $safeName . '.pdf';
|
|
||||||
$finalPath = 'uploads/GRNumber/' . $finalFileName;
|
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($finalPath)) {
|
|
||||||
Notification::make()
|
|
||||||
->title('Duplicate File')
|
|
||||||
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
return; // Stop here
|
|
||||||
}
|
|
||||||
|
|
||||||
$storedPath = $uploaded->storeAs(
|
|
||||||
'uploads/GRNumber',
|
|
||||||
$finalFileName,
|
|
||||||
'local'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// $fullPath = storage_path('app/' . $storedPath);
|
|
||||||
$fullPath = storage_path('app/private/' . $storedPath);
|
|
||||||
$parser = new Parser();
|
|
||||||
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
|
||||||
$pdf = $parser->parseFile($fullPath);
|
|
||||||
$text = $pdf->getText();
|
|
||||||
|
|
||||||
//dd($text);
|
|
||||||
|
|
||||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
|
||||||
$item1 = $matches[1];
|
|
||||||
}
|
|
||||||
// else if (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
|
|
||||||
|
|
||||||
// $item2 = $matches[1];
|
|
||||||
// dd($item2);
|
|
||||||
// }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('Item Code Not Found')
|
|
||||||
->body('Could not find Item code in uploaded PDF.')
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
|
||||||
Storage::disk('local')->delete($storedPath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$processOrder = $get('gr_number');
|
|
||||||
|
|
||||||
$itemId = $get('item_id');
|
|
||||||
|
|
||||||
$plant = $get('plant_id');
|
|
||||||
|
|
||||||
$item = Item::find($itemId);
|
|
||||||
|
|
||||||
$plant = Plant::find($plant);
|
|
||||||
|
|
||||||
if ($item)
|
|
||||||
{
|
|
||||||
$itemCode = $item->code;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$itemCode = null;
|
|
||||||
Notification::make()
|
|
||||||
->title('Item Not Found')
|
|
||||||
->body("Item not found in uploaded pdf.")
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
|
||||||
Storage::disk('local')->delete($storedPath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$storedPath = $uploaded->storeAs(
|
|
||||||
'uploads/GRNumber',
|
|
||||||
$finalFileName,
|
|
||||||
'local'
|
|
||||||
);
|
|
||||||
|
|
||||||
if($itemCode == $item1)
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('Success')
|
|
||||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('Item Code not matched')
|
|
||||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
|
||||||
Storage::disk('local')->delete($storedPath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('No file selected to upload')
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// Action::make('uploadNow1')
|
|
||||||
// ->label('Upload OCR')
|
|
||||||
// ->action(function ($get, callable $set) {
|
|
||||||
// $uploadedFiles = $get('photo');
|
|
||||||
|
|
||||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
|
||||||
// {
|
|
||||||
// $uploaded = reset($uploadedFiles);
|
|
||||||
|
|
||||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
|
||||||
// $grNumber = $get('gr_number');
|
|
||||||
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
|
||||||
// // $originalName = $uploaded->getClientOriginalName();
|
|
||||||
// // $path = 'uploads/GRNumber/' . $originalName;
|
|
||||||
// $finalFileName = $safeName . '.jpg';
|
|
||||||
// $finalPath = 'uploads/OCR/' . $finalFileName;
|
|
||||||
|
|
||||||
// // if (Storage::disk('local')->exists($finalPath)) {
|
|
||||||
// // Notification::make()
|
|
||||||
// // ->title('Duplicate File')
|
|
||||||
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
|
||||||
// // ->warning()
|
|
||||||
// // ->send();
|
|
||||||
// // return; // Stop here
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
|
||||||
// 'uploads/OCR',
|
|
||||||
// $finalFileName,
|
|
||||||
// 'local'
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
|
||||||
// // $fullPath = storage_path('app/' . $storedPath);
|
|
||||||
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
|
||||||
|
|
||||||
// $fullPath = storage_path('app/private/' . $storedPath);
|
|
||||||
|
|
||||||
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
|
||||||
|
|
||||||
// $rawText = $text;
|
|
||||||
|
|
||||||
// preg_match_all('/\d+/', $rawText, $matches);
|
|
||||||
|
|
||||||
// $serialNumbers = $matches[0];
|
|
||||||
|
|
||||||
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
|
||||||
|
|
||||||
// //dd($serialNumbers);
|
|
||||||
|
|
||||||
// $processOrder = $get('gr_number');
|
|
||||||
|
|
||||||
// $itemId = $get('item_id');
|
|
||||||
|
|
||||||
// $plant = $get('plant_id');
|
|
||||||
|
|
||||||
// $item = Item::find($itemId);
|
|
||||||
|
|
||||||
// $plant = Plant::find($plant);
|
|
||||||
|
|
||||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
|
||||||
|
|
||||||
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
|
||||||
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
|
||||||
// 'uploads/GRNumber',
|
|
||||||
// $finalFileName,
|
|
||||||
// 'local'
|
|
||||||
// );
|
|
||||||
|
|
||||||
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
|
||||||
|
|
||||||
// $templateId = $pdf->setSourceFile($templatePath);
|
|
||||||
// $templatePage = $pdf->importPage(1);
|
|
||||||
|
|
||||||
// $pdf->AddPage();
|
|
||||||
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
|
||||||
|
|
||||||
// $pdf->SetFont('Helvetica', '', 10);
|
|
||||||
// $pdf->SetTextColor(0, 0, 0);
|
|
||||||
|
|
||||||
// $slots = [
|
|
||||||
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
|
|
||||||
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
|
|
||||||
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
|
|
||||||
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// $qrSlots = [
|
|
||||||
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
|
|
||||||
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
|
|
||||||
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
|
|
||||||
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// // foreach ($serialNumbers as $i => $serial) {
|
|
||||||
// // if (isset($slots[$i])) {
|
|
||||||
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
|
|
||||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
|
||||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
|
||||||
// // // $pdf->Write(0, $serial);
|
|
||||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // $pdf->Output('F', $outputPath);
|
|
||||||
// // return response()->download($outputPath);
|
|
||||||
|
|
||||||
// //
|
|
||||||
|
|
||||||
// // foreach ($serialNumbers as $i => $serial) {
|
|
||||||
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
|
||||||
|
|
||||||
// // //Generate QR code PNG temporarily
|
|
||||||
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
|
||||||
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
|
||||||
|
|
||||||
// // //Place QR code above serial
|
|
||||||
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
|
||||||
|
|
||||||
// // //Erase old serial
|
|
||||||
// // $pdf->SetFillColor(255, 255, 255);
|
|
||||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
|
||||||
|
|
||||||
// // //Write new serial number
|
|
||||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
|
||||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// foreach ($serialNumbers as $i => $serial) {
|
|
||||||
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
|
||||||
|
|
||||||
// // Erase old QR completely (slightly larger)
|
|
||||||
// $pdf->SetFillColor(255, 255, 255);
|
|
||||||
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
|
||||||
|
|
||||||
// // Generate new QR code
|
|
||||||
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
|
||||||
// $qrDir = storage_path('app/private/uploads/QR');
|
|
||||||
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
|
||||||
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
|
||||||
|
|
||||||
// // Place QR code
|
|
||||||
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
|
||||||
|
|
||||||
// // Erase old serial
|
|
||||||
// $pdf->SetFillColor(255, 255, 255);
|
|
||||||
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
|
||||||
|
|
||||||
// // Write new serial
|
|
||||||
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
|
||||||
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Save the final PDF
|
|
||||||
// $pdf->Output('F', $outputPath);
|
|
||||||
|
|
||||||
// // Download
|
|
||||||
// return response()->download($outputPath);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// Notification::make()
|
|
||||||
// ->title('No file selected to upload')
|
|
||||||
// ->warning()
|
|
||||||
// ->send();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
|
|
||||||
Action::make('downloadAttachment')
|
|
||||||
->label('Download PDF')
|
|
||||||
->action(function ($get) {
|
|
||||||
$equipmentNumber = $get('gr_number');
|
|
||||||
|
|
||||||
if (!$equipmentNumber) {
|
|
||||||
Notification::make()
|
|
||||||
->title('No GR Number entered')
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = Storage::disk('local')->files('uploads/GRNumber');
|
|
||||||
|
|
||||||
$fileToDownload = null;
|
|
||||||
foreach ($files as $file) {
|
|
||||||
if (str_contains($file, $equipmentNumber)) {
|
|
||||||
$fileToDownload = $file;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$fileToDownload) {
|
|
||||||
Notification::make()
|
|
||||||
->title('PDF not found for this process order')
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
|
||||||
{
|
|
||||||
return $table
|
|
||||||
->columns([
|
|
||||||
Tables\Columns\TextColumn::make('No.')
|
|
||||||
->label('No.')
|
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
|
||||||
$paginator = $livewire->getTableRecords();
|
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
|
||||||
}),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('item.code')
|
|
||||||
->label('Item Code')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('gr_number')
|
|
||||||
->label('GR Number')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('serial_number')
|
|
||||||
->label('Serial Number')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('status')
|
|
||||||
->label('Status')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->label('Created At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->label('Updated At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->label('Deleted At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
])
|
|
||||||
->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 GR Masters')
|
|
||||||
->color('warning')
|
|
||||||
->importer(GrMasterImporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import gr master');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export GR Masters')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(GrMasterExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export gr master');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListGrMasters::route('/'),
|
|
||||||
'create' => Pages\CreateGrMaster::route('/create'),
|
|
||||||
'view' => Pages\ViewGrMaster::route('/{record}'),
|
|
||||||
'edit' => Pages\EditGrMaster::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\GrMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateGrMaster extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = GrMasterResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\GrMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditGrMaster extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = GrMasterResource::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\GrMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\GrMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListGrMasters extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = GrMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\GrMasterResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewGrMaster extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = GrMasterResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ use App\Filament\Imports\GuardNameImporter;
|
|||||||
use App\Filament\Resources\GuardNameResource\Pages;
|
use App\Filament\Resources\GuardNameResource\Pages;
|
||||||
use App\Filament\Resources\GuardNameResource\RelationManagers;
|
use App\Filament\Resources\GuardNameResource\RelationManagers;
|
||||||
use App\Models\GuardName;
|
use App\Models\GuardName;
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -29,7 +28,7 @@ class GuardNameResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
protected static ?string $navigationGroup = 'Master Entries';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 14;
|
protected static ?int $navigationSort = 13;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
@@ -40,10 +39,6 @@ class GuardNameResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(GuardName::latest()->first())->plant_id;
|
return optional(GuardName::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -78,14 +73,14 @@ class GuardNameResource extends Resource
|
|||||||
->ignore($get('id'));
|
->ignore($get('id'));
|
||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('identification1')
|
Forms\Components\TextInput::make('identification1')
|
||||||
->label('Aadhar Number')
|
->label('Identification-1')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('identification2')
|
Forms\Components\TextInput::make('identification2')
|
||||||
->label('PAN Number')
|
->label('Identification-2')
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
@@ -166,15 +161,11 @@ class GuardNameResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import Guard Names')
|
|
||||||
->color('warning')
|
|
||||||
->importer(GuardNameImporter::class)
|
->importer(GuardNameImporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view import guard name');
|
return Filament::auth()->user()->can('view import guard name');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Guard Names')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(GuardNameExporter::class)
|
->exporter(GuardNameExporter::class)
|
||||||
->visible(function() {
|
->visible(function() {
|
||||||
return Filament::auth()->user()->can('view export guard name');
|
return Filament::auth()->user()->can('view export guard name');
|
||||||
|
|||||||
@@ -52,10 +52,6 @@ class GuardPatrolEntryResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
@@ -283,12 +279,8 @@ class GuardPatrolEntryResource extends Resource
|
|||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->nullable()
|
->nullable()
|
||||||
// ->options(function () {
|
->options(function () {
|
||||||
// return Plant::pluck('name', 'id');
|
return Plant::pluck('name', 'id');
|
||||||
// })
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -419,11 +411,7 @@ class GuardPatrolEntryResource extends Resource
|
|||||||
->label('Import Guard Patrol Entries')
|
->label('Import Guard Patrol Entries')
|
||||||
->form([
|
->form([
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
// ->options(Plant::pluck('name', 'id')->toArray())
|
->options(Plant::pluck('name', 'id')->toArray())
|
||||||
->options(function (callable $get) {
|
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
|
|||||||
@@ -1,622 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\InvoiceDataValidationExporter;
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource\Pages;
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource\RelationManagers;
|
|
||||||
use App\Models\InvoiceDataValidation;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\FileUpload;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Filament\Forms\Get;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
|
||||||
use App\Models\StickerMaster;
|
|
||||||
use App\Models\User;
|
|
||||||
use DB;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class InvoiceDataValidationResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = InvoiceDataValidation::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Invoice Management';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('distribution_channel_desc')
|
|
||||||
->label('Distribution Channel Description')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('customer_code')
|
|
||||||
->label('Customer Code')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('document_number')
|
|
||||||
->label('Document Number')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\DatePicker::make('document_date')
|
|
||||||
->label('Document Date')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('customer_trade_name')
|
|
||||||
->label('Customer Trade Name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('customer_location')
|
|
||||||
->label('Customer Location')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('location')
|
|
||||||
->label('Location')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.code')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('distribution_channel_desc')
|
|
||||||
->label('Distribution Channel Description')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('customer_code')
|
|
||||||
->label('Customer Code')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('document_number')
|
|
||||||
->label('Document Number')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('document_date')
|
|
||||||
->label('Document Date')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->date()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('customer_trade_name')
|
|
||||||
->label('Customer Trade Name')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('customer_location')
|
|
||||||
->label('Customer Location')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('location')
|
|
||||||
->label('Location')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->label('Created At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->label('Updated At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->label('Deleted At')
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
])
|
|
||||||
->actions([
|
|
||||||
Tables\Actions\ViewAction::make(),
|
|
||||||
Tables\Actions\EditAction::make(),
|
|
||||||
])
|
|
||||||
->bulkActions([
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->headerActions([
|
|
||||||
Tables\Actions\Action::make('Import Invoice Data')
|
|
||||||
->label('Import Invoice Data')
|
|
||||||
->form([
|
|
||||||
FileUpload::make('invoice_data_file')
|
|
||||||
->label('Invoice Data File')
|
|
||||||
// ->required()
|
|
||||||
->preserveFilenames()
|
|
||||||
->storeFiles(false)
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->disk('local')
|
|
||||||
//->visible(fn (Get $get) => !empty($get('plant_id')))
|
|
||||||
->directory('uploads/temp'),
|
|
||||||
])
|
|
||||||
->action(function (array $data) {
|
|
||||||
$uploadedFile = $data['invoice_data_file'];
|
|
||||||
|
|
||||||
$disk = Storage::disk('local');
|
|
||||||
|
|
||||||
$user = Filament::auth()->user();
|
|
||||||
|
|
||||||
$operatorName = $user->name;
|
|
||||||
|
|
||||||
// Get original filename
|
|
||||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
|
||||||
|
|
||||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
|
||||||
|
|
||||||
// Store manually using storeAs to keep original name
|
|
||||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
|
||||||
|
|
||||||
$fullPath = Storage::disk('local')->path($path);
|
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
|
||||||
|
|
||||||
if ((count($rows) - 1) <= 0)
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('Records Not Found')
|
|
||||||
->body("Import the valid 'Invoice Data' file to proceed..!")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invalidPlantCode = [];
|
|
||||||
$invalidPlaCoFound = [];
|
|
||||||
$invalidDisChaDesc = [];
|
|
||||||
$invalidCustomerCode = [];
|
|
||||||
$invalidDocNo = [];
|
|
||||||
$invalidDocDate = [];
|
|
||||||
$invalidCusTradeName = [];
|
|
||||||
$invalidCusLocation = [];
|
|
||||||
$invalidUser = [];
|
|
||||||
$userNotFound = [];
|
|
||||||
$invalidPlantType = [];
|
|
||||||
$invalidLocation = [];
|
|
||||||
|
|
||||||
$seenPlantDoc = [];
|
|
||||||
//$duplicateEntries = [];
|
|
||||||
$duplicateEntriesExcel = [];
|
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
|
||||||
{
|
|
||||||
if ($index == 0) continue; // Skip header
|
|
||||||
|
|
||||||
$DisChaDesc = trim($row[3]);
|
|
||||||
$plantCode = trim($row[4]);
|
|
||||||
$CustomerCode = trim($row[5]);
|
|
||||||
$DocNo = trim($row[6]);
|
|
||||||
$DocDate = trim($row[7]);
|
|
||||||
$CusTradeName = trim($row[9]);
|
|
||||||
$CusLocation = trim($row[10]);
|
|
||||||
$Location = trim($row[36]);
|
|
||||||
|
|
||||||
// if (empty($plantCode)) $invalidPlantCode[] = "Row {$index}";
|
|
||||||
if (empty($DisChaDesc)){
|
|
||||||
$invalidDisChaDesc[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
if (empty($CustomerCode)){
|
|
||||||
$invalidCustomerCode[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
if (empty($DocNo))
|
|
||||||
{
|
|
||||||
$invalidDocNo[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
if (empty($CusTradeName))
|
|
||||||
{
|
|
||||||
$invalidCusTradeName[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
if (empty($CusLocation))
|
|
||||||
{
|
|
||||||
$invalidCusLocation[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
if (empty($Location))
|
|
||||||
{
|
|
||||||
$invalidLocation[] = "Row {$index}";
|
|
||||||
}
|
|
||||||
// if (empty($createdBy)) $invalidUser[] = "Row {$index}";
|
|
||||||
|
|
||||||
if (strlen($plantCode) < 4) {
|
|
||||||
$invalidPlantCode[] = $plantCode;
|
|
||||||
}
|
|
||||||
if (!is_numeric($plantCode)) {
|
|
||||||
$invalidPlantType[] = $plantCode;
|
|
||||||
}
|
|
||||||
else if (!Plant::where('code', $plantCode)->first())
|
|
||||||
{
|
|
||||||
$invalidPlaCoFound[] = $plantCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Find Plant by code ---
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
|
||||||
|
|
||||||
// //Duplicate Check in DB ---
|
|
||||||
// $exists = InvoiceDataValidation::where('plant_id', $plant->id)
|
|
||||||
// ->where('document_number', $DocNo)
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// if ($exists)
|
|
||||||
// {
|
|
||||||
// $duplicateEntries[] = "Duplicate record: Document Number '{$DocNo}' already exists for Plant '{$plant->name}'";
|
|
||||||
// }
|
|
||||||
|
|
||||||
//Also check duplicates within the same file ---
|
|
||||||
$uniqueKey = $plantCode . '_' . $DocNo;
|
|
||||||
if (in_array($uniqueKey, $seenPlantDoc)) {
|
|
||||||
$duplicateEntriesExcel[] = "Duplicate in file at Row {$index}: Document Number '{$DocNo}' already exists for Plant '{$plant->name}'";
|
|
||||||
}
|
|
||||||
$seenPlantDoc[] = $uniqueKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($invalidCustomerCode) || !empty($invalidDocNo) || !empty($invalidDocDate) || !empty($invalidCusTradeName) || !empty($invalidCusLocation))
|
|
||||||
{
|
|
||||||
$errorMsg = '';
|
|
||||||
|
|
||||||
//if (!empty($invalidDisChaDesc)) $errorMsg .= 'Missing Distribution Channel Description in rows: ' . implode(', ', $invalidDisChaDesc) . '<br>';
|
|
||||||
if (!empty($invalidCustomerCode)) $errorMsg .= 'Missing Customer Code in rows: ' . implode(', ', $invalidCustomerCode) . '<br>';
|
|
||||||
if (!empty($invalidDocNo)) $errorMsg .= 'Missing Document Number in rows: ' . implode(', ', $invalidDocNo) . '<br>';
|
|
||||||
if (!empty($invalidDocDate)) $errorMsg .= 'Missing Document Date in rows: ' . implode(', ', $invalidDocDate) . '<br>';
|
|
||||||
if (!empty($invalidCusTradeName)) $errorMsg .= 'Missing Customer Trade Name in rows: ' . implode(', ', $invalidCusTradeName) . '<br>';
|
|
||||||
if (!empty($invalidCusLocation)) $errorMsg .= 'Missing Customer Location in rows: ' . implode(', ', $invalidCusLocation) . '<br>';
|
|
||||||
if (!empty($invalidLocation)) $errorMsg .= 'Missing Location in rows: ' . implode(', ', $invalidLocation) . '<br>';
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Missing Mandatory Fields')
|
|
||||||
->body($errorMsg)
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!empty($invalidPlantCode))
|
|
||||||
{
|
|
||||||
$invalidPlantCode = array_unique($invalidPlantCode);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid Plant Codes')
|
|
||||||
->body('The following plant codes should contain minimum 4 digits:<br>' . implode(', ', $invalidPlantCode))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!empty($invalidPlantType))
|
|
||||||
{
|
|
||||||
$invalidPlantType = array_unique($invalidPlantType);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid Plant Codes')
|
|
||||||
->body('The following plant codes should contain numeric values:<br>' . implode(', ', $invalidPlantType))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!empty($invalidPlaCoFound))
|
|
||||||
{
|
|
||||||
$invalidPlaCoFound = array_unique($invalidPlaCoFound);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid Plant Codes')
|
|
||||||
->body('The following plant codes not found in plants:<br>' . implode(', ', $invalidPlaCoFound))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (!empty($duplicateEntries))
|
|
||||||
// {
|
|
||||||
// $duplicateGroupedByPlant = [];
|
|
||||||
|
|
||||||
// foreach ($duplicateEntries as $message)
|
|
||||||
// {
|
|
||||||
// if (preg_match("/Document Number '([^']+)' already exists for Plant '([^']+)'/", $message, $matches)) {
|
|
||||||
// $docNo = $matches[1];
|
|
||||||
// $plantName = trim($matches[2]);
|
|
||||||
// $duplicateGroupedByPlant[$plantName][] = $docNo;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $errorMsg = 'Duplicate Document Number found in Database :<br>';
|
|
||||||
|
|
||||||
// foreach ($duplicateGroupedByPlant as $plant => $docNumbers) {
|
|
||||||
// $count = count($docNumbers);
|
|
||||||
|
|
||||||
// if ($count > 10)
|
|
||||||
// {
|
|
||||||
// $errorMsg .= "Duplicate record(s) for Plant <b>{$plant}</b> : {$count} document numbers already exist in DB<br>";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// $errorMsg .= "Duplicate record(s) for Plant <b>{$plant}</b> : "
|
|
||||||
// . implode(', ', $docNumbers)
|
|
||||||
// . " already exist<br>";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Notification::make()
|
|
||||||
// //->title('Duplicate Entries in Database')
|
|
||||||
// ->body($errorMsg)
|
|
||||||
// ->danger()
|
|
||||||
// ->send();
|
|
||||||
|
|
||||||
// if ($disk->exists($path)) {
|
|
||||||
// $disk->delete($path);
|
|
||||||
// }
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!empty($duplicateEntriesExcel))
|
|
||||||
{
|
|
||||||
$duplicateGroupedByPlantExcel = [];
|
|
||||||
|
|
||||||
foreach ($duplicateEntriesExcel as $message) {//"/Document Number '([^']+)' already exist(?:s)?(?: for Plant (.+))?/"
|
|
||||||
if (preg_match("/Document Number '([^']+)' already exists for Plant '([^']+)'/", $message, $matches)) {
|
|
||||||
$docNo = $matches[1];
|
|
||||||
$plantName = $matches[2] ?? 'Unknown';
|
|
||||||
$duplicateGroupedByPlantExcel[$plantName][] = $docNo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$errorMsg = 'Duplicate Document Number found in Uploaded File :<br>';
|
|
||||||
|
|
||||||
foreach ($duplicateGroupedByPlantExcel as $plant => $docNumbers)
|
|
||||||
{
|
|
||||||
// Remove duplicate document numbers for each plant
|
|
||||||
$uniqueDocNumbers = array_unique($docNumbers);
|
|
||||||
$count = count($uniqueDocNumbers);
|
|
||||||
|
|
||||||
if ($count > 10) {
|
|
||||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plant}</b> : {$count} Document Numbers already exist in uploaded file<br>";
|
|
||||||
} else {
|
|
||||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plant}</b> : '"
|
|
||||||
. implode(', ', $uniqueDocNumbers)
|
|
||||||
. "' already exist in uploaded file<br>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
//->title('Duplicate Document Number in Uploaded File')
|
|
||||||
->body($errorMsg)
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (!empty($duplicateEntriesExcel))
|
|
||||||
// {
|
|
||||||
// //$errorMsg = 'Duplicate Document Number found in the uploaded file:<br>' . implode('<br>', $duplicateEntriesExcel);
|
|
||||||
// $errorMsg = buildDuplicateMessage($duplicateEntriesExcel, 'Duplicate Document Number found in Uploaded File');
|
|
||||||
// Notification::make()
|
|
||||||
// ->title('Duplicate Document Number in Uploaded File')
|
|
||||||
// ->body($errorMsg)
|
|
||||||
|
|
||||||
$successCount = 0;
|
|
||||||
$failedRecords = [];
|
|
||||||
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach ($rows as $index => $row) {
|
|
||||||
if ($index == 0) continue;
|
|
||||||
|
|
||||||
$rowNumber = $index + 1;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$DisChaDesc = trim($row[3]);
|
|
||||||
$plantCode = trim($row[4]);
|
|
||||||
$CustomerCode = trim($row[5]);
|
|
||||||
$DocNo = trim($row[6]);
|
|
||||||
$DocDate = trim($row[7]);
|
|
||||||
$CusTradeName = trim($row[9]);
|
|
||||||
$CusLocation = trim($row[10]);
|
|
||||||
$Location = trim($row[36]);
|
|
||||||
|
|
||||||
if (empty($DocNo)) {
|
|
||||||
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
|
||||||
}
|
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
|
||||||
if (!$plant) {
|
|
||||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($DocDate)) {
|
|
||||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $DocDate)) {
|
|
||||||
[$day, $month, $year] = preg_split('/[-\/]/', $DocDate);
|
|
||||||
$formattedDate = "{$year}-{$month}-{$day}";
|
|
||||||
} elseif (is_numeric($DocDate)) {
|
|
||||||
$formattedDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($DocDate)->format('Y-m-d');
|
|
||||||
} else {
|
|
||||||
$formattedDate = date('Y-m-d', strtotime($DocDate));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$formattedDate = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$record = InvoiceDataValidation::where('plant_id', $plant->id)
|
|
||||||
->where('document_number', $DocNo)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$curStat = $record ? 'Updation' : 'Insertion';
|
|
||||||
|
|
||||||
if ($record) {
|
|
||||||
$record->update([
|
|
||||||
'distribution_channel_desc' => $DisChaDesc,
|
|
||||||
'customer_code' => $CustomerCode,
|
|
||||||
'document_date' => $formattedDate,
|
|
||||||
'customer_trade_name' => $CusTradeName,
|
|
||||||
'customer_location' => $CusLocation,
|
|
||||||
'location' => $Location,
|
|
||||||
'updated_by' => $operatorName
|
|
||||||
]);
|
|
||||||
$inserted = $record;
|
|
||||||
} else {
|
|
||||||
// Record does not exist, create with 'created_by'
|
|
||||||
$inserted = InvoiceDataValidation::create([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'document_number' => $DocNo,
|
|
||||||
'distribution_channel_desc' => $DisChaDesc,
|
|
||||||
'customer_code' => $CustomerCode,
|
|
||||||
'document_date' => $formattedDate,
|
|
||||||
'customer_trade_name' => $CusTradeName,
|
|
||||||
'customer_location' => $CusLocation,
|
|
||||||
'location' => $Location,
|
|
||||||
'created_by' => $operatorName
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// $inserted = InvoiceDataValidation::create([
|
|
||||||
// 'plant_id' => $plant->id,
|
|
||||||
// 'document_number' => $DocNo,
|
|
||||||
// 'distribution_channel_desc' => $DisChaDesc,
|
|
||||||
// 'customer_code' => $CustomerCode,
|
|
||||||
// 'document_date' => $formattedDate,
|
|
||||||
// 'customer_trade_name' => $CusTradeName,
|
|
||||||
// 'customer_location' => $CusLocation,
|
|
||||||
// 'created_by' => $operatorName
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
if (!$inserted) {
|
|
||||||
throw new \Exception("{$curStat} failed for Document Number : {$DocNo}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$successCount++;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$failedRecords[] = [
|
|
||||||
'row' => $rowNumber,
|
|
||||||
'document_number' => $DocNo ?? null,
|
|
||||||
'error' => $e->getMessage()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
|
|
||||||
if (count($failedRecords) > 0) {
|
|
||||||
$failedSummary = collect($failedRecords)
|
|
||||||
->map(fn($f) => "Row {$f['row']} ({$f['document_number']}) : {$f['error']}")
|
|
||||||
->take(5) // limit preview to first 5 errors
|
|
||||||
->implode("\n");
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Partial Import Warning')
|
|
||||||
->body("'{$successCount}' records inserted. " . count($failedRecords) . " failed.\n\n{$failedSummary}")
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
} else {
|
|
||||||
Notification::make()
|
|
||||||
->title('Import Success')
|
|
||||||
->body("Successfully imported '{$successCount}' records.")
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
DB::rollBack();
|
|
||||||
Notification::make()
|
|
||||||
->title('Import Failed')
|
|
||||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import invoice data validation');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export Invoice Data')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(InvoiceDataValidationExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export invoice data validation');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListInvoiceDataValidations::route('/'),
|
|
||||||
'create' => Pages\CreateInvoiceDataValidation::route('/create'),
|
|
||||||
'view' => Pages\ViewInvoiceDataValidation::route('/{record}'),
|
|
||||||
'edit' => Pages\EditInvoiceDataValidation::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\InvoiceDataValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateInvoiceDataValidation extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceDataValidationResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\InvoiceDataValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditInvoiceDataValidation extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceDataValidationResource::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\InvoiceDataValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListInvoiceDataValidations extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceDataValidationResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\InvoiceDataValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceDataValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewInvoiceDataValidation extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceDataValidationResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,537 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Exports\InvoiceOutValidationExporter;
|
|
||||||
use App\Filament\Resources\InvoiceOutValidationResource\Pages;
|
|
||||||
use App\Filament\Resources\InvoiceOutValidationResource\RelationManagers;
|
|
||||||
use App\Models\InvoiceOutValidation;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use App\Models\User;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use DB;
|
|
||||||
use Filament\Forms;
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Resources\Resource;
|
|
||||||
use Filament\Tables;
|
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\FileUpload;
|
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
|
||||||
use Storage;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
|
|
||||||
|
|
||||||
class InvoiceOutValidationResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = InvoiceOutValidation::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Invoice Management';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Section::make('')
|
|
||||||
->schema([
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('qr_code')
|
|
||||||
->label('QR Code'),
|
|
||||||
Forms\Components\DateTimePicker::make('scanned_at')
|
|
||||||
->label('Scanned At'),
|
|
||||||
Forms\Components\TextInput::make('scanned_by')
|
|
||||||
->label('Scanned By'),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->default(Filament::auth()->user()?->name),
|
|
||||||
])
|
|
||||||
->columns(4),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.code')
|
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('qr_code')
|
|
||||||
->label('QR Code')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('scanned_at')
|
|
||||||
->label('Scanned At')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->dateTime()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('scanned_by')
|
|
||||||
->label('Scanned By')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->searchable()
|
|
||||||
->dateTime()
|
|
||||||
->sortable(),
|
|
||||||
//->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('created_by')
|
|
||||||
->label('Created By')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('updated_at')
|
|
||||||
->dateTime()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
// ->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('updated_by')
|
|
||||||
->label('Updated By')
|
|
||||||
->searchable()
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('deleted_at')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
])
|
|
||||||
->filters([
|
|
||||||
Tables\Filters\TrashedFilter::make(),
|
|
||||||
])
|
|
||||||
->actions([
|
|
||||||
Tables\Actions\ViewAction::make(),
|
|
||||||
Tables\Actions\EditAction::make(),
|
|
||||||
])
|
|
||||||
->bulkActions([
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->headerActions([
|
|
||||||
Tables\Actions\Action::make('Import Invoice Out Data')
|
|
||||||
->label('Import Invoice Out Data')
|
|
||||||
->form([
|
|
||||||
FileUpload::make('invoice_data_file')
|
|
||||||
->label('Invoice Out Data')
|
|
||||||
// ->required()
|
|
||||||
->preserveFilenames()
|
|
||||||
->storeFiles(false)
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->disk('local')
|
|
||||||
//->visible(fn (Get $get) => !empty($get('plant_id')))
|
|
||||||
->directory('uploads/temp'),
|
|
||||||
])
|
|
||||||
->action(function (array $data) {
|
|
||||||
$uploadedFile = $data['invoice_data_file'];
|
|
||||||
|
|
||||||
$disk = Storage::disk('local');
|
|
||||||
|
|
||||||
$user = Filament::auth()->user();
|
|
||||||
|
|
||||||
$operatorName = $user->name;
|
|
||||||
|
|
||||||
// Get original filename
|
|
||||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
|
||||||
|
|
||||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
|
||||||
|
|
||||||
// Store manually using storeAs to keep original name
|
|
||||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
|
||||||
|
|
||||||
$fullPath = Storage::disk('local')->path($path);
|
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
|
||||||
|
|
||||||
if ((count($rows) - 1) <= 0)
|
|
||||||
{
|
|
||||||
Notification::make()
|
|
||||||
->title('Records Not Found')
|
|
||||||
->body("Import the valid 'Invoice Data' file to proceed..!")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invalidPlantCode = [];
|
|
||||||
$invalidPlaCoFound = [];
|
|
||||||
$invalidqrCode = [];
|
|
||||||
$invalidScannedAt = [];
|
|
||||||
$invalidScannedBy = [];
|
|
||||||
$invalidUser = [];
|
|
||||||
$userNotFound = [];
|
|
||||||
$seenPlantQr = [];
|
|
||||||
$duplicateQrExcel = [];
|
|
||||||
//$duplicateQrDb = [];
|
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
|
||||||
{
|
|
||||||
if ($index == 0) continue;
|
|
||||||
|
|
||||||
$qrCode = trim($row[1]);
|
|
||||||
$plantCode = trim($row[2]);
|
|
||||||
$scannedAt = trim($row[3]);
|
|
||||||
$scannedby = trim($row[4]);
|
|
||||||
|
|
||||||
if (empty($plantCode)) $invalidPlantCode[] = "Row {$index}";
|
|
||||||
if (empty($qrCode)) $invalidqrCode[] = "Row {$index}";
|
|
||||||
if (empty($scannedAt)) $invalidScannedAt[] = "Row {$index}";
|
|
||||||
if (empty($scannedby)) $invalidScannedBy[] = "Row {$index}";
|
|
||||||
|
|
||||||
if (strlen($plantCode) < 4) {
|
|
||||||
$invalidPlantCode[] = $plantCode;
|
|
||||||
}
|
|
||||||
else if(!Plant::where('code', $plantCode)->first())
|
|
||||||
{
|
|
||||||
$invalidPlaCoFound[] = $plantCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
|
||||||
|
|
||||||
$plantId = $plant->id;
|
|
||||||
|
|
||||||
$uniqueKey = $plantCode . '_' . $qrCode;
|
|
||||||
|
|
||||||
if (in_array($uniqueKey, $seenPlantQr)) {
|
|
||||||
$duplicateQrExcel[] = "Duplicate in file at Row {$index}: Document Number '{$qrCode}' already exists for Plant '{$plant->name}'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$seenPlantQr[] = $uniqueKey;
|
|
||||||
|
|
||||||
// $existsInDb = InvoiceOutValidation::where('plant_id', $plantId)
|
|
||||||
// ->where('qr_code', $qrCode)
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// if ($existsInDb) {
|
|
||||||
// $duplicateQrDb[] = "Document Numbers '{$qrCode}' already exists in DB for Plant '{$plant->name}'";
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($invalidqrCode) || !empty($invalidScannedAt) || !empty($invalidScannedBy) || !empty($invalidUser))
|
|
||||||
{
|
|
||||||
$errorMsg = '';
|
|
||||||
|
|
||||||
if (!empty($invalidqrCode)) $errorMsg .= 'Missing Qr code in rows: '.implode(', ', $invalidqrCode) . '<br>';
|
|
||||||
if (!empty($invalidScannedAt)) $errorMsg .= 'Missing Scanned At in rows: '.implode(', ', $invalidScannedAt) . '<br>';
|
|
||||||
if (!empty($invalidScannedBy)) $errorMsg .= 'Missing Scanned By in rows: '.implode(', ', $invalidScannedBy) . '<br>';
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Missing Mandatory Fields')
|
|
||||||
->body($errorMsg)
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($invalidPlantCode)) {
|
|
||||||
$invalidPlantCode = array_unique($invalidPlantCode);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid Plant Codes')
|
|
||||||
->body('The following plant codes should contain minimum 4 digits:<br>' . implode(', ', $invalidPlantCode))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($invalidPlaCoFound)) {
|
|
||||||
$invalidPlaCoFound = array_unique($invalidPlaCoFound);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid Plant Codes')
|
|
||||||
->body('The following plant codes not found in plants:<br>' . implode(', ', $invalidPlaCoFound))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($userNotFound)) {
|
|
||||||
$userNotFound = array_unique($userNotFound);
|
|
||||||
Notification::make()
|
|
||||||
->title('Invalid User')
|
|
||||||
->body('The following user not found:<br>' . implode(', ', $userNotFound))
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($duplicateQrExcel))
|
|
||||||
{
|
|
||||||
$duplicateGroupedByPlantQr = [];
|
|
||||||
|
|
||||||
foreach ($duplicateQrExcel as $message) {//"/Document Numbers '([^']+)' already exists for Plant Code (\S+)/"
|
|
||||||
if (preg_match("/Document Number '([^']+)' already exists for Plant '([^']+)'/", $message, $matches)) {
|
|
||||||
$qrCode = $matches[1];
|
|
||||||
$plantCode = $matches[2];
|
|
||||||
$duplicateGroupedByPlantQr[$plantCode][] = $qrCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$errorMsg = 'Duplicate Document Number found in Uploaded File :<br>';
|
|
||||||
|
|
||||||
foreach ($duplicateGroupedByPlantQr as $plantCode => $qrCodes) {
|
|
||||||
$uniqueQrCodes = array_unique($qrCodes);
|
|
||||||
$count = count($uniqueQrCodes);
|
|
||||||
|
|
||||||
if ($count > 10) {
|
|
||||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b> : {$count} Document Numbers already exist in uploaded file<br>";
|
|
||||||
} else {
|
|
||||||
$errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b> : '"
|
|
||||||
. implode(', ', $uniqueQrCodes)
|
|
||||||
. "' already exist in uploaded file<br>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
//->title('Duplicate Document Number in Uploaded File')
|
|
||||||
->body($errorMsg)
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
|
||||||
$disk->delete($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (!empty($duplicateQrDb)) {
|
|
||||||
// $duplicateGroupedByPlantDb = [];
|
|
||||||
|
|
||||||
// foreach ($duplicateQrDb as $message) {
|
|
||||||
// if (preg_match("/Document Numbers '([^']+)' already exists in DB for Plant '([^']+)'/", $message, $matches)) {
|
|
||||||
// $qrCode = $matches[1];
|
|
||||||
// $plantCode = $matches[2];
|
|
||||||
// $duplicateGroupedByPlantDb[$plantCode][] = $qrCode;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $errorMsg = 'Duplicate Document Numbers found in Database:<br>';
|
|
||||||
|
|
||||||
// foreach ($duplicateGroupedByPlantDb as $plantCode => $qrCodes) {
|
|
||||||
// $uniqueQrCodes = array_unique($qrCodes);
|
|
||||||
// $count = count($uniqueQrCodes);
|
|
||||||
|
|
||||||
// if ($count > 10) {
|
|
||||||
// $errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b>: {$count} Document Numbers already exist in DB<br>";
|
|
||||||
// } else {
|
|
||||||
// $errorMsg .= "Duplicate Document Numbers for Plant <b>{$plantCode}</b>: "
|
|
||||||
// . implode(', ', $uniqueQrCodes)
|
|
||||||
// . " already exist in DB<br>";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Notification::make()
|
|
||||||
// // ->title('Duplicate Document Numbers in Database')
|
|
||||||
// ->body($errorMsg)
|
|
||||||
// ->danger()
|
|
||||||
// ->send();
|
|
||||||
|
|
||||||
// if ($disk->exists($path)) {
|
|
||||||
// $disk->delete($path);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
$successCount = 0;
|
|
||||||
$failedRecords = [];
|
|
||||||
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach ($rows as $index => $row) {
|
|
||||||
if ($index == 0) continue;
|
|
||||||
|
|
||||||
$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");
|
|
||||||
}
|
|
||||||
|
|
||||||
$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()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
|
|
||||||
if (count($failedRecords) > 0) {
|
|
||||||
$failedSummary = collect($failedRecords)
|
|
||||||
->map(fn($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
|
||||||
->take(5) // limit preview to first 5 errors
|
|
||||||
->implode("\n");
|
|
||||||
|
|
||||||
Notification::make()
|
|
||||||
->title('Partial Import Warning')
|
|
||||||
->body("'{$successCount}' records inserted. " . count($failedRecords) . " failed.\n\n{$failedSummary}")
|
|
||||||
->warning()
|
|
||||||
->send();
|
|
||||||
} else {
|
|
||||||
Notification::make()
|
|
||||||
->title('Import Success')
|
|
||||||
->body("Successfully imported '{$successCount}' records.")
|
|
||||||
->success()
|
|
||||||
->send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
DB::rollBack();
|
|
||||||
Notification::make()
|
|
||||||
->title('Import Failed')
|
|
||||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
|
||||||
->danger()
|
|
||||||
->send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view import invoice out validation');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export Invoice Out Data')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(InvoiceOutValidationExporter::class)
|
|
||||||
->visible(function() {
|
|
||||||
return Filament::auth()->user()->can('view export invoice out validation');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListInvoiceOutValidations::route('/'),
|
|
||||||
'create' => Pages\CreateInvoiceOutValidation::route('/create'),
|
|
||||||
'view' => Pages\ViewInvoiceOutValidation::route('/{record}'),
|
|
||||||
'edit' => Pages\EditInvoiceOutValidation::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\InvoiceOutValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceOutValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateInvoiceOutValidation extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceOutValidationResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\InvoiceOutValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceOutValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditInvoiceOutValidation extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceOutValidationResource::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\InvoiceOutValidationResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceOutValidationResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListInvoiceOutValidations extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = InvoiceOutValidationResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user