Compare commits
1 Commits
f9e362784f
...
renovate/c
| Author | SHA1 | Date | |
|---|---|---|---|
| 090bcff02a |
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\LaserStopMail;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LaserStopConsolidateReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:laser-stop-consolidate-report {schedule_type} {plant} {machine_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
$machineId = (int) $this->argument('machine_id');
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'LaserStopReport')
|
||||
->where('rule_name', 'LaserStopMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
$emails = $mailRules
|
||||
->pluck('email')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = $mailRules
|
||||
->pluck('cc_emails')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$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(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
$plantName = $plant?->name ?? $plantId;
|
||||
|
||||
$machine = Machine::find($machineId);
|
||||
|
||||
$machineName = $machine?->work_center ?? $machineId;
|
||||
|
||||
$records = ClassCharacteristic::where('is_stopped', '!=', 0)
|
||||
->where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->get();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No laser stop records found.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Send mail to mapped email IDs
|
||||
Mail::to($emails)
|
||||
->cc($ccEmails)
|
||||
->send(
|
||||
new LaserStopMail(
|
||||
$records,
|
||||
$plantId,
|
||||
$machineId,
|
||||
$plantName,
|
||||
$machineName,
|
||||
)
|
||||
);
|
||||
|
||||
$this->info('Laser stop final report mail sent successfully.');
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '08:00') {
|
||||
if (now()->format('H:i') == '11:10') {
|
||||
try {
|
||||
\Artisan::call('send-import-transit', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
@@ -394,89 +394,11 @@ class Scheduler extends Command
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//..Laser Stop Report
|
||||
$laserStopReport = AlertMailRule::where('module', 'LaserStopAlert')
|
||||
->where('rule_name', 'LaserStopAlertMail')
|
||||
->select('plant', 'schedule_type', 'machine_id')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($laserStopReport as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:laser-stop-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//..Laser Stop Final Report
|
||||
|
||||
$laserStopFinalReport = AlertMailRule::where('module', 'LaserStopReport')
|
||||
->where('rule_name', 'LaserStopMail')
|
||||
->select('plant', 'schedule_type', 'machine_id')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($laserStopFinalReport as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '08:00') {
|
||||
\Artisan::call('send:laser-stop-consolidate-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
'machine_id' => $rule->machine_id,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to call Artisan commands with parameters.
|
||||
*/
|
||||
*/
|
||||
protected function callArtisanCommand($commandName, $rule)
|
||||
{
|
||||
\Artisan::call($commandName, [
|
||||
|
||||
@@ -4,13 +4,9 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ImportTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\ImportTransit;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Console\Command;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\ImportTransitReportExport;
|
||||
|
||||
class SendImportTransit extends Command
|
||||
{
|
||||
@@ -55,14 +51,44 @@ class SendImportTransit extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$tableData = ImportTransit::where('status', '!=', 'Delivered')->orderByRaw("
|
||||
CASE
|
||||
WHEN cri_rfq_number ~ '[0-9]+'
|
||||
THEN CAST(regexp_replace(cri_rfq_number, '[^0-9]', '', 'g') AS INTEGER)
|
||||
ELSE NULL
|
||||
END NULLS LAST
|
||||
")->get();
|
||||
// $todayRecordExists = ImportTransit::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
// if (!$todayRecordExists) {
|
||||
// $this->info('No records created today. Mail not sent.');
|
||||
// return;
|
||||
// }
|
||||
|
||||
$tableData = ImportTransit::select([
|
||||
'cri_rfq_number',
|
||||
'mail_received_date',
|
||||
'pricol_ref_number',
|
||||
'requester',
|
||||
'shipper',
|
||||
'shipper_location',
|
||||
'shipper_invoice',
|
||||
'shipper_invoice_date',
|
||||
'customs_agent_name',
|
||||
'eta_date',
|
||||
'status',
|
||||
'delivery_location',
|
||||
'etd_date',
|
||||
'mode',
|
||||
'inco_terms',
|
||||
'port_of_loading',
|
||||
'port_of_discharge',
|
||||
'delivery_city',
|
||||
'packages',
|
||||
'type_of_package',
|
||||
'gross_weight',
|
||||
'volume',
|
||||
'bill_number',
|
||||
'bill_received_date',
|
||||
'vessel_number',
|
||||
'remark',
|
||||
'is_transit_identified',
|
||||
])
|
||||
->where('status', '!=', 'Delivered')
|
||||
->get();
|
||||
|
||||
if ($tableData->isEmpty()) {
|
||||
$this->info('No pending Import Transit records found. Mail skipped.');
|
||||
@@ -75,30 +101,10 @@ class SendImportTransit extends Command
|
||||
|
||||
$mailSubject = 'Daily Import Transit Report';
|
||||
|
||||
$fileName = 'reports/pending_import_shipment_' . now()->format('Ymd_His') . '.xlsx';
|
||||
|
||||
Excel::store(
|
||||
new ImportTransitReportExport($tableData),
|
||||
$fileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
$updatedBy = $tableData->last()?->updated_by;
|
||||
|
||||
$employee = EmployeeMaster::where('code', $updatedBy)
|
||||
->select('name', 'mobile_number')
|
||||
->first();
|
||||
|
||||
$employeeName = $employee?->name;
|
||||
$mobileNumber = $employee?->mobile_number;
|
||||
|
||||
$mail = new ImportTransitMail(
|
||||
$scheduleType,
|
||||
$tableData,
|
||||
$mailSubject,
|
||||
$fileName,
|
||||
$employeeName,
|
||||
$mobileNumber,
|
||||
$mailSubject
|
||||
);
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
@@ -124,9 +130,11 @@ class SendImportTransit extends Command
|
||||
->cc($ccEmails)
|
||||
->send($mail);
|
||||
|
||||
$this->info("Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails));
|
||||
|
||||
$this->info(
|
||||
"Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\LaserStopReportMail;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendLaserStopReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:laser-stop-report {schedule_type} {plant} {machine_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
$machineId = (int) $this->argument('machine_id');
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'LaserStopAlert')
|
||||
->where('rule_name', 'LaserStopAlertMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
$emails = $mailRules
|
||||
->pluck('email')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$ccEmails = $mailRules
|
||||
->pluck('cc_emails')
|
||||
->filter()
|
||||
->flatMap(function ($email) {
|
||||
return array_map('trim', explode(',', $email));
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$plants = $plantId == 0
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
$plantName = $plant?->name ?? $plantId;
|
||||
|
||||
$machine = Machine::find($machineId);
|
||||
|
||||
$machineName = $machine?->work_center ?? $machineId;
|
||||
|
||||
$records = ClassCharacteristic::where('is_stopped', 2)
|
||||
->where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No laser stop records found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$recordIds = $records->pluck('id');
|
||||
|
||||
// Send mail to mapped email IDs
|
||||
Mail::to($emails)
|
||||
->cc($ccEmails)
|
||||
->send(
|
||||
new LaserStopReportMail(
|
||||
$records,
|
||||
$plantId,
|
||||
$machineId,
|
||||
$plantName,
|
||||
$machineName,
|
||||
)
|
||||
);
|
||||
|
||||
ClassCharacteristic::whereIn('id', $recordIds)
|
||||
->update([
|
||||
'is_stopped' => 1,
|
||||
]);
|
||||
|
||||
$this->info('Laser stop report mail sent successfully.');
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class SendVehicleReport extends Command
|
||||
'type',
|
||||
])
|
||||
->where('plant_id', $plant->id)
|
||||
->whereBetween('entry_time', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->get();
|
||||
|
||||
if ($vehicleEntries->isEmpty()) {
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
|
||||
class ImportTransitReportExport implements FromCollection, WithHeadings, WithMapping, WithEvents
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'CRI RFQ Number',
|
||||
'Requestor',
|
||||
'Shipper',
|
||||
'Shipper Location',
|
||||
'Shipper Invoice',
|
||||
'Shipper Invoice Date',
|
||||
'Custom Agent Name',
|
||||
'ETA',
|
||||
'Status',
|
||||
'Delivery Location',
|
||||
'ETD Date',
|
||||
'Remark',
|
||||
];
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->data);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
static $srNo = 0;
|
||||
$srNo++;
|
||||
|
||||
return [
|
||||
$srNo,
|
||||
$row->cri_rfq_number,
|
||||
$row->requester,
|
||||
$row->shipper,
|
||||
$row->shipper_location,
|
||||
$row->shipper_invoice,
|
||||
$row->shipper_invoice_date,
|
||||
$row->customs_agent_name,
|
||||
$row->eta_date,
|
||||
$row->status,
|
||||
$row->delivery_location,
|
||||
$row->etd_date,
|
||||
$row->remark,
|
||||
];
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
|
||||
$rowNumber = 2; // Excel row starts after header
|
||||
|
||||
foreach ($this->data as $row) {
|
||||
|
||||
if ((int) $row->is_transit_identified == 1) {
|
||||
|
||||
$event->sheet
|
||||
->getStyle("A{$rowNumber}:M{$rowNumber}")
|
||||
->applyFromArray([
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'startColor' => [
|
||||
'rgb' => 'FFFF00',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$rowNumber++;
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Illuminate\Support\Collection;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
|
||||
|
||||
class SerialExport extends DefaultValueBinder implements FromCollection, WithHeadings, WithCustomValueBinder
|
||||
, WithColumnFormatting
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
protected $itemCode;
|
||||
protected $fromSerial;
|
||||
protected $toSerial;
|
||||
|
||||
public function __construct($itemCode, $fromSerial, $toSerial)
|
||||
{
|
||||
$this->itemCode = $itemCode;
|
||||
$this->fromSerial = $fromSerial;
|
||||
$this->toSerial = $toSerial;
|
||||
}
|
||||
|
||||
public function bindValue(Cell $cell, $value)
|
||||
{
|
||||
$cell->setValueExplicit((string) $value, DataType::TYPE_STRING);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
for ($i = $this->fromSerial; $i <= $this->toSerial; $i++) {
|
||||
$rows[] = [
|
||||
'item_code' => $this->itemCode,
|
||||
'serial_number' => str_pad($i, 6, '0', STR_PAD_LEFT),
|
||||
];
|
||||
}
|
||||
|
||||
return new Collection($rows);
|
||||
}
|
||||
|
||||
public function columnFormats(): array
|
||||
{
|
||||
return [
|
||||
'B' => NumberFormat::FORMAT_TEXT,
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Item Code',
|
||||
'Serial Number',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,6 @@ class AlertMailRuleExporter extends Exporter
|
||||
$plant = Plant::find($state);
|
||||
return $plant ? $plant->code : 'Unknown';
|
||||
}),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('cc_emails')
|
||||
->label('CC EMAILS'),
|
||||
ExportColumn::make('invoiceMaster.receiving_plant_name')
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\BeforeTestReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class BeforeTestReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = BeforeTestReading::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('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('motorTestingMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('motorTestingMaster.item.description')
|
||||
->label('MODEL DESCRIPTION'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('motorTestingMaster.kw')
|
||||
->label('KW'),
|
||||
ExportColumn::make('motorTestingMaster.hp')
|
||||
->label('HP'),
|
||||
ExportColumn::make('motorTestingMaster.phase')
|
||||
->label('PHASE'),
|
||||
ExportColumn::make('motorTestingMaster.connection')
|
||||
->label('CONNECTION'),
|
||||
ExportColumn::make('motorTestingMaster.isi_model')
|
||||
->label('ISI MODEL'),
|
||||
ExportColumn::make('before_fr_res_ry')
|
||||
->label('BEFORE FR RESISTANCE RY'),
|
||||
ExportColumn::make('before_fr_res_yb')
|
||||
->label('BEFORE FR RESISTANCE YB'),
|
||||
ExportColumn::make('before_fr_res_br')
|
||||
->label('BEFORE FR RESISTANCE BR'),
|
||||
ExportColumn::make('before_fr_ir')
|
||||
->label('BEFORE FR IR'),
|
||||
ExportColumn::make('tested_by')
|
||||
->label('TESTED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your before test 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;
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,6 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('class')
|
||||
@@ -210,7 +201,7 @@ class ClassCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWERFACTOR'),
|
||||
ExportColumn::make('zmm_tagno')
|
||||
->label('ZMM TAGNO'),
|
||||
->label('ZMM TANGO'),
|
||||
ExportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
@@ -309,23 +300,14 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)')),
|
||||
ExportColumn::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME'),
|
||||
ExportColumn::make('stopped_by')
|
||||
->label('STOPPED BY'),
|
||||
ExportColumn::make('mark_status')
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME'),
|
||||
ExportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME'),
|
||||
ExportColumn::make('marked_by')
|
||||
->label('MARKED BY'),
|
||||
ExportColumn::make('man_marked_status')
|
||||
@@ -340,8 +322,6 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('MOTOR MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME'),
|
||||
ExportColumn::make('motor_marked_datetime')
|
||||
->label('MOTOR MARKED DATETIME'),
|
||||
ExportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY'),
|
||||
ExportColumn::make('pump_marked_status')
|
||||
@@ -350,24 +330,18 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('PUMP MARKED PHYSICAL COUNT'),
|
||||
ExportColumn::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME'),
|
||||
ExportColumn::make('pump_marked_datetime')
|
||||
->label('PUMP MARKED DATETIME'),
|
||||
ExportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY'),
|
||||
ExportColumn::make('name_plate_marked_status')
|
||||
->label('NAME PLATE MARKED STATUS'),
|
||||
ExportColumn::make('name_plate_expected_time')
|
||||
->label('NAME PLATE EXPECTED TIME'),
|
||||
ExportColumn::make('name_plate_marked_datetime')
|
||||
->label('NAME PLATE MARKED DATETIME'),
|
||||
ExportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY'),
|
||||
ExportColumn::make('motor_pump_pumpset_status')
|
||||
->label('MOTOR PUMP PUMPSET STATUS'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('winded_rework_status')
|
||||
->label('WINDED REWORK STATUS'),
|
||||
ExportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME'),
|
||||
ExportColumn::make('pump_machine_name')
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\DealerVisitPlan;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class DealerVisitPlanExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = DealerVisitPlan::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('name')
|
||||
->label('DEALER NAME'),
|
||||
ExportColumn::make('company')
|
||||
->label('DEALER COMPANY'),
|
||||
ExportColumn::make('visit_plan_date')
|
||||
->label('VISIT PLAN DATE'),
|
||||
ExportColumn::make('organizer')
|
||||
->label('ORGANIZER'),
|
||||
ExportColumn::make('employeeMaster.name')
|
||||
->label('RECIPIENT NAME'),
|
||||
ExportColumn::make('number_of_person')
|
||||
->label('NUMBER OF PERSON'),
|
||||
ExportColumn::make('purpose_of_visit')
|
||||
->label('PURPOSE OF VISIT'),
|
||||
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 dealer visit plan 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;
|
||||
}
|
||||
}
|
||||
@@ -36,18 +36,12 @@ class ImportTransitExporter extends Exporter
|
||||
->label('SHIPPER INVOICE'),
|
||||
ExportColumn::make('shipper_invoice_date')
|
||||
->label('SHIPPER INVOICE DATE'),
|
||||
ExportColumn::make('inv_value')
|
||||
->label('Inv Value'),
|
||||
ExportColumn::make('freight_charge')
|
||||
->label('Freight Charge'),
|
||||
ExportColumn::make('customs_agent_name')
|
||||
->label('CUSTOMS AGENT NAME'),
|
||||
ExportColumn::make('eta_date')
|
||||
->label('ETA DATE'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('insurance_status')
|
||||
->label('Insurance Status'),
|
||||
ExportColumn::make('delivery_location')
|
||||
->label('DELIVERY LOCATION'),
|
||||
ExportColumn::make('etd_date')
|
||||
|
||||
@@ -36,6 +36,15 @@ class InvoiceValidationExporter extends Exporter
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('stickerMaster.item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('stickerMaster.material_type')
|
||||
->label('MATERIAL TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
@@ -56,6 +65,10 @@ class InvoiceValidationExporter extends Exporter
|
||||
->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')
|
||||
@@ -77,7 +90,7 @@ class InvoiceValidationExporter extends Exporter
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your serial invoice validation export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
$body = 'Your invoice validation export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
|
||||
@@ -1,355 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ItemCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ItemCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ItemCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('class')
|
||||
->label('CLASS'),
|
||||
ExportColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORDER'),
|
||||
ExportColumn::make('zmm_amps')
|
||||
->label('ZMM AMPS'),
|
||||
ExportColumn::make('zmm_brand')
|
||||
->label('ZMM BRAND'),
|
||||
ExportColumn::make('zmm_degreeofprotection')
|
||||
->label('ZMM DEGREE OF PROTECTION'),
|
||||
ExportColumn::make('zmm_delivery')
|
||||
->label('ZMM DELIVERY'),
|
||||
ExportColumn::make('zmm_dir_rot')
|
||||
->label('ZMM DIRECTION OF ROTATION'),
|
||||
ExportColumn::make('zmm_discharge')
|
||||
->label('ZMM DISCHARGE'),
|
||||
ExportColumn::make('zmm_discharge_max')
|
||||
->label('ZMM DISCHARGE MAX'),
|
||||
ExportColumn::make('zmm_discharge_min')
|
||||
->label('ZMM DISCHARGE MIN'),
|
||||
ExportColumn::make('zmm_duty')
|
||||
->label('ZMM DUTY'),
|
||||
ExportColumn::make('zmm_eff_motor')
|
||||
->label('ZMM EFF MOTOR'),
|
||||
ExportColumn::make('zmm_eff_pump')
|
||||
->label('ZMM EFF PUMP'),
|
||||
ExportColumn::make('zmm_frequency')
|
||||
->label('ZMM FREQUENCY'),
|
||||
ExportColumn::make('zmm_head')
|
||||
->label('ZMM HEAD'),
|
||||
ExportColumn::make('zmm_heading')
|
||||
->label('ZMM HEADING'),
|
||||
ExportColumn::make('zmm_head_max')
|
||||
->label('ZMM HEAD MAX'),
|
||||
ExportColumn::make('zmm_head_minimum')
|
||||
->label('ZMM HEAD MINIMUM'),
|
||||
ExportColumn::make('zmm_idx_eff_mtr')
|
||||
->label('ZMM IDX EFF MTR'),
|
||||
ExportColumn::make('zmm_idx_eff_pump')
|
||||
->label('ZMM IDX EFF PUMP'),
|
||||
ExportColumn::make('zmm_kvacode')
|
||||
->label('ZMM KVACODE'),
|
||||
ExportColumn::make('zmm_maxambtemp')
|
||||
->label('ZMM MAXAMB TEMP'),
|
||||
ExportColumn::make('zmm_mincoolingflow')
|
||||
->label('ZMM MIN COOLING FLOW'),
|
||||
ExportColumn::make('zmm_motorseries')
|
||||
->label('ZMM MOTOR SERIES'),
|
||||
ExportColumn::make('zmm_motor_model')
|
||||
->label('ZMM MOTOR MODEL'),
|
||||
ExportColumn::make('zmm_outlet')
|
||||
->label('ZMM OUTLET'),
|
||||
ExportColumn::make('zmm_phase')
|
||||
->label('ZMM PHASE'),
|
||||
ExportColumn::make('zmm_pressure')
|
||||
->label('ZMM PRESSURE'),
|
||||
ExportColumn::make('zmm_pumpflowtype')
|
||||
->label('ZMM PUMP FLOW TYPE'),
|
||||
ExportColumn::make('zmm_pumpseries')
|
||||
->label('ZMM PUMP SERIES'),
|
||||
ExportColumn::make('zmm_pump_model')
|
||||
->label('ZMM PUMP MODEL'),
|
||||
ExportColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATED POWER'),
|
||||
ExportColumn::make('zmm_region')
|
||||
->label('ZMM REGION'),
|
||||
ExportColumn::make('zmm_servicefactor')
|
||||
->label('ZMM SERVICE FACTOR'),
|
||||
ExportColumn::make('zmm_servicefactormaximumamps')
|
||||
->label('ZMM SERVICE FACTOR MAXIMUM AMPS'),
|
||||
ExportColumn::make('zmm_speed')
|
||||
->label('ZMM SPEED'),
|
||||
ExportColumn::make('zmm_suction')
|
||||
->label('ZMM SUCTION'),
|
||||
ExportColumn::make('zmm_suctionxdelivery')
|
||||
->label('ZMM SUCTION X DELIVERY'),
|
||||
ExportColumn::make('zmm_supplysource')
|
||||
->label('ZMM SUPPLY SOURCE'),
|
||||
ExportColumn::make('zmm_temperature')
|
||||
->label('ZMM TEMPERATURE'),
|
||||
ExportColumn::make('zmm_thrustload')
|
||||
->label('ZMM THRUST LOAD'),
|
||||
ExportColumn::make('zmm_volts')
|
||||
->label('ZMM VOLTS'),
|
||||
ExportColumn::make('zmm_wire')
|
||||
->label('ZMM WIRE'),
|
||||
ExportColumn::make('zmm_package')
|
||||
->label('ZMM PACKAGE'),
|
||||
ExportColumn::make('zmm_pvarrayrating')
|
||||
->label('ZMM PV ARRAY RATING'),
|
||||
ExportColumn::make('zmm_isi')
|
||||
->label('ZMM ISI'),
|
||||
ExportColumn::make('zmm_isimotor')
|
||||
->label('ZMM ISI MOTOR'),
|
||||
ExportColumn::make('zmm_isipump')
|
||||
->label('ZMM ISI PUMP'),
|
||||
ExportColumn::make('zmm_isipumpset')
|
||||
->label('ZMM ISI PUMPSET'),
|
||||
ExportColumn::make('zmm_pumpset_model')
|
||||
->label('ZMM PUMPSET MODEL'),
|
||||
ExportColumn::make('zmm_stages')
|
||||
->label('ZMM STAGES'),
|
||||
ExportColumn::make('zmm_headrange')
|
||||
->label('ZMM HEAD RANGE'),
|
||||
ExportColumn::make('zmm_overall_efficiency')
|
||||
->label('ZMM OVERALL EFFICIENCY'),
|
||||
ExportColumn::make('zmm_connection')
|
||||
->label('ZMM CONNECTION'),
|
||||
ExportColumn::make('zmm_min_bore_size')
|
||||
->label('ZMM MIN BORE SIZE'),
|
||||
ExportColumn::make('zmm_isireference')
|
||||
->label('ZMM ISI REFERENCE'),
|
||||
ExportColumn::make('zmm_category')
|
||||
->label('ZMM CATEGORY'),
|
||||
ExportColumn::make('zmm_submergence')
|
||||
->label('ZMM SUBMERGENCE'),
|
||||
ExportColumn::make('zmm_capacitorstart')
|
||||
->label('ZMM CAPACITOR START'),
|
||||
ExportColumn::make('zmm_capacitorrun')
|
||||
->label('ZMM CAPACITOR RUN'),
|
||||
ExportColumn::make('zmm_inch')
|
||||
->label('ZMM INCH'),
|
||||
ExportColumn::make('zmm_motor_type')
|
||||
->label('ZMM MOTOR TYPE'),
|
||||
ExportColumn::make('zmm_dismantle_direction')
|
||||
->label('ZMM DISMANTLE DIRECTION'),
|
||||
ExportColumn::make('zmm_eff_ovrall')
|
||||
->label('ZMM EFF OVRALL'),
|
||||
ExportColumn::make('zmm_bodymoc')
|
||||
->label('ZMM BODY MOC'),
|
||||
ExportColumn::make('zmm_rotormoc')
|
||||
->label('ZMM ROTOR MOC'),
|
||||
ExportColumn::make('zmm_dlwl')
|
||||
->label('ZMM DLWL'),
|
||||
ExportColumn::make('zmm_inputpower')
|
||||
->label('ZMM INPUT POWER'),
|
||||
ExportColumn::make('zmm_imp_od')
|
||||
->label('ZMM IMP OD'),
|
||||
ExportColumn::make('zmm_ambtemp')
|
||||
->label('ZMM AMBTEMP'),
|
||||
ExportColumn::make('zmm_de')
|
||||
->label('ZMM DE'),
|
||||
ExportColumn::make('zmm_dischargerange')
|
||||
->label('ZMM DISCHARGE RANGE'),
|
||||
ExportColumn::make('zmm_efficiency_class')
|
||||
->label('ZMM EFFICIENCY CLASS'),
|
||||
ExportColumn::make('zmm_framesize')
|
||||
->label('ZMM FRAME SIZE'),
|
||||
ExportColumn::make('zmm_impellerdiameter')
|
||||
->label('ZMM IMPELLER DIAMETER'),
|
||||
ExportColumn::make('zmm_insulationclass')
|
||||
->label('ZMM INSULATION CLASS'),
|
||||
ExportColumn::make('zmm_maxflow')
|
||||
->label('ZMM MAX FLOW'),
|
||||
ExportColumn::make('zmm_minhead')
|
||||
->label('ZMM MIN HEAD'),
|
||||
ExportColumn::make('zmm_mtrlofconst')
|
||||
->label('ZMM MTR LOF CONST'),
|
||||
ExportColumn::make('zmm_nde')
|
||||
->label('ZMM NDE'),
|
||||
ExportColumn::make('zmm_powerfactor')
|
||||
->label('ZMM POWER FACTOR'),
|
||||
ExportColumn::make('zmm_tagno')
|
||||
->label('ZMM TAG NO'),
|
||||
ExportColumn::make('zmm_year')
|
||||
->label('ZMM YEAR'),
|
||||
ExportColumn::make('zmm_laser_name')
|
||||
->label('ZMM LASER NAME'),
|
||||
ExportColumn::make('zmm_beenote')
|
||||
->label('ZMM BEENOTE'),
|
||||
ExportColumn::make('zmm_beenumber')
|
||||
->label('ZMM BEENUMBER'),
|
||||
ExportColumn::make('zmm_beestar')
|
||||
->label('ZMM BEESTAR'),
|
||||
ExportColumn::make('zmm_logo_ce')
|
||||
->label('ZMM LOGO CE'),
|
||||
ExportColumn::make('zmm_codeclass')
|
||||
->label('ZMM CODECLASS'),
|
||||
ExportColumn::make('zmm_colour')
|
||||
->label('ZMM COLOUR'),
|
||||
ExportColumn::make('zmm_logo_cp')
|
||||
->label('ZMM LOGO CP'),
|
||||
ExportColumn::make('zmm_grade')
|
||||
->label('ZMM GRADE'),
|
||||
ExportColumn::make('zmm_grwt_pset')
|
||||
->label('ZMM GRWT PSET'),
|
||||
ExportColumn::make('zmm_grwt_cable')
|
||||
->label('ZMM GRWT CABLE'),
|
||||
ExportColumn::make('zmm_grwt_motor')
|
||||
->label('ZMM GRWT MOTOR'),
|
||||
ExportColumn::make('zmm_grwt_pf')
|
||||
->label('ZMM GRWT PF'),
|
||||
ExportColumn::make('zmm_grwt_pump')
|
||||
->label('ZMM GRWT PUMP'),
|
||||
ExportColumn::make('zmm_isivalve')
|
||||
->label('ZMM ISI VALVE'),
|
||||
ExportColumn::make('zmm_isi_wc')
|
||||
->label('ZMM ISI WC'),
|
||||
ExportColumn::make('zmm_labelperiod')
|
||||
->label('ZMM LABEL PERIOD'),
|
||||
ExportColumn::make('zmm_length')
|
||||
->label('ZMM LENGTH'),
|
||||
ExportColumn::make('zmm_license_cml_no')
|
||||
->label('ZMM LICENSE CML NO'),
|
||||
ExportColumn::make('zmm_mfgmonyr')
|
||||
->label('ZMM MFG MON YR'),
|
||||
ExportColumn::make('zmm_modelyear')
|
||||
->label('ZMM MODEL YEAR'),
|
||||
ExportColumn::make('zmm_motoridentification')
|
||||
->label('ZMM MOTOR IDENTIFICATION'),
|
||||
ExportColumn::make('zmm_newt_pset')
|
||||
->label('ZMM NEWT PSET'),
|
||||
ExportColumn::make('zmm_newt_cable')
|
||||
->label('ZMM NEWT CABLE'),
|
||||
ExportColumn::make('zmm_newt_motor')
|
||||
->label('ZMM NEWT MOTOR'),
|
||||
ExportColumn::make('zmm_newt_pf')
|
||||
->label('ZMM NEWT PF'),
|
||||
ExportColumn::make('zmm_newt_pump')
|
||||
->label('ZMM NEWT PUMP'),
|
||||
ExportColumn::make('zmm_logo_nsf')
|
||||
->label('ZMM LOGO NSF'),
|
||||
ExportColumn::make('zmm_packtype')
|
||||
->label('ZMM PACK TYPE'),
|
||||
ExportColumn::make('zmm_panel')
|
||||
->label('ZMM PANEL'),
|
||||
ExportColumn::make('zmm_performance_factor')
|
||||
->label('ZMM PERFORMANCE FACTOR'),
|
||||
ExportColumn::make('zmm_pumpidentification')
|
||||
->label('ZMM PUMP IDENTIFICATION'),
|
||||
ExportColumn::make('zmm_psettype')
|
||||
->label('ZMM PSET TYPE'),
|
||||
ExportColumn::make('zmm_size')
|
||||
->label('ZMM SIZE'),
|
||||
ExportColumn::make('zmm_eff_ttl')
|
||||
->label('ZMM EFF TTL'),
|
||||
ExportColumn::make('zmm_type')
|
||||
->label('ZMM TYPE'),
|
||||
ExportColumn::make('zmm_usp')
|
||||
->label('ZMM USP'),
|
||||
ExportColumn::make('zmm_operating_range')
|
||||
->label('ZMM OPERATING RANGE'),
|
||||
ExportColumn::make('zmm_intake_air')
|
||||
->label('ZMM INTAKE AIR'),
|
||||
ExportColumn::make('zmm_oxygen_transfer_rate')
|
||||
->label('ZMM OXYGEN TRANSFER RATE'),
|
||||
ExportColumn::make('zmm_air_inlet_pipesize')
|
||||
->label('ZMM AIR INLET PIPE SIZE'),
|
||||
ExportColumn::make('zmm_sump_depth')
|
||||
->label('ZMM SUMP DEPTH'),
|
||||
ExportColumn::make('zmm_poles')
|
||||
->label('ZMM POLES'),
|
||||
ExportColumn::make('zmm_motor_heading')
|
||||
->label('ZMM MOTOR HEADING'),
|
||||
ExportColumn::make('zmm_motor_speed')
|
||||
->label('ZMM MOTOR SPEED'),
|
||||
ExportColumn::make('zqmm_qty')
|
||||
->label('ZMM QTY'),
|
||||
ExportColumn::make('zmm_1')
|
||||
->label('ZMM 1')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_2')
|
||||
->label('ZMM 2')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_3')
|
||||
->label('ZMM 3')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_4')
|
||||
->label('ZMM 4')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_5')
|
||||
->label('ZMM 5')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_6')
|
||||
->label('ZMM 6')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_7')
|
||||
->label('ZMM 7')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_8')
|
||||
->label('ZMM 8')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_9')
|
||||
->label('ZMM 9')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_10')
|
||||
->label('ZMM 10')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_11')
|
||||
->label('ZMM 11')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_12')
|
||||
->label('ZMM 12')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_13')
|
||||
->label('ZMM 13')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_14')
|
||||
->label('ZMM 14')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('zmm_15')
|
||||
->label('ZMM 15')
|
||||
->enabledByDefault(false),
|
||||
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 item characteristic export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MaterialInvoiceValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::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('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('stickerMaster.item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('stickerMaster.item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('stickerMaster.material_type')
|
||||
->label('MATERIAL TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('upload_status')
|
||||
->label('UPLOAD STATUS'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your material invoice validation export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PanelBoxValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PanelBoxValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PanelBoxValidation::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('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('inspection_lot_number')
|
||||
->label('INSPECTION LOT NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('serial_number_panel')
|
||||
->label('SERIAL NUMBER PANEL'),
|
||||
ExportColumn::make('pack_slip_panel')
|
||||
->label('PACK SLIP PANEL'),
|
||||
ExportColumn::make('name_plate_panel')
|
||||
->label('NAME PLATE PANEL'),
|
||||
ExportColumn::make('tube_sticker_panel')
|
||||
->label('TUBE STICKER PANEL'),
|
||||
ExportColumn::make('warranty_card_panel')
|
||||
->label('WARRANTY CARD PANEL'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('part_validation3')
|
||||
->label('PART VALIDATION 3'),
|
||||
ExportColumn::make('part_validation4')
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
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 panel box 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,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PanelGrMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PanelGrMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PanelGrMaster::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('document_number')
|
||||
->label('DOCUMENT NUMBER'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('supplier_number')
|
||||
->label('SUPPLIER NUMBER'),
|
||||
ExportColumn::make('inspection_lot_number')
|
||||
->label('INSPECTION LOT NUMBER'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your panel 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;
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ class ProductionCharacteristicExporter extends Exporter
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('inspection_status')
|
||||
->label('INSPECTION STATUS'),
|
||||
ExportColumn::make('remark')
|
||||
->label('REMARK'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PumpTestingEntry;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PumpTestingEntryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PumpTestingEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('tested_date')
|
||||
->label('TESTED DATE'),
|
||||
ExportColumn::make('tested_type')
|
||||
->label('TESTED TYPE'),
|
||||
ExportColumn::make('pumpTestingMaster.item.code')
|
||||
->label('PUMP CODE'),
|
||||
ExportColumn::make('pumpTestingMaster.item.category')
|
||||
->label('PUMP CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('pumpTestingMaster.item.description')
|
||||
->label('PUMP TYPE'),
|
||||
ExportColumn::make('pumpTestingMaster.item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('pump_serial_number')
|
||||
->label('PUMP SERIAL NUMBER'),
|
||||
ExportColumn::make('correction_head')
|
||||
->label('CORRECTION HEAD'),
|
||||
ExportColumn::make('sl_no')
|
||||
->label('SL. NO.'),
|
||||
ExportColumn::make('voltage')
|
||||
->label('VOLTAGE'),
|
||||
ExportColumn::make('frequency')
|
||||
->label('FREQUENCY'),
|
||||
ExportColumn::make('speed')
|
||||
->label('SPEED'),
|
||||
ExportColumn::make('head')
|
||||
->label('HEAD'),
|
||||
ExportColumn::make('flow_reading')
|
||||
->label('FLOW READING'),
|
||||
ExportColumn::make('current')
|
||||
->label('CURRENT'),
|
||||
ExportColumn::make('watt')
|
||||
->label('WATT'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your pump testing entry 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,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PumpTestingMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PumpTestingMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PumpTestingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('PUMP CODE'),
|
||||
ExportColumn::make('item.category')
|
||||
->label('PUMP CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.description')
|
||||
->label('PUMP TYPE'),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('head')
|
||||
->label('HEAD'),
|
||||
ExportColumn::make('head_type')
|
||||
->label('HEAD TYPE'),
|
||||
ExportColumn::make('discharge')
|
||||
->label('DISCHARGE'),
|
||||
ExportColumn::make('discharge_type')
|
||||
->label('DISCHARGE TYPE'),
|
||||
ExportColumn::make('motor_efficiency')
|
||||
->label('MOTOR EFFICIENCY'),
|
||||
ExportColumn::make('pump_efficiency')
|
||||
->label('PUMP EFFICIENCY'),
|
||||
ExportColumn::make('speed')
|
||||
->label('SPEED'),
|
||||
ExportColumn::make('frequency')
|
||||
->label('FREQUENCY'),
|
||||
ExportColumn::make('i_max')
|
||||
->label('I-MAX'),
|
||||
ExportColumn::make('p_input')
|
||||
->label('P-INPUT'),
|
||||
ExportColumn::make('delivery_size')
|
||||
->label('DELIVERY SIZE'),
|
||||
ExportColumn::make('no_of_stages')
|
||||
->label('NO OF STAGES'),
|
||||
ExportColumn::make('size')
|
||||
->label('SIZE'),
|
||||
ExportColumn::make('maximum_head')
|
||||
->label('MAXIMUM HEAD'),
|
||||
ExportColumn::make('motor_type')
|
||||
->label('MOTOR TYPE'),
|
||||
ExportColumn::make('motor_code')
|
||||
->label('MOTOR CODE'),
|
||||
ExportColumn::make('kw_hp')
|
||||
->label('KW / HP'),
|
||||
ExportColumn::make('connection_type')
|
||||
->label('CONNECTION TYPE'),
|
||||
ExportColumn::make('voltage')
|
||||
->label('VOLTAGE'),
|
||||
ExportColumn::make('phase')
|
||||
->label('PHASE'),
|
||||
ExportColumn::make('oh_minimum')
|
||||
->label('OH MINIMUM'),
|
||||
ExportColumn::make('oh_maximum')
|
||||
->label('OH MAXIMUM'),
|
||||
ExportColumn::make('current_minimum')
|
||||
->label('CURRENT MINIMUM'),
|
||||
ExportColumn::make('current_maximum')
|
||||
->label('CURRENT MAXIMUM'),
|
||||
ExportColumn::make('class_of_insulation')
|
||||
->label('CLASS OF INSULATION'),
|
||||
ExportColumn::make('testing_code')
|
||||
->label('TESTING CODE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your pump testing 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,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StickerDetail;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StickerDetailExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StickerDetail::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('stickerStructureDetail.sticker_id')
|
||||
->label('STICKER ID'),
|
||||
ExportColumn::make('design_element_type')
|
||||
->label('DESIGN ELEMENT TYPE'),
|
||||
ExportColumn::make('element_id')
|
||||
->label('ELEMENT ID'),
|
||||
ExportColumn::make('element_type')
|
||||
->label('ELEMENT TYPE'),
|
||||
ExportColumn::make('characteristics_type')
|
||||
->label('CHARACTERISTICS TYPE'),
|
||||
ExportColumn::make('string_value')
|
||||
->label('STRING VALUE'),
|
||||
ExportColumn::make('string_font')
|
||||
->label('STRING FONT'),
|
||||
ExportColumn::make('string_size')
|
||||
->label('STRING SIZE'),
|
||||
ExportColumn::make('element_colour')
|
||||
->label('ELEMENT COLOUR'),
|
||||
ExportColumn::make('string_align')
|
||||
->label('STRING ALIGN'),
|
||||
ExportColumn::make('string_x_value')
|
||||
->label('STRING X VALUE'),
|
||||
ExportColumn::make('string_y_value')
|
||||
->label('STRING Y VALUE'),
|
||||
ExportColumn::make('shape_name')
|
||||
->label('SHAPE NAME'),
|
||||
ExportColumn::make('shape_pen_size')
|
||||
->label('SHAPE PEN SIZE'),
|
||||
ExportColumn::make('curve_radius')
|
||||
->label('CURVE RADIUS'),
|
||||
ExportColumn::make('shape_x1_value')
|
||||
->label('SHAPE X1 VALUE'),
|
||||
ExportColumn::make('shape_y1_value')
|
||||
->label('SHAPE Y1 VALUE'),
|
||||
ExportColumn::make('shape_x2_value')
|
||||
->label('SHAPE X2 VALUE'),
|
||||
ExportColumn::make('shape_y2_value')
|
||||
->label('SHAPE Y2 VALUE'),
|
||||
ExportColumn::make('image_x')
|
||||
->label('IMAGE X'),
|
||||
ExportColumn::make('image_y')
|
||||
->label('IMAGE Y'),
|
||||
ExportColumn::make('image_width')
|
||||
->label('IMAGE WIDTH'),
|
||||
ExportColumn::make('image_height')
|
||||
->label('IMAGE HEIGHT'),
|
||||
ExportColumn::make('qr_value')
|
||||
->label('QR VALUE'),
|
||||
ExportColumn::make('qr_align')
|
||||
->label('QR ALIGN'),
|
||||
ExportColumn::make('qr_size')
|
||||
->label('QR SIZE'),
|
||||
ExportColumn::make('qr_x_value')
|
||||
->label('QR X VALUE'),
|
||||
ExportColumn::make('qr_y_value')
|
||||
->label('QR Y VALUE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your sticker detail 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,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StickerMappingMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StickerMappingMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StickerMappingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('itemCharacteristic.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('sticker_structure1_id')
|
||||
->label('STICKER 1')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker1Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker1_machine_id')
|
||||
->label('WC STICKER 1')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker1Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker1_print_ip')
|
||||
->label('STICKER 1 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure2_id')
|
||||
->label('STICKER 2')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker2_machine_id')
|
||||
->label('WC STICKER 2')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker2_print_ip')
|
||||
->label('STICKER 2 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure3_id')
|
||||
->label('STICKER 3')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker3Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker3_machine_id')
|
||||
->label('WC STICKER 3')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker3Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker3_print_ip')
|
||||
->label('STICKER 3 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure4_id')
|
||||
->label('STICKER 4')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker4Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker4_machine_id')
|
||||
->label('WC STICKER 4')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker4Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker4_print_ip')
|
||||
->label('STICKER 4 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure5_id')
|
||||
->label('STICKER 5')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker5Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker5_machine_id')
|
||||
->label('WC STICKER 5')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker5Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker5_print_ip')
|
||||
->label('STICKER 5 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure6_id')
|
||||
->label('STICKER 6')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker6Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker6_machine_id')
|
||||
->label('WC STICKER 6')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker6Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker6_print_ip')
|
||||
->label('STICKER 6 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure7_id')
|
||||
->label('STICKER 7')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker7Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker7_machine_id')
|
||||
->label('WC STICKER 7')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker7_print_ip')
|
||||
->label('STICKER 7 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure8_id')
|
||||
->label('STICKER 8')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker8Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker8_machine_id')
|
||||
->label('WC STICKER 8')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker8Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker8_print_ip')
|
||||
->label('STICKER 8 PRINT IP'),
|
||||
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 sticker mapping 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;
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,8 @@ class StickerMasterExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION'),
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StickerStructureDetail;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StickerStructureDetailExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StickerStructureDetail::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('sticker_id')
|
||||
->label('STICKER ID'),
|
||||
ExportColumn::make('sticker_width')
|
||||
->label('STICKER WIDTH'),
|
||||
ExportColumn::make('sticker_height')
|
||||
->label('STICKER HEIGHT'),
|
||||
ExportColumn::make('sticker_lmargin')
|
||||
->label('STICKER LEFT MARGIN'),
|
||||
ExportColumn::make('sticker_rmargin')
|
||||
->label('STICKER RIGHT MARGIN'),
|
||||
ExportColumn::make('sticker_tmargin')
|
||||
->label('STICKER TOP MARGIN'),
|
||||
ExportColumn::make('sticker_bmargin')
|
||||
->label('STICKER BOTTOM MARGIN'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your sticker structure detail export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -300,8 +299,6 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('model_type')
|
||||
@@ -324,10 +321,10 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your temp class characteristic export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
$body = 'Your temp class characteristic export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -29,7 +29,7 @@ class WeightValidationExporter extends Exporter
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('obd_number')
|
||||
->label('OBD / GR NUMBER'),
|
||||
->label('OBD NUMBER'),
|
||||
ExportColumn::make('line_number')
|
||||
->label('LINE NUMBER'),
|
||||
ExportColumn::make('batch_number')
|
||||
@@ -41,7 +41,7 @@ class WeightValidationExporter extends Exporter
|
||||
ExportColumn::make('vehicle_number')
|
||||
->label('VEHICLE NUMBER'),
|
||||
ExportColumn::make('bundle_number')
|
||||
->label('BUNDLE / COIL NUMBER'),
|
||||
->label('BUNDLE NUMBER'),
|
||||
ExportColumn::make('picked_weight')
|
||||
->label('PICKED WEIGHT'),
|
||||
ExportColumn::make('scanned_by')
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\WindedSerialValidationError;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class WindedSerialValidationErrorExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = WindedSerialValidationError::class;
|
||||
|
||||
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.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('aufnr')
|
||||
->label('AUFNR'),
|
||||
ExportColumn::make('gernr')
|
||||
->label('GERNR'),
|
||||
ExportColumn::make('model_type')
|
||||
->label('MODEL TYPE'),
|
||||
ExportColumn::make('winded_status')
|
||||
->label('WINDED STATUS'),
|
||||
ExportColumn::make('winded_qr')
|
||||
->label('WINDED QR'),
|
||||
ExportColumn::make('winded_code')
|
||||
->label('WINDED CODE'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(true),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your winded serial validation error 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,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class WireMasterPackingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = WireMasterPacking::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('customerPo.customer_po')
|
||||
->label('CUSTOMER PO NUMBER'),
|
||||
ExportColumn::make('wire_packing_number')
|
||||
->label('WIRE PACKING NUMBER'),
|
||||
ExportColumn::make('process_order')
|
||||
->label('PROCESS ORDER'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('weight')
|
||||
->label('WEIGHT'),
|
||||
ExportColumn::make('wire_packing_status')
|
||||
->label('WIRE PACKING STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your wire master packing 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;
|
||||
}
|
||||
}
|
||||
@@ -579,26 +579,14 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->exampleHeader('ZMM OPERATING TEMPERATURE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->exampleHeader('ZMM AXIAL FORCE')
|
||||
->example(''),
|
||||
ImportColumn::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
->exampleHeader('IS STOPPED')
|
||||
->example('0'),
|
||||
ImportColumn::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME')
|
||||
->exampleHeader('STOPPED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->exampleHeader('STOPPED BY')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->exampleHeader('MARKED STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->exampleHeader('MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->exampleHeader('MARKED PHYSICAL COUNT')
|
||||
@@ -607,10 +595,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->exampleHeader('MARKED EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->exampleHeader('MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->exampleHeader('MARKED BY')
|
||||
@@ -639,10 +623,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->exampleHeader('MOTOR EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('motor_marked_datetime')
|
||||
->label('MOTOR MARKED DATETIME')
|
||||
->exampleHeader('MOTOR MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->exampleHeader('MOTOR MARKED BY')
|
||||
@@ -659,10 +639,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->exampleHeader('PUMP EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('pump_marked_datetime')
|
||||
->label('PUMP MARKED DATETIME')
|
||||
->exampleHeader('PUMP MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->exampleHeader('PUMP MARKED BY')
|
||||
@@ -675,10 +651,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('NAME PLATE EXPECTED TIME')
|
||||
->exampleHeader('NAME PLATE EXPECTED TIME')
|
||||
->example('0'),
|
||||
ImportColumn::make('name_plate_marked_datetime')
|
||||
->label('NAME PLATE MARKED DATETIME')
|
||||
->exampleHeader('NAME PLATE MARKED DATETIME')
|
||||
->example('01-01-2026 00:08:00'),
|
||||
ImportColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY')
|
||||
->exampleHeader('NAME PLATE MARKED BY')
|
||||
@@ -691,10 +663,6 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_rework_status')
|
||||
->label('WINDED REWORK STATUS')
|
||||
->exampleHeader('WINDED REWORK STATUS')
|
||||
->example(''),
|
||||
ImportColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->exampleHeader('MOTOR MACHINE NAME')
|
||||
|
||||
@@ -111,13 +111,6 @@ class CustomerPoMasterImporter extends Importer
|
||||
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'.";
|
||||
}
|
||||
|
||||
$existingPoItem = CustomerPoMaster::where('plant_id', $plant->id)->where('item_id', $item->id)->where('customer_po', $this->data['customer_po'])->where('customer_name', $this->data['customer_name'])->first();
|
||||
|
||||
if ($existingPoItem)
|
||||
{
|
||||
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already exist with item code '{$this->data['item']}' and customer name '{$this->data['customer_name']}'.";
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found';
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\DealerVisitPlan;
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DealerVisitPlanImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = DealerVisitPlan::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Dealer Name')
|
||||
->example('Suresh')
|
||||
->label('Dealer Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('company')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Dealer Company')
|
||||
->example('Suresh Traders')
|
||||
->label('Dealer Company')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('visit_plan_date')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Visit Plan Date')
|
||||
->example('2026-07-20')
|
||||
->label('Visit Plan Date'),
|
||||
ImportColumn::make('organizer')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Organizer')
|
||||
->example('Ramesh')
|
||||
->label('Organizer'),
|
||||
ImportColumn::make('employee_master_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Receipient Employee Code')
|
||||
->example('RAS001234')
|
||||
->label('Receipient Employee Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('number_of_person')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Number Of Person')
|
||||
->example('10')
|
||||
->label('Number Of Person'),
|
||||
ImportColumn::make('purpose_of_visit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Purpose Of Visit')
|
||||
->example('Meeting')
|
||||
->label('Purpose Of Visit'),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Status')
|
||||
->example('Planned/Completed')
|
||||
->label('Status'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?DealerVisitPlan
|
||||
{
|
||||
$warnMsg = [];
|
||||
|
||||
$user = null;
|
||||
$dealerName = trim($this->data['name']);
|
||||
$dealerCompany = trim($this->data['company']);
|
||||
$visitPlanDt = trim($this->data['visit_plan_date']);
|
||||
$organizer = trim($this->data['organizer']);
|
||||
$employeeCode = trim($this->data['employee_master_id']);
|
||||
$noOfPerson = trim($this->data['number_of_person']);
|
||||
$purposeOfVisit = trim($this->data['purpose_of_visit']);
|
||||
$status = trim($this->data['status']);
|
||||
$user = Filament::auth()->user()->name;
|
||||
|
||||
if (Str::length($employeeCode) < 5) {
|
||||
$warnMsg[] = 'Invalid receipient employee number found!';
|
||||
}
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$employeeId = EmployeeMaster::where('code', $employeeCode)->first();
|
||||
|
||||
$eId = $employeeId->id;
|
||||
|
||||
DealerVisitPlan::updateOrCreate(
|
||||
[
|
||||
'name' => $dealerName,
|
||||
'company' => $dealerCompany,
|
||||
'visit_plan_date' => Carbon::createFromFormat('d-m-Y', $visitPlanDt)->format('Y-m-d'),
|
||||
'organizer' => $organizer,
|
||||
'employee_master_id' => $eId,
|
||||
'number_of_person' => $noOfPerson,
|
||||
'purpose_of_visit' => $purposeOfVisit,
|
||||
'status' => $status,
|
||||
'created_by' => $user,
|
||||
'updated_by' => $user,
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
|
||||
// return new DealerVisitPlan();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your dealer visit plan 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;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class ImportTransitImporter extends Importer
|
||||
->label('Status'),
|
||||
ImportColumn::make('insurance_status')
|
||||
->exampleHeader('Insurance Status')
|
||||
->example('Yes')
|
||||
->example('Receipted')
|
||||
->label('Insurance Status'),
|
||||
ImportColumn::make('delivery_location')
|
||||
->exampleHeader('Delivery Location')
|
||||
@@ -176,7 +176,6 @@ class ImportTransitImporter extends Importer
|
||||
|
||||
return ImportTransit::updateOrCreate([
|
||||
'cri_rfq_number' => $criRfqNumber,
|
||||
'shipper_invoice' => $shipperInvoice,
|
||||
],
|
||||
[
|
||||
'mail_received_date' => $this->formatDate($mailRecDate),
|
||||
@@ -188,6 +187,7 @@ class ImportTransitImporter extends Importer
|
||||
'requester' => $requester,
|
||||
'shipper' => $shipper,
|
||||
'shipper_location' => $shipperLocation,
|
||||
'shipper_invoice' => $shipperInvoice,
|
||||
'inv_value' => $invValue,
|
||||
'freight_charge' => $freightCharge,
|
||||
'custom_agent_name' => $customsAgentname,
|
||||
|
||||
@@ -359,7 +359,7 @@ class InvoiceValidationImporter extends Importer
|
||||
$curPanelBoxSerialNumber = $record->panel_box_serial_number ?? null;
|
||||
}
|
||||
|
||||
$warnMsg[] = 'Invoice Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||
$warnMsg[] = 'Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||
if ($record->invoice_number != $invoiceNumber) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Invoice number mismatch with existing record!';
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ItemCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ItemCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ItemCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('class'),
|
||||
ImportColumn::make('zz1_cn_bill_ord'),
|
||||
ImportColumn::make('zmm_amps'),
|
||||
ImportColumn::make('zmm_brand'),
|
||||
ImportColumn::make('zmm_degreeofprotection'),
|
||||
ImportColumn::make('zmm_delivery'),
|
||||
ImportColumn::make('zmm_dir_rot'),
|
||||
ImportColumn::make('zmm_discharge'),
|
||||
ImportColumn::make('zmm_discharge_max'),
|
||||
ImportColumn::make('zmm_discharge_min'),
|
||||
ImportColumn::make('zmm_duty'),
|
||||
ImportColumn::make('zmm_eff_motor'),
|
||||
ImportColumn::make('zmm_eff_pump'),
|
||||
ImportColumn::make('zmm_frequency'),
|
||||
ImportColumn::make('zmm_head'),
|
||||
ImportColumn::make('zmm_heading'),
|
||||
ImportColumn::make('zmm_head_max'),
|
||||
ImportColumn::make('zmm_head_minimum'),
|
||||
ImportColumn::make('zmm_idx_eff_mtr'),
|
||||
ImportColumn::make('zmm_idx_eff_pump'),
|
||||
ImportColumn::make('zmm_kvacode'),
|
||||
ImportColumn::make('zmm_maxambtemp'),
|
||||
ImportColumn::make('zmm_mincoolingflow'),
|
||||
ImportColumn::make('zmm_motorseries'),
|
||||
ImportColumn::make('zmm_motor_model'),
|
||||
ImportColumn::make('zmm_outlet'),
|
||||
ImportColumn::make('zmm_phase'),
|
||||
ImportColumn::make('zmm_pressure'),
|
||||
ImportColumn::make('zmm_pumpflowtype'),
|
||||
ImportColumn::make('zmm_pumpseries'),
|
||||
ImportColumn::make('zmm_pump_model'),
|
||||
ImportColumn::make('zmm_ratedpower'),
|
||||
ImportColumn::make('zmm_region'),
|
||||
ImportColumn::make('zmm_servicefactor'),
|
||||
ImportColumn::make('zmm_servicefactormaximumamps'),
|
||||
ImportColumn::make('zmm_speed'),
|
||||
ImportColumn::make('zmm_suction'),
|
||||
ImportColumn::make('zmm_suctionxdelivery'),
|
||||
ImportColumn::make('zmm_supplysource'),
|
||||
ImportColumn::make('zmm_temperature'),
|
||||
ImportColumn::make('zmm_thrustload'),
|
||||
ImportColumn::make('zmm_volts'),
|
||||
ImportColumn::make('zmm_wire'),
|
||||
ImportColumn::make('zmm_package'),
|
||||
ImportColumn::make('zmm_pvarrayrating'),
|
||||
ImportColumn::make('zmm_isi'),
|
||||
ImportColumn::make('zmm_isimotor'),
|
||||
ImportColumn::make('zmm_isipump'),
|
||||
ImportColumn::make('zmm_isipumpset'),
|
||||
ImportColumn::make('zmm_pumpset_model'),
|
||||
ImportColumn::make('zmm_stages'),
|
||||
ImportColumn::make('zmm_headrange'),
|
||||
ImportColumn::make('zmm_overall_efficiency'),
|
||||
ImportColumn::make('zmm_connection'),
|
||||
ImportColumn::make('zmm_min_bore_size'),
|
||||
ImportColumn::make('zmm_isireference'),
|
||||
ImportColumn::make('zmm_category'),
|
||||
ImportColumn::make('zmm_submergence'),
|
||||
ImportColumn::make('zmm_capacitorstart'),
|
||||
ImportColumn::make('zmm_capacitorrun'),
|
||||
ImportColumn::make('zmm_inch'),
|
||||
ImportColumn::make('zmm_motor_type'),
|
||||
ImportColumn::make('zmm_dismantle_direction'),
|
||||
ImportColumn::make('zmm_eff_ovrall'),
|
||||
ImportColumn::make('zmm_bodymoc'),
|
||||
ImportColumn::make('zmm_rotormoc'),
|
||||
ImportColumn::make('zmm_dlwl'),
|
||||
ImportColumn::make('zmm_inputpower'),
|
||||
ImportColumn::make('zmm_imp_od'),
|
||||
ImportColumn::make('zmm_ambtemp'),
|
||||
ImportColumn::make('zmm_de'),
|
||||
ImportColumn::make('zmm_dischargerange'),
|
||||
ImportColumn::make('zmm_efficiency_class'),
|
||||
ImportColumn::make('zmm_framesize'),
|
||||
ImportColumn::make('zmm_impellerdiameter'),
|
||||
ImportColumn::make('zmm_insulationclass'),
|
||||
ImportColumn::make('zmm_maxflow'),
|
||||
ImportColumn::make('zmm_minhead'),
|
||||
ImportColumn::make('zmm_mtrlofconst'),
|
||||
ImportColumn::make('zmm_nde'),
|
||||
ImportColumn::make('zmm_powerfactor'),
|
||||
ImportColumn::make('zmm_tagno'),
|
||||
ImportColumn::make('zmm_year'),
|
||||
ImportColumn::make('zmm_laser_name'),
|
||||
ImportColumn::make('zmm_beenote'),
|
||||
ImportColumn::make('zmm_beenumber'),
|
||||
ImportColumn::make('zmm_beestar'),
|
||||
ImportColumn::make('zmm_logo_ce'),
|
||||
ImportColumn::make('zmm_codeclass'),
|
||||
ImportColumn::make('zmm_colour'),
|
||||
ImportColumn::make('zmm_logo_cp'),
|
||||
ImportColumn::make('zmm_grade'),
|
||||
ImportColumn::make('zmm_grwt_pset'),
|
||||
ImportColumn::make('zmm_grwt_cable'),
|
||||
ImportColumn::make('zmm_grwt_motor'),
|
||||
ImportColumn::make('zmm_grwt_pf'),
|
||||
ImportColumn::make('zmm_grwt_pump'),
|
||||
ImportColumn::make('zmm_isivalve'),
|
||||
ImportColumn::make('zmm_isi_wc'),
|
||||
ImportColumn::make('zmm_labelperiod'),
|
||||
ImportColumn::make('zmm_length'),
|
||||
ImportColumn::make('zmm_license_cml_no'),
|
||||
ImportColumn::make('zmm_mfgmonyr'),
|
||||
ImportColumn::make('zmm_modelyear'),
|
||||
ImportColumn::make('zmm_motoridentification'),
|
||||
ImportColumn::make('zmm_newt_pset'),
|
||||
ImportColumn::make('zmm_newt_cable'),
|
||||
ImportColumn::make('zmm_newt_motor'),
|
||||
ImportColumn::make('zmm_newt_pf'),
|
||||
ImportColumn::make('zmm_newt_pump'),
|
||||
ImportColumn::make('zmm_logo_nsf'),
|
||||
ImportColumn::make('zmm_packtype'),
|
||||
ImportColumn::make('zmm_panel'),
|
||||
ImportColumn::make('zmm_performance_factor'),
|
||||
ImportColumn::make('zmm_pumpidentification'),
|
||||
ImportColumn::make('zmm_psettype'),
|
||||
ImportColumn::make('zmm_size'),
|
||||
ImportColumn::make('zmm_eff_ttl'),
|
||||
ImportColumn::make('zmm_type'),
|
||||
ImportColumn::make('zmm_usp'),
|
||||
ImportColumn::make('zmm_operating_range'),
|
||||
ImportColumn::make('zmm_intake_air'),
|
||||
ImportColumn::make('zmm_oxygen_transfer_rate'),
|
||||
ImportColumn::make('zmm_air_inlet_pipesize'),
|
||||
ImportColumn::make('zmm_sump_depth'),
|
||||
ImportColumn::make('zmm_poles'),
|
||||
ImportColumn::make('zmm_motor_heading'),
|
||||
ImportColumn::make('zmm_motor_speed'),
|
||||
ImportColumn::make('zqmm_qty'),
|
||||
ImportColumn::make('zmm_1'),
|
||||
ImportColumn::make('zmm_2'),
|
||||
ImportColumn::make('zmm_3'),
|
||||
ImportColumn::make('zmm_4'),
|
||||
ImportColumn::make('zmm_5'),
|
||||
ImportColumn::make('zmm_6'),
|
||||
ImportColumn::make('zmm_7'),
|
||||
ImportColumn::make('zmm_8'),
|
||||
ImportColumn::make('zmm_9'),
|
||||
ImportColumn::make('zmm_10'),
|
||||
ImportColumn::make('zmm_11'),
|
||||
ImportColumn::make('zmm_12'),
|
||||
ImportColumn::make('zmm_13'),
|
||||
ImportColumn::make('zmm_14'),
|
||||
ImportColumn::make('zmm_15'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ItemCharacteristic
|
||||
{
|
||||
// return ItemCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ItemCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your item characteristic import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\PanelBoxValidation;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class PanelBoxValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PanelBoxValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('stickerMaster')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('serial_number'),
|
||||
ImportColumn::make('serial_number_panel'),
|
||||
ImportColumn::make('pack_slip_panel'),
|
||||
ImportColumn::make('name_plate_panel'),
|
||||
ImportColumn::make('tube_sticker_panel'),
|
||||
ImportColumn::make('warranty_card_panel'),
|
||||
ImportColumn::make('part_validation1'),
|
||||
ImportColumn::make('part_validation2'),
|
||||
ImportColumn::make('part_validation3'),
|
||||
ImportColumn::make('part_validation4'),
|
||||
ImportColumn::make('part_validation5'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('panel_box_supplier'),
|
||||
ImportColumn::make('panel_box_serial_number'),
|
||||
ImportColumn::make('panel_box_code'),
|
||||
ImportColumn::make('inspection_lot_number'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?PanelBoxValidation
|
||||
{
|
||||
// return PanelBoxValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new PanelBoxValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your panel box validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\PanelGrMaster;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
|
||||
class PanelGrMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PanelGrMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('document_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Document Number')
|
||||
->example('11023567')
|
||||
->label('Document Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Invoice Number')
|
||||
->example('3RAW0012345')
|
||||
->label('Invoice Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('supplier_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Supplier Number')
|
||||
->example('154564564')
|
||||
->label('Supplier Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('inspection_lot_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Inspection Lot Number')
|
||||
->example('154564564')
|
||||
->label('Inspection Lot Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Quantity')
|
||||
->example('10')
|
||||
->label('Quantity')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?PanelGrMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$item = null;
|
||||
$userName = Filament::auth()->user()?->name;
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->data['document_number'])) {
|
||||
$warnMsg[] = 'Document Number cannot be empty.';
|
||||
}
|
||||
|
||||
// if (Str::length($this->data['invoice_number']) < 7 || ! ctype_alnum($this->data['invoice_number'])) {
|
||||
// $warnMsg[] = 'Invalid invoice number found';
|
||||
// }
|
||||
|
||||
if (empty($this->data['supplier_number'])) {
|
||||
$warnMsg[] = 'Supplier Number cannot be empty.';
|
||||
}
|
||||
|
||||
if (empty($this->data['inspection_lot_number'])) {
|
||||
$warnMsg[] = 'Inspection Lot Number cannot be empty.';
|
||||
}
|
||||
if (!is_numeric($this->data['inspection_lot_number'])) {
|
||||
$warnMsg[] = 'Inspection Lot Number must be a valid number.';
|
||||
}
|
||||
|
||||
if (empty($this->data['quantity'])) {
|
||||
$warnMsg[] = 'Quantity cannot be empty.';
|
||||
}
|
||||
elseif (!is_numeric($this->data['quantity'])) {
|
||||
$warnMsg[] = 'Quantity must be a valid number.';
|
||||
} elseif ((float) $this->data['quantity'] <= 0) {
|
||||
$warnMsg[] = 'Quantity must be greater than 0.';
|
||||
}
|
||||
|
||||
$existingRecord = PanelGrMaster::where('document_number', $this->data['document_number'])->where('inspection_lot_number', $this->data['inspection_lot_number'])->where('plant_id', $this->data['plant'])->first();
|
||||
|
||||
if ($existingRecord)
|
||||
{
|
||||
$warnMsg[] = "Document Number '{$this->data['document_number']}' is already associated with Inspection Lot Number '{$existingRecord->inspection_lot_number}'.";
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
PanelGrMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $item->id,
|
||||
'document_number' => $this->data['document_number'],
|
||||
'invoice_number' => $this->data['invoice_number'],
|
||||
'supplier_number' => $this->data['supplier_number'] ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
],
|
||||
[
|
||||
'quantity' => $this->data['quantity'] ?? null,
|
||||
'updated_by' => $userName,
|
||||
'created_by' => $userName, // Only used when creating
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
// return new PanelGrMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your panel 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;
|
||||
}
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class SapInvoiceValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('2040')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('INVOICE NUMBER')
|
||||
->example('INV000001')
|
||||
->label('INVOICE NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_reference') // stickerMaster
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
// ->relationship() // resolveUsing: 'items.code'
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('12345678901234')
|
||||
->label('SERIAL NUMBER'),
|
||||
ImportColumn::make('scanned_status_set')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PUMPSET SCANNED STATUS')
|
||||
->example('1')
|
||||
->label('PUMPSET SCANNED STATUS'),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('19-06-2026 15:00:00')
|
||||
->label('CREATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OPERATOR ID')
|
||||
->example('USER00001')
|
||||
->label('OPERATOR ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?InvoiceValidation
|
||||
{
|
||||
// return InvoiceValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantId = null;
|
||||
$stickId = null;
|
||||
|
||||
$plantCod = $this->data['plant'];
|
||||
$invoiceNumber = strtoupper(trim($this->data['invoice_number'])) ?? null;
|
||||
$iCode = strtoupper(trim($this->data['item_reference'])) ?? null;
|
||||
$serialNumber = trim($this->data['serial_number']) ?? null;
|
||||
$curPumpSetQr = trim($this->data['scanned_status_set']) ?? null;
|
||||
$curScanStatus = null;
|
||||
$loadRate = 0;
|
||||
$operatorId = trim($this->data['operator_id']);
|
||||
$createdAt = $this->data['created_at'];
|
||||
$createdBy = Filament::auth()->user()?->name;
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
$packCnt = 0;
|
||||
$scanCnt = 0;
|
||||
$hasPumpSetQr = null;
|
||||
$hadPumpSetQr = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif ($invoiceNumber == null || $invoiceNumber == '') {
|
||||
$warnMsg[] = "Invoice number can't be empty!";
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif ($serialNumber == null || $serialNumber == '') {
|
||||
$warnMsg[] = "Serial number can't be empty!";
|
||||
} elseif ($curPumpSetQr != null && $curPumpSetQr != '' && $curPumpSetQr != '1' && $curPumpSetQr != 1) {
|
||||
$warnMsg[] = 'PumpSet scanned status is invalid!';
|
||||
} elseif ($operatorId == null || $operatorId == '') {
|
||||
$warnMsg[] = "Operator ID can't be empty!";
|
||||
} elseif ($createdAt == null || $createdAt == '') {
|
||||
$warnMsg[] = "Created at timestamp can't be empty!";
|
||||
}
|
||||
|
||||
if (Str::length($plantCod) > 0) {
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif ($plantCod == '2040') { // 2040
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
} else {
|
||||
$warnMsg[] = "Unknown plant code '$plantCod' found!";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($invoiceNumber) > 0 && ! ctype_alnum($invoiceNumber)) {
|
||||
$warnMsg[] = "Invalid invoice number '$invoiceNumber' found!";
|
||||
} elseif (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = "Invalid item code '$iCode' found!";
|
||||
} elseif ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master!';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in item master for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found in sticker master for the given plant!';
|
||||
} elseif ($itemCode->material_type != '' && $itemCode->material_type != null) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Material invoice item code found!';
|
||||
} else {
|
||||
$stickId = $itemCode->id;
|
||||
$loadRate = $itemCode->load_rate ?? 0;
|
||||
$invalidPackage = false;
|
||||
|
||||
$hasMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $itemCode->tube_sticker_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasCapacitorQr = $itemCode->panel_box_code ?? null;
|
||||
|
||||
if (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr) {// && ! $hasCapacitorQr
|
||||
$hasMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
$hasPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
} else {
|
||||
if (! $hasPumpSetQr && ! $hasPumpQr) {
|
||||
$hasPumpQr = $itemCode->pack_slip_pump ?? null;
|
||||
}
|
||||
|
||||
$hasTubeMotorQr = $itemCode->tube_sticker_motor ?? null;
|
||||
$hasPackMotorQr = $itemCode->pack_slip_motor ?? null;
|
||||
$hasTubePumpSetQr = $itemCode->tube_sticker_pumpset ?? null;
|
||||
$hasPackPumpSetQr = $itemCode->pack_slip_pumpset ?? null;
|
||||
if ($hasTubeMotorQr != $hasPackMotorQr || $hasTubePumpSetQr != $hasPackPumpSetQr) {
|
||||
$invalidPackage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasMotorQr || $hasPumpQr || ! $hasPumpSetQr || $hasCapacitorQr || $invalidPackage) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = "Item code doesn't have valid package type to proceed!";
|
||||
} else {
|
||||
$packCnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||
|
||||
if ($record) {
|
||||
if ($record->sticker_master_id != $stickId) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Item code mismatch with existing record!';
|
||||
} else {
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)
|
||||
->whereHas('stickerMasterRelation.item', function ($query) use ($plantId, $iCode) {
|
||||
$query->where('plant_id', $plantId)->where('code', $iCode);
|
||||
})
|
||||
->first();
|
||||
|
||||
if ($record) {
|
||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||
|
||||
if ($hadPumpSetQr && $hasPumpSetQr) {
|
||||
$curPumpSetQr = $hadPumpSetQr;
|
||||
}
|
||||
|
||||
$warnMsg[] = 'Invoice Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||
if ($record->invoice_number != $invoiceNumber) {
|
||||
$stickId = null;
|
||||
$warnMsg[] = 'Invoice number mismatch with existing record!';
|
||||
} elseif ($record->scanned_status == 'Scanned') {
|
||||
$stickId = null;
|
||||
|
||||
return null;
|
||||
} else {
|
||||
if ($hasPumpSetQr) {
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
$record->scanned_status_set = $curPumpSetQr;
|
||||
if ($packCnt == $scanCnt) {
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->upload_status = 'Y';
|
||||
$record->updated_by = $updatedBy;
|
||||
$record->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
$cDateTime = null;
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($cDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
if ($stickId) {
|
||||
if ($hasPumpSetQr) {
|
||||
$scanCnt = $curPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
if ($packCnt == $scanCnt) {
|
||||
$curScanStatus = 'Scanned';
|
||||
} else {
|
||||
$curScanStatus = null;
|
||||
}
|
||||
}
|
||||
// $curScanStatus
|
||||
|
||||
InvoiceValidation::updateOrCreate([
|
||||
'plant_id' => $plantId,
|
||||
'sticker_master_id' => $stickId,
|
||||
'serial_number' => $serialNumber,
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'scanned_status_set' => $curPumpSetQr,
|
||||
'scanned_status' => $curScanStatus,
|
||||
'load_rate' => $loadRate,
|
||||
'upload_status' => 'Y',
|
||||
'operator_id' => $operatorId,
|
||||
'created_by' => $createdBy,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
// return new InvoiceValidation;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sap invoice validation import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerDetail;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class StickerDetailImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StickerDetail::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('sticker_structure_detail_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Sticker ID')
|
||||
->example('123456')
|
||||
->label('STICKER ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('design_element_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Design Element Type')
|
||||
->label('DESIGN ELEMENT TYPE')
|
||||
->example('Text/Shape/Image/QR'),
|
||||
ImportColumn::make('element_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Element ID')
|
||||
->label('ELEMENT ID')
|
||||
->example('001'),
|
||||
ImportColumn::make('element_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Element Type')
|
||||
->label('ELEMENT TYPE')
|
||||
->example('Static/Dynamic'),
|
||||
ImportColumn::make('characteristics_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Characteristics Type')
|
||||
->label('CHARACTERISTICS TYPE')
|
||||
->example('zmm_heading'),
|
||||
ImportColumn::make('string_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String Value')
|
||||
->label('STRING VALUE')
|
||||
->example('1'),
|
||||
ImportColumn::make('string_font')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String Font')
|
||||
->label('STRING FONT')
|
||||
->example('Arial'),
|
||||
ImportColumn::make('string_size')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String Size')
|
||||
->label('STRING SIZE')
|
||||
->example('12'),
|
||||
ImportColumn::make('element_colour')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Element Colour')
|
||||
->label('ELEMENT COLOUR')
|
||||
->example('Black'),
|
||||
ImportColumn::make('string_align')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String Align')
|
||||
->label('STRING ALIGN')
|
||||
->example('Left/Center/Right'),
|
||||
ImportColumn::make('string_x_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String X Value')
|
||||
->label('STRING X VALUE')
|
||||
->example('10'),
|
||||
ImportColumn::make('string_y_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('String Y Value')
|
||||
->label('STRING Y VALUE')
|
||||
->example('20'),
|
||||
ImportColumn::make('shape_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape Name')
|
||||
->label('SHAPE NAME')
|
||||
->example('Line/Rectangle/CurvedRectangle'),
|
||||
ImportColumn::make('shape_pen_size')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape Pen Size')
|
||||
->label('SHAPE PEN SIZE')
|
||||
->example('0.3'),
|
||||
ImportColumn::make('curve_radius')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Curve Radius')
|
||||
->label('CURVE RADIUS')
|
||||
->example('3'),
|
||||
ImportColumn::make('shape_x1_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape X1 Value')
|
||||
->label('SHAPE X1 VALUE')
|
||||
->example('10'),
|
||||
ImportColumn::make('shape_y1_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape Y1 Value')
|
||||
->label('SHAPE Y1 VALUE')
|
||||
->example('20'),
|
||||
ImportColumn::make('shape_x2_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape X2 Value')
|
||||
->label('SHAPE X2 VALUE')
|
||||
->example('30'),
|
||||
ImportColumn::make('shape_y2_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shape Y2 Value')
|
||||
->label('SHAPE Y2 VALUE')
|
||||
->example('40'),
|
||||
ImportColumn::make('image_x')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Image X')
|
||||
->label('IMAGE X')
|
||||
->example('15'),
|
||||
ImportColumn::make('image_y')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Image Y')
|
||||
->label('IMAGE Y')
|
||||
->example('25'),
|
||||
ImportColumn::make('image_width')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Image Width')
|
||||
->label('IMAGE WIDTH')
|
||||
->example('100'),
|
||||
ImportColumn::make('image_height')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Image Height')
|
||||
->label('IMAGE HEIGHT')
|
||||
->example('100'),
|
||||
ImportColumn::make('qr_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QR Value')
|
||||
->label('QR VALUE')
|
||||
->example('246118|53246735267'),
|
||||
ImportColumn::make('qr_align')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QR Align')
|
||||
->label('QR ALIGN')
|
||||
->example('Left/Center/Right'),
|
||||
ImportColumn::make('qr_size')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QR Size')
|
||||
->label('QR SIZE')
|
||||
->example('10'),
|
||||
ImportColumn::make('qr_x_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QR X Value')
|
||||
->label('QR X VALUE')
|
||||
->example('30'),
|
||||
ImportColumn::make('qr_y_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('QR Y Value')
|
||||
->label('QR Y VALUE')
|
||||
->example('40'),
|
||||
// ImportColumn::make('created_by')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Created By')
|
||||
// ->label('CREATED BY')
|
||||
// ->example('RAW001234'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerDetail
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
|
||||
$sticker = $this->data['sticker_structure_detail_id'] ?? null;
|
||||
|
||||
$stickerCode = StickerStructureDetail::where('sticker_id', $sticker)->first();
|
||||
if (!$stickerCode) {
|
||||
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
||||
}else{
|
||||
$stickerId = $stickerCode->id;
|
||||
}
|
||||
|
||||
if (!$stickerId || $stickerId == null || $stickerId == '') {
|
||||
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
||||
}
|
||||
|
||||
$designType = strtolower($this->data['design_element_type'] ?? '');
|
||||
|
||||
$rules = [
|
||||
'text' => [
|
||||
'required' => ['string_x_value', 'string_y_value'],
|
||||
'allowed' => [
|
||||
'string_value',
|
||||
'string_font',
|
||||
'string_size',
|
||||
'string_align',
|
||||
'string_colour',
|
||||
'string_x_value',
|
||||
'string_y_value',
|
||||
],
|
||||
],
|
||||
|
||||
'image' => [
|
||||
'required' => ['image_x', 'image_y', 'image_width', 'image_height'],
|
||||
'allowed' => [
|
||||
'image_x',
|
||||
'image_y',
|
||||
'image_width',
|
||||
'image_height',
|
||||
],
|
||||
],
|
||||
|
||||
'shape' => [
|
||||
'required' => ['shape_name', 'shape_pen_size', 'shape_x1_value', 'shape_y1_value', 'shape_x2_value', 'shape_y2_value'],
|
||||
'allowed' => [
|
||||
'shape_name',
|
||||
'shape_pen_size',
|
||||
'curve_radius',
|
||||
'shape_x1_value',
|
||||
'shape_y1_value',
|
||||
'shape_x2_value',
|
||||
'shape_y2_value',
|
||||
],
|
||||
],
|
||||
|
||||
'qr' => [
|
||||
'required' => ['qr_x_value', 'qr_y_value', 'qr_size'],
|
||||
'allowed' => [
|
||||
'qr_value',
|
||||
'qr_align',
|
||||
'qr_size',
|
||||
'qr_x_value',
|
||||
'qr_y_value',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (!isset($rules[$designType])) {
|
||||
$warnMsg[] = "Invalid Design Element Type: {$designType}";
|
||||
}
|
||||
|
||||
if (isset($rules[$designType])) {
|
||||
foreach ($rules[$designType]['required'] as $field) {
|
||||
if (empty($this->data[$field])) {
|
||||
$warnMsg[] = ucfirst($designType) . " requires {$field}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$allElementFields = [
|
||||
'string_value','string_font','string_size','string_align','string_colour',
|
||||
'string_x_value','string_y_value',
|
||||
'image_x','image_y','image_width','image_height',
|
||||
'shape_name','shape_pen_size','curve_radius',
|
||||
'shape_x1_value','shape_y1_value','shape_x2_value','shape_y2_value',
|
||||
'qr_value','qr_align','qr_size','qr_x_value','qr_y_value',
|
||||
];
|
||||
|
||||
if (isset($rules[$designType])) {
|
||||
$allowed = $rules[$designType]['allowed'];
|
||||
|
||||
foreach ($allElementFields as $field) {
|
||||
if (!in_array($field, $allowed, true) && !empty($this->data[$field])) {
|
||||
$warnMsg[] = "Field {$field} is not allowed for {$designType} element";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(' | ', $warnMsg));
|
||||
}
|
||||
|
||||
StickerDetail::Create([
|
||||
'sticker_structure_detail_id' => $stickerId,
|
||||
'design_element_type' => $this->data['design_element_type'],
|
||||
'element_id' => $this->data['element_id'],
|
||||
'element_type' => $this->data['element_type'],
|
||||
'characteristics_type' => $this->data['characteristics_type'],
|
||||
'string_value' => $this->data['string_value'],
|
||||
'string_font' => $this->data['string_font'],
|
||||
'string_size' => $this->data['string_size'],
|
||||
'element_colour' => $this->data['element_colour'],
|
||||
'string_align' => $this->data['string_align'],
|
||||
'string_x_value' => $this->data['string_x_value'],
|
||||
'string_y_value' => $this->data['string_y_value'],
|
||||
'shape_name' => $this->data['shape_name'],
|
||||
'shape_pen_size' => $this->data['shape_pen_size'],
|
||||
'curve_radius' => $this->data['curve_radius'],
|
||||
'shape_x1_value' => $this->data['shape_x1_value'],
|
||||
'shape_y1_value' => $this->data['shape_y1_value'],
|
||||
'shape_x2_value' => $this->data['shape_x2_value'],
|
||||
'shape_y2_value' => $this->data['shape_y2_value'],
|
||||
'image_x' => $this->data['image_x'],
|
||||
'image_y' => $this->data['image_y'],
|
||||
'image_width' => $this->data['image_width'],
|
||||
'image_height' => $this->data['image_height'],
|
||||
'qr_value' => $this->data['qr_value'],
|
||||
'qr_align' => $this->data['qr_align'],
|
||||
'qr_size' => $this->data['qr_size'],
|
||||
'qr_x_value' => $this->data['qr_x_value'],
|
||||
'qr_y_value' => $this->data['qr_y_value'],
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
//return new StickerDetail();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sticker detail 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,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StickerMappingMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class StickerMappingMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StickerMappingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker1'),
|
||||
ImportColumn::make('sticker2'),
|
||||
ImportColumn::make('sticker3'),
|
||||
ImportColumn::make('sticker4'),
|
||||
ImportColumn::make('sticker5'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerMappingMaster
|
||||
{
|
||||
// return StickerMappingMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new StickerMappingMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sticker mapping 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,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StickerStructureDetail;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class StickerStructureDetailImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StickerStructureDetail::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('sticker_id'),
|
||||
ImportColumn::make('sticker_width'),
|
||||
ImportColumn::make('sticker_height'),
|
||||
ImportColumn::make('sticker_lmargin'),
|
||||
ImportColumn::make('sticker_rmargin'),
|
||||
ImportColumn::make('sticker_tmargin'),
|
||||
ImportColumn::make('sticker_bmargin'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerStructureDetail
|
||||
{
|
||||
// return StickerStructureDetail::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new StickerStructureDetail();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sticker structure detail 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;
|
||||
}
|
||||
}
|
||||
@@ -579,10 +579,6 @@ class TempClassCharacteristicImporter extends Importer
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->exampleHeader('ZMM OPERATING TEMPERATURE')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->exampleHeader('ZMM AXIAL FORCE')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->label('WINDed SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
@@ -609,15 +605,15 @@ class TempClassCharacteristicImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TempClassCharacteristic;
|
||||
return new TempClassCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your temp class characteristic import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
$body = 'Your temp class characteristic import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class WireMasterPackingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = WireMasterPacking::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('customer_po_master_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CUSTOMER PO NUMBER')
|
||||
->example('PO12345')
|
||||
->label('CUSTOMER PO NUMBER')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('wire_packing_number')
|
||||
->exampleHeader('WIRE PACKING NUMBER')
|
||||
->example('WP001')
|
||||
->label('WIRE PACKING NUMBER'),
|
||||
ImportColumn::make('process_order')
|
||||
->exampleHeader('PROCESS ORDER')
|
||||
->example('PO001')
|
||||
->label('PROCESS ORDER'),
|
||||
ImportColumn::make('batch_number')
|
||||
->exampleHeader('BATCH NUMBER')
|
||||
->example('BN001')
|
||||
->label('BATCH NUMBER'),
|
||||
ImportColumn::make('weight')
|
||||
->exampleHeader('WEIGHT')
|
||||
->example('100.5')
|
||||
->label('WEIGHT'),
|
||||
ImportColumn::make('wire_packing_status')
|
||||
->exampleHeader('WIRE PACKING STATUS')
|
||||
->example('Active')
|
||||
->label('WIRE PACKING STATUS'),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('John Doe')
|
||||
->label('CREATED BY'),
|
||||
ImportColumn::make('updated_by')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('Jane Smith')
|
||||
->label('UPDATED BY'),
|
||||
ImportColumn::make('scanned_by')
|
||||
->exampleHeader('SCANNED BY')
|
||||
->example('John Doe')
|
||||
->label('SCANNED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?WireMasterPacking
|
||||
{
|
||||
// return WireMasterPacking::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new WireMasterPacking();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your wire master packing 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;
|
||||
}
|
||||
}
|
||||
@@ -128,8 +128,7 @@ class CycleCount extends Page
|
||||
$operatorName = $user->name;
|
||||
|
||||
$pattern1 = '/^[^#]*#[^#]*#[^#]*#[^#]*#$/';
|
||||
// $pattern2 = '/^[^|]*\|[^|]*\|[^|]*$/';
|
||||
$pattern2 = '/^[^|]+\|[^|]+(?:\|[^|]*)?$/';
|
||||
$pattern2 = '/^[^|]*\|[^|]*\|[^|]*$/';
|
||||
$pattern3 = '/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPp])?\|?$/';
|
||||
|
||||
// $pattern2 = '/^[^|]+\|[^|]+\|[^|]+\|?$/'; Optional Pipeline at end
|
||||
@@ -679,7 +678,7 @@ class CycleCount extends Page
|
||||
$stock->update([
|
||||
'bin' => $bin,
|
||||
'batch' => $this->batch,
|
||||
'doc_no' =>$this->docNo,
|
||||
// 'doc_no' =>$this->docNo,
|
||||
'scanned_quantity' => $newScannedQty,
|
||||
'scanned_status' => $status,
|
||||
]);
|
||||
@@ -722,28 +721,13 @@ class CycleCount extends Page
|
||||
$parts = explode('|', $value);
|
||||
|
||||
$this->itemCode = $parts[0] ?? null;
|
||||
|
||||
if (count($parts) == 2) {
|
||||
// Format: itemcode|serialnumber
|
||||
if (strlen($parts[1]) > strlen($parts[2])) {
|
||||
$this->sNo = $parts[1];
|
||||
$this->batch = null;
|
||||
$this->batch = $parts[2];
|
||||
} else {
|
||||
// Format: itemcode|value1|value2
|
||||
if (strlen($parts[1]) > strlen($parts[2])) {
|
||||
$this->sNo = $parts[1];
|
||||
$this->batch = $parts[2];
|
||||
} else {
|
||||
$this->batch = $parts[1];
|
||||
$this->sNo = $parts[2];
|
||||
}
|
||||
$this->batch = $parts[1];
|
||||
$this->sNo = $parts[2];
|
||||
}
|
||||
// if (strlen($parts[1]) > strlen($parts[2])) {
|
||||
// $this->sNo = $parts[1];
|
||||
// $this->batch = $parts[2];
|
||||
// } else {
|
||||
// $this->batch = $parts[1];
|
||||
// $this->sNo = $parts[2];
|
||||
// }
|
||||
|
||||
if (strlen($this->itemCode) < 6) {
|
||||
Notification::make()
|
||||
@@ -775,7 +759,7 @@ class CycleCount extends Page
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (count($parts) !== 2 && strlen($this->batch) < 5) {
|
||||
} elseif (strlen($this->batch) < 5) {
|
||||
Notification::make()
|
||||
->title('Unknown Batch')
|
||||
->body("Batch should contain minimum 5 digits '$this->batch'")
|
||||
@@ -943,7 +927,7 @@ class CycleCount extends Page
|
||||
'bin' => $bin,
|
||||
'serial_number' => $this->sNo,
|
||||
'stickerMasterId' => $stickerMasterId,
|
||||
'batch' => $this->batch ?? null,
|
||||
'batch' => $this->batch,
|
||||
'docNo' => $this->docNo,
|
||||
'quantity' => $this->quantity,
|
||||
]),
|
||||
@@ -1256,7 +1240,7 @@ class CycleCount extends Page
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($parts) !== 2 && ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null)){
|
||||
if ($serialAgaPlant->batch != '' || $serialAgaPlant->batch != null) {
|
||||
|
||||
if ($serialAgaPlant->batch != $this->batch) {
|
||||
|
||||
@@ -1412,7 +1396,7 @@ class CycleCount extends Page
|
||||
'bin' => $bin,
|
||||
'serial_number' => $this->sNo,
|
||||
'stickerMasterId' => $stickerMasterId,
|
||||
'batch' => $this->batch ?? null,
|
||||
'batch' => $this->batch,
|
||||
'docNo' => $this->docNo,
|
||||
'quantity' => $this->quantity,
|
||||
]),
|
||||
@@ -1431,8 +1415,8 @@ class CycleCount extends Page
|
||||
|
||||
$serial->update([
|
||||
'bin' => $bin ?? null,
|
||||
'batch' => count($parts) !== 2 ? $this->batch : $serial->batch,
|
||||
// 'doc_no' => $this->docNo ?? null,
|
||||
'batch' => $this->batch ?? null,
|
||||
'doc_no' => $this->docNo ?? null,
|
||||
'scanned_status' => 'Scanned',
|
||||
'scanned_quantity' => '1',
|
||||
'updated_at' => now(),
|
||||
@@ -2148,7 +2132,6 @@ class CycleCount extends Page
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Mail\VisitorOutMail;
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\VisitorEntry;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
@@ -17,8 +14,6 @@ use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Mail\VisitorMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class GateOutEntry extends Page implements HasForms
|
||||
{
|
||||
@@ -42,182 +37,38 @@ class GateOutEntry extends Page implements HasForms
|
||||
->schema([
|
||||
Section::make('') // You can give your section a title or leave it blank
|
||||
->schema([
|
||||
Select::make('scan_out_gate_pass')
|
||||
->label('Scan Gate Pass')
|
||||
->required()
|
||||
->reactive()
|
||||
->options([
|
||||
'In' => 'In',
|
||||
'Out' => 'Out',
|
||||
]),
|
||||
TextInput::make('scan_out_gate_pass_in')
|
||||
->label('Scan In Gate Pass')
|
||||
->required()
|
||||
->reactive()
|
||||
->visible(fn ($get) => $get('scan_out_gate_pass') == 'In')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processGatePassIn($event.target.value)',
|
||||
]),
|
||||
TextInput::make('scan_out_gate_pass_out')
|
||||
TextInput::make('scan_out_gate_pass')
|
||||
->label('Scan Out Gate Pass')
|
||||
->required()
|
||||
->reactive()
|
||||
->visible(fn ($get) => $get('scan_out_gate_pass') == 'Out')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processGatePassOut($event.target.value)',
|
||||
'wire:keydown.enter' => 'processGatePass($event.target.value)',
|
||||
]),
|
||||
])
|
||||
->columns(5)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processGatePassIn($gatePass)
|
||||
public function processGatePass($gatePass)
|
||||
{
|
||||
$entry = VisitorEntry::where('register_id', $gatePass)->latest()->first();
|
||||
$entry = VisitorEntry::where('register_id', $gatePass)->first();
|
||||
|
||||
if ($entry)
|
||||
{
|
||||
if($entry->in_time && !$entry->out_time && (empty($entry->valid_upto) || $entry->valid_upto == '' || $entry->valid_upto == null)){
|
||||
Notification::make()
|
||||
->title('Already Entered')
|
||||
->body('Gate pass In has already been processed for entry.')
|
||||
->warning()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_in'] = '';
|
||||
return;
|
||||
}
|
||||
elseif (
|
||||
!empty($entry->valid_upto) &&
|
||||
Carbon::parse($entry->valid_upto)->endOfDay()->gte(now())
|
||||
){
|
||||
if (empty($entry->out_time)) {
|
||||
Notification::make()
|
||||
->title('Gate In Not Allowed')
|
||||
->body("Previous gate-out has not been punched. Please complete gate-out first for ID ' . $gatePass . '.")
|
||||
->warning()
|
||||
->send();
|
||||
if ($entry) {
|
||||
$entry->out_time = now();
|
||||
$entry->save();
|
||||
|
||||
$this->filters['scan_out_gate_pass_in'] = '';
|
||||
return;
|
||||
}
|
||||
else{
|
||||
$newEntry = $entry->replicate();
|
||||
$newEntry->in_time = now();
|
||||
$newEntry->out_time = null;
|
||||
|
||||
$newEntry->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Gate In')
|
||||
->body('Gate in has been successfully processed. Visitor marked as entered.')
|
||||
->success()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_in'] = '';
|
||||
}
|
||||
}
|
||||
else{
|
||||
Notification::make()
|
||||
->title('Visitor Pass Expired')
|
||||
->body('Your visitor pass validity has expired.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_in'] = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Gate Pass Processed')
|
||||
->body('Gate pass has been successfully processed. Visitor marked as exited.')
|
||||
->success()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass'] = '';
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Invalid Gate Pass')
|
||||
->body('Scanned gate in pass is not valid.')
|
||||
->body('The scanned gate pass is not valid. Please try again.')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function processGatePassOut($gatePass)
|
||||
{
|
||||
$entry = VisitorEntry::where('register_id', $gatePass)->latest()->first();
|
||||
|
||||
if (!$entry) {
|
||||
Notification::make()
|
||||
->title('Invalid Gate Pass')
|
||||
->body('Scanned gate out pass is not valid.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($entry->valid_upto) || $entry->valid_upto == '' || $entry->valid_upto == null) {
|
||||
|
||||
if (!empty($entry->out_time)) {
|
||||
Notification::make()
|
||||
->title('Already Exited')
|
||||
->body('Gate pass has already been processed.')
|
||||
->warning()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry->out_time = now();
|
||||
$entry->save();
|
||||
|
||||
$employee = EmployeeMaster::find($entry->employee_master_id);
|
||||
|
||||
if ($employee && !empty($employee->email)) {
|
||||
Mail::to($employee->email)
|
||||
->send(new VisitorOutMail($entry)); // or ->send()
|
||||
}
|
||||
else{
|
||||
\Log::warning('No email found for employee ID: ' . $entry->employee_master_id);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Gate Pass Processed')
|
||||
->body('Visitor marked as exited.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif ((empty($entry->valid_upto) || $entry->valid_upto != '' || $entry->valid_upto != null))
|
||||
{
|
||||
if (Carbon::parse($entry->valid_upto)->endOfDay()->lt(now()))
|
||||
{
|
||||
Notification::make()
|
||||
->title('Visitor Pass Expired')
|
||||
->body('Your visitor pass validity has expired.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
return;
|
||||
}
|
||||
if (!empty($entry->out_time)) {
|
||||
Notification::make()
|
||||
->title('Already Exited')
|
||||
->body('Gate pass has already been processed.')
|
||||
->warning()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
return;
|
||||
}
|
||||
else{
|
||||
$entry->out_time = now();
|
||||
$entry->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Gate Out')
|
||||
->body('Visitor marked as exited.')
|
||||
->success()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass_out'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use App\Models\StickerDetail;
|
||||
use App\Models\StickerMappingMaster;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use App\Models\StickerValidation;
|
||||
use App\Services\StickerPdfService;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StickerPrint extends Page implements HasForms
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.sticker-print';
|
||||
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public $serNo;
|
||||
|
||||
public $ref_number;
|
||||
|
||||
//public $workCenter;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->options(function(){
|
||||
|
||||
$plantId = Filament::auth()->user()->plant_id;
|
||||
|
||||
return $plantId
|
||||
? Plant::where('id',$plantId)
|
||||
->pluck('name','id')
|
||||
: Plant::pluck('name','id');
|
||||
|
||||
})
|
||||
->required(),
|
||||
Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->reactive()
|
||||
->options(function(callable $get){
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
|
||||
})
|
||||
->required(),
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required(),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processSnoNo($event.target.value)',
|
||||
]),
|
||||
])
|
||||
->columns(4),
|
||||
]);
|
||||
}
|
||||
|
||||
public function processSnoNo($qrcode)
|
||||
{
|
||||
|
||||
$parts = explode('|', $qrcode, 2);
|
||||
|
||||
$itemCode = $parts[0] ?? null;
|
||||
$serialNumber = $parts[1] ?? null;
|
||||
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$workCenter = $this->form->getState()['machine_id'];
|
||||
|
||||
$prodOrderNo= $this->form->getState()['production_order'];
|
||||
|
||||
$prodOrderNo = trim($prodOrderNo) ?? null;
|
||||
|
||||
|
||||
if (!$qrcode || !preg_match('/^\d+\|\d+$/', $qrcode)) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Code')
|
||||
->body('QR code format should be like: 123456|12456456464')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
elseif (!preg_match('/^[A-Za-z0-9]+$/', $itemCode)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body('Item code should contain only alpha-numeric values.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
elseif (!preg_match('/^[A-Za-z0-9]+$/', $serialNumber)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body('Serial number should contain only alpha-numeric values.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
$plantName = $plant ? $plant->name : null;
|
||||
|
||||
$pOrderExist = ProductionOrder::where('plant_id', $plantId)
|
||||
->where('production_order', $prodOrderNo)
|
||||
->first();
|
||||
|
||||
if(!$pOrderExist){
|
||||
Notification::make()
|
||||
->title('Unknown Production Order')
|
||||
->body("Production Order not found against plant '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemExist = Item::where('code', $itemCode)->first();
|
||||
|
||||
$itemAgaPlant = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$itemExist){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code '$itemCode' not found.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
elseif(!$itemAgaPlant){
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code '$itemCode' not found against the the plant '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
elseif ($itemAgaPlant->id != $pOrderExist->item_id) {
|
||||
Notification::make()
|
||||
->title('Item Code Mismatch')
|
||||
->body("Item code '$itemCode' does not match the item associated with production order '$prodOrderNo'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$productionOrders = ProductionOrder::where('plant_id', $plantId)
|
||||
->where('production_order', $prodOrderNo)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->get();
|
||||
|
||||
$serialExist = null;
|
||||
|
||||
foreach ($productionOrders as $productionOrder) {
|
||||
|
||||
for (
|
||||
$serial = (int) $productionOrder->from_serial_number;
|
||||
$serial <= (int) $productionOrder->to_serial_number;
|
||||
$serial++
|
||||
) {
|
||||
if ($serial == (int) $serialNumber) {
|
||||
$serialExist = $productionOrder;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$serialExist){
|
||||
Notification::make()
|
||||
->title('Serial Number Not Found')
|
||||
->body("Serial number '$serialNumber' not found for production order '$prodOrderNo', item '$itemCode' and plant '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $prodOrderNo,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//..Generate Sticker PDF and download it
|
||||
|
||||
$this->ref_number = $this->form->getState()['production_order'];
|
||||
|
||||
$this->serNo = $serialNumber;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
$duplicate = StickerValidation::where('plant_id', $plantId)
|
||||
->where('production_order', $this->ref_number)
|
||||
->where('serial_number', $serialNumber)
|
||||
->first();
|
||||
|
||||
if ($duplicate) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Duplicate Serial Number')
|
||||
->body("Serial number $serialNumber already exists for this plant and production order!")
|
||||
->seconds(3)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $this->ref_number,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$itemC = Item::where('code', $itemCode)
|
||||
->where('plant_id',$plantId)
|
||||
->first();
|
||||
|
||||
$itemId = $itemC->id;
|
||||
|
||||
$item = ItemCharacteristic::where('item_id', $itemId)
|
||||
->where('plant_id',$plantId)
|
||||
->first();
|
||||
|
||||
$itemI = $item->id;
|
||||
|
||||
$mapping = StickerMappingMaster::where('plant_id', $plantId)
|
||||
->where('sticker1_machine_id', $workCenter)
|
||||
->where('item_characteristic_id', $itemI)
|
||||
->first();
|
||||
|
||||
if (!$mapping) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Sticker Mapping Not Found')
|
||||
->body("No sticker mapping found for this item and plant.")
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$stickers = [];
|
||||
|
||||
for ($i = 1; $i <= 8; $i++) {
|
||||
$machineColumn = "sticker{$i}_machine_id";
|
||||
$ipColumn = "sticker{$i}_print_ip";
|
||||
$stickerColumn = "sticker_structure{$i}_id";
|
||||
$itemColumn = "item_characteristic_id";
|
||||
|
||||
if (
|
||||
!empty($mapping->$machineColumn) &&
|
||||
!empty($mapping->$stickerColumn)
|
||||
) {
|
||||
$stickers[] = [
|
||||
'machine_id' => $mapping->$machineColumn,
|
||||
'sticker_id' => $mapping->$stickerColumn,
|
||||
'item_characteristic' => $mapping->$itemColumn,
|
||||
'print_ip' => $mapping->$ipColumn,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($stickers)) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('No Sticker Configuration Found')
|
||||
->body('No sticker and machine mappings configured for this item and plant.')
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
StickerValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $this->ref_number ?? null,
|
||||
'serial_number' => $serialNumber,
|
||||
'status' => 'Printed',
|
||||
// 'sticker_id' => $matchedSticker,
|
||||
'created_by' => $operatorName,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sticker Recorded')
|
||||
->body("Item: $itemCode, Serial: $serialNumber recorded successfully!")
|
||||
->seconds(3)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $workCenter,
|
||||
'production_order' => $this->ref_number,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
|
||||
$pdfUrls = [];
|
||||
|
||||
foreach ($stickers as $sticker)
|
||||
{
|
||||
|
||||
$structure = StickerStructureDetail::findOrFail($sticker['sticker_id']);
|
||||
|
||||
$itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)
|
||||
->where('id', $sticker['item_characteristic'])
|
||||
->firstOrFail();
|
||||
|
||||
$dynamicElements = StickerDetail::where(
|
||||
'sticker_structure_detail_id',
|
||||
$structure->id
|
||||
)->where('element_type', 'Dynamic')->get();
|
||||
|
||||
$pdfContent = (new StickerPdfService())->generatePdf1(
|
||||
$structure->sticker_id,
|
||||
$dynamicElements,
|
||||
$itemCharacteristic,
|
||||
$serialNumber,
|
||||
$itemCode,
|
||||
$plantId
|
||||
);
|
||||
|
||||
$tempPdfPath = storage_path('app/temp_sticker_' . uniqid() . '.pdf');
|
||||
|
||||
file_put_contents($tempPdfPath, $pdfContent);
|
||||
|
||||
// $pdfUrl = route('sticker.preview', [
|
||||
// 'path' => basename($tempPdfPath),
|
||||
// ]);
|
||||
$pdfUrls[] = route('sticker.preview', ['path' => basename($tempPdfPath)]);
|
||||
}
|
||||
|
||||
$this->dispatch('open-sticker-pdf', urls: $pdfUrls);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sticker Printed')
|
||||
->body("Sticker for Serial Number: $serialNumber printed successfully!")
|
||||
->seconds(3)
|
||||
->send();
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view sticker print page');
|
||||
}
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerDetail;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use App\Services\StickerPdfService;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StickerStructurePreviewPage extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.sticker-structure-preview-page';
|
||||
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
public $stickerId;
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $itemId;
|
||||
|
||||
public ?string $pdfPreview = null;
|
||||
|
||||
// public array $filters = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['stick_id', 'selected_plant', 'selected_item']);
|
||||
$this->form->fill([
|
||||
'sticker_id' => null,
|
||||
'plant' => null,
|
||||
'item' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Store form state in 'filters'
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('sticker_id')
|
||||
->label('Sticker ID')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
|
||||
return StickerStructureDetail::orderByDesc('id')->pluck('sticker_id', 'sticker_id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(callback: function ($state, callable $set) {
|
||||
session(['stick_id' => $state]);
|
||||
$set('plant', null);
|
||||
$set('item', null);
|
||||
$this->pdfPreview = null;
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->required(),
|
||||
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(['stick_id' => $state]);
|
||||
session(['selected_plant' => $state]);
|
||||
$set('item', null);
|
||||
session()->forget('item');
|
||||
$this->pdfPreview = null;
|
||||
}),
|
||||
Select::make('item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plant = $get('plant');
|
||||
|
||||
return $plant ? ItemCharacteristic::where('plant_id', $plant)->with('item')->get()->pluck('item.code', 'id')->toArray() : []; // ->orderBy('plant_id')
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['stick_id' => $state]);
|
||||
session(['selected_plant' => $state]);
|
||||
session(['selected_item' => $state]);
|
||||
$this->pdfPreview = null;
|
||||
// $set('item_id', null);
|
||||
// session()->forget('item');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
// ViewField::make('generate_template')
|
||||
// ->view('fields.generate-template-preview')
|
||||
// ->reactive()
|
||||
// // ->key(fn ($get) => 'generate-template' . ($get('sticker_id_live') ?? 'empty'))
|
||||
// ->key(fn (Get $get) => 'generate-template-'.
|
||||
// ($get('sticker_id') ?? 'empty').'-'.
|
||||
// ($get('plant') ?? 'empty').'-'.
|
||||
// ($get('item_characteristic_id') ?? 'empty')
|
||||
// )
|
||||
// // ->viewData(fn (Get $get) => [
|
||||
// // 'sticker_id' => $get('sticker_id_live') ?? 'empty',
|
||||
// // ]),
|
||||
// ->viewData(fn (Get $get) => [
|
||||
// 'sticker_id' => $get('sticker_id') ?? 'empty',
|
||||
// 'plant_id' => $get('plant') ?? 'empty',
|
||||
// 'item_characteristic_id' => $get('item') ?? 'empty',
|
||||
// ])
|
||||
// ->hidden(fn (callable $get) => ($get('sticker_id') == null || $get('sticker_id') == '0' || empty($get('sticker_id'))) || (($get('plant') != null || $get('plant') != '') &&
|
||||
// ($get('item') == null || $get('item') == '' || empty($get('item'))))),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public function showPreview()
|
||||
{
|
||||
$state = $this->form->getState();
|
||||
$stickerId = trim($state['sticker_id'] ?? '') ?: null;
|
||||
// $stickerId = $this->form->getState()['sticker_id'];
|
||||
// $stickerId = trim($stickerId) ?? null;
|
||||
$this->stickerId = $stickerId;
|
||||
|
||||
$plantId = trim($state['plant'] ?? '') ?: null;
|
||||
// $plantId = $this->form->getState()['plant'];
|
||||
// $plantId = trim($plantId) ?? null;
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$itemId = trim($state['item'] ?? '') ?: null;
|
||||
// $itemId = $this->form->getState()['item'];
|
||||
// $itemId = trim($itemId) ?? null;
|
||||
$this->itemId = $itemId;
|
||||
|
||||
$this->pdfPreview = null;
|
||||
|
||||
// $operatorName = Filament::auth()->user()->name;
|
||||
|
||||
if (! $stickerId) {
|
||||
Notification::make()->title('Please select a Sticker ID first!')->danger()->duration(2000)->send();
|
||||
|
||||
$this->form->fill([
|
||||
'sticker_id' => $stickerId ?? null,
|
||||
'plant' => $plantId ?? null,
|
||||
'item' => $itemId ?? null,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif ($plantId && ! $itemId) {
|
||||
Notification::make()->title('Please select an Item Code!')->danger()->duration(2000)->send();
|
||||
|
||||
$this->form->fill([
|
||||
'sticker_id' => $stickerId,
|
||||
'plant' => $plantId ?? null,
|
||||
'item' => $itemId ?? null,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif ($stickerId && $plantId && $itemId != null && $itemId != '') {
|
||||
|
||||
$itemCharacteristic = $itemId ? ItemCharacteristic::find($itemId) : null;
|
||||
|
||||
$structure = StickerStructureDetail::where('sticker_id', $stickerId)->first();
|
||||
if (! $structure) {
|
||||
Notification::make()->title('Sticker structure not found!')->danger()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$dynamicElements = StickerDetail::where('sticker_structure_detail_id', $structure->id)->get();
|
||||
|
||||
try {
|
||||
$stickerPdfService = new StickerPdfService;
|
||||
$this->pdfPreview = $stickerPdfService->generateStickerItem($stickerId, $dynamicElements, $itemCharacteristic);
|
||||
|
||||
Notification::make()
|
||||
->title('Sticker Preview Generated!')
|
||||
->success()
|
||||
->duration(2000)
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Error generating sticker preview!')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
} else {
|
||||
$elements = StickerStructureDetail::where('sticker_id', $stickerId)->first();
|
||||
|
||||
try {
|
||||
$stickerPdfService = new StickerPdfService;
|
||||
$this->pdfPreview = $stickerPdfService->generateSticker($stickerId, $elements->toArray());
|
||||
|
||||
Notification::make()
|
||||
->title('Sticker Preview Generated!')
|
||||
->success()
|
||||
->duration(2000)
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Error generating sticker preview!')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Sticker Structure Preview';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Sticker Structure Preview';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view sticker structure preview');
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WireMasterPrint extends Page
|
||||
{
|
||||
@@ -78,69 +77,41 @@ class WireMasterPrint extends Page
|
||||
return [];
|
||||
}
|
||||
|
||||
return CustomerPoMaster::where('plant_id', $plantId)->distinct()->pluck('customer_po', 'customer_po'); //->pluck('customer_po', 'id'); ->distinct()
|
||||
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('scan_pallet_no', null);
|
||||
}),
|
||||
Select::make('scan_pallet_no')
|
||||
->required(),
|
||||
select::make('scan_pallet_no')
|
||||
->label('Scan Pallet No')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
|
||||
// $plantId = $get('plant_id');
|
||||
// $customerPoId = $get('customer_po_master_id');
|
||||
|
||||
// if (! $plantId || ! $customerPoId) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// $palletNumbers = WireMasterPacking::query()
|
||||
// ->select('wire_packing_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('customer_po_master_id', $customerPoId)
|
||||
// ->whereNotNull('wire_packing_number')
|
||||
// ->groupBy('wire_packing_number')
|
||||
// ->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||
// ->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||
// ->orderBy('wire_packing_number', 'asc')
|
||||
// ->pluck('wire_packing_number')
|
||||
// ->toArray();
|
||||
|
||||
// return collect($palletNumbers)
|
||||
// ->mapWithKeys(fn ($number) => [$number => $number])
|
||||
// ->toArray();
|
||||
|
||||
//..New Logic
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$customerPo = $get('customer_po_master_id');
|
||||
$customerPoId = $get('customer_po_master_id');
|
||||
|
||||
if (! $plantId || ! $customerPo)
|
||||
{
|
||||
if (! $plantId || ! $customerPoId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$poIds = CustomerPoMaster::where('plant_id', $plantId)->where('customer_po', $customerPo)->pluck('id');
|
||||
$palletNumbers = WireMasterPacking::query()
|
||||
->select('wire_packing_number')
|
||||
->where('plant_id', $plantId)
|
||||
->whereIn('customer_po_master_id', $poIds)
|
||||
->where('customer_po_master_id', $customerPoId)
|
||||
->whereNotNull('wire_packing_number')
|
||||
->groupBy('wire_packing_number')
|
||||
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||
->orderBy('wire_packing_number')
|
||||
->orderBy('wire_packing_number', 'asc')
|
||||
->pluck('wire_packing_number')
|
||||
->toArray();
|
||||
return collect($palletNumbers) ->mapWithKeys(fn ($number) => [$number => $number]) ->toArray();
|
||||
|
||||
return collect($palletNumbers)
|
||||
->mapWithKeys(fn ($number) => [$number => $number])
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
$palletNo = $state;
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
})
|
||||
->extraAttributes([
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Machine;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
@@ -50,25 +49,6 @@ class AlertMailRuleResource extends Resource
|
||||
->required(fn ($get) => ! $get('is_active'))
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->whereNotNull('work_center')
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('module', null);
|
||||
}),
|
||||
Forms\Components\Select::make('module')
|
||||
->label('Module')
|
||||
->required()
|
||||
@@ -80,9 +60,6 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceTransit' => 'InvoiceTransit',
|
||||
'ImportTransit' => 'ImportTransit',
|
||||
'VehicleReport' => 'VehicleReport',
|
||||
'ExportDispatchReport' => 'ExportDispatchReport',
|
||||
'LaserStopAlert' => 'LaserStopAlert',
|
||||
'LaserStopReport' => 'LaserStopReport',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -96,9 +73,6 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
||||
'ImportTransitMail' => 'Import Transit Mail',
|
||||
'VehicleReportMail' => 'Vehicle Report Mail',
|
||||
'ExportDispatchReportMail' => 'Export Dispatch Report Mail',
|
||||
'LaserStopAlertMail' => 'Laser Stop Alert Mail',
|
||||
'LaserStopMail' => 'Laser Stop Report Mail'
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
@@ -209,11 +183,6 @@ class AlertMailRuleResource extends Resource
|
||||
|
||||
return $plants[$state] ?? 'All Plants';
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('module')
|
||||
->label('Module Name')
|
||||
->alignCenter()
|
||||
@@ -224,14 +193,14 @@ class AlertMailRuleResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name')
|
||||
// ->label('Receiving Plant')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
// Tables\Columns\TextColumn::make('invoiceMaster.transport_name')
|
||||
// ->label('Transporter')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name')
|
||||
->label('Receiving Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoiceMaster.transport_name')
|
||||
->label('Transporter')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('TO Emails')
|
||||
->searchable()
|
||||
|
||||
@@ -285,27 +285,27 @@ class AsrsItemValidationResource extends Resource
|
||||
|
||||
$status = $data['status'] ?? 'NotUpdated';
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['item_code']) && empty($data['uom']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
// $query->where('status', 'NotUpdated');
|
||||
}
|
||||
|
||||
// if (
|
||||
// empty($data['Plant']) &&
|
||||
// empty($data['item_code']) &&
|
||||
// empty($data['uom']) &&
|
||||
// empty($data['status']) &&
|
||||
// empty($data['created_from']) &&
|
||||
// empty($data['created_to'])
|
||||
// ) {
|
||||
// // $query->where('status', 'NotUpdated');
|
||||
// $query->where(function ($q) {
|
||||
// $q->where('status', 'NotUpdated')
|
||||
// ->orWhereNull('status')
|
||||
// ->orWhere('status', '');
|
||||
// });
|
||||
// if (empty($data['Plant']) && empty($data['item_code']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
// // return $query->whereRaw('1 = 0');
|
||||
// $query->where('status', 'NotUpdated');
|
||||
// }
|
||||
|
||||
if (
|
||||
empty($data['Plant']) &&
|
||||
empty($data['item_code']) &&
|
||||
empty($data['uom']) &&
|
||||
empty($data['status']) &&
|
||||
empty($data['created_from']) &&
|
||||
empty($data['created_to'])
|
||||
) {
|
||||
// $query->where('status', 'NotUpdated');
|
||||
$query->where(function ($q) {
|
||||
$q->where('status', 'NotUpdated')
|
||||
->orWhereNull('status')
|
||||
->orWhere('status', '');
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
@@ -387,12 +387,11 @@ class AsrsItemValidationResource extends Resource
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
// ->hidden(function ($record): bool {
|
||||
// if (auth()->user()?->hasRole('Super Admin')) {
|
||||
// if (auth()->user()?->hasRole('SuperAdmin')) {
|
||||
// return false;
|
||||
// }
|
||||
// else{
|
||||
// return trim(($record->status)) == 'Updated';
|
||||
// }
|
||||
|
||||
// return trim(strtolower($record->status)) == 'updated';
|
||||
// }),
|
||||
// ->visible(function ($record): bool {
|
||||
// return auth()->user()?->hasRole('SuperAdmin')
|
||||
|
||||
@@ -1,736 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\BeforeTestReadingExporter;
|
||||
use App\Filament\Resources\BeforeTestReadingResource\Pages;
|
||||
use App\Models\BeforeTestReading;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class BeforeTestReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = BeforeTestReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Motor Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->columnSpan(1) // (['default' => 1, 'sm' => 2])
|
||||
->searchable()
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(BeforeTestReading::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('tPrError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
// ->relationship('line', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(BeforeTestReading::latest()->first())->line_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'work_center')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (! $lineId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Only show machines for the selected line
|
||||
return Machine::where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(BeforeTestReading::latest()->first())->machine_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('motor_testing_master_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('motorTestingMaster', 'item.code')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (!$plantId) {
|
||||
// return [];
|
||||
// }
|
||||
// return MotorTestingMaster::with('item')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->get()
|
||||
// //->filter(fn ($mtm) => $mtm->item)
|
||||
// ->pluck('item.code', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return MotorTestingMaster::query()
|
||||
->join('items', 'motor_testing_masters.item_id', '=', 'items.id')
|
||||
->where('motor_testing_masters.plant_id', $plantId)
|
||||
->select('motor_testing_masters.id', 'items.code')
|
||||
->pluck('items.code', 'motor_testing_masters.id')
|
||||
->toArray();
|
||||
})
|
||||
// ->getOptionLabelUsing(fn ($value) =>
|
||||
// MotorTestingMaster::with('item')->find($value)?->item?->code
|
||||
// )
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_ry')
|
||||
->label('Before FR Resistance RY')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_yb')
|
||||
->label('Before FR Resistance YB')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_res_br')
|
||||
->label('Before FR Resistance BR')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('before_fr_ir')
|
||||
->label('Before FR IR')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('tested_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->readOnly()
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
// Tables\Columns\TextColumn::make('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
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 Name')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
||||
->label('Model')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.kw')
|
||||
->label('KW')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.hp')
|
||||
->label('HP')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.phase')
|
||||
->label('Phase')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.connection')
|
||||
->label('Connection')
|
||||
->alignCenter(),
|
||||
Tables\Columns\IconColumn::make('motorTestingMaster.isi_model')
|
||||
->label('ISI Model')
|
||||
->alignCenter()
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('before_fr_res_ry')
|
||||
->label('Before FR Resistance RY')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('before_fr_res_yb')
|
||||
->label('Before FR Resistance YB')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('before_fr_res_br')
|
||||
->label('Before FR Resistance BR')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('before_fr_ir')
|
||||
->label('Before FR IR')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('scanned_at')
|
||||
->label('Scanned At')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->dateTime(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tested_by')
|
||||
->label('Tested By')
|
||||
->alignCenter()
|
||||
->numeric(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->dateTime(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->numeric(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->dateTime()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('beforeTestReadings', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Line', null);
|
||||
$set('item_code', null);
|
||||
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
Select::make('machine_name')
|
||||
->label('Search by Work Center')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
|
||||
if (! $plantId || ! $lineId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('item_code')
|
||||
->label('Search by Item Code')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
return Item::where('plant_id', $plantId)
|
||||
->whereHas('motorTestingMasters')
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('code', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_description', null);
|
||||
}),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Serial Number'),
|
||||
Select::make('subassembly_code')
|
||||
->label('Search by Subassembly Code')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
return MotorTestingMaster::whereHas('beforeTestReadings', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->whereNotNull('subassembly_code')->orderBy('subassembly_code')->pluck('subassembly_code', 'id');
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('code', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_description', null);
|
||||
}),
|
||||
Select::make('item_description')
|
||||
->label('Search by Model')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
// $query = Item::query();
|
||||
// if ($plantId) {
|
||||
// $query->where('plant_id', $plantId);
|
||||
// }
|
||||
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
return Item::where('plant_id', $plantId)
|
||||
->whereHas('motorTestingMasters')
|
||||
->pluck('description', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('description', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
// return $query->pluck('description', 'description')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
Select::make('connection')
|
||||
->label('Connection')
|
||||
->required()
|
||||
->default('Star')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->reactive(),
|
||||
Select::make('tested_by')
|
||||
->label('Tested By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return BeforeTestReading::whereNotNull('tested_by')->select('tested_by')->distinct()->pluck('tested_by', 'tested_by');
|
||||
} else {
|
||||
return BeforeTestReading::where('plant_id', $plantId)->whereNotNull('tested_by')->select('tested_by')->distinct()->pluck('tested_by', 'tested_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
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),
|
||||
Select::make('updated_by')
|
||||
->label('Updated By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return BeforeTestReading::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
} else {
|
||||
return BeforeTestReading::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
|
||||
// dd($data);
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['item_code']) && empty($data['subassembly_code']) && empty($data['machine_name']) && empty($data['item_description']) && empty($data['serial_number']) && empty($data['connection']) && empty($data['tested_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
// && empty($data['phase'])
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (! empty($data['item_code'])) {
|
||||
// $query->where('item_id', $data['item_code']);
|
||||
$query->whereHas('motorTestingMaster', function ($subQuery) use ($data) {
|
||||
$subQuery->where('item_id', $data['item_code']);
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['subassembly_code'])) {
|
||||
$query->where('motor_testing_master_id', $data['subassembly_code']);
|
||||
}
|
||||
|
||||
if (! empty($data['machine_name'])) {
|
||||
$query->where('machine_id', $data['machine_name']);
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['item_description'])) {
|
||||
$itemId = $data['item_description']; // Item::where('description', $data['item_description'])->first()?->id ?? null;
|
||||
|
||||
if ($itemId) { // $item
|
||||
$mastId = MotorTestingMaster::where('item_id', $itemId)->first()?->id ?? null;
|
||||
if ($mastId) { // $item
|
||||
$motId = BeforeTestReading::where('motor_testing_master_id', $mastId)->first()?->id ?? null;
|
||||
if ($motId) { // $item
|
||||
$query->where('motor_testing_master_id', $mastId);
|
||||
// $query->whereHas('motorTestingMaster', function ($subQuery) use ($itemId) {
|
||||
// $subQuery->where('item_id', $itemId); //$item->id
|
||||
// });
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
// if (!empty($data['phase']))
|
||||
// {
|
||||
// //$query->where('phase',$data['phase']);
|
||||
// $query->whereHas('motorTestingMaster', function ($subQuery) use ($data) {
|
||||
// $subQuery->where('phase', $data['phase']);
|
||||
// });
|
||||
// }
|
||||
|
||||
if (! empty($data['connection'])) {
|
||||
// $query->where('connection',$data['connection']);
|
||||
$query->whereHas('motorTestingMaster', function ($subQuery) use ($data) {
|
||||
$subQuery->where('connection', $data['connection']);
|
||||
});
|
||||
}
|
||||
|
||||
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['tested_by'])) {
|
||||
$query->where('tested_by', $data['tested_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
if (! empty($data['machine_name'])) {
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine_name'])->value('work_center');
|
||||
}
|
||||
if (! empty($data['item_code'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code');
|
||||
}
|
||||
if (! empty($data['subassembly_code'])) {
|
||||
$indicators[] = 'Subassembly Code: '.MotorTestingMaster::where('id', $data['subassembly_code'])->value('subassembly_code');
|
||||
}
|
||||
if (! empty($data['item_description'])) {
|
||||
$item = Item::where('id', $data['item_description'])->first()?->description ?? null;
|
||||
$indicators[] = 'Model: '.$item;
|
||||
}
|
||||
// if (!empty($data['phase'])) {
|
||||
// $indicators[] = 'Phase: ' . $data['phase'];
|
||||
// }
|
||||
if (! empty($data['connection'])) {
|
||||
$indicators[] = 'Connection: '.$data['connection'];
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$indicators[] = 'Serial Number: '.$data['serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['tested_by'])) {
|
||||
$indicators[] = 'Tested By: '.$data['tested_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: '.$data['updated_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([
|
||||
ExportAction::make()
|
||||
->label('Export Before Test Readings')
|
||||
->color('warning')
|
||||
->exporter(BeforeTestReadingExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export before test reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListBeforeTestReadings::route('/'),
|
||||
'create' => Pages\CreateBeforeTestReading::route('/create'),
|
||||
'view' => Pages\ViewBeforeTestReading::route('/{record}'),
|
||||
'edit' => Pages\EditBeforeTestReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BeforeTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BeforeTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBeforeTestReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BeforeTestReadingResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BeforeTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BeforeTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBeforeTestReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = BeforeTestReadingResource::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\BeforeTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BeforeTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBeforeTestReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = BeforeTestReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BeforeTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BeforeTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBeforeTestReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = BeforeTestReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,25 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
|
||||
class CharacteristicApproverMasterResource extends Resource
|
||||
{
|
||||
@@ -33,8 +34,6 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -225,8 +224,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('duration2')
|
||||
->label('Duration (HH.MM)')
|
||||
->reactive()
|
||||
->minLength(4)
|
||||
->maxLength(5)
|
||||
->length(4)
|
||||
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
||||
->validationMessages([
|
||||
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
||||
@@ -258,8 +256,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('duration3')
|
||||
->label('Duration (HH.MM)')
|
||||
->reactive()
|
||||
->minLength(4)
|
||||
->maxLength(5)
|
||||
->length(4)
|
||||
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
||||
->validationMessages([
|
||||
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
||||
@@ -414,7 +411,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('characteristicApproverMaster', function ($query) {
|
||||
return Plant::whereHas('requestCharacteristics', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
@@ -437,7 +434,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::whereHas('characteristicApproverMaster', function ($query) use ($plantId) {
|
||||
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
|
||||
@@ -11,22 +11,22 @@ use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
class ClassCharacteristicResource extends Resource
|
||||
{
|
||||
@@ -36,8 +36,6 @@ class ClassCharacteristicResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -78,7 +76,7 @@ class ClassCharacteristicResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->orderBy('work_center')->pluck('work_center', 'id')->toArray();
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function (callable $get) {
|
||||
@@ -105,7 +103,7 @@ class ClassCharacteristicResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->orderBy('code')->pluck('code', 'id')->toArray();
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function (callable $get) {
|
||||
@@ -976,76 +974,12 @@ class ClassCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
// ->nullable()
|
||||
->selectablePlaceholder(false)
|
||||
->options(function () {
|
||||
return [
|
||||
'0' => 'No',
|
||||
'1' => 'Yes',
|
||||
'2' => 'Yes (Alert Pending)',
|
||||
];
|
||||
})
|
||||
->default('0')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME')
|
||||
->reactive()
|
||||
->placeholder('Select Stopped DateTime')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->reactive()
|
||||
->readOnly(fn (callable $get) => ! $get('id'))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// Forms\Components\TextInput::make('is_stopped')
|
||||
// ->label('IS STOPPED')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function (callable $set) {
|
||||
// $set('updated_by', Filament::auth()->user()?->name);
|
||||
// })
|
||||
// ->default(0)
|
||||
// ->required(),
|
||||
Forms\Components\TextInput::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->integer()
|
||||
->maxValue(3)
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(0)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->reactive()
|
||||
@@ -1055,10 +989,25 @@ class ClassCharacteristicResource extends Resource
|
||||
})
|
||||
->default(now())
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('marked_expected_time')
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->reactive()
|
||||
->readOnly(fn (callable $get) => ! $get('id'))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -1098,14 +1047,11 @@ class ClassCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('motor_marked_physical_count')
|
||||
->label('MOTOR MARKED PHYSICAL COUNT')
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->integer()
|
||||
->maxValue(3)
|
||||
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(0)
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('motor_expected_time')
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
@@ -1116,13 +1062,6 @@ class ClassCharacteristicResource extends Resource
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('motor_marked_datetime')
|
||||
->label('MOTOR MARKED DATETIME')
|
||||
->reactive()
|
||||
->placeholder('Select Motor Marked DateTime')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->reactive()
|
||||
@@ -1140,14 +1079,11 @@ class ClassCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('pump_marked_physical_count')
|
||||
->label('PUMP MARKED PHYSICAL COUNT')
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->integer()
|
||||
->maxValue(3)
|
||||
->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(0)
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('pump_expected_time')
|
||||
->label('PUMP EXPECTED TIME')
|
||||
@@ -1158,13 +1094,6 @@ class ClassCharacteristicResource extends Resource
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('pump_marked_datetime')
|
||||
->label('PUMP MARKED DATETIME')
|
||||
->reactive()
|
||||
->placeholder('Select Pump Marked DateTime')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->reactive()
|
||||
@@ -1188,13 +1117,6 @@ class ClassCharacteristicResource extends Resource
|
||||
})
|
||||
->default('0')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('name_plate_marked_datetime')
|
||||
->label('NAME PLATE MARKED DATETIME')
|
||||
->reactive()
|
||||
->placeholder('Select Name Plate Marked DateTime')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY')
|
||||
->reactive()
|
||||
@@ -1243,15 +1165,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_rework_status')
|
||||
->label('WINDED REWORK STATUS')
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->integer()
|
||||
->maxValue(1)
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->reactive()
|
||||
@@ -1301,7 +1214,6 @@ class ClassCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('pending_released_status')
|
||||
->label('PENDING RELEASED STATUS')
|
||||
->reactive()
|
||||
->integer()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -1310,9 +1222,6 @@ class ClassCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID')
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->integer()
|
||||
->maxValue(3)
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -1361,27 +1270,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('DESCRIPTION')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.category')
|
||||
->label('CATEGORY')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('AUFNR')
|
||||
->alignCenter()
|
||||
@@ -1406,7 +1294,6 @@ class ClassCharacteristicResource extends Resource
|
||||
Tables\Columns\TextColumn::make('gernr')
|
||||
->label('GERNR')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD')
|
||||
@@ -1927,27 +1814,14 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_axial_force')
|
||||
->label('ZMM AXIAL FORCE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('is_stopped')
|
||||
->label('IS STOPPED')
|
||||
->alignCenter()
|
||||
->formatStateUsing(fn ($state) => ($state == '0') ? 'No' : ($state == '1' ? 'Yes' : 'Yes (Alert Pending)'))
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stopped_datetime')
|
||||
->label('STOPPED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('stopped_by')
|
||||
->label('STOPPED BY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('marked_physical_count')
|
||||
->label('MARKED PHYSICAL COUNT')
|
||||
->alignCenter()
|
||||
@@ -1956,10 +1830,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('MARKED EXPECTED TIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('marked_datetime')
|
||||
->label('MARKED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('marked_by')
|
||||
->label('MARKED BY')
|
||||
->alignCenter()
|
||||
@@ -1988,10 +1858,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('MOTOR EXPECTED TIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_marked_datetime')
|
||||
->label('MOTOR MARKED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_marked_by')
|
||||
->label('MOTOR MARKED BY')
|
||||
->alignCenter()
|
||||
@@ -2008,10 +1874,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('PUMP EXPECTED TIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pump_marked_datetime')
|
||||
->label('PUMP MARKED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pump_marked_by')
|
||||
->label('PUMP MARKED BY')
|
||||
->alignCenter()
|
||||
@@ -2024,10 +1886,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('NAME PLATE EXPECTED TIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name_plate_marked_datetime')
|
||||
->label('NAME PLATE MARKED DATETIME')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name_plate_marked_by')
|
||||
->label('NAME PLATE MARKED BY')
|
||||
->alignCenter()
|
||||
@@ -2040,10 +1898,6 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('winded_rework_status')
|
||||
->label('WINDED REWORK STATUS')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_machine_name')
|
||||
->label('MOTOR MACHINE NAME')
|
||||
->alignCenter()
|
||||
@@ -2092,10 +1946,12 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('UPDATED AT')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->alignCenter()
|
||||
@@ -2129,6 +1985,7 @@ class ClassCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('machine', null);
|
||||
$set('item_id', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('machine')
|
||||
->label('Search by Work Center')
|
||||
@@ -2147,6 +2004,10 @@ class ClassCharacteristicResource extends Resource
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('item_id', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('item_id')
|
||||
->label('Search by Item Code')
|
||||
@@ -2165,6 +2026,9 @@ class ClassCharacteristicResource extends Resource
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
TextInput::make('aufnr')
|
||||
->label('Job Number')
|
||||
@@ -2177,37 +2041,7 @@ class ClassCharacteristicResource extends Resource
|
||||
TextInput::make('zmm_heading')
|
||||
->label('Heading')
|
||||
->placeholder('Enter Heading'),
|
||||
DateTimePicker::make('motor_marked_from')
|
||||
->label('Motor Marked From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('motor_marked_to')
|
||||
->label('Motor Marked To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('pump_marked_from')
|
||||
->label('Pump Marked From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('pump_marked_to')
|
||||
->label('Pump Marked To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('name_plate_marked_from')
|
||||
->label('Name Plate Marked From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('name_plate_marked_to')
|
||||
->label('Name Plate Marked To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_from')
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
@@ -2217,36 +2051,10 @@ class ClassCharacteristicResource extends Resource
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('created_by')
|
||||
->label('Search by Created By')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function () {
|
||||
return ClassCharacteristic::pluck('created_by', 'created_by');
|
||||
}),
|
||||
DateTimePicker::make('updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('updated_by')
|
||||
->label('Search by Updated By')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function () {
|
||||
return ClassCharacteristic::pluck('updated_by', 'updated_by');
|
||||
}),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['motor_marked_from']) && empty($data['motor_marked_to']) && empty($data['pump_marked_from']) && empty($data['pump_marked_to']) && empty($data['name_plate_marked_from']) && empty($data['name_plate_marked_to']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['updated_from']) && empty($data['updated_to']) && empty($data['updated_by'])) {
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -2280,30 +2088,6 @@ class ClassCharacteristicResource extends Resource
|
||||
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['motor_marked_from'])) {
|
||||
$query->where('motor_marked_datetime', '>=', $data['motor_marked_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['motor_marked_to'])) {
|
||||
$query->where('motor_marked_datetime', '<=', $data['motor_marked_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['pump_marked_from'])) {
|
||||
$query->where('pump_marked_datetime', '>=', $data['pump_marked_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['pump_marked_to'])) {
|
||||
$query->where('pump_marked_datetime', '<=', $data['pump_marked_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['name_plate_marked_from'])) {
|
||||
$query->where('name_plate_marked_datetime', '>=', $data['name_plate_marked_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['name_plate_marked_to'])) {
|
||||
$query->where('name_plate_marked_datetime', '<=', $data['name_plate_marked_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -2311,22 +2095,6 @@ class ClassCharacteristicResource extends Resource
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
@@ -2361,52 +2129,12 @@ class ClassCharacteristicResource extends Resource
|
||||
$indicators[] = 'Heading: '.$data['zmm_heading'];
|
||||
}
|
||||
|
||||
if (! empty($data['motor_marked_from'])) {
|
||||
$indicators[] = 'Motor Marked From: '.$data['motor_marked_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['motor_marked_to'])) {
|
||||
$indicators[] = 'Motor Marked To: '.$data['motor_marked_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['pump_marked_from'])) {
|
||||
$indicators[] = 'Pump Marked From: '.$data['pump_marked_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['pump_marked_to'])) {
|
||||
$indicators[] = 'Pump Marked To: '.$data['pump_marked_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['name_plate_marked_from'])) {
|
||||
$indicators[] = 'Name Plate Marked From: '.$data['name_plate_marked_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['name_plate_marked_to'])) {
|
||||
$indicators[] = 'Name Plate Marked To: '.$data['name_plate_marked_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: '.$data['created_from'];
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['created_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
|
||||
@@ -82,13 +82,6 @@ class CustomerPoMasterResource extends Resource
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
@@ -117,18 +110,10 @@ class CustomerPoMasterResource extends Resource
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\DealerVisitPlanResource\Pages;
|
||||
use App\Filament\Resources\DealerVisitPlanResource\RelationManagers;
|
||||
use App\Models\DealerVisitPlan;
|
||||
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\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use App\Filament\Exports\DealerVisitPlanExporter;
|
||||
use App\Filament\Imports\DealerVisitPlanImporter;
|
||||
|
||||
class DealerVisitPlanResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DealerVisitPlan::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Gate Entry';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('organizer')
|
||||
->label('Organizer'),
|
||||
Forms\Components\TextInput::make('mobile_number')
|
||||
->label('Mobile Number'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Dealer Name'),
|
||||
Forms\Components\TextInput::make('company')
|
||||
->label('Dealer Company'),
|
||||
Forms\Components\DatePicker::make('visit_plan_date')
|
||||
->label('Visit Plan Date'),
|
||||
Forms\Components\Select::make('employee_master_id')
|
||||
->label('Recipient Employee')
|
||||
->relationship('employeeMaster', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('number_of_person')
|
||||
->label('Number Of Person'),
|
||||
Forms\Components\TextInput::make('purpose_of_visit')
|
||||
->label('Purpose Of Visit'),
|
||||
Forms\Components\Select::make('mode_of_travel')
|
||||
->label('Mode Of Travel')
|
||||
->options([
|
||||
'Rental' => 'Rental',
|
||||
'Car' => 'Car',
|
||||
'Bike' => 'Bike',
|
||||
])
|
||||
->reactive()
|
||||
->placeholder('Select Mode of Travel'),
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Planned' => 'Planned',
|
||||
'Completed' => 'Completed',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Dealer Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('company')
|
||||
->label('Dealer Company')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('visit_plan_date')
|
||||
->label('Visit Plan Date')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->date()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('organizer')
|
||||
->label('Organizer')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mobile_number')
|
||||
->label('Mobile Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('employeeMaster.name')
|
||||
->label('Recipient Employee')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('number_of_person')
|
||||
->label('No of Person')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('purpose_of_visit')
|
||||
->label('Purpose of Visit')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mode_of_travel')
|
||||
->label('Mode of travel')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Dealer Visit Plan')
|
||||
->color('warning')
|
||||
->importer(DealerVisitPlanImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import dealer visit plan');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Dealer Visit Plan')
|
||||
->color('warning')
|
||||
->exporter(DealerVisitPlanExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export dealer visit plan');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDealerVisitPlans::route('/'),
|
||||
'create' => Pages\CreateDealerVisitPlan::route('/create'),
|
||||
'view' => Pages\ViewDealerVisitPlan::route('/{record}'),
|
||||
'edit' => Pages\EditDealerVisitPlan::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DealerVisitPlanResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDealerVisitPlan extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DealerVisitPlanResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DealerVisitPlanResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDealerVisitPlan extends EditRecord
|
||||
{
|
||||
protected static string $resource = DealerVisitPlanResource::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\DealerVisitPlanResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DealerVisitPlanResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDealerVisitPlans extends ListRecords
|
||||
{
|
||||
protected static string $resource = DealerVisitPlanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DealerVisitPlanResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewDealerVisitPlan extends ViewRecord
|
||||
{
|
||||
protected static string $resource = DealerVisitPlanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@@ -31,7 +30,7 @@ class EquipmentMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Motor Testing Panel';
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
@@ -40,32 +39,18 @@ class EquipmentMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->searchable()
|
||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('machine_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(EquipmentMaster::latest()->first())->plant_id;
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
// ->relationship('machine', 'name')
|
||||
->label('Work Center')
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -75,30 +60,15 @@ class EquipmentMasterResource extends Resource
|
||||
|
||||
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Name'),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Description'),
|
||||
Forms\Components\TextInput::make('make')
|
||||
->label('Make')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Make'),
|
||||
Forms\Components\TextInput::make('model')
|
||||
->label('Model')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Model'),
|
||||
Forms\Components\TextInput::make('equipment_number')
|
||||
->label('Equipment Number')
|
||||
->reactive()
|
||||
@@ -112,8 +82,6 @@ class EquipmentMasterResource extends Resource
|
||||
];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (! $state) {
|
||||
return;
|
||||
}
|
||||
@@ -140,10 +108,7 @@ class EquipmentMasterResource extends Resource
|
||||
// }
|
||||
// }),
|
||||
Forms\Components\TextInput::make('instrument_serial_number')
|
||||
->label('Instrument Serial Number')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Instrument Serial Number'),
|
||||
// Forms\Components\DateTimePicker::make('calibrated_on')
|
||||
// ->label('Calibrated On')
|
||||
// ->required(),
|
||||
@@ -163,7 +128,6 @@ class EquipmentMasterResource extends Resource
|
||||
$frequency = $get('frequency') ?? '1';
|
||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $frequency = (int) $get('frequency');
|
||||
@@ -188,7 +152,6 @@ class EquipmentMasterResource extends Resource
|
||||
$calibratedOn = $get('calibrated_on');
|
||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $calibratedOn = $get('calibrated_on');
|
||||
@@ -208,21 +171,12 @@ class EquipmentMasterResource extends Resource
|
||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||
->label('Next Calibration Date')
|
||||
->readOnly()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('calibrated_by')
|
||||
->label('Calibrated By')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Calibrated By'),
|
||||
Forms\Components\Textarea::make('calibration_certificate')
|
||||
->label('Calibration Certificate')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Calibration Certificate'),
|
||||
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
@@ -231,10 +185,7 @@ class EquipmentMasterResource extends Resource
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->reactive(),
|
||||
|
||||
// Forms\Components\Actions::make([
|
||||
// Action::make('uploadNow')
|
||||
@@ -390,11 +341,7 @@ class EquipmentMasterResource extends Resource
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
->label('Updated By'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -412,7 +359,7 @@ class EquipmentMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
@@ -466,30 +413,24 @@ class EquipmentMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('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(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
|
||||
@@ -77,48 +77,42 @@ class GuardPatrolEntryResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('gPePlantError') ? $get('gPePlantError') : null)
|
||||
->hintColor('danger'),
|
||||
// Forms\Components\Select::make('guard_name_id')
|
||||
// ->label('Guard Name')
|
||||
// // ->relationship('guardNames', 'name')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (! $plantId) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// return GuardName::where('plant_id', $plantId)
|
||||
// ->pluck('name', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
// ->required()
|
||||
// ->reactive()
|
||||
// ->default(function () {
|
||||
// return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->guard_name_id;
|
||||
// })
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $guardName = $get('guard_name_id');
|
||||
// if (! $guardName) {
|
||||
// $set('gPeGuardNameError', 'Please select a guard name first.');
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// $set('patrol_time', now()->format('Y-m-d H:i:s'));
|
||||
// $set('updated_by', Filament::auth()->user()?->name);
|
||||
// $set('gPeGuardNameError', null);
|
||||
// }
|
||||
// })
|
||||
// ->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('gPeGuardNameError') ? 'border-red-500' : '',
|
||||
// ])
|
||||
// ->hint(fn ($get) => $get('gPeGuardNameError') ? $get('gPeGuardNameError') : null)
|
||||
// ->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('guard_name')
|
||||
Forms\Components\Select::make('guard_name_id')
|
||||
->label('Guard Name')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->readOnly()
|
||||
->dehydrated(),
|
||||
// ->relationship('guardNames', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return GuardName::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->guard_name_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$guardName = $get('guard_name_id');
|
||||
if (! $guardName) {
|
||||
$set('gPeGuardNameError', 'Please select a guard name first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('patrol_time', now()->format('Y-m-d H:i:s'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('gPeGuardNameError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('gPeGuardNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('gPeGuardNameError') ? $get('gPeGuardNameError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Hidden::make('check_point_name')// TextInput
|
||||
->label('Check Point Name')
|
||||
->reactive()
|
||||
@@ -129,89 +123,50 @@ class GuardPatrolEntryResource extends Resource
|
||||
->extraAttributes([
|
||||
'x-on:keydown.enter.prevent' => '$wire.processCheckPointName()',
|
||||
]),
|
||||
// Forms\Components\Select::make('check_point_name_id')
|
||||
// ->label('Check Point Name')
|
||||
// // ->relationship('checkPointNames', 'name')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (! $plantId) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// return CheckPointName::where('plant_id', $plantId)
|
||||
// ->pluck('name', 'id')
|
||||
// ->toArray();
|
||||
// })
|
||||
// ->required()
|
||||
// ->reactive()
|
||||
// // ->default(function () {
|
||||
// // return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point_name_id;
|
||||
// // })
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $checkPointName = $get('check_point_name_id');
|
||||
// if (! $checkPointName) {
|
||||
// $set('check_point_name_id', null);
|
||||
// $set('gPeCheckPointNameError', 'Please select a check point name first.');
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// $set('patrol_time', now()->format('Y-m-d H:i:s'));
|
||||
// $set('updated_by', Filament::auth()->user()?->name);
|
||||
// $set('gPeCheckPointNameError', null);
|
||||
// }
|
||||
// })
|
||||
// ->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('gPeCheckPointNameError') ? 'border-red-500' : '',
|
||||
// ])
|
||||
// ->hint(fn ($get) => $get('gPeCheckPointNameError') ? $get('gPeCheckPointNameError') : null)
|
||||
// ->hintColor('danger')
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('guard_patrol_entries', 'check_point_name_id')
|
||||
// ->where('guard_name_id', $get('guard_name_id'))
|
||||
// ->where('patrol_time', now())
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
|
||||
Forms\Components\Hidden::make('check_point_name_id')
|
||||
->dehydrated(true),
|
||||
Forms\Components\TextInput::make('check_point_name')
|
||||
Forms\Components\Select::make('check_point_name_id')
|
||||
->label('Check Point Name')
|
||||
// ->relationship('checkPointNames', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CheckPointName::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->required()
|
||||
->autofocus()
|
||||
->reactive()
|
||||
// ->default(function () {
|
||||
// return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point_name_id;
|
||||
// })
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if (blank($state)) {
|
||||
$checkPointName = $get('check_point_name_id');
|
||||
if (! $checkPointName) {
|
||||
$set('check_point_name_id', null);
|
||||
$set('gPeCheckPointNameError', 'Please enter a check point name.');
|
||||
$set('gPeCheckPointNameError', 'Please select a check point name first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('patrol_time', now()->format('Y-m-d H:i:s'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('gPeCheckPointNameError', null);
|
||||
}
|
||||
|
||||
$checkPoint = CheckPointName::where('plant_id', $get('plant_id'))
|
||||
->whereRaw('LOWER(name) = ?', [strtolower(trim($state))])
|
||||
->first();
|
||||
|
||||
if (! $checkPoint) {
|
||||
$set('check_point_name_id', null);
|
||||
$set('gPeCheckPointNameError', 'Invalid check point name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set('check_point_name_id', $checkPoint->id);
|
||||
$set('patrol_time', now());
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
$set('gPeCheckPointNameError', null);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('gPeCheckPointNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('gPeCheckPointNameError'))
|
||||
->hintColor('danger'),
|
||||
->hint(fn ($get) => $get('gPeCheckPointNameError') ? $get('gPeCheckPointNameError') : null)
|
||||
->hintColor('danger')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('guard_patrol_entries', 'check_point_name_id')
|
||||
->where('guard_name_id', $get('guard_name_id'))
|
||||
->where('patrol_time', now())
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('reader_code')
|
||||
->label('Reader Code')
|
||||
->hidden(fn (Get $get) => ! $get('id'))
|
||||
@@ -222,11 +177,11 @@ class GuardPatrolEntryResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Hidden::make('patrol_time')
|
||||
Forms\Components\DateTimePicker::make('patrol_time')
|
||||
->label('Patrol Time')
|
||||
->reactive()
|
||||
->default(fn () => now())
|
||||
// ->readOnly(fn (Get $get) => ! $get('id'))
|
||||
->readOnly(fn (Get $get) => ! $get('id'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
namespace App\Filament\Resources\GuardPatrolEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GuardPatrolEntryResource;
|
||||
use App\Models\CheckPointName;
|
||||
use App\Models\CheckPointTime;
|
||||
use App\Models\GuardName;
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -33,100 +29,6 @@ class CreateGuardPatrolEntry extends CreateRecord
|
||||
|
||||
// public ?array $data = null;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$guardId = GuardName::where(
|
||||
'name',
|
||||
Filament::auth()->user()?->name
|
||||
)->value('id');
|
||||
|
||||
if (! $guardId) {
|
||||
|
||||
Notification::make()
|
||||
->title('Guard Name Not Matched')
|
||||
->body('Logged-in user name was not found in Guard Name Master.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
$data['guard_name_id'] = $guardId;
|
||||
|
||||
$checkPoint = CheckPointName::where('plant_id', $data['plant_id'])
|
||||
->where('name', trim($data['check_point_name']))
|
||||
->value('id');
|
||||
|
||||
if (! $checkPoint) {
|
||||
Notification::make()
|
||||
->title('Invalid Check Point')
|
||||
->body('The entered check point name does not exist.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
// $lastScan = GuardPatrolEntry::where('plant_id', $data['plant_id'])
|
||||
// ->where('guard_name_id', $guardId)
|
||||
// ->latest('id')
|
||||
// ->first();
|
||||
|
||||
// if ($lastScan) {
|
||||
|
||||
// $previousPoint = $lastScan->check_point_name_id;
|
||||
|
||||
// $route = CheckPointTime::where('plant_id', $data['plant_id'])
|
||||
// ->where('check_point1_id', $previousPoint)
|
||||
// ->where('check_point2_id', $checkPoint->id)
|
||||
// ->first();
|
||||
|
||||
|
||||
// if (! $route) {
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Wrong Check Point Order')
|
||||
// ->body('This checkpoint is not the next allowed point.')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// $this->halt();
|
||||
// }
|
||||
|
||||
|
||||
// } else {
|
||||
|
||||
|
||||
// // First scan must start from sequence 1
|
||||
|
||||
// $firstRoute = CheckPointTime::where('plant_id', $data['plant_id'])
|
||||
// ->where('check_point2_id', $checkPoint->id)
|
||||
// ->where('sequence_number', 1)
|
||||
// ->first();
|
||||
|
||||
|
||||
// if (! $firstRoute) {
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Invalid Starting Point')
|
||||
// ->body('Patrol must start from the first checkpoint.')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// $this->halt();
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
$data['check_point_name_id'] = $checkPoint;
|
||||
|
||||
|
||||
unset($data['check_point_name']);
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function processCheckPointName()
|
||||
{
|
||||
|
||||
@@ -24,10 +24,6 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
// use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class ImportTransitResource extends Resource
|
||||
@@ -44,16 +40,16 @@ class ImportTransitResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('cri_rfq_number')
|
||||
->label('CRI/RFQ Number')
|
||||
->required()
|
||||
->disabled(fn ($operation) => $operation == 'edit'),
|
||||
->disabled(fn ($operation) => $operation == 'edit')
|
||||
->unique(ignoreRecord: true),
|
||||
Forms\Components\DatePicker::make('mail_received_date')
|
||||
->label('Mail Received Date')
|
||||
->required(),
|
||||
// Forms\Components\TextInput::make('pricol_ref_number')
|
||||
// ->label('Ref Number')
|
||||
// ->afterStateUpdated(function (callable $set) {
|
||||
// $set('updated_by', Filament::auth()->user()?->name);
|
||||
// }),
|
||||
Forms\Components\TextInput::make('pricol_ref_number')
|
||||
->label('Pricol Ref Number')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('requester')
|
||||
->label('Requester')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
@@ -79,7 +75,7 @@ class ImportTransitResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('inv_value')
|
||||
Forms\Components\DatePicker::make('inv_value')
|
||||
->label('Inv Value')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -99,8 +95,16 @@ class ImportTransitResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('status')
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Under Service Provider Finalization' => 'Under Service Provider Finalization',
|
||||
'Yet to pick up' => 'Yet to pick up',
|
||||
'Awaiting Vessel Loading' => 'Awaiting Vessel Loading',
|
||||
'In Transit' => 'In Transit',
|
||||
'Under Import Customs Clearance in Destination' => 'Under Import Customs Clearance in Destination',
|
||||
'Delivered' => 'Delivered',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -180,17 +184,8 @@ class ImportTransitResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('remark')
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->options([
|
||||
'Under Service Provider Finalization' => 'Under Service Provider Finalization',
|
||||
'Yet to pick up' => 'Yet to pick up',
|
||||
'Awaiting Vessel Loading' => 'Awaiting Vessel Loading',
|
||||
'In Transit' => 'In Transit',
|
||||
'Under Import Customs Clearance in Destination' => 'Under Import Customs Clearance in Destination',
|
||||
'Delivered' => 'Delivered',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -225,158 +220,128 @@ class ImportTransitResource extends Resource
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('cri_rfq_number')
|
||||
->label('CRI/RFQ Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail_received_date')
|
||||
->label('Mail Received Date')
|
||||
->searchable()
|
||||
->date()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pricol_ref_number')
|
||||
->label('Ref Number')
|
||||
->searchable()
|
||||
->label('Pricol Ref Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requester')
|
||||
->label('Requester')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper')
|
||||
->label('Shipper')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_location')
|
||||
->label('Shipper Location')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_invoice')
|
||||
->label('Shipper Invoice')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_invoice_date')
|
||||
->label('Shipper Invoice Date')
|
||||
->searchable()
|
||||
->date()
|
||||
->formatStateUsing(fn ($state) => $state?->format('Y-m-d'))
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inv_value')
|
||||
->label('Inv Value')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('freight_charge')
|
||||
->label('Freight Charge')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('customs_agent_name')
|
||||
->label('Customs Agent Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('eta_date')
|
||||
->label('ETA Date')
|
||||
->searchable()
|
||||
->date()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('insurance_status')
|
||||
->label('Insurance Status')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('delivery_location')
|
||||
->label('Delivery Location')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('etd_date')
|
||||
->label('ETD Date')
|
||||
->searchable()
|
||||
->date()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mode')
|
||||
->label('Mode')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inco_terms')
|
||||
->label('Inco Terms')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('port_of_loading')
|
||||
->label('Port of Loading')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('port_of_discharge')
|
||||
->label('Port of Discharge')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('delivery_city')
|
||||
->label('Delivery City')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('packages')
|
||||
->label('Packages')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type_of_package')
|
||||
->label('Type of Package')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('gross_weight')
|
||||
->label('Gross Weight')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('volume')
|
||||
->label('Volume')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bill_number')
|
||||
->label('Bill Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bill_received_date')
|
||||
->label('Bill Received Date')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->date()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('vessel_number')
|
||||
->label('Vessel Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('is_transit_identified')
|
||||
->label('Is Transit Identified')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -407,100 +372,7 @@ class ImportTransitResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
TextInput::make('cri_rfq_number')
|
||||
->label('CRI RFQ Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Rfq Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
}),
|
||||
TextInput::make('status')
|
||||
->label('Status')
|
||||
->reactive()
|
||||
->placeholder('Enter Status')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
}),
|
||||
Select::make('is_transit_identified')
|
||||
->label('Is Transit Identified')
|
||||
->reactive()
|
||||
->options([
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
}),
|
||||
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['cri_rfq_number']) && empty($data['status']) && ! isset($data['is_transit_identified']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if (! empty($data['cri_rfq_number'])) {
|
||||
$query->where('cri_rfq_number', 'like', '%'.$data['cri_rfq_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$query->where('status', 'like', '%'.$data['status'].'%');
|
||||
}
|
||||
|
||||
if (isset($data['is_transit_identified'])) {
|
||||
$query->where('is_transit_identified', $data['is_transit_identified']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['cri_rfq_number'])) {
|
||||
$indicators[] = 'CRI Rfq Number: '.$data['cri_rfq_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$indicators[] = 'Status: '.$data['status'];
|
||||
}
|
||||
|
||||
if (isset($data['is_transit_identified'])) {
|
||||
$indicators[] = 'Is Transit Identified: '.$data['is_transit_identified'];
|
||||
}
|
||||
|
||||
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(),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -211,31 +211,16 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} else {
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
$totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); // ->where('quantity', '!=', '')
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if ($totMQuan > 0) {
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totMQuan;
|
||||
$scanMatQuan = $scanMQuan;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
if ($totQuan == $scanMQuan) {
|
||||
@@ -626,7 +611,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => 1,
|
||||
'quantity' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
@@ -669,7 +653,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => $bundleQty,
|
||||
'quantity' => $bundleQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
@@ -714,13 +697,11 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// 8 = 3 + 5 // 8 = 5 + 3 // 8 = 0 + 8 // 8 = 8 + 0
|
||||
// 8 = 3 + 5 // 8 = 5 + 3 // 8 = 0 + 8 // 8 = 8 + 0
|
||||
// 0 = 0 + 0
|
||||
// 4 = 1.5 + 2.5
|
||||
$existQty = $existEmpQty + $existComQty;
|
||||
|
||||
// 8 <= 11 // 8 <= 8 // 8 <= 11 // 8 <= 9
|
||||
// 8 <= 7 // 8 <= 7 // 8 <= 7 // 8 <= 7
|
||||
// 0 <= 5
|
||||
// 4 <= 2
|
||||
|
||||
if ($existQty <= $totalExcelQty) {
|
||||
// 6 = 11 - 5 // 5 = 8 - 3 // 3 = 11 - 8 // 9 = 9 - 0
|
||||
@@ -742,46 +723,29 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'updated_by' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
|
||||
->update([
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
]);
|
||||
|
||||
$newQuan--;
|
||||
$inserted++;
|
||||
} elseif ($newInsQty > 0) { // if ($sticker) // create
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
|
||||
->update([
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
]);
|
||||
|
||||
InvoiceValidation::create([
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
// 8 > 7 // 8 > 7 // 8 > 7 // 8 > 7
|
||||
// 4 > 2
|
||||
else {
|
||||
// 2 = 7 - 5 // 4 = 7 - 3 // -1 = 7 - 8 // 7 = 7 - 0
|
||||
// -0.5 = 2 - 2.5 //
|
||||
$newInsQty = $totalExcelQty - $existComQty;
|
||||
|
||||
// 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0
|
||||
// 1.5 > 0 //
|
||||
if ($newInsQty > 0 && $existEmpQty > 0) { // update
|
||||
if ($existEmpQty > 0) { // update
|
||||
// 3 = 2 // 5 = 4 // 0 = -1 // 8 = 7
|
||||
// 1.5 == -0.5 //
|
||||
if ($existEmpQty == $newInsQty) {
|
||||
continue;
|
||||
}
|
||||
@@ -792,12 +756,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'updated_by' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
|
||||
->update([
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
]);
|
||||
|
||||
$newQuan--;
|
||||
$inserted++;
|
||||
} elseif ($newInsQty > 0) { // create
|
||||
@@ -805,18 +763,11 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)
|
||||
->update([
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
]);
|
||||
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
@@ -844,27 +795,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totalQuantity;
|
||||
$scanMatQuan = $scannedQuantity;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity' => $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity) {
|
||||
@@ -891,27 +827,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totalQuantity;
|
||||
$scanMatQuan = $scannedQuantity;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity' => $scannedQuantity,
|
||||
]);
|
||||
|
||||
// if ($disk->exists($filePath)) {
|
||||
@@ -1870,7 +1791,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => 1,
|
||||
'quantity' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
@@ -1906,7 +1826,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => $bundleQty,
|
||||
'quantity' => $bundleQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
@@ -1940,7 +1859,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_quantity' => $totalExcelQty,
|
||||
'quantity' => $totalExcelQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
@@ -1963,27 +1881,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totalQuantity;
|
||||
$scanMatQuan = $scannedQuantity;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity' => $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity) {
|
||||
@@ -2011,27 +1914,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totalQuantity;
|
||||
$scanMatQuan = $scannedQuantity;
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity' => $scannedQuantity,
|
||||
]);
|
||||
|
||||
// if ($disk->exists($filePath)) {
|
||||
@@ -2523,20 +2411,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
} else {
|
||||
if ($totMQuan > 0) {
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totQuan;
|
||||
$scanMatQuan = $scanMQuan;
|
||||
}
|
||||
|
||||
if ($totQuan == $scanMQuan) {
|
||||
Notification::make()
|
||||
->title('Completed: Material Invoice')
|
||||
@@ -2573,9 +2447,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
@@ -2613,9 +2487,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2632,9 +2506,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2675,9 +2549,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2709,9 +2583,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2744,9 +2618,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2787,9 +2661,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2820,9 +2694,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2852,9 +2726,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2894,9 +2768,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -2927,9 +2801,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3003,6 +2877,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$duplicateSerial = [];
|
||||
$weightExceeded = [];
|
||||
$processedItems = [];
|
||||
$invalidMaterialItems = [];
|
||||
|
||||
$wireItems1 = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||
@@ -3021,6 +2896,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$palletWeight = $wireItem->pallet_weight;
|
||||
$itemCode = $wireItem->item_code;
|
||||
|
||||
$processedItems[] = $itemCode;
|
||||
|
||||
$duplicate = InvoiceValidation::where('plant_id', $this->plantId)
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('serial_number', $processOrder)
|
||||
@@ -3206,29 +3083,16 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
$totQuan = InvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totQuan;
|
||||
$scanMatQuan = $scanMQuan;
|
||||
}
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3267,9 +3131,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3305,9 +3169,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3342,9 +3206,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3365,9 +3229,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3400,9 +3264,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3428,9 +3292,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3450,9 +3314,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3472,9 +3336,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3483,7 +3347,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$createdDt = $record->created_at;
|
||||
$stickMasterId = $record->sticker_master_id;
|
||||
$curExistQty = $record->quantity;
|
||||
$curItemInvQty = $record->invoice_quantity;
|
||||
// $curScanQty = 2;
|
||||
|
||||
if ($curExistQty > $curScanQty) { // 5 > 2
|
||||
@@ -3499,7 +3362,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $serialNumber,
|
||||
'batch_number' => $batchNumber,
|
||||
'invoice_quantity' => $curItemInvQty,
|
||||
'quantity' => $curScanQty,
|
||||
'created_at' => $createdDt,
|
||||
'operator_id' => $operatorName,
|
||||
@@ -3538,9 +3400,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3566,9 +3428,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -3591,21 +3453,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// ->send();
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$checkMat = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->latest('updated_at')->first(); // ->where('quantity', '!=', '')
|
||||
if (($checkMat?->stickerMaster->material_type ?? 0) == 3) {
|
||||
Notification::make()
|
||||
->title("Material Type : {$checkMat?->stickerMaster->material_type}")
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$totMatQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->invoice_quantity ?? 0;
|
||||
$scanMatQuan = number_format($totMatQuan - (InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNull('serial_number')->where('plant_id', $plantId)->latest('updated_at')->first()?->quantity ?? 0), 3, '.', ''); // ('updated_at', 'desc')
|
||||
} else {
|
||||
$totMatQuan = $totQuan;
|
||||
$scanMatQuan = $scannedMQuantity;
|
||||
}
|
||||
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if ($totQuan == $scannedMQuantity) {
|
||||
Notification::make()
|
||||
@@ -3642,9 +3491,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totMatQuan,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMatQuan,
|
||||
'scanned_quantity' => $scannedMQuantity,
|
||||
]);
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
@@ -3696,7 +3545,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
|
||||
}
|
||||
|
||||
// TN01/BOX22/SERIAL999 >> PANEL BOX QR
|
||||
// /^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
|
||||
if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
|
||||
Notification::make()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ItemCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ItemCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateItemCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ItemCharacteristicResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ItemCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ItemCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditItemCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = ItemCharacteristicResource::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\ItemCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ItemCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListItemCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = ItemCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ItemCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ItemCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewItemCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ItemCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class LeakTestReadingResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Motor Testing Panel';
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Exports\LineExporter;
|
||||
use App\Filament\Imports\LineImporter;
|
||||
use App\Filament\Resources\LineResource\Pages;
|
||||
use App\Models\Block;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
@@ -25,11 +24,6 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Unique;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
|
||||
class LineResource extends Resource
|
||||
{
|
||||
@@ -1190,207 +1184,7 @@ class LineResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('items', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('code', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('name')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId ? Line::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('type')
|
||||
->label('Search by Line Type')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId ? Line::where('plant_id', $plantId)->distinct()->pluck('type', 'type')->toArray(): [];
|
||||
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('work_group_id')
|
||||
->label('Search by WorkGroupCenter')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
$workGroupIds = Line::where('plant_id', $plantId)
|
||||
->get([
|
||||
'work_group1_id',
|
||||
'work_group2_id',
|
||||
'work_group3_id',
|
||||
'work_group4_id',
|
||||
'work_group5_id',
|
||||
'work_group6_id',
|
||||
'work_group7_id',
|
||||
'work_group8_id',
|
||||
'work_group9_id',
|
||||
'work_group10_id',
|
||||
])
|
||||
->flatMap(function ($line) {
|
||||
return [
|
||||
$line->work_group1_id,
|
||||
$line->work_group2_id,
|
||||
$line->work_group3_id,
|
||||
$line->work_group4_id,
|
||||
$line->work_group5_id,
|
||||
$line->work_group6_id,
|
||||
$line->work_group7_id,
|
||||
$line->work_group8_id,
|
||||
$line->work_group9_id,
|
||||
$line->work_group10_id,
|
||||
];
|
||||
})
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
return WorkGroupMaster::whereIn('id', $workGroupIds)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
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['name']) && empty($data['type']) && empty($data['work_group_id']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_from']) && empty($data['updated_to'])) {
|
||||
// return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$query->where('id', $data['name']);
|
||||
}
|
||||
|
||||
if (! empty($data['type'])) {
|
||||
$query->where('type', $data['type']);
|
||||
}
|
||||
|
||||
// if (! empty($data['work_group_id'])) {
|
||||
// $query->where('name', $data['work_group_id']);
|
||||
// }
|
||||
|
||||
if (! empty($data['work_group_id'])) {
|
||||
|
||||
$query->where(function ($q) use ($data) {
|
||||
|
||||
$q->where('work_group1_id', $data['work_group_id'])
|
||||
->orWhere('work_group2_id', $data['work_group_id'])
|
||||
->orWhere('work_group3_id', $data['work_group_id'])
|
||||
->orWhere('work_group4_id', $data['work_group_id'])
|
||||
->orWhere('work_group5_id', $data['work_group_id'])
|
||||
->orWhere('work_group6_id', $data['work_group_id'])
|
||||
->orWhere('work_group7_id', $data['work_group_id'])
|
||||
->orWhere('work_group8_id', $data['work_group_id'])
|
||||
->orWhere('work_group9_id', $data['work_group_id'])
|
||||
->orWhere('work_group10_id', $data['work_group_id']);
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['name'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['type'])) {
|
||||
$indicators[] = 'Line Type: '.Line::where('type', $data['type'])->value('type');
|
||||
}
|
||||
|
||||
if (! empty($data['work_group_id'])) {
|
||||
$indicators[] = 'Work Group: ' .
|
||||
WorkGroupMaster::where('id', $data['work_group_id'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -11,17 +11,13 @@ use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
@@ -70,8 +66,6 @@ class MachineResource extends Resource
|
||||
return;
|
||||
} else {
|
||||
$set('mPlantError', null);
|
||||
$set('line_id', null);
|
||||
$set('work_group_master_id', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
@@ -113,7 +107,6 @@ class MachineResource extends Resource
|
||||
// return;
|
||||
// }
|
||||
$set('mLineError', null);
|
||||
$set('work_group_master_id', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
@@ -256,177 +249,7 @@ class MachineResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('machines', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('code', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::whereHas('machines', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('name')
|
||||
->label('Description')
|
||||
->reactive(),
|
||||
Select::make('work_group_master')
|
||||
->label('Search by Work Group Center')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return WorkGroupMaster::whereHas('machines', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('work_center')
|
||||
->label('Search by Work Center')
|
||||
->options(function (callable $get) {
|
||||
|
||||
$plantId = $get('Plant');
|
||||
$workGroupMasterId = $get('work_group_master');
|
||||
|
||||
if (! $workGroupMasterId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::query()
|
||||
->when($plantId, fn ($q) => $q->where('plant_id', $plantId))
|
||||
->where('work_group_master_id', $workGroupMasterId)
|
||||
->pluck('work_center', 'work_center')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['name']) && empty($data['work_group_master']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_from']) && empty($data['updated_to'])) {
|
||||
// return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$query->where('name', $data['name']);
|
||||
}
|
||||
|
||||
if (! empty($data['work_group_master'])) {
|
||||
$query->where('work_group_master_id', $data['work_group_master']);
|
||||
}
|
||||
|
||||
if (! empty($data['work_center'])) {
|
||||
$query->where('work_center', $data['work_center']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$indicators[] = 'Description: '.$data['name'];
|
||||
}
|
||||
|
||||
if (! empty($data['work_group_master'])) {
|
||||
$indicators[] = 'Work Group Center: '.WorkGroupMaster::where('id', $data['work_group_master'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['work_center'])) {
|
||||
$indicators[] = 'Work Center: '.Machine::where('work_center', $data['work_center'])->value('work_center');
|
||||
}
|
||||
|
||||
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(),
|
||||
|
||||
@@ -13,7 +13,6 @@ use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -34,7 +33,7 @@ class MotorTestingMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Motor Testing Panel';
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
@@ -42,429 +41,387 @@ class MotorTestingMasterResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->columnSpan(1) // (['default' => 1, 'sm' => 2])
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(MotorTestingMaster::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('mTmError', 'Please select a plant first.');
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(MotorTestingMaster::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('mTmError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('mTmError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mTmError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TimePicker::make('routine_test_time')
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id');
|
||||
} else {
|
||||
$itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||
|
||||
return Item::where('plant_id', $plantId)
|
||||
->where(function ($query) use ($itemId) {
|
||||
$query->whereDoesntHave('motorTestingMasters')
|
||||
->orWhere('id', $itemId);
|
||||
})
|
||||
->pluck('code', 'id');
|
||||
}
|
||||
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('motor_testing_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
// ->required()
|
||||
->placeholder('Scan the subassembly code')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('subassembly_code');
|
||||
if (! $code) {
|
||||
$set('iCodeError', 'Scan the valid Subassembly Code.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (strlen($code) < 6) {
|
||||
$set('iCodeError', 'Subassembly code must be at least 6 digits.');
|
||||
|
||||
return;
|
||||
} elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
|
||||
$set('code', null);
|
||||
$set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.');
|
||||
|
||||
return;
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Select::make('isi_model')
|
||||
->label('ISI Model')
|
||||
->options([
|
||||
1 => 'Yes',
|
||||
0 => 'No',
|
||||
])
|
||||
->selectablePlaceholder(false)
|
||||
->default(1)
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('phase')
|
||||
->label('Phase')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('Single')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('hp')
|
||||
->label('HP')
|
||||
->placeholder('Scan the HP')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('kw')
|
||||
->label('KW')
|
||||
->placeholder('Scan the KW')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('volt')
|
||||
->label('Volt')
|
||||
->placeholder('Scan the volt')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('current')
|
||||
->label('Current')
|
||||
->placeholder('Scan the current')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('rpm')
|
||||
->label('RPM')
|
||||
->placeholder('Scan the RPM')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('torque')
|
||||
->label('Torque')
|
||||
->placeholder('Scan the torque')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency')
|
||||
->placeholder('Scan the frequency')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('connection')
|
||||
->label('Connection')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->default('Star')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('ins_res_limit')
|
||||
->label('Insulation Resistance Limit')
|
||||
->placeholder('Scan the insulation resistance limit')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\Select::make('ins_res_type')
|
||||
->label('Insulation Resistance Type')
|
||||
->placeholder('Scan the insulation resistance type')
|
||||
->columnSpan(1)
|
||||
->default('O')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'INSULATION_RESISTANCE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'INSULATION_RESISTANCE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_ry_ll')
|
||||
->label('Resistance RY LL')
|
||||
->placeholder('Scan the resistance RY LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_ry_ul')
|
||||
->label('Resistance RY UL')
|
||||
->placeholder('Scan the resistance RY UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_yb_ll')
|
||||
->label('Resistance YB LL')
|
||||
->placeholder('Scan the resistance YB LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_yb_ul')
|
||||
->label('Resistance YB UL')
|
||||
->placeholder('Scan the resistance YB UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_br_ll')
|
||||
->label('Resistance BR LL')
|
||||
->placeholder('Scan the resistance BR LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_br_ul')
|
||||
->label('Resistance BR UL')
|
||||
->placeholder('Scan the resistance BR UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_volt_limit')
|
||||
->label('Lock Volt Limit')
|
||||
->placeholder('Scan the lock volt limit')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('leak_cur_limit')
|
||||
->label('Leakage Current Limit')
|
||||
->placeholder('Scan the leakage current limit')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_cur_ll')
|
||||
->label('Lock Current LL')
|
||||
->placeholder('Scan the lock current LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_cur_ul')
|
||||
->label('Lock Current UL')
|
||||
->placeholder('Scan the lock current UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_cur_ll')
|
||||
->label('No Load Current LL')
|
||||
->placeholder('Scan the no load current LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_cur_ul')
|
||||
->label('No Load Current UL')
|
||||
->placeholder('Scan the no load current UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_pow_ll')
|
||||
->label('No Load Power LL')
|
||||
->placeholder('Scan the no load power LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_pow_ul')
|
||||
->label('No Load Power UL')
|
||||
->placeholder('Scan the no load power UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_spd_ll')
|
||||
->label('No Load Speed LL')
|
||||
->placeholder('Scan the no load speed LL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_spd_ul')
|
||||
->label('No Load Speed UL')
|
||||
->placeholder('Scan the no load speed UL')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->columnSpan(1)
|
||||
->readOnly(),
|
||||
return;
|
||||
} else {
|
||||
$set('mTmError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mTmError') ? 'border-red-500' : '',
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TimePicker::make('routine_test_time')
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id');
|
||||
} else {
|
||||
$itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||
|
||||
return Item::where('plant_id', $plantId)
|
||||
->where(function ($query) use ($itemId) {
|
||||
$query->whereDoesntHave('motorTestingMasters')
|
||||
->orWhere('id', $itemId);
|
||||
})
|
||||
->pluck('code', 'id');
|
||||
}
|
||||
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('motor_testing_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
// ->required()
|
||||
->placeholder('Scan the subassembly code')
|
||||
->reactive()
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('subassembly_code');
|
||||
if (! $code) {
|
||||
$set('iCodeError', 'Scan the valid Subassembly Code.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (strlen($code) < 6) {
|
||||
$set('iCodeError', 'Subassembly code must be at least 6 digits.');
|
||||
|
||||
return;
|
||||
} elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
|
||||
$set('code', null);
|
||||
$set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.');
|
||||
|
||||
return;
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Select::make('isi_model')
|
||||
->label('ISI Model')
|
||||
->options([
|
||||
1 => 'Yes',
|
||||
0 => 'No',
|
||||
])
|
||||
->selectablePlaceholder(false)
|
||||
->default(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('phase')
|
||||
->label('Phase')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('Single')
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('hp')
|
||||
->label('HP')
|
||||
->placeholder('Scan the HP')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('kw')
|
||||
->label('KW')
|
||||
->placeholder('Scan the KW')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('volt')
|
||||
->label('Volt')
|
||||
->placeholder('Scan the volt')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('current')
|
||||
->label('Current')
|
||||
->placeholder('Scan the current')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('rpm')
|
||||
->label('RPM')
|
||||
->placeholder('Scan the RPM')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('torque')
|
||||
->label('Torque')
|
||||
->placeholder('Scan the torque')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency')
|
||||
->placeholder('Scan the frequency')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('connection')
|
||||
->label('Connection')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->default('Star')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('ins_res_limit')
|
||||
->label('Insulation Resistance Limit')
|
||||
->placeholder('Scan the insulation resistance limit')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('ins_res_type')
|
||||
->label('Insulation Resistance Type')
|
||||
->placeholder('Scan the insulation resistance type')
|
||||
->default('O')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'INSULATION_RESISTANCE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'INSULATION_RESISTANCE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_ry_ll')
|
||||
->label('Resistance RY LL')
|
||||
->placeholder('Scan the resistance RY LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_ry_ul')
|
||||
->label('Resistance RY UL')
|
||||
->placeholder('Scan the resistance RY UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_yb_ll')
|
||||
->label('Resistance YB LL')
|
||||
->placeholder('Scan the resistance YB LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_yb_ul')
|
||||
->label('Resistance YB UL')
|
||||
->placeholder('Scan the resistance YB UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_br_ll')
|
||||
->label('Resistance BR LL')
|
||||
->placeholder('Scan the resistance BR LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('res_br_ul')
|
||||
->label('Resistance BR UL')
|
||||
->placeholder('Scan the resistance BR UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_volt_limit')
|
||||
->label('Lock Volt Limit')
|
||||
->placeholder('Scan the lock volt limit')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('leak_cur_limit')
|
||||
->label('Leakage Current Limit')
|
||||
->placeholder('Scan the leakage current limit')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_cur_ll')
|
||||
->label('Lock Current LL')
|
||||
->placeholder('Scan the lock current LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('lock_cur_ul')
|
||||
->label('Lock Current UL')
|
||||
->placeholder('Scan the lock current UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_cur_ll')
|
||||
->label('No Load Current LL')
|
||||
->placeholder('Scan the no load current LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_cur_ul')
|
||||
->label('No Load Current UL')
|
||||
->placeholder('Scan the no load current UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_pow_ll')
|
||||
->label('No Load Power LL')
|
||||
->placeholder('Scan the no load power LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_pow_ul')
|
||||
->label('No Load Power UL')
|
||||
->placeholder('Scan the no load power UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_spd_ll')
|
||||
->label('No Load Speed LL')
|
||||
->placeholder('Scan the no load speed LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('noload_spd_ul')
|
||||
->label('No Load Speed UL')
|
||||
->placeholder('Scan the no load speed UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -620,7 +577,6 @@ class MotorTestingMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
|
||||
@@ -146,22 +146,21 @@ class OcrValidationResource extends Resource
|
||||
// $fullPath = storage_path('app/' . $storedPath);
|
||||
$fullPath = storage_path('app/private/'.$storedPath);
|
||||
$parser = new Parser;
|
||||
$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
$pdf = $parser->parseFile($fullPath);
|
||||
$text = $pdf->getText();
|
||||
|
||||
// dd($text);
|
||||
|
||||
// dd($text);
|
||||
$item1 = null;
|
||||
$item2 = null;
|
||||
|
||||
// if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
// $item1 = $matches[1];
|
||||
// }
|
||||
// // elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
// else if (preg_match('/(?:Item\s*code|E[-\s]*CODE)\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
// $item2 = $matches[1];
|
||||
// }
|
||||
|
||||
// dd($item2);
|
||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
$item1 = $matches[1];
|
||||
} elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
$item2 = $matches[1];
|
||||
}
|
||||
|
||||
$processOrder = $get('gr_number');
|
||||
|
||||
@@ -195,45 +194,36 @@ class OcrValidationResource extends Resource
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
if ($itemCode == $item1) {
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
if ($itemCode == $item2) {
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
|
||||
// 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();
|
||||
|
||||
// return;
|
||||
// }
|
||||
// if ($itemCode == $item2) {
|
||||
// Notification::make()
|
||||
// ->title('Success')
|
||||
// ->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
// ->success()
|
||||
// ->send();
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
// return;
|
||||
// }
|
||||
// else {
|
||||
// Notification::make()
|
||||
// ->title('Item Code not matched')
|
||||
// ->body("Item Code: {$item->code} not matched with the uploaded pdf code $item2.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// if (Storage::disk('local')->exists($storedPath)) {
|
||||
// Storage::disk('local')->delete($storedPath);
|
||||
// }
|
||||
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Notification::make()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,295 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelBoxValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelBoxValidationResource;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Filament\Actions\Action;
|
||||
|
||||
class CreatePanelBoxValidation extends CreateRecord {
|
||||
|
||||
protected static string $resource = PanelBoxValidationResource::class;
|
||||
|
||||
|
||||
public $showChecklist = false;
|
||||
public $checklist;
|
||||
|
||||
public $skipChecklistValidation = false;
|
||||
|
||||
public bool $shouldSkipChecklist = false;
|
||||
|
||||
public $existingRecords = [];
|
||||
|
||||
protected $listeners = [
|
||||
'checklistUpdated' => 'setChecklist',
|
||||
'checklist-cancelled' => 'handleChecklistCancel',
|
||||
'checklist-saved' => 'checkListSaved',
|
||||
];
|
||||
|
||||
public function setChecklist($checklist)
|
||||
{
|
||||
$this->data['checklist'] = $checklist;
|
||||
}
|
||||
|
||||
public function doCreate()
|
||||
{
|
||||
$this->create();
|
||||
}
|
||||
public function getCreateFormAction(): Action
|
||||
{
|
||||
return parent::getCreateFormAction()
|
||||
->visible(fn () => $this->data['serial_exists'] != true);
|
||||
}
|
||||
|
||||
protected function getCreateAnotherFormAction(): Action
|
||||
{
|
||||
return parent::getCreateAnotherFormAction()
|
||||
->visible(fn () => ($this->data['serial_exists'] ?? false) != true);
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
parent::mount();
|
||||
|
||||
session()->forget([
|
||||
'last_selected_plant_id',
|
||||
'last_selected_line',
|
||||
'last_selected_production',
|
||||
'last_selected_inspection',
|
||||
]);
|
||||
}
|
||||
|
||||
public function handleChecklistCancel()
|
||||
{
|
||||
$this->skipChecklistValidation = true;
|
||||
$this->showChecklist = false;
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
// if ($this->shouldSkipChecklist) {
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
if ($this->checkIfHasCharacteristics($data)) {
|
||||
$this->showChecklist = true;
|
||||
$this->halt();
|
||||
}
|
||||
else{
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Characteristics not found for the scanned item.')
|
||||
->danger()
|
||||
->send();
|
||||
$this->halt();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkIfHasCharacteristics(array $data)
|
||||
{
|
||||
$plantId = $data['plant_id'] ?? null;
|
||||
$itemCode = $data['item_id'] ?? null;
|
||||
$lineId = $data['line_id'] ?? null;
|
||||
|
||||
if (!$plantId || !$itemCode || !$lineId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = \App\Models\Item::where('code', $itemCode)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$categoryName = trim($item->category) ?? null;
|
||||
|
||||
if (!$item) {
|
||||
$this->existingRecords = collect();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $item->id)
|
||||
->where('line_id', $lineId)
|
||||
->orderBy('id', 'asc')
|
||||
->get();
|
||||
|
||||
return $this->existingRecords->isNotEmpty();
|
||||
}
|
||||
|
||||
public function checkListSaved()
|
||||
{
|
||||
$this->showChecklist = false;
|
||||
|
||||
$plantId = $this->data['plant_id'] ?? null;
|
||||
$lineId = $this->data['line_id'] ?? null;
|
||||
$productionOrder = $this->data['production_order'] ?? null;
|
||||
|
||||
return redirect()->to(
|
||||
static::getResource()::getUrl('create', [
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if (!empty($this->data['validationError'])) {
|
||||
$errors['validationError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['serialPanelError'])) {
|
||||
$errors['serialPanelError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['packSlipPanelError'])) {
|
||||
$errors['packSlipPanelError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['namePlatePanelError'])) {
|
||||
$errors['namePlatePanelError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..name plate
|
||||
|
||||
if (!empty($this->data['tubeStickerPanelError'])) {
|
||||
$errors['tubeStickerPanelError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['warrantyCardPanelError'])) {
|
||||
$errors['warrantyCardPanelError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..part validations
|
||||
|
||||
if (!empty($this->data['part_validation1_error'])) {
|
||||
$errors['part_validation1_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation2_error'])) {
|
||||
$errors['part_validation2_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation3_error'])) {
|
||||
$errors['part_validation3_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation4_error'])) {
|
||||
$errors['part_validation4_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['part_validation5_error'])) {
|
||||
$errors['part_validation5_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
|
||||
$this->checkExisting();
|
||||
|
||||
$checklist = $this->data['data']['checklist'] ?? [];
|
||||
|
||||
if (count($this->existingRecords) > 0){
|
||||
|
||||
$this->showChecklist = true;
|
||||
$this->halt();
|
||||
}
|
||||
else{
|
||||
$this->showChecklist = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkExisting()
|
||||
{
|
||||
$plant_id = $this->data['plant_id'] ?? null;
|
||||
$item_code = $this->data['item_id'] ?? null;
|
||||
$line_id = $this->data['line_id'] ?? null;
|
||||
|
||||
|
||||
$item = \App\Models\Item::where('code', $item_code)->where('plant_id', $plant_id)->first();
|
||||
|
||||
if (!$item) {
|
||||
$this->existingRecords = collect();
|
||||
return;
|
||||
}
|
||||
|
||||
// $item_id = $item->id;
|
||||
$categoryName = trim($item->category) ?? null;
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plant_id)
|
||||
->where('category', $categoryName)
|
||||
->where('line_id', $line_id)
|
||||
->get();
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
// Get the value from the hidden field 'plant'
|
||||
$plant = $this->form->getState()['plant'] ?? null;
|
||||
$line = $this->form->getState()['line'] ?? null;
|
||||
$production = $this->form->getState()['production'] ?? null;
|
||||
$inspection = $this->form->getState()['inspection'] ?? null;
|
||||
|
||||
// $this->skipChecklistValidation = false;
|
||||
// $this->showChecklist = false;
|
||||
// $this->checklist = [];
|
||||
|
||||
// $this->form->fill();
|
||||
|
||||
// reset checklist
|
||||
$this->checklist = [];
|
||||
|
||||
$this->skipChecklistValidation = false;
|
||||
$this->showChecklist = false;
|
||||
|
||||
$this->form->fill([]);
|
||||
|
||||
$this->data = [];
|
||||
|
||||
$this->resetValidation();
|
||||
$this->resetErrorBag();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => null,
|
||||
'line_id' => null,
|
||||
'production_order' => null,
|
||||
'inspection_lot_number' => null,
|
||||
]);
|
||||
|
||||
|
||||
// $this->dispatch('focus-item-id');
|
||||
session()->flash('focus_item_id_after_redirect', true);
|
||||
logger('Focus flag set in session');
|
||||
|
||||
if ($plant) {
|
||||
session(['last_selected_plant_id' => $plant]);
|
||||
}
|
||||
if ($line) {
|
||||
session(['last_selected_line' => $line]);
|
||||
}
|
||||
if ($production) {
|
||||
session(['last_selected_production' => $production]);
|
||||
}
|
||||
if ($inspection) {
|
||||
session(['last_selected_inspection' => $inspection]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
//return $this->getResource()::getUrl('create'); // Stay on Create Page after savin
|
||||
|
||||
return $this->getResource()::getUrl('create', [
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelBoxValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelBoxValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPanelBoxValidation extends EditRecord
|
||||
{
|
||||
protected static string $resource = PanelBoxValidationResource::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\PanelBoxValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelBoxValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPanelBoxValidations extends ListRecords
|
||||
{
|
||||
protected static string $resource = PanelBoxValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelBoxValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelBoxValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewPanelBoxValidation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = PanelBoxValidationResource::class;
|
||||
|
||||
public bool $showChecklist = false;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,371 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\PanelGrMasterExporter;
|
||||
use App\Filament\Imports\PanelGrMasterImporter;
|
||||
use App\Filament\Resources\PanelGrMasterResource\Pages;
|
||||
use App\Filament\Resources\PanelGrMasterResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\PanelGrMaster;
|
||||
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\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Closure;
|
||||
|
||||
class PanelGrMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PanelGrMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Panel Box';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('item_id', null);
|
||||
$set('document_number', null);
|
||||
$set('invoice_number', null);
|
||||
$set('supplier_number', null);
|
||||
$set('quantity', '1');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('document_number', null);
|
||||
$set('invoice_number', null);
|
||||
$set('supplier_number', null);
|
||||
$set('quantity', '1');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('document_number')
|
||||
->label('Document Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('supplier_number')
|
||||
->label('Supplier Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('inspection_lot_number')
|
||||
->label('Inspection Lot Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('quantity')
|
||||
->label('Quantity')
|
||||
->numeric()
|
||||
->default(1)
|
||||
->minValue(1)
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
if ((float) $state == 0) {
|
||||
$set('quantity', null);
|
||||
}
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('document_number')
|
||||
->label('Document Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('supplier_number')
|
||||
->label('Supplier Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inspection_lot_number')
|
||||
->label('Inspection Lot Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('scanned_by', null);
|
||||
}),
|
||||
Select::make('item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('panelGrMasters', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('document_number')
|
||||
->label('Document Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Document Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
TextInput::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Invoice Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
TextInput::make('supplier_number')
|
||||
->label('Supplier Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Supplier Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
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['document_number']) && empty($data['invoice_number']) && empty($data['supplier_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['document_number'])) {
|
||||
$query->where('document_number', 'like', '%' . $data['document_number'] . '%');
|
||||
}
|
||||
|
||||
if (! empty($data['invoice_number'])) {
|
||||
$query->where('invoice_number', 'like', '%' . $data['invoice_number'] . '%');
|
||||
}
|
||||
|
||||
if (! empty($data['supplier_number'])) {
|
||||
$query->where('supplier_number', 'like', '%' . $data['supplier_number'] . '%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['document_number'])) {
|
||||
$indicators[] = 'Doc No: '.$data['document_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['invoice_number'])) {
|
||||
$indicators[] = 'Invoice No: '.$data['invoice_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['supplier_number'])) {
|
||||
$indicators[] = 'Supplier No: '.$data['supplier_number'];
|
||||
}
|
||||
|
||||
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 Panel GR Masters')
|
||||
->color('warning')
|
||||
->importer(PanelGrMasterImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import panel gr master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Panel GR Masters')
|
||||
->color('warning')
|
||||
->exporter(PanelGrMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export panel gr master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPanelGrMasters::route('/'),
|
||||
'create' => Pages\CreatePanelGrMaster::route('/create'),
|
||||
'view' => Pages\ViewPanelGrMaster::route('/{record}'),
|
||||
'edit' => Pages\EditPanelGrMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelGrMasterResource;
|
||||
use App\Models\PanelGrMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreatePanelGrMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PanelGrMasterResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$exists = PanelGrMaster::where('plant_id', $data['plant_id'])
|
||||
->where('item_id', $data['item_id'])
|
||||
->where('document_number', $data['document_number'])
|
||||
->where('invoice_number', $data['invoice_number'])
|
||||
->where('supplier_number', $data['supplier_number'])
|
||||
->where('inspection_lot_number', $data['inspection_lot_number'])
|
||||
->first();
|
||||
|
||||
if ($exists) {
|
||||
$message = 'Duplicate record found. '
|
||||
. 'Document Number: ' . $data['document_number']
|
||||
. ', Invoice Number: ' . $data['invoice_number']
|
||||
. ', Inspection Lot Number: ' . $data['inspection_lot_number'];
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate Record')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'document_number' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelGrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPanelGrMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = PanelGrMasterResource::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\PanelGrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelGrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPanelGrMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = PanelGrMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PanelGrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewPanelGrMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = PanelGrMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -170,8 +170,6 @@ class ProductionCharacteristicResource extends Resource
|
||||
->label('Production Order'),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number'),
|
||||
Forms\Components\TextInput::make('inspection_lot_number')
|
||||
->label('Inspection Lot No'),
|
||||
Forms\Components\TextInput::make('characteristic_name')
|
||||
->label('Characteristic Name'),
|
||||
Forms\Components\TextInput::make('observed_value')
|
||||
@@ -190,11 +188,7 @@ class ProductionCharacteristicResource extends Resource
|
||||
->label('Remark')
|
||||
->reactive()
|
||||
->required(fn ($get) => $get('status') == 'ConditionallyAccepted')
|
||||
// ->visible(fn ($get) => $get('status') == 'ConditionallyAccepted'),
|
||||
->visible(fn ($get) => in_array($get('status'), [
|
||||
'NotOk',
|
||||
'ConditionallyAccepted',
|
||||
])),
|
||||
->visible(fn ($get) => $get('status') == 'ConditionallyAccepted'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By'),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
@@ -241,12 +235,7 @@ class ProductionCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('production_order')
|
||||
->label('Production Order / Doc No')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inspection_lot_number')
|
||||
->label('Inspection Lot No')
|
||||
->label('Production Order')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -264,9 +253,9 @@ class ProductionCharacteristicResource extends Resource
|
||||
->label('Spec. Value')
|
||||
// ->searchable()
|
||||
->formatStateUsing(function ($record) {
|
||||
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->where('line_id', $record->line_id)->where('machine_id', $record->machine_id)->where('name', $record->characteristic_name)->first();
|
||||
// return $record?->plant_id.'-'.$record?->item_id.'-'.$record->line_id.'-'.$record?->machine_id;
|
||||
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->where('line_id', $record->line_id)->where('machine_id', $record->machine_id)->first();
|
||||
|
||||
// return $record?->plant_id.'-'.$record?->item_id.'-'.$record->line_id.'-'.$record?->machine_id;
|
||||
return $specVal?->lower.' - '.$specVal?->upper;
|
||||
})
|
||||
->alignCenter()
|
||||
@@ -287,10 +276,21 @@ class ProductionCharacteristicResource extends Resource
|
||||
'Not Ok' => 'danger',
|
||||
'NotOk' => 'danger',
|
||||
'ConditionallyAccepted' => 'success',
|
||||
default => 'black',
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('inspection_status')
|
||||
// ->label('Inspection Status')
|
||||
// ->searchable()
|
||||
// ->color(fn (string $state): string => match ($state) {
|
||||
// 'Ok' => 'success',
|
||||
// 'Not Ok' => 'danger',
|
||||
// 'NotOk' => 'danger',
|
||||
// default => 'gray',
|
||||
// })
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->searchable()
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -283,64 +282,6 @@ class CreateProductionOrder extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function exportSerialNo(){
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$itemId = trim($this->form->getState()['item_id'] ?? '') ?? null;
|
||||
|
||||
$fromSerNo = trim($this->form->getState()['from_serial_number'] ?? '') ?? null;
|
||||
|
||||
$toSerNo = trim($this->form->getState()['to_serial_number'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
// $itemCode = Item::where('id', $itemId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($fromSerNo)) {
|
||||
Notification::make()
|
||||
->title('From serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($toSerNo)) {
|
||||
Notification::make()
|
||||
->title('To serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.exportSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode, 'from_serial_no' => $fromSerNo, 'to_serial_no' => $toSerNo]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
|
||||
@@ -157,64 +157,6 @@ class EditProductionOrder extends EditRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function exportSerialNo(){
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$itemId = trim($this->form->getState()['item_id'] ?? '') ?? null;
|
||||
|
||||
$fromSerNo = trim($this->form->getState()['from_serial_number'] ?? '') ?? null;
|
||||
|
||||
$toSerNo = trim($this->form->getState()['to_serial_number'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
// $itemCode = Item::where('id', $itemId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($fromSerNo)) {
|
||||
Notification::make()
|
||||
->title('From serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($toSerNo)) {
|
||||
Notification::make()
|
||||
->title('To serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.exportSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode, 'from_serial_no' => $fromSerNo, 'to_serial_no' => $toSerNo]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Actions;
|
||||
@@ -160,64 +159,6 @@ class ViewProductionOrder extends ViewRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function exportSerialNo(){
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$itemId = trim($this->form->getState()['item_id'] ?? '') ?? null;
|
||||
|
||||
$fromSerNo = trim($this->form->getState()['from_serial_number'] ?? '') ?? null;
|
||||
|
||||
$toSerNo = trim($this->form->getState()['to_serial_number'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
// $itemCode = Item::where('id', $itemId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($fromSerNo)) {
|
||||
Notification::make()
|
||||
->title('From serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
elseif (empty($toSerNo)) {
|
||||
Notification::make()
|
||||
->title('To serial number cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.exportSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode, 'from_serial_no' => $fromSerNo, 'to_serial_no' => $toSerNo]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -1,758 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\PumpTestingEntryExporter;
|
||||
use App\Filament\Resources\PumpTestingEntryResource\Pages;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\PumpTestingEntry;
|
||||
use App\Models\PumpTestingMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PumpTestingEntryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PumpTestingEntry::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Pump Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->columnSpan(1) // (['default' => 1, 'sm' => 2])
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(PumpTestingEntry::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('pump_testing_master_id', null);
|
||||
$set('pump_master_id', null);
|
||||
// $set('pump_type', null);
|
||||
|
||||
if (! $plantId) {
|
||||
$set('pTeError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('pTeError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pTeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pTeError') ? $get('pTeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('tested_type')
|
||||
->label('Tested Type')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_DISPLAY_TEST_TYPE')
|
||||
->whereNot('c_value', 'Routine Test')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_DISPLAY_TEST_TYPE')
|
||||
->whereNot('c_value', 'Routine Test')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->default('Pump Performance Test')
|
||||
->reactive(),
|
||||
Forms\Components\DatePicker::make('tested_date')
|
||||
->label('Tested Date')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->default(now())
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('correction_head')
|
||||
->label('Correction Head')
|
||||
->placeholder('Scan the correction head')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('pump_testing_master_id')
|
||||
// ->relationship('pumpTestingMasters', 'id')
|
||||
->required(),
|
||||
Forms\Components\Select::make('pump_master_id')
|
||||
->label('Pump Code')
|
||||
// ->relationship('pumpTestingMasters', 'id')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->whereHas('pumpTestingMasters')->orderBy('code')->pluck('code', 'code');
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id'); // Get selected plant
|
||||
$set('pump_testing_master_id', null);
|
||||
// $set('pump_type', null);
|
||||
if (! $plantId) {
|
||||
$set('pump_master_id', null);
|
||||
} elseif ($state) {
|
||||
// $pumpMaster = PumpTestingMaster::where('plant_id', $plantId)->where('item_id', $state)->first();
|
||||
$pumpMaster = PumpTestingMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($state) {
|
||||
$query->where('code', $state);
|
||||
})->first();
|
||||
|
||||
if (! $pumpMaster) {
|
||||
$set('pump_master_id', null);
|
||||
} else {
|
||||
$set('pump_testing_master_id', $pumpMaster->id);
|
||||
// $set('pump_type', $pumpMaster->item->description ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
$itemId = PumpTestingMaster::where('id', $get('pump_testing_master_id'))->first()?->item_id;
|
||||
if ($itemId) {
|
||||
$item = Item::where('id', $itemId)->first()?->code;
|
||||
if ($item) {
|
||||
$set('pump_master_id', $item);
|
||||
} else {
|
||||
$set('pump_master_id', null);
|
||||
}
|
||||
} else {
|
||||
$set('pump_master_id', null);
|
||||
}
|
||||
}
|
||||
}),
|
||||
// Forms\Components\TextInput::make('pump_type')
|
||||
// ->label('Pump Type]')
|
||||
// ->placeholder('Choose the pump code first')
|
||||
// ->readOnly()
|
||||
// ->afterStateUpdated(function ($state, callable $set) {
|
||||
// $set('updated_by', Filament::auth()->user()?->name);
|
||||
// })
|
||||
// ->columnSpan(1)
|
||||
// ->required()
|
||||
// ->reactive(),
|
||||
Forms\Components\TextInput::make('pump_serial_number')
|
||||
->label('Pump Serial Number')
|
||||
->placeholder('Scan the pump serial number')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('pump_testing_entries', 'pump_serial_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('pump_testing_master_id', $get('pump_testing_master_id'))
|
||||
->where('tested_type', $get('tested_type'))
|
||||
->where('sl_no', $get('sl_no'))
|
||||
->ignore($get('id'));
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
|
||||
if (strpos($state, '|') != false) {
|
||||
$parts = explode('|', $state);
|
||||
$set('pump_serial_number', $parts[1]);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('sl_no')
|
||||
->label('Sl. No.')
|
||||
->placeholder('Scan the sl. no.')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('voltage')
|
||||
->label('Voltage')
|
||||
->placeholder('Scan the voltage')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency')
|
||||
->placeholder('Scan the frequency')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('speed')
|
||||
->label('Speed')
|
||||
->placeholder('Scan the speed')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('head')
|
||||
->label('Head')
|
||||
->placeholder('Scan the head')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('flow_reading')
|
||||
->label('Flow Reading')
|
||||
->placeholder('Scan the flow reading')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('current')
|
||||
->label('Current')
|
||||
->placeholder('Scan the current')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('watt')
|
||||
->label('Watt')
|
||||
->placeholder('Scan the watt')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->columnSpan(1)
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
// Tables\Columns\TextColumn::make('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
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 Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tested_date')
|
||||
->label('Tested Date')
|
||||
->date() // 'F d, Y'
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tested_type')
|
||||
->label('Tested Type')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pumpTestingMasters.item.code')
|
||||
->label('Pump Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pumpTestingMasters.item.category')
|
||||
->label('Pump Category')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('pumpTestingMasters.item.description')
|
||||
->label('Pump Type')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pumpTestingMasters.item.uom')
|
||||
->label('Unit Of Measure')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('pump_serial_number')
|
||||
->label('Pump Serial Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('correction_head')
|
||||
->label('Correction Head')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('sl_no')
|
||||
->label('Sl. No.')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage')
|
||||
->label('Voltage')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('speed')
|
||||
->label('Speed')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('head')
|
||||
->label('Head')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('flow_reading')
|
||||
->label('Flow Reading')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('current')
|
||||
->label('Current')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('watt')
|
||||
->label('Watt')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('pumpTestingEntries', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('isi_type', null);
|
||||
$set('created_by', null);
|
||||
$set('updated_by', null);
|
||||
}),
|
||||
DatePicker::make('tested_from')
|
||||
->label('Tested From')
|
||||
->placeholder('Select From Date')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DatePicker::make('tested_to')
|
||||
->label('Tested To')
|
||||
->placeholder('Select To Date')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('tested_type')
|
||||
->label('Tested Type')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return PumpTestingEntry::whereNotNull('tested_type')->select('tested_type')->distinct()->pluck('tested_type', 'tested_type');
|
||||
} else {
|
||||
return PumpTestingEntry::where('plant_id', $plantId)->whereNotNull('tested_type')->select('tested_type')->distinct()->pluck('tested_type', 'tested_type');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('Item')
|
||||
->label('Search by Pump Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
if (! $pId) {
|
||||
return [];
|
||||
} else {
|
||||
return Item::whereHas('pumpTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
$query->whereHas('pumpTestingEntries');
|
||||
})->pluck('code', 'id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('description')
|
||||
->label('Pump Type')
|
||||
->placeholder('Enter the Pump Type'),
|
||||
TextInput::make('pump_serial_number')
|
||||
->label('Pump Serial Number')
|
||||
->placeholder('Enter the Pump Serial Number'),
|
||||
Select::make('created_by')
|
||||
->label('Search by Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return PumpTestingEntry::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
} else {
|
||||
return PumpTestingEntry::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
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),
|
||||
Select::make('updated_by')
|
||||
->label('Search by Updated By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return PumpTestingEntry::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
} else {
|
||||
return PumpTestingEntry::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated 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['tested_from']) && empty($data['tested_to']) && empty($data['tested_type']) && empty($data['Item']) && empty($data['description']) && empty($data['pump_serial_number']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All')
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['tested_from'])) {
|
||||
$query->where('tested_date', '>=', $data['tested_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['tested_to'])) {
|
||||
$query->where('tested_date', '<=', $data['tested_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['tested_type'])) {
|
||||
$query->where('tested_type', $data['tested_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['Item']) && ! empty($data['Plant'])) {
|
||||
$itemIds = Item::where('id', $data['Item'])
|
||||
->where('plant_id', $data['Plant'])
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (! empty($itemIds)) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$pId = $data['Plant'] ?? null;
|
||||
$descIds = Item::where('description', 'like', '%'.$data['description'].'%')->whereHas('pumpTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
|
||||
if (! empty($descIds)) {
|
||||
$query->whereIn('item_id', $descIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['pump_serial_number'])) {
|
||||
$query->where('pump_serial_number', 'like', '%'.$data['pump_serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
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['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['tested_from'])) {
|
||||
$indicators[] = 'Tested From: '.$data['tested_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['tested_to'])) {
|
||||
$indicators[] = 'Tested To: '.$data['tested_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['tested_type'])) {
|
||||
$indicators[] = 'Tested Type: '.$data['tested_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['Item']) && ! empty($data['Plant'])) {
|
||||
$itemCode = Item::find($data['Item'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Pump Code: '.$itemCode;
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$indicators[] = 'Pump Type: '.$data['description'];
|
||||
}
|
||||
|
||||
if (! empty($data['pump_serial_number'])) {
|
||||
$indicators[] = 'Pump Serial Number: '.$data['pump_serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['created_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->label('Export Pump Testing Entries')
|
||||
->color('warning')
|
||||
->exporter(PumpTestingEntryExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export pump testing entries');
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPumpTestingEntries::route('/'),
|
||||
'create' => Pages\CreatePumpTestingEntry::route('/create'),
|
||||
'view' => Pages\ViewPumpTestingEntry::route('/{record}'),
|
||||
'edit' => Pages\EditPumpTestingEntry::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PumpTestingEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePumpTestingEntry extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PumpTestingEntryResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PumpTestingEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPumpTestingEntry extends EditRecord
|
||||
{
|
||||
protected static string $resource = PumpTestingEntryResource::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\PumpTestingEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPumpTestingEntries extends ListRecords
|
||||
{
|
||||
protected static string $resource = PumpTestingEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PumpTestingEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewPumpTestingEntry extends ViewRecord
|
||||
{
|
||||
protected static string $resource = PumpTestingEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,991 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\PumpTestingMasterExporter;
|
||||
use App\Filament\Resources\PumpTestingMasterResource\Pages;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\PumpTestingMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PumpTestingMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PumpTestingMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Pump Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->columnSpan(1) // (['default' => 1, 'sm' => 2])
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(PumpTestingMaster::latest()->first())->plant_id ?? null;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('pTmError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('pTmError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('pTmError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('pTmError') ? $get('pTmError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
return Item::where('plant_id', $plantId)->whereDoesntHave('pumpTestingMasters')->pluck('code', 'id');
|
||||
} else {
|
||||
$itemId = PumpTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||
|
||||
return Item::where('plant_id', $plantId)
|
||||
->where(function ($query) use ($itemId) {
|
||||
$query->whereDoesntHave('pumpTestingMasters')
|
||||
->orWhere('id', $itemId);
|
||||
})
|
||||
->pluck('code', 'id');
|
||||
}
|
||||
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('pump_testing_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('head')
|
||||
->label('Head')
|
||||
->placeholder('Scan the head')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('head_type')
|
||||
->label('Head Type')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_HEAD_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_HEAD_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->default('m')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('discharge')
|
||||
->label('Discharge')
|
||||
->placeholder('Scan the discharge')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('discharge_type')
|
||||
->label('Discharge Type')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_DISCHARGE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_DISCHARGE_TYPE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->default('lps')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('motor_efficiency')
|
||||
->label('Motor Efficiency')
|
||||
->placeholder('Scan the motor efficiency')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('pump_efficiency')
|
||||
->label('Pump Efficiency')
|
||||
->placeholder('Scan the pump efficiency')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('speed')
|
||||
->label('Speed')
|
||||
->placeholder('Scan the Speed')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency')
|
||||
->placeholder('Scan the frequency')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('i_max')
|
||||
->label('I-Max')
|
||||
->placeholder('Scan the I-Max')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('p_input')
|
||||
->label('P-Input')
|
||||
->placeholder('Scan the P-Input')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('delivery_size')
|
||||
->label('Delivery Size')
|
||||
->placeholder('Scan the delivery size')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('no_of_stages')
|
||||
->label('No of Stages')
|
||||
->placeholder('Scan the no of stages')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('size')
|
||||
->label('Size')
|
||||
->placeholder('Scan the size')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('maximum_head')
|
||||
->label('Maximum Head')
|
||||
->placeholder('Scan the maximum head')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('motor_type')
|
||||
->label('Motor Type')
|
||||
->placeholder('Scan the motor type')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('motor_code')
|
||||
->label('Motor Code')
|
||||
->placeholder('Scan the motor code')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('kw_hp')
|
||||
->label('KW / HP')
|
||||
->placeholder('Scan the KW / HP')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('connection_type')
|
||||
->label('Connection Type')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'STAR DELTA') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->default('STAR')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('voltage')
|
||||
->label('Voltage')
|
||||
->placeholder('Scan the voltage')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('phase')
|
||||
->label('Phase')
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state == 'Single' && $get('connection_type') == 'STAR DELTA') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('Single')
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('oh_minimum')
|
||||
->label('OH Minimum')
|
||||
->placeholder('Scan the OH minimum')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('oh_maximum')
|
||||
->label('OH Maximum')
|
||||
->placeholder('Scan the OH maximum')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('current_minimum')
|
||||
->label('Current Minimum')
|
||||
->placeholder('Scan the current minimum')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('current_maximum')
|
||||
->label('Current Maximum')
|
||||
->placeholder('Scan the current maximum')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('class_of_insulation')
|
||||
->label('Class of Insulation')
|
||||
->placeholder('Scan the class of insulation')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('testing_code')
|
||||
->label('Testing Code')
|
||||
->placeholder('Scan the testing code')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->columnSpan(1)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->columnSpan(1)
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
]);
|
||||
}
|
||||
|
||||
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 Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Pump Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.category')
|
||||
->label('Pump Category')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Pump Type')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit Of Measure')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('head')
|
||||
->label('Head')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('head_type')
|
||||
->label('Head Type')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('discharge')
|
||||
->label('Discharge')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('discharge_type')
|
||||
->label('Discharge Type')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_efficiency')
|
||||
->label('Motor Efficiency')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('pump_efficiency')
|
||||
->label('Pump Efficiency')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('speed')
|
||||
->label('Speed')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('i_max')
|
||||
->label('I-Max')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('p_input')
|
||||
->label('P-Input')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('delivery_size')
|
||||
->label('Delivery Size')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('no_of_stages')
|
||||
->label('No of Stages')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('size')
|
||||
->label('Size')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('maximum_head')
|
||||
->label('Maximum Head')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motor_type')
|
||||
->label('Motor Type')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motor_code')
|
||||
->label('Motor Code')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('kw_hp')
|
||||
->label('KW / HP')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('connection_type')
|
||||
->label('Connection Type')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage')
|
||||
->label('Voltage')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('phase')
|
||||
->label('Phase')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('oh_minimum')
|
||||
->label('OH Minimum')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('oh_maximum')
|
||||
->label('OH Maximum')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('current_minimum')
|
||||
->label('Current Minimum')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('current_maximum')
|
||||
->label('Current Maximum')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('class_of_insulation')
|
||||
->label('Class of Insulation')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('testing_code')
|
||||
->label('Testing Code')
|
||||
->default('-')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('pumpTestingMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('isi_type', null);
|
||||
$set('created_by', null);
|
||||
$set('updated_by', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Pump Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
if (! $pId) {
|
||||
return [];
|
||||
} else {
|
||||
return Item::whereHas('pumpTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('description')
|
||||
->label('Pump Type')
|
||||
->placeholder('Enter the Pump Type'),
|
||||
Select::make('motor_code')
|
||||
->label('Search by Motor Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
} else {
|
||||
return PumpTestingMaster::where('plant_id', $plantId)->whereNotNull('motor_code')->select('motor_code')->distinct()->pluck('motor_code', 'motor_code');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('phase_type')
|
||||
->label('Select Phase')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if ($state == 'Single' && $get('connection_type') == 'STAR DELTA') {
|
||||
$set('phase_type', 'Three');
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('connection_type')
|
||||
->label('Select Connection')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId) {
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'PUMP_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
} else {
|
||||
return Configuration::where('c_name', 'PUMP_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'STAR DELTA') {
|
||||
$set('phase_type', 'Three');
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('created_by')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return PumpTestingMaster::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
} else {
|
||||
return PumpTestingMaster::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
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),
|
||||
Select::make('updated_by')
|
||||
->label('Updated By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (! $plantId) {
|
||||
return PumpTestingMaster::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
} else {
|
||||
return PumpTestingMaster::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['description']) && empty($data['motor_code']) && empty($data['phase_type']) && empty($data['connection_type']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All')
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$itemIds = Item::where('id', $data['Item'])
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (! empty($itemIds)) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$pId = $data['Plant'] ?? null;
|
||||
$descIds = Item::where('description', 'like', '%'.$data['description'].'%')->whereHas('pumpTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
|
||||
if (! empty($descIds)) {
|
||||
$query->whereIn('item_id', $descIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['motor_code'])) {
|
||||
$query->where('motor_code', $data['motor_code']);
|
||||
}
|
||||
|
||||
if (! empty($data['phase_type'])) {
|
||||
$query->where('phase', $data['phase_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['connection_type'])) {
|
||||
$query->where('connection_type', $data['connection_type']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
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['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_by']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$itemCode = Item::find($data['Item'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Pump Code: '.$itemCode;
|
||||
}
|
||||
|
||||
if (! empty($data['description'])) {
|
||||
$indicators[] = 'Pump Type: '.$data['description'];
|
||||
}
|
||||
|
||||
if (! empty($data['motor_code'])) {
|
||||
$indicators[] = 'Motor Code: '.$data['motor_code'];
|
||||
}
|
||||
|
||||
if (! empty($data['phase_type'])) {
|
||||
$indicators[] = 'Phase: '.$data['phase_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['connection_type'])) {
|
||||
$indicators[] = 'Connection: '.$data['connection_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['created_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->label('Export Pump Testing Masters')
|
||||
->color('warning')
|
||||
->exporter(PumpTestingMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export pump testing master');
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPumpTestingMasters::route('/'),
|
||||
'create' => Pages\CreatePumpTestingMaster::route('/create'),
|
||||
'view' => Pages\ViewPumpTestingMaster::route('/{record}'),
|
||||
'edit' => Pages\EditPumpTestingMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PumpTestingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePumpTestingMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PumpTestingMasterResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PumpTestingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\PumpTestingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPumpTestingMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = PumpTestingMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user