Compare commits
69 Commits
56152816e2
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bba1e2636 | ||
|
|
64d7f98f3b | ||
|
|
091234323d | ||
|
|
e890e01cd3 | ||
|
|
b3b046c92c | ||
|
|
01cbfc9391 | ||
|
|
290ad727fa | ||
|
|
9b5d3168de | ||
|
|
268eb143cc | ||
|
|
8b34e17096 | ||
|
|
d21581ea61 | ||
|
|
b9e62618a0 | ||
|
|
1325b77eb3 | ||
|
|
0a9d6514cb | ||
|
|
f2d0d3da8e | ||
|
|
469b47d2dc | ||
|
|
702dd69c94 | ||
|
|
ce65c68125 | ||
|
|
92f3352f6b | ||
|
|
a14cf0aef6 | ||
|
|
bdd8e9dfc3 | ||
|
|
951a69b85e | ||
|
|
dc6fd87c7b | ||
|
|
f464facd56 | ||
|
|
21d009ee1c | ||
|
|
8e7030b80b | ||
|
|
1931412511 | ||
|
|
0fef7b27bf | ||
|
|
115fe43428 | ||
|
|
5eb067899b | ||
|
|
8a2dac9982 | ||
|
|
79f09236ab | ||
|
|
0947408462 | ||
|
|
538f0961b4 | ||
|
|
5fccde0160 | ||
|
|
52de3aa0cc | ||
|
|
02c9059cf3 | ||
|
|
dec4900659 | ||
|
|
3550d8248e | ||
|
|
be5aee3df6 | ||
|
|
ece0a9e226 | ||
|
|
c12697a1af | ||
|
|
c0929b4153 | ||
|
|
349d04b7f9 | ||
|
|
341f4f20b4 | ||
|
|
88e1e54cf7 | ||
|
|
c0e4b77eda | ||
|
|
54bcf4cf28 | ||
|
|
2fbbbe579b | ||
|
|
1b1a02a565 | ||
|
|
c4153169eb | ||
|
|
d71eef3833 | ||
|
|
738f81043d | ||
|
|
9a9051b884 | ||
|
|
547ee4b78f | ||
|
|
4fe23afe13 | ||
|
|
19817b4cfa | ||
|
|
0e301e12e1 | ||
|
|
17545040fe | ||
|
|
ae4e7d0239 | ||
|
|
7deb78f574 | ||
|
|
0ce614ab53 | ||
|
|
1106e40a51 | ||
|
|
7c777076d7 | ||
|
|
8b9cc874b5 | ||
|
|
ca3ecb20af | ||
|
|
86ddb3cb82 | ||
|
|
c67c92c8f5 | ||
|
|
528c04f1e7 |
@@ -211,7 +211,7 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '10:45') {
|
||||
if (now()->format('H:i') == '11:00') {
|
||||
try {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
|
||||
@@ -48,12 +48,12 @@ class SendInvoiceTransitReport extends Command
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily')
|
||||
{
|
||||
$results = DB::table('invoice_in_transits as it')
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
$results = DB::table('invoice_in_transits as it')
|
||||
->join('invoice_masters as im', function ($join) {
|
||||
$join->on('im.receiving_plant_name', '=', 'it.receiving_plant_name')->on('im.transport_name', '=', 'it.transport_name');
|
||||
})
|
||||
@@ -84,17 +84,18 @@ class SendInvoiceTransitReport extends Command
|
||||
')
|
||||
|
||||
)
|
||||
->when($plantId != 0, fn($q) => $q->where('it.plant_id', $plantId))
|
||||
->when($plantId != 0, fn ($q) => $q->where('it.plant_id', $plantId))
|
||||
->whereNotNull('it.lr_bl_aw_date')
|
||||
->whereRaw('
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER) > 0
|
||||
')
|
||||
->distinct('it.invoice_number')
|
||||
->get();
|
||||
|
||||
|
||||
if ($results->isEmpty()) {
|
||||
$this->info('No invoice transit records found for today.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,24 +104,25 @@ class SendInvoiceTransitReport extends Command
|
||||
foreach ($mailRules as $rule) {
|
||||
|
||||
$ruleInvoices = $results->where('invoice_master_id', $rule->invoice_master_id);
|
||||
//$ruleInvoices = $results->filter(fn($item) => $item->invoice_master_id == (int)$rule->invoice_master_id);
|
||||
|
||||
// $ruleInvoices = $results->filter(fn($item) => $item->invoice_master_id == (int)$rule->invoice_master_id);
|
||||
|
||||
if ($ruleInvoices->isEmpty()) {
|
||||
$this->info("Skipping rule {$rule->id} — no invoice transit data.");
|
||||
continue; // ❌ DO NOT SEND MAIL
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$invoiceMaster = InvoiceMaster::find($rule->invoice_master_id);
|
||||
|
||||
$mailSubject = $invoiceMaster
|
||||
? "Despatch Invoice In Transit ({$invoiceMaster->receiving_plant_name} - {$invoiceMaster->transport_name})"
|
||||
: "Despatch Invoice In Transit";
|
||||
: 'Despatch Invoice In Transit';
|
||||
|
||||
if ($ruleInvoices->isEmpty()) {
|
||||
$tableData = [];
|
||||
$this->info("No despatch invoices in transit found for rule {$rule->id}.");
|
||||
} else {
|
||||
|
||||
$tableData = $ruleInvoices->values()->map(function ($item, $index) use ($plantCodes) {
|
||||
return [
|
||||
'no' => $index + 1,
|
||||
@@ -132,9 +134,10 @@ class SendInvoiceTransitReport extends Command
|
||||
'lr_bl_aw_date' => $item->lr_bl_aw_date,
|
||||
'lr_bl_aw_number' => $item->lr_bl_aw_number,
|
||||
'transit_days' => $item->transit_days,
|
||||
'status' => $item->delayed_days . ' Days',
|
||||
'status' => $item->delayed_days.' Days',
|
||||
];
|
||||
})->toArray();
|
||||
|
||||
}
|
||||
|
||||
$mail = new InvoiceTransitMail($scheduleType, $tableData, $mailSubject);
|
||||
@@ -155,13 +158,14 @@ class SendInvoiceTransitReport extends Command
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule {$rule->id} — no To emails.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info(
|
||||
"Mail sent → Rule {$rule->id} | Invoice Master ID: {$rule->invoice_master_id} | To: " . implode(', ', $toEmails)
|
||||
"Mail sent → Rule {$rule->id} | Invoice Master ID: {$rule->invoice_master_id} | To: ".implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
231
app/Exports/MotorFreeRunExport.php
Normal file
231
app/Exports/MotorFreeRunExport.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Support\Facades\View as FacadesView;
|
||||
use Illuminate\View\View as ViewView;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
// use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStartRow;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
|
||||
use Maatwebsite\Excel\Events\BeforeExport;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
// {
|
||||
// public function __construct(
|
||||
// public $records,
|
||||
// ) {}
|
||||
|
||||
// // public function view(): View
|
||||
// // {
|
||||
// // return view('exports.export-isi-pdf', [
|
||||
// // 'records' => $this->records,
|
||||
// // ]);
|
||||
// // }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// // Top two rows (Company info + Motor KW/HP)
|
||||
// return [
|
||||
// ['C.R.I. Pumps Private Limited', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Unit: MOTOR FREE RUN TEST REGISTER'],
|
||||
// ['Motor KW/HP : - / -', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Phase : -'],
|
||||
// // Column headers
|
||||
// [
|
||||
// 'Date', 'Motor SNo', 'Item Code', 'Motor Type',
|
||||
// 'Voltage', 'Current', 'Power', 'IR.Hot', 'IR.Cool', 'Frequency', 'Speed', 'Leakage Current', // AFTER FREE RUN
|
||||
// 'Voltage', 'Current', 'Power', // LOCKED ROTOR TEST
|
||||
// 'No Load Pickup Voltage', 'Room Temp.', 'High Voltage Test', 'Result', 'Remark'
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
|
||||
// public function registerEvents(): array
|
||||
// {
|
||||
// return [
|
||||
// AfterSheet::class => function (AfterSheet $event) {
|
||||
// $sheet = $event->sheet->getDelegate();
|
||||
|
||||
// // Merge top rows for company info
|
||||
// $sheet->mergeCells('A1:S1'); // Company Name
|
||||
// $sheet->mergeCells('T1:T1'); // Unit/Register info
|
||||
// $sheet->mergeCells('A2:S2'); // Motor KW/HP row
|
||||
// $sheet->mergeCells('T2:T2'); // Phase
|
||||
|
||||
// // Merge headers for grouped columns (AFTER FREE RUN & LOCKED ROTOR TEST)
|
||||
// $sheet->mergeCells('E3:L3'); // AFTER FREE RUN
|
||||
// $sheet->mergeCells('M3:O3'); // LOCKED ROTOR TEST
|
||||
|
||||
// // Optional: style headers
|
||||
// $sheet->getStyle('A1:T3')->getFont()->setBold(true);
|
||||
// $sheet->getStyle('A1:T3')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
// $sheet->getStyle('A1:T3')->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
|
||||
// // Set column widths (optional for better visibility)
|
||||
// $columns = range('A', 'T');
|
||||
// foreach ($columns as $col) {
|
||||
// $sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
// }
|
||||
// },
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// class MotorFreeRunExport implements FromCollection, WithMapping, WithStartRow
|
||||
// {
|
||||
// protected Collection $records;
|
||||
|
||||
// public function __construct(Collection $records)
|
||||
// {
|
||||
// $this->records = $records;
|
||||
// }
|
||||
|
||||
// public function collection()
|
||||
// {
|
||||
// return $this->records;
|
||||
// }
|
||||
|
||||
// public function startRow(): int
|
||||
// {
|
||||
// return 3; // insert data starting from row 3
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// return [
|
||||
// $record['Date'] ?? '',
|
||||
// $record['Output'] ?? '',
|
||||
// $record['Motor SNo'] ?? '',
|
||||
// $record['Item Code'] ?? '',
|
||||
// $record['Motor Type'] ?? '',
|
||||
// $record['kw'] ?? '',
|
||||
// $record['hp'] ?? '',
|
||||
// $record['phase'] ?? '',
|
||||
// $record['isi_model'] ?? '',
|
||||
// $record['Voltage_Before'] ?? '',
|
||||
// $record['Current_Before'] ?? '',
|
||||
// $record['Power_Before'] ?? '',
|
||||
// $record['Resistance_RY'] ?? '',
|
||||
// $record['Resistance_YB'] ?? '',
|
||||
// $record['Resistance_BR'] ?? '',
|
||||
// $record['Insulation_Resistance'] ?? '',
|
||||
// $record['Frequency_Before'] ?? '',
|
||||
// $record['Speed_Before'] ?? '',
|
||||
// $record['Voltage_After'] ?? '',
|
||||
// $record['Current_After'] ?? '',
|
||||
// $record['Power_After'] ?? '',
|
||||
// $record['IR_Hot'] ?? '',
|
||||
// $record['IR_Cool'] ?? '',
|
||||
// $record['Leakage_Current'] ?? '',
|
||||
// $record['Frequency_After'] ?? '',
|
||||
// $record['Speed_After'] ?? '',
|
||||
// $record['Voltage_Locked'] ?? '',
|
||||
// $record['Current_Locked'] ?? '',
|
||||
// $record['Power_Locked'] ?? '',
|
||||
// $record['No_Load_Pickup_Voltage'] ?? '',
|
||||
// $record['Room_Temp'] ?? '',
|
||||
// $record['High_Voltage_Test'] ?? '',
|
||||
// $record['Batch_Number'] ?? '',
|
||||
// $record['Batch_Count'] ?? '',
|
||||
// $record['Result'] ?? '',
|
||||
// $record['Remark'] ?? '',
|
||||
// $record['Tested_By'] ?? '',
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
class MotorFreeRunExport implements WithCustomStartCell, WithMapping, WithStartRow, WithChunkReading
|
||||
{
|
||||
protected $records;
|
||||
protected $templatePath;
|
||||
|
||||
public function __construct($records)
|
||||
{
|
||||
$this->records = $records;
|
||||
// dd($this->records);
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->records;
|
||||
}
|
||||
|
||||
public function startRow(): int
|
||||
{
|
||||
return 7; // Start inserting data from row 7
|
||||
}
|
||||
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A7'; // Start inserting data from row 7 column A
|
||||
}
|
||||
|
||||
public function map($record): array
|
||||
{
|
||||
return [
|
||||
$record['Date'] ?? '',
|
||||
$record['Output'] ?? '',
|
||||
$record['Motor SNo'] ?? '',
|
||||
$record['Item Code'] ?? '',
|
||||
$record['Motor Type'] ?? '',
|
||||
$record['kw'] ?? '',
|
||||
$record['hp'] ?? '',
|
||||
$record['phase'] ?? '',
|
||||
$record['isi_model'] ?? '',
|
||||
$record['Voltage_Before'] ?? '',
|
||||
$record['Current_Before'] ?? '',
|
||||
$record['Power_Before'] ?? '',
|
||||
$record['Resistance_RY'] ?? '',
|
||||
$record['Resistance_YB'] ?? '',
|
||||
$record['Resistance_BR'] ?? '',
|
||||
$record['Insulation_Resistance'] ?? '',
|
||||
$record['Frequency_Before'] ?? '',
|
||||
$record['Speed_Before'] ?? '',
|
||||
$record['Voltage_After'] ?? '',
|
||||
$record['Current_After'] ?? '',
|
||||
$record['Power_After'] ?? '',
|
||||
$record['IR_Hot'] ?? '',
|
||||
$record['IR_Cool'] ?? '',
|
||||
$record['Leakage_Current'] ?? '',
|
||||
$record['Frequency_After'] ?? '',
|
||||
$record['Speed_After'] ?? '',
|
||||
$record['Voltage_Locked'] ?? '',
|
||||
$record['Current_Locked'] ?? '',
|
||||
$record['Power_Locked'] ?? '',
|
||||
$record['No_Load_Pickup_Voltage'] ?? '',
|
||||
$record['Room_Temp'] ?? '',
|
||||
$record['High_Voltage_Test'] ?? '',
|
||||
$record['Batch_Number'] ?? '',
|
||||
$record['Batch_Count'] ?? '',
|
||||
$record['Result'] ?? '',
|
||||
$record['Remark'] ?? '',
|
||||
$record['Tested_By'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
public function chunkSize(): int
|
||||
{
|
||||
return 1000; // load 1000 records at a time
|
||||
}
|
||||
}
|
||||
159
app/Exports/TestingPanelReadingExport.php
Normal file
159
app/Exports/TestingPanelReadingExport.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\TestingPanelReading;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithChunkReading;
|
||||
// use Maatwebsite\Excel\Concerns\ShouldQueue;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
// class TestingPanelReadingExport implements FromCollection
|
||||
// {
|
||||
// /**
|
||||
// * @return \Illuminate\Support\Collection
|
||||
// */
|
||||
// public function collection()
|
||||
// {
|
||||
// return TestingPanelReading::all();
|
||||
// }
|
||||
// }
|
||||
|
||||
// class TestingPanelReadingExport implements FromQuery, WithChunkReading, ShouldQueue, WithHeadings
|
||||
// {
|
||||
// protected array $ids;
|
||||
// protected int $counter = 0;
|
||||
|
||||
// public function __construct(array $ids)
|
||||
// {
|
||||
// $this->ids = $ids;
|
||||
// }
|
||||
// public function query()
|
||||
// {
|
||||
// return TestingPanelReading::query()
|
||||
// ->whereIn('id', $this->ids)
|
||||
// ->select('id', 'plant_id', 'line_id', 'motor_testing_master_id', 'machine_id', 'output', 'serial_number', 'winded_serial_number', 'before_fr_volt', 'before_fr_cur', 'before_fr_pow', 'before_fr_res_ry', 'before_fr_res_yb', 'before_fr_res_br', 'before_fr_ir', 'before_fr_ir_r', 'before_fr_ir_y', 'before_fr_ir_b', 'before_fr_freq', 'before_fr_speed', 'after_fr_vol', 'after_fr_cur', 'after_fr_pow', 'after_fr_ir_hot','after_fr_ir_hot_r', 'after_fr_ir_hot_y', 'after_fr_ir_hot_b', 'after_fr_ir_cool', 'after_fr_ir_cool_r', 'after_fr_ir_cool_y', 'after_fr_ir_cool_b', 'after_fr_freq', 'after_fr_speed', 'after_fr_leak_cur', 'locked_rt_volt', 'locked_rt_cur', 'locked_rt_pow', 'no_load_pickup_volt', 'room_temperature', 'hv_test', 'batch_number', 'batch_count', 'result', 'remark', 'rework_count', 'update_count', 'output_flag', 'tested_by', 'updated_by', 'created_at', 'updated_at', 'scanned_at', 'created_at');
|
||||
// }
|
||||
|
||||
// public function chunkSize(): int
|
||||
// {
|
||||
// return 1000; // process 1000 rows at a time
|
||||
// }
|
||||
|
||||
// public function headings(): array
|
||||
// {
|
||||
// return ['NO', 'PLANT', 'LINE', 'MOTORTESTINGMASTER', 'MACHINE', 'OUTPUT', 'SERIAL NUMBER', 'WINDED SERIAL NUMBER', 'BEFORE FR VOLT', 'BEFORE FR CUR', 'BEFORE FR POW', 'BEFORE FR RES RY', 'BEFORE FR RES YB', 'BEFORE FR RES BR', 'BEFORE FR IR', 'BEFORE FR IR R', 'BEFORE FR IR Y', 'BEFORE FR IR B', 'BEFORE FR FREQ', 'BEFORE FR SPEED', 'AFTER FR VOL', 'AFTER FR CUR', 'AFTER FR POW', 'AFTER FR IR HOT', 'AFTER FR IR HOT R', 'AFTER FR IR HOT Y', 'AFTER FR IR HOT B', 'AFTER FR IR COOL', 'AFTER FR IR COOL R', 'AFTER FR IR COOL Y', 'AFTER FR IR COOL B', 'AFTER FR FREQ', 'AFTER FR SPEED', 'AFTER FR LEAK CUR', 'LOCKED RT VOLT', 'LOCKED RT CUR', 'LOCKED RT POW', 'NO LOAD PICKUP VOLT', 'ROOM TEMPERATURE', 'HV TEST', 'BATCH NUMBER', 'BATCH COUNT', 'RESULT', 'REMARK', 'REWORK COUNT', 'UPDATE COUNT', 'OUTPUT FLAG', 'TETSED BY', 'UPDATED BY', 'CREATED AT', 'UPDATED AT', 'SCANNED AT', 'CREATED AT'];
|
||||
// }
|
||||
|
||||
// public function map($record): array
|
||||
// {
|
||||
// $this->counter++;
|
||||
// return [
|
||||
// $this->counter, // No.
|
||||
// $record->plant_id,
|
||||
// $record->line_id,
|
||||
// $record->motor_testing_master_id,
|
||||
// $record->machine_id,
|
||||
// $record->output,
|
||||
// $record->serial_number,
|
||||
// $record->winded_serial_number,
|
||||
// $record->before_fr_volt,
|
||||
// $record->before_fr_cur,
|
||||
// $record->before_fr_pow,
|
||||
// $record->before_fr_res_ry,
|
||||
// $record->before_fr_res_yb,
|
||||
// $record->before_fr_res_br,
|
||||
// $record->before_fr_ir,
|
||||
// $record->before_fr_ir_r,
|
||||
// $record->before_fr_ir_y,
|
||||
// $record->before_fr_ir_b,
|
||||
// $record->before_fr_freq,
|
||||
// $record->before_fr_speed,
|
||||
// $record->after_fr_vol,
|
||||
// $record->after_fr_cur,
|
||||
// $record->after_fr_pow,
|
||||
// $record->after_fr_ir_hot,
|
||||
// $record->after_fr_ir_hot_r,
|
||||
// $record->after_fr_ir_hot_y,
|
||||
// $record->after_fr_ir_hot_b,
|
||||
// $record->after_fr_ir_cool,
|
||||
// $record->after_fr_ir_cool_r,
|
||||
// $record->after_fr_ir_cool_y,
|
||||
// $record->after_fr_ir_cool_b,
|
||||
// $record->after_fr_freq,
|
||||
// $record->after_fr_speed,
|
||||
// $record->after_fr_leak_cur,
|
||||
// $record->locked_rt_volt,
|
||||
// $record->locked_rt_cur,
|
||||
// $record->locked_rt_pow,
|
||||
// $record->no_load_pickup_volt,
|
||||
// $record->room_temperature,
|
||||
// $record->hv_test,
|
||||
// $record->batch_number,
|
||||
// $record->batch_count,
|
||||
// $record->result,
|
||||
// $record->remark,
|
||||
// $record->rework_count,
|
||||
// $record->update_count,
|
||||
// $record->output_flag,
|
||||
// $record->tested_by,
|
||||
// $record->updated_by,
|
||||
// // $record->created_at,
|
||||
// $record->updated_at,
|
||||
// $record->scanned_at,
|
||||
// $record->created_at,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
class TestingPanelReadingExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $records;
|
||||
protected $isAllStarDelta;
|
||||
|
||||
public function __construct($records, $isAllStarDelta)
|
||||
{
|
||||
$this->records = $records;
|
||||
$this->isAllStarDelta = $isAllStarDelta;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->records)->map(function ($record) {
|
||||
if (!$this->isAllStarDelta) {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'Date' => date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return array_keys($this->collection()->first() ?? []);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class CharacteristicApproverMasterExporter extends Exporter
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD 1'),
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('mail1')
|
||||
|
||||
@@ -44,6 +44,8 @@ class InvoiceValidationExporter extends Exporter
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
@@ -61,9 +63,13 @@ class InvoiceValidationExporter extends Exporter
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
// ->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
|
||||
@@ -18,7 +18,7 @@ class UserImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
@@ -54,10 +54,13 @@ class UserImporter extends Importer
|
||||
public function resolveRecord(): ?User
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plantCod = $this->data['plant_id'];
|
||||
$plant = null;
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) <= 0) {
|
||||
$plant = null;
|
||||
$plantCod = null;
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
|
||||
@@ -357,18 +357,6 @@ class InvoicePendingReason extends Page
|
||||
]);
|
||||
return;
|
||||
}
|
||||
// else if(!empty($import->remarkEmpty)) {
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Import failed')
|
||||
// ->body("Remark can't be empty")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $this->filtersForm->fill([
|
||||
// 'file' => null,
|
||||
// ]);
|
||||
// return;
|
||||
// }
|
||||
else if (! empty($import->duplicateExcelDocs)) {
|
||||
|
||||
$duplicates = collect($import->duplicateExcelDocs)
|
||||
|
||||
@@ -7,13 +7,11 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift'; // 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
public function getHeading(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
0
app/Filament/Pages/test.php
Normal file
0
app/Filament/Pages/test.php
Normal file
@@ -65,41 +65,65 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->default('NIL')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine')
|
||||
->columnSpan(2)
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(5)
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->machine_name ?? '';
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->columnSpan(2)
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(1)
|
||||
->default('NIL')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if (strtolower($state) == 'nil' || $state == '' || $state == null) {
|
||||
$set('characteristic_field', 'NIL');
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Section::make('Approver - 1')
|
||||
// ->description('Prevent abuse by limiting the number of requests per period')
|
||||
->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name1')
|
||||
->label('Name')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail1')
|
||||
->label('Mail')
|
||||
->label('Mail ID')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->reactive()
|
||||
->required()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration1')
|
||||
->label('Duration (HH.MM)')
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(4)
|
||||
->maxLength(5)
|
||||
->regex('/^([0-9]|0[0-9]|1[0-9]|2[0-3])\.(0[0-9]|[1-5][0-9])$/')
|
||||
->validationMessages([
|
||||
// 'regex' => 'Duration must be 4 digits in HH.MM format (e.g., 12.30, 23.59). Hours: 00-23, Minutes: 00-59.',
|
||||
'regex' => 'Duration must be HH.MM format (example: 00.00 - 23.59)',
|
||||
// 'length' => 'Duration must be exactly 5 characters',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -111,17 +135,28 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name2')
|
||||
->label('Name')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail2')
|
||||
->label('Mail')
|
||||
->label('Mail ID')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->reactive()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration2')
|
||||
->label('Duration (HH.MM)')
|
||||
->reactive()
|
||||
->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)',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -133,17 +168,28 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name3')
|
||||
->label('Name')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mail3')
|
||||
->label('Mail')
|
||||
->label('Mail ID')
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
->reactive()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration3')
|
||||
->label('Duration (HH.MM)')
|
||||
->reactive()
|
||||
->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)',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -205,7 +251,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail1')
|
||||
->label('Mail 1')
|
||||
->label('E-Mail 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -219,7 +265,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail2')
|
||||
->label('Mail 2')
|
||||
->label('E-Mail 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -233,7 +279,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail3')
|
||||
->label('Mail 3')
|
||||
->label('E-Mail 3')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -289,14 +335,14 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->label('Import Characteristics Approver Master')
|
||||
// ->color('warning')
|
||||
// ->importer(CharacteristicApproverMasterImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import characteristic approver master');
|
||||
// }),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->label('Export Characteristics Approver Master')
|
||||
->color('warning')
|
||||
->exporter(CharacteristicApproverMasterExporter::class)
|
||||
->visible(function () {
|
||||
|
||||
@@ -67,17 +67,20 @@ class InvoiceValidationResource extends Resource
|
||||
->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();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
// return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('update_invoice', null);
|
||||
// Ensure `linestop_id` is not cleared
|
||||
|
||||
if (! $plantId) {
|
||||
$set('invoice_number', null);
|
||||
$set('serial_number', null);
|
||||
@@ -87,6 +90,11 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
return;
|
||||
} else {
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
if (! Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
$set('ivPlantError', null);
|
||||
}
|
||||
})
|
||||
@@ -113,8 +121,19 @@ class InvoiceValidationResource extends Resource
|
||||
// ->afterStateHydrated(function (TextInput $component, string $state) {
|
||||
// $component->state(ucwords($state));
|
||||
// })
|
||||
->autofocus(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$sNo = $get('serial_number');
|
||||
if (! $plantId || $sNo) {
|
||||
return false;
|
||||
} elseif ($plantId && ! $sNo) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$invNo = $get('invoice_number');
|
||||
// $invNo = $get('invoice_number');
|
||||
$set('serial_number', null);
|
||||
$set('update_invoice', null);
|
||||
// Session::put('invoice_number', $state);
|
||||
@@ -207,6 +226,14 @@ class InvoiceValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(true),
|
||||
// Forms\Components\Hidden::make('created_by')
|
||||
// ->label('Created By')
|
||||
// ->default(Filament::auth()->user()?->name)
|
||||
// ->reactive(),
|
||||
// Forms\Components\Hidden::make('updated_by')
|
||||
// ->label('Updated By')
|
||||
// ->default(Filament::auth()->user()?->name)
|
||||
// ->reactive(),
|
||||
])
|
||||
->columns(5),
|
||||
]);
|
||||
@@ -262,9 +289,11 @@ class InvoiceValidationResource extends Resource
|
||||
Tables\Columns\TextColumn::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->alignCenter(),
|
||||
// Tables\Columns\TextColumn::make('stickerMaster.panel_box_code')
|
||||
// ->label('Panel Box Code')
|
||||
// ->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_code')// stickerMaster.panel_box_code
|
||||
->label('Panel Box Code')
|
||||
->alignCenter()
|
||||
->sortable(), // ->searchable()
|
||||
// ->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||
->label('Panel Box Supplier')
|
||||
->alignCenter(),
|
||||
@@ -289,11 +318,20 @@ class InvoiceValidationResource extends Resource
|
||||
->label('Plant')
|
||||
->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()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
@@ -332,7 +370,7 @@ class InvoiceValidationResource extends Resource
|
||||
->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();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
@@ -341,19 +379,37 @@ class InvoiceValidationResource extends Resource
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
$plantId = $get('plant_id');
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
if ($plantId && ! Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
|
||||
FileUpload::make('invoice_serial_number')
|
||||
->label('Invoice Serial Number')
|
||||
// ->required()
|
||||
->preserveFilenames() // <- this keeps the original filename
|
||||
->storeFiles(false) // prevent auto-storing, we will store manually
|
||||
->reactive()
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-excel', // Legacy .xls fallback if needed
|
||||
])
|
||||
->rules(['mimes:xlsx']) // Laravel validation: extension check
|
||||
->preserveFilenames() // <- this keeps the original filename
|
||||
->reactive()
|
||||
->storeFiles(false) // prevent auto-storing, we will store manually
|
||||
->disk('local') // 'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
|
||||
->visible(fn (Get $get) => ! empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
->directory(function (callable $get) {
|
||||
$plant = Plant::find($get('plant_id'));
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
return "uploads/temp/{$plantCode}";
|
||||
})
|
||||
->uploadingMessage('Uploading...')
|
||||
->helperText('Only .xlsx files are allowed (Excel files).'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_serial_number'];
|
||||
@@ -362,17 +418,40 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
$plantId = $data['plant_id'];
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
||||
|
||||
$extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
if ($extension !== 'xlsx') {
|
||||
throw new \Exception('Only .xlsx files allowed.');
|
||||
}
|
||||
|
||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
$originalName = "{$originalNameOnly}.xlsx";
|
||||
|
||||
// Store manually using storeAs to keep original name
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
|
||||
// uploads/temp/3RA0018735.xlsx
|
||||
$path = $uploadedFile->storeAs("uploads/temp/{$plantCode}", $originalName, 'local'); // returns relative path
|
||||
// uploads/temp/{$plantCode}/3RA0018735.xlsx
|
||||
|
||||
if (strlen($originalNameOnly) < 8 || ! ctype_alnum($originalNameOnly)) {
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' should contain minimum 8 digit alpha numeric values!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/{$plantCode}/3RA0018735.xlsx
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0) {
|
||||
@@ -637,7 +716,7 @@ class InvoiceValidationResource extends Resource
|
||||
->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();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
@@ -646,32 +725,68 @@ class InvoiceValidationResource extends Resource
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_material', null);
|
||||
$plantId = $get('plant_id');
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
if ($plantId && ! Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
|
||||
FileUpload::make('invoice_material')
|
||||
->label('Invoice Material')
|
||||
->required()
|
||||
->preserveFilenames()
|
||||
->reactive() // <- this keeps the original filename
|
||||
->preserveFilenames() // <- this keeps the original filename
|
||||
->reactive()
|
||||
->storeFiles(false) // prevent auto-storing
|
||||
->disk('local')
|
||||
->visible(fn (Get $get) => ! empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
->directory(function (callable $get) {
|
||||
$plant = Plant::find($get('plant_id'));
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
return "uploads/temp/{$plantCode}";
|
||||
})
|
||||
->helperText('Only .xlsx files are allowed (Excel files).'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_material'];
|
||||
|
||||
$plantId = $data['plant_id']; // Access the selected plant_id
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName();
|
||||
|
||||
$extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
if ($extension !== 'xlsx') {
|
||||
throw new \Exception('Only .xlsx files allowed.');
|
||||
}
|
||||
|
||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local');
|
||||
$originalName = "{$originalNameOnly}.xlsx";
|
||||
|
||||
$path = $uploadedFile->storeAs("uploads/temp/{$plantCode}", $originalName, 'local');
|
||||
|
||||
if (strlen($originalNameOnly) < 8 || ! ctype_alnum($originalNameOnly)) {
|
||||
Notification::make()
|
||||
->title("Material invoice number : '$originalNameOnly' should contain minimum 8 digit alpha numeric values!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
@@ -1024,11 +1139,11 @@ class InvoiceValidationResource extends Resource
|
||||
// ])
|
||||
->options(function () {
|
||||
$userRights = Filament::auth()->user();
|
||||
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Manager']) ?? null);
|
||||
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Supervisor Hub Upload', 'Sales Manager']) ?? null);
|
||||
|
||||
$hasSerial = ($userRights->hasRole(['Sales Supervisor 1', 'Sales Supervisor Inventory', 'Sales Employee Inventory']) ?? null);
|
||||
$hasSerial = ($userRights->hasRole(['Sales Employee 1', 'Sales Supervisor 1', 'Sales Supervisor Upload 1']) ?? null); // , 'Sales Supervisor Inventory', 'Sales Supervisor Inventory Upload', 'Sales Employee Inventory'
|
||||
|
||||
$hasMaterial = $userRights->hasRole('Sales Supervisor 2') ?? null;
|
||||
$hasMaterial = ($userRights->hasRole(['Sales Employee 2', 'Sales Supervisor 2', 'Sales Supervisor Upload 2']) ?? null);
|
||||
|
||||
$retRes = [
|
||||
'Serial' => 'Serial',
|
||||
@@ -1048,11 +1163,11 @@ class InvoiceValidationResource extends Resource
|
||||
// ->default('Serial')
|
||||
->default(function () {
|
||||
$userRights = Filament::auth()->user();
|
||||
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Manager']) ?? null);
|
||||
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Supervisor Hub Upload', 'Sales Manager']) ?? null);
|
||||
|
||||
$hasSerial = ($userRights->hasRole(['Sales Supervisor 1', 'Sales Supervisor Inventory', 'Sales Employee Inventory']) ?? null);
|
||||
$hasSerial = ($userRights->hasRole(['Sales Employee 1', 'Sales Supervisor 1', 'Sales Supervisor Upload 1']) ?? null); // , 'Sales Supervisor Inventory', 'Sales Supervisor Inventory Upload', 'Sales Employee Inventory'
|
||||
|
||||
$hasMaterial = $userRights->hasRole('Sales Supervisor 2') ?? null;
|
||||
$hasMaterial = ($userRights->hasRole(['Sales Employee 2', 'Sales Supervisor 2', 'Sales Supervisor Upload 2']) ?? null);
|
||||
|
||||
if ($hasBoth || $hasSerial) {
|
||||
return 'Serial';
|
||||
@@ -1073,7 +1188,7 @@ class InvoiceValidationResource extends Resource
|
||||
->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();
|
||||
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 {
|
||||
|
||||
@@ -117,8 +117,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->plantId = $plantId;
|
||||
|
||||
// $plant = Plant::find($plantId);
|
||||
// $plantCode = $plant ? $plant->code : null;
|
||||
$plant = Plant::find($plantId);
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
// ..GET SERIAL INVOICE API
|
||||
|
||||
@@ -233,7 +233,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -266,7 +266,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if ($updateStatus == '1') {
|
||||
// 'Material invoice update in progress...';
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
$fullPath = $disk->path($filePath);
|
||||
@@ -613,6 +613,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -653,6 +655,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $bundleQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -716,6 +720,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$existEmpRecQty->update([
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$newQuan--;
|
||||
@@ -727,6 +732,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -746,6 +753,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$existEmpRecQty->update([
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$newQuan--;
|
||||
@@ -757,6 +765,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $newInsQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -780,6 +790,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->update(['updated_by' => $operatorName]); // 'updated_at' => now(),
|
||||
|
||||
// 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();
|
||||
@@ -877,7 +889,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -907,16 +919,15 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if ($updateStatus == '1') {
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
$fullPath = $disk->path($filePath);
|
||||
|
||||
// Check if file exists //if ($disk->exists($filePath))
|
||||
if ($fullPath && file_exists($fullPath)) {
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/{$plantCode}/3RA0018735.xlsx
|
||||
// 'Serial invoice update in progress...'
|
||||
|
||||
// Now you can read/process the file here
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
@@ -1233,6 +1244,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $serialNumber,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -1255,6 +1268,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->update(['updated_by' => $operatorName]); // 'updated_at' => now(),
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
@@ -1337,7 +1352,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
$fullPath = null; // $fullPath = $disk->path($filePath);
|
||||
@@ -1778,6 +1793,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -1811,6 +1828,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $bundleQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -1842,6 +1861,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $totalExcelQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -2206,6 +2227,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $serialNumber,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
@@ -2358,6 +2381,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$invoiceNumber = $this->form->getState()['invoice_number'];
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
$plantCode = $plant?->code ?? null;
|
||||
|
||||
$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', '!=', '')
|
||||
@@ -2395,7 +2421,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -2899,7 +2925,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if ($dupRecord) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned 'Material QR' already completed the scanning process.")
|
||||
->body("Scanned Material QR : '{$serialNumber}' already completed the scanning process..!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
@@ -2947,6 +2973,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if ($curExistQty > $curScanQty) { // 5 > 2
|
||||
$record->quantity = $curExistQty - $curScanQty; // 5 - 2
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
// $record->updated_at = now();
|
||||
$record->save();
|
||||
|
||||
@@ -2959,12 +2986,15 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'quantity' => $curScanQty,
|
||||
'created_at' => $createdDt,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
} elseif ($curExistQty == $curScanQty) { // 2 = 2
|
||||
// $record->delete();
|
||||
$record->serial_number = $serialNumber;
|
||||
$record->batch_number = $batchNumber;
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
// $record->updated_at = now();
|
||||
$record->save();
|
||||
|
||||
@@ -2975,6 +3005,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// 'quantity' => $curScanQty,
|
||||
// 'created_at' => $createdDt,
|
||||
// 'operator_id'=> $operatorName,
|
||||
// 'created_by' => $operatorName,
|
||||
// 'updated_by' => $operatorName,
|
||||
// ]);
|
||||
} else {
|
||||
Notification::make()
|
||||
@@ -2998,19 +3030,19 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
} else {
|
||||
if (str_contains($serialNumber, '|')) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned Material QR : '{$serialNumber}' already completed the scanning process..!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$itemCode = null;
|
||||
$this->currentItemCode = '';
|
||||
$batchNumber = null;
|
||||
$serNo = null;
|
||||
$serialNumber = null;
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate: Material QR')
|
||||
->body("Scanned 'Material QR' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
@@ -3030,6 +3062,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->batch_number = $batchNumber;
|
||||
// $record->updated_at = now();
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
$record->save();
|
||||
}
|
||||
|
||||
@@ -3055,7 +3088,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -3099,7 +3132,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -3359,7 +3392,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadMotorQr == $hasMotorQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Motor QR')
|
||||
->body("Scanned 'Motor' serial number already completed the scanning process.")
|
||||
->body("Scanned Motor Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3398,6 +3431,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
$record->save();
|
||||
|
||||
// Notification::make()
|
||||
@@ -3427,7 +3461,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -3476,7 +3510,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadPumpQr == $hasPumpQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump QR')
|
||||
->body("Scanned 'Pump' serial number already completed the scanning process.")
|
||||
->body("Scanned Pump Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3514,6 +3548,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
$record->save();
|
||||
|
||||
// Notification::make()
|
||||
@@ -3544,7 +3579,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
@@ -3595,7 +3630,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadCapacitorQr == '1' && $hasCapacitorQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Capacitor QR')
|
||||
->body("Scanned 'Capacitor' serial number already completed the scanning process.")
|
||||
->body("Scanned Capacitor Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3657,7 +3692,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
} elseif ($hadPumpSetQr == $hasPumpSetQr) {
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump Set QR')
|
||||
->body("Scanned 'Pump Set' serial number already completed the scanning process.")
|
||||
->body("Scanned Pump Set Serial Number : '{$serialNumber}' already completed the scanning process.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
@@ -3696,6 +3731,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
$record->save();
|
||||
|
||||
// Notification::make()
|
||||
@@ -3740,7 +3776,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// }
|
||||
|
||||
$filename = $invoiceNumber.'.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory.'/'.$filename;
|
||||
// $fullPath = null;
|
||||
|
||||
@@ -48,13 +48,13 @@ class ProcessOrderResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', null);
|
||||
@@ -65,6 +65,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('coilNumberError', null);
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('poPlantError') ? 'border-red-500' : '',
|
||||
@@ -74,7 +75,6 @@ class ProcessOrderResource extends Resource
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
@@ -83,6 +83,7 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('item_id', null);
|
||||
$set('item_description', null);
|
||||
@@ -92,13 +93,13 @@ class ProcessOrderResource extends Resource
|
||||
$set('received_quantity', null);
|
||||
$set('sfg_number', null);
|
||||
$set('machine_name', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'id')
|
||||
// ->required(),
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
@@ -108,6 +109,7 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
@@ -133,6 +135,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('item_description', null);
|
||||
$set('item_uom', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
|
||||
@@ -150,8 +153,10 @@ class ProcessOrderResource extends Resource
|
||||
$set('item_description', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('item_uom')
|
||||
->label('UOM')
|
||||
->readOnly()
|
||||
@@ -167,13 +172,10 @@ class ProcessOrderResource extends Resource
|
||||
$set('item_uom', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
// ->readOnly(true),
|
||||
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->reactive()
|
||||
@@ -188,6 +190,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('coilNumberError', null);
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, \Closure $fail) use ($get) {
|
||||
@@ -255,6 +258,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('coilNumberError', null);
|
||||
}
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('coilNumberError') ? 'border-red-500' : '',
|
||||
@@ -264,13 +268,27 @@ class ProcessOrderResource extends Resource
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('order_quantity')
|
||||
->label('Order Quantity')
|
||||
->required(),
|
||||
->default('1.000')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->default('0')
|
||||
->required(),
|
||||
->default('0.000')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('scrap_quantity')
|
||||
->label('Scrap Quantity'),
|
||||
->label('Scrap Quantity')
|
||||
->default('0.000')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->reactive()
|
||||
@@ -297,6 +315,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('sfgNumberError', null);
|
||||
}
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('sfgNumberError') ? 'border-red-500' : '',
|
||||
@@ -304,10 +323,27 @@ class ProcessOrderResource extends Resource
|
||||
->hint(fn ($get) => $get('sfgNumberError') ? $get('sfgNumberError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine ID'),
|
||||
Forms\Components\TextInput::make('rework_status')
|
||||
->label('Machine ID')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('rework_status')
|
||||
->label('Rework Status')
|
||||
->default(0),
|
||||
->default(0)
|
||||
->reactive()
|
||||
->options([0 => 'No', 1 => 'Yes'])
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// if ($get('id') && $get('rework_status') == 1) {
|
||||
// $set('rework_status', 1);
|
||||
// }
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->hasRole('Super Admin'); // || Filament::auth()->user()->can('update process order rework status')
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
@@ -327,6 +363,7 @@ class ProcessOrderResource extends Resource
|
||||
})
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
$uploaded = reset($uploadedFiles);
|
||||
@@ -415,8 +452,9 @@ class ProcessOrderResource extends Resource
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->action(function ($get) {
|
||||
->action(function ($get, callable $set) {
|
||||
$equipmentNumber = $get('process_order');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (! $equipmentNumber) {
|
||||
Notification::make()
|
||||
@@ -448,54 +486,16 @@ class ProcessOrderResource extends Resource
|
||||
|
||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
}),
|
||||
|
||||
// Action::make('removeAttachment')
|
||||
// ->label('Remove PDF')
|
||||
// ->action(function ($get) {
|
||||
// $equipmentNumber = $get('process_order');
|
||||
|
||||
// if (!$equipmentNumber) {
|
||||
// Notification::make()
|
||||
// ->title('No process order entered')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Get all files from uploads/temp
|
||||
// $files = Storage::disk('local')->files('uploads/ProcessOrder');
|
||||
|
||||
// $fileToDelete = null;
|
||||
// foreach ($files as $file) {
|
||||
// if (str_contains($file, $equipmentNumber)) {
|
||||
// $fileToDelete = $file;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!$fileToDelete) {
|
||||
// Notification::make()
|
||||
// ->title('PDF not found for this process order')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Delete the matched file
|
||||
// Storage::disk('local')->delete($fileToDelete);
|
||||
|
||||
// Notification::make()
|
||||
// ->title('PDF removed successfully')
|
||||
// ->body("File for process order {$equipmentNumber} has been deleted.")
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }),
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ class ProcessOrderResource extends Resource
|
||||
->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();
|
||||
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) {
|
||||
@@ -765,7 +765,7 @@ class ProcessOrderResource extends Resource
|
||||
->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();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
@@ -21,6 +22,7 @@ use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RequestCharacteristicResource extends Resource
|
||||
@@ -236,7 +238,7 @@ class RequestCharacteristicResource extends Resource
|
||||
})
|
||||
->required(),
|
||||
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
||||
Section::make('Request Characteristic')
|
||||
Section::make('Request Characteristic Field')
|
||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||
->reactive()
|
||||
->schema([
|
||||
@@ -244,24 +246,82 @@ class RequestCharacteristicResource extends Resource
|
||||
->label('Characteristic Name')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('characteristic_name', strtoupper($state));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
->rules([
|
||||
// function (callable $get) {
|
||||
// return Rule::unique('request_characteristics', 'characteristic_name')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->where('machine_id', $get('machine_id'))
|
||||
// ->where('machine_name', $get('machine_name'))
|
||||
// ->ignore($get('id'));
|
||||
// },
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$charVal = strtolower($value);
|
||||
$columns = Schema::getColumnListing('class_characteristics');
|
||||
|
||||
if (! in_array($charVal, $columns, true)) {
|
||||
$fail('Unknown characteristic field found.'); // .implode(', ', $columns).
|
||||
} else {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$jobNo = $get('aufnr');
|
||||
$updId = $get('id');
|
||||
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('characteristic_name', $value)->latest()->first();
|
||||
|
||||
if ($pendingExists) {
|
||||
if ($updId && $pendingExists->id == $updId) {
|
||||
return;
|
||||
}
|
||||
$app1 = $pendingExists->approver_status1 ?? null;
|
||||
$app2 = $pendingExists->approver_status2 ?? null;
|
||||
$app3 = $pendingExists->approver_status3 ?? null;
|
||||
|
||||
if ($app1 != 'Rejected' && $app2 != 'Rejected' && $app3 != 'Rejected' && $app1 != 'Approved' && $app2 != 'Approved' && $app3 != 'Approved') {
|
||||
$fail('Approval is already pending.');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
])
|
||||
->readOnly(fn ($get) => self::isFieldDisabled($get)), // disabled
|
||||
Forms\Components\TextInput::make('current_value')
|
||||
->label('Current Value')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled(get: $get)),
|
||||
->required(function (callable $get) {
|
||||
$updateVal = $get('update_value');
|
||||
if ($updateVal == null || $updateVal == '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->readOnly(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('update_value')
|
||||
->label('Update Value')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
->rules([
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$currVal = $get('current_value');
|
||||
|
||||
if ($value == $currVal) {
|
||||
$fail('Update value must be different from current value.');
|
||||
}
|
||||
};
|
||||
},
|
||||
])
|
||||
->readOnly(fn ($get) => self::isFieldDisabled($get)),
|
||||
])
|
||||
->collapsible()
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
@@ -798,6 +858,19 @@ class RequestCharacteristicResource extends Resource
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail_status')
|
||||
->label('Mail Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('trigger_at')
|
||||
->label('Trigger At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TestingTempResource\Pages;
|
||||
use App\Filament\Resources\TestingTempResource\RelationManagers;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TestingTemp;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Storage;
|
||||
|
||||
class TestingTempResource extends Resource
|
||||
{
|
||||
@@ -30,12 +30,77 @@ class TestingTempResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->searchable()
|
||||
// ->preload()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('ivPlantError', null);
|
||||
$set('name', null);
|
||||
$set('selected_file', null);
|
||||
$set('attachment', null);
|
||||
if (! $plantId) {
|
||||
$set('ivPlantError', 'Please select a plant first.');
|
||||
} else {
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
$directory = "uploads/temp/{$plantCode}";
|
||||
if (! Storage::disk('local')->exists($directory)) {
|
||||
Storage::disk('local')->makeDirectory($directory);
|
||||
}
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('ivPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('ivPlantError') ? $get('ivPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('File Name'),
|
||||
->label('File Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$fileNam = $get('name');
|
||||
// $set('selected_file', null);
|
||||
if (! $plantId) {
|
||||
$set('name', null);
|
||||
} elseif (! $fileNam) {
|
||||
$set('attachment', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('selected_file')
|
||||
->label('Select Uploaded File')
|
||||
->options(function () {
|
||||
return collect(Storage::disk('local')->files('uploads'))
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
return collect(Storage::disk('local')->files('uploads/temp'))
|
||||
->mapWithKeys(function ($file) {
|
||||
return [
|
||||
$file => basename($file), // value => label
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
return collect(Storage::disk('local')->files("uploads/temp/{$plantCode}"))
|
||||
->mapWithKeys(function ($file) {
|
||||
return [
|
||||
$file => basename($file), // value => label
|
||||
@@ -43,101 +108,157 @@ class TestingTempResource extends Resource
|
||||
})
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $plantId = $get('plant_id');
|
||||
// if (! $plantId) {
|
||||
// $set('selected_file', null);
|
||||
// }
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
// ->disabled(fn (callable $get) => ! $get('plant_id')),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('Upload')
|
||||
->label('Choose File to Upload')
|
||||
// ->acceptedFileTypes(['application/pdf'])
|
||||
->storeFiles(false)
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->directory(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
return "uploads/temp/{$plantCode}";
|
||||
})
|
||||
->preserveFilenames()
|
||||
->maxSize(20480)
|
||||
->reactive(),
|
||||
->maxSize(20480) // 20 MB
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('attachment', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(function (callable $get) {
|
||||
$selFile = $get('selected_file');
|
||||
$selAtt = $get('attachment');
|
||||
if (! $selAtt && ! $selFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->reactive()
|
||||
->disabled(fn (callable $get) => ! $get('plant_id') || ! $get('name')),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('File Upload')
|
||||
->color('success')
|
||||
->action(function ($get) {
|
||||
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
|
||||
$baseName = $get('name');
|
||||
$extension = $uploaded->getClientOriginalExtension();
|
||||
|
||||
$finalFileName = $baseName . '.' . $extension;
|
||||
|
||||
$uploaded->storeAs(
|
||||
'uploads',
|
||||
$finalFileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title("File uploaded successfully: {$finalFileName}")
|
||||
->success()
|
||||
->send();
|
||||
->label('Upload File')
|
||||
->color('success')
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('attachment');
|
||||
if ($filePath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
return false;
|
||||
})
|
||||
->action(function (callable $get, callable $set) {
|
||||
|
||||
// Action::make('downloadAttachment')
|
||||
// ->label('Download File')
|
||||
// ->action(function ($get) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
// $fileName = basename($get('selected_file'));
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
|
||||
// //dd($fileName);
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
// // if (!$fileName) {
|
||||
// // Notification::make()
|
||||
// // ->title('Enter file name to download')
|
||||
// // ->danger()
|
||||
// // ->send();
|
||||
// // return;
|
||||
// // }
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
|
||||
// $files = Storage::disk('local')->files('uploads');
|
||||
$baseName = $get('name');
|
||||
$extension = $uploaded->getClientOriginalExtension();
|
||||
|
||||
// foreach ($files as $file) {
|
||||
$finalFileName = $baseName.'.'.$extension;
|
||||
|
||||
// if (pathinfo($file, PATHINFO_FILENAME) === $fileName) {
|
||||
// dd($fileName);
|
||||
// Notification::make()
|
||||
// ->title("File downloaded successfully")
|
||||
// ->success()
|
||||
// ->send();
|
||||
$plantId = $get('plant_id');
|
||||
$plantCode = Plant::find($plantId)?->code ?? null;
|
||||
|
||||
// return response()->download(
|
||||
// Storage::disk('local')->path($file)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
if (! $plantCode) {
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (! $baseName) {
|
||||
Notification::make()
|
||||
->title('Please enter a file name first.')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
// return "uploads/temp/{$plantCode}";
|
||||
|
||||
$uploaded->storeAs(
|
||||
"uploads/temp/{$plantCode}",
|
||||
$finalFileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
Notification::make()
|
||||
->title("File uploaded successfully: {$finalFileName}")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (! $get('plant_id')) {
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->warning()
|
||||
->send();
|
||||
} elseif (! $get('name')) {
|
||||
Notification::make()
|
||||
->title('Please enter a file name first.')
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
// // Notification::make()
|
||||
// // ->title('File not found')
|
||||
// // ->danger()
|
||||
// // ->send();
|
||||
// }),
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download File')
|
||||
->action(function ($get) {
|
||||
->color('warning')
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('selected_file');
|
||||
if ($filePath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->action(function (callable $get, callable $set) {
|
||||
$filePath = $get('selected_file'); // uploads/filename.pdf
|
||||
|
||||
if (!$filePath || !Storage::disk('local')->exists($filePath)) {
|
||||
// if (! $get('plant_id')) {
|
||||
// Notification::make()
|
||||
// ->title('Please select a plant first.')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// } else
|
||||
if (! $filePath) {
|
||||
Notification::make()
|
||||
->title('Please select a file first.')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (! Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('File not found')
|
||||
->danger()
|
||||
@@ -146,6 +267,8 @@ class TestingTempResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
Notification::make()
|
||||
->title('File downloaded successfully')
|
||||
->success()
|
||||
@@ -156,38 +279,65 @@ class TestingTempResource extends Resource
|
||||
);
|
||||
}),
|
||||
|
||||
Action::make('deleteAttachment')
|
||||
Action::make('deleteAttachment')
|
||||
->label('Delete File')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->action(function ($get) {
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('selected_file');
|
||||
|
||||
if ($filePath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
->action(function ($get, $set) {
|
||||
|
||||
$filePath = $get('selected_file'); // uploads/filename.pdf
|
||||
|
||||
if (!$filePath || !Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('File not found')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('local')->delete($filePath);
|
||||
// if (! $get('plant_id')) {
|
||||
// Notification::make()
|
||||
// ->title('Please select a plant first.')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// } else
|
||||
if (! $filePath) {
|
||||
Notification::make()
|
||||
->title('File deleted successfully')
|
||||
->success()
|
||||
->title('Please select a file first.')
|
||||
->warning()
|
||||
->send();
|
||||
}),
|
||||
|
||||
]),
|
||||
return;
|
||||
} elseif (! Storage::disk('local')->exists($filePath)) {
|
||||
Notification::make()
|
||||
->title('File not found')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('local')->delete($filePath);
|
||||
|
||||
$set('selected_file', null);
|
||||
|
||||
Notification::make()
|
||||
->title('File deleted successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->reactive(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\UserExporter;
|
||||
use App\Filament\Imports\UserImporter;
|
||||
use App\Filament\Resources\UserResource\Pages;
|
||||
use App\Filament\Resources\UserResource\RelationManagers;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -36,16 +36,21 @@ class UserResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->nullable()
|
||||
->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(User::latest()->first())->plant_id;
|
||||
}),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->autofocus()
|
||||
//->reactive()
|
||||
// ->reactive()
|
||||
->live(debounce: 600)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('email', $state . '@cripumps.com');
|
||||
$set('email', $state.'@cripumps.com');
|
||||
})
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('email')
|
||||
@@ -58,7 +63,7 @@ class UserResource extends Resource
|
||||
// ->ignore($get('id')); // Ignore current record during updates
|
||||
// })
|
||||
->reactive()
|
||||
//->prefix(fn ($get) => $get('name') ?? null)
|
||||
// ->prefix(fn ($get) => $get('name') ?? null)
|
||||
// ->suffix('@cripumps.com')
|
||||
->maxLength(255),
|
||||
Forms\Components\DateTimePicker::make('email_verified_at'),
|
||||
@@ -73,7 +78,7 @@ class UserResource extends Resource
|
||||
// ->relationship('roles', 'name'),
|
||||
Forms\Components\Select::make('roles')
|
||||
->relationship('roles', 'name')
|
||||
//->relationship(name: 'roles', titleAttribute: 'name')
|
||||
// ->relationship(name: 'roles', titleAttribute: 'name')
|
||||
// ->saveRelationshipsUsing(function (Model $record, $state) {
|
||||
// $record->roles()->syncWithPivotValues($state, [config('permission.column_names.team_foreign_key') => getPermissionsTeamId()]);
|
||||
// })
|
||||
@@ -101,6 +106,7 @@ class UserResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
@@ -122,7 +128,8 @@ class UserResource extends Resource
|
||||
->label('Email Verified At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('roles.name')
|
||||
->label('Roles')
|
||||
->alignCenter()
|
||||
@@ -165,14 +172,14 @@ class UserResource extends Resource
|
||||
->label('Import Users')
|
||||
->color('warning')
|
||||
->importer(UserImporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import user');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Users')
|
||||
->color('warning')
|
||||
->exporter(UserExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export user');
|
||||
}),
|
||||
]);
|
||||
|
||||
188
app/Filament/Resources/VehicleEntryResource.php
Normal file
188
app/Filament/Resources/VehicleEntryResource.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
use App\Filament\Resources\VehicleEntryResource\RelationManagers;
|
||||
use App\Models\Plant;
|
||||
use App\Models\VehicleEntry;
|
||||
use Carbon\Carbon;
|
||||
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;
|
||||
|
||||
class VehicleEntryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = VehicleEntry::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('entry_time')
|
||||
->label('Entry Time')
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
$exitTime = $get('exit_time');
|
||||
|
||||
if ($state && $exitTime) {
|
||||
$duration = Carbon::parse($exitTime)
|
||||
->diff(Carbon::parse($state))
|
||||
->format('%H:%I:%S');
|
||||
|
||||
$set('duration', $duration);
|
||||
}
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('exit_time')
|
||||
->label('Exit Time')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
$entryTime = $get('entry_time');
|
||||
|
||||
if ($state && $entryTime) {
|
||||
$duration = Carbon::parse($state)
|
||||
->diff(Carbon::parse($entryTime))
|
||||
->format('%H:%I:%S');
|
||||
|
||||
$set('duration', $duration);
|
||||
}
|
||||
}),
|
||||
Forms\Components\TextInput::make('duration')
|
||||
->label('Duration')
|
||||
->readOnly()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('type')
|
||||
->label('Type')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By'),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('entry_time')
|
||||
->label('Entry Time')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('exit_time')
|
||||
->label('Exit Time')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('duration')
|
||||
->label('Duration')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Type')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListVehicleEntries::route('/'),
|
||||
'create' => Pages\CreateVehicleEntry::route('/create'),
|
||||
'view' => Pages\ViewVehicleEntry::route('/{record}'),
|
||||
'edit' => Pages\EditVehicleEntry::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateVehicleEntry extends CreateRecord
|
||||
{
|
||||
protected static string $resource = VehicleEntryResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditVehicleEntry extends EditRecord
|
||||
{
|
||||
protected static string $resource = VehicleEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListVehicleEntries extends ListRecords
|
||||
{
|
||||
protected static string $resource = VehicleEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewVehicleEntry extends ViewRecord
|
||||
{
|
||||
protected static string $resource = VehicleEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,17 +16,6 @@ class CharacteristicApprovalController extends Controller
|
||||
return $this->updateStatus($request, 'Approved');
|
||||
}
|
||||
|
||||
/**
|
||||
* HOLD
|
||||
*/
|
||||
// public function hold(Request $request)
|
||||
// {
|
||||
// return $this->updateStatus($request, 'Hold');
|
||||
// }
|
||||
|
||||
/**
|
||||
* REJECT
|
||||
*/
|
||||
public function reject(Request $request)
|
||||
{
|
||||
return $this->updateStatus($request, 'Rejected');
|
||||
@@ -35,7 +24,6 @@ class CharacteristicApprovalController extends Controller
|
||||
public function holdForm(Request $request)
|
||||
{
|
||||
$id = $request->query('id');
|
||||
// $level = $request->query('level');
|
||||
|
||||
$level = (int) $request->query('level');
|
||||
|
||||
@@ -48,14 +36,44 @@ class CharacteristicApprovalController extends Controller
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$levels = [
|
||||
1 => 'approver_status1',
|
||||
2 => 'approver_status2',
|
||||
3 => 'approver_status3',
|
||||
];
|
||||
|
||||
$currentStatus = $record->$statusColumn;
|
||||
|
||||
$currentStatusColumn = $levels[$level];
|
||||
|
||||
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $currentStatus,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'Already processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$allowedMailStatusByLevel = [
|
||||
1 => 'Sent',
|
||||
2 => 'Sent-Mail2',
|
||||
3 => 'Sent-Mail3',
|
||||
];
|
||||
|
||||
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'You are not authorized to act at this level',
|
||||
]);
|
||||
}
|
||||
|
||||
return view('approval.hold-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
@@ -74,6 +92,14 @@ class CharacteristicApprovalController extends Controller
|
||||
default => abort(403, 'Invalid approver level'),
|
||||
};
|
||||
|
||||
$levels = [
|
||||
1 => 'approver_status1',
|
||||
2 => 'approver_status2',
|
||||
3 => 'approver_status3',
|
||||
];
|
||||
|
||||
$currentStatusColumn = $levels[$level];
|
||||
|
||||
$currentStatus = $record->$statusColumn;
|
||||
|
||||
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||
@@ -82,6 +108,28 @@ class CharacteristicApprovalController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'Already processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$allowedMailStatusByLevel = [
|
||||
1 => 'Sent',
|
||||
2 => 'Sent-Mail2',
|
||||
3 => 'Sent-Mail3',
|
||||
];
|
||||
|
||||
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'You are not authorized to act at this level',
|
||||
]);
|
||||
}
|
||||
|
||||
return view('approval.reject-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
@@ -107,109 +155,6 @@ class CharacteristicApprovalController extends Controller
|
||||
return $this->updateStatus($request, 'Rejected', false);
|
||||
}
|
||||
|
||||
// protected function updateStatus(Request $request, string $status)
|
||||
// {
|
||||
// $requestId = $request->query('id');
|
||||
// $level = (int) $request->query('level');
|
||||
|
||||
// $record = RequestCharacteristic::findOrFail($requestId);
|
||||
|
||||
// $column = match ($level) {
|
||||
// 1 => 'approver_status1',
|
||||
// 2 => 'approver_status2',
|
||||
// 3 => 'approver_status3',
|
||||
// default => abort(403, 'Invalid approver level'),
|
||||
// };
|
||||
|
||||
// $pendingRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
// ->where('machine_id', $record->machine_id)
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->whereNull('approver_status1')
|
||||
// ->whereNull('approver_status2')
|
||||
// ->whereNull('approver_status3')
|
||||
// ->get();
|
||||
|
||||
// if ($pendingRecords->isEmpty()) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => 'No pending records for this group'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($pendingRecords->first()->$column != null) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => $pendingRecords->first()->$column
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // Update all records in the group for this approver level
|
||||
// foreach ($pendingRecords as $rec) {
|
||||
// $rec->update([$column => $status]);
|
||||
// }
|
||||
|
||||
// return match ($status) {
|
||||
// 'Approved' => view('approval.success'),
|
||||
// 'Hold' => view('approval.hold-success'),
|
||||
// 'Rejected' => view('approval.reject-success'),
|
||||
// default => abort(500),
|
||||
// };
|
||||
// }
|
||||
|
||||
// protected function updateStatus(Request $request, string $status)
|
||||
// {
|
||||
// $requestId = $request->query('id');
|
||||
// $level = (int) $request->query('level');
|
||||
|
||||
// $record = RequestCharacteristic::findOrFail($requestId);
|
||||
|
||||
// [$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||
// 1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||
// 2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||
// 3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||
// default => abort(403, 'Invalid approver level'),
|
||||
// };
|
||||
|
||||
// $pendingRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
|
||||
// ->where('machine_id', $record->machine_id)
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->where('work_flow_id', $record->work_flow_id)
|
||||
// ->whereNull('approver_status1')
|
||||
// ->whereNull('approver_status2')
|
||||
// ->whereNull('approver_status3')
|
||||
// ->get();
|
||||
|
||||
// if ($pendingRecords->isEmpty()) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => 'No pending records for this group',
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if ($pendingRecords->first()->$statusColumn !== null) {
|
||||
// return view('approval.already-processed', [
|
||||
// 'status' => $pendingRecords->first()->$statusColumn,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// $updateData = [
|
||||
// $statusColumn => $status,
|
||||
// $remarkColumn => $request->input('remark')
|
||||
// ];
|
||||
|
||||
// if ($status == 'Approved') {
|
||||
// $updateData[$approvedAtColumn] = Carbon::now();
|
||||
// }
|
||||
|
||||
// foreach ($pendingRecords as $rec) {
|
||||
// $rec->update($updateData);
|
||||
// }
|
||||
|
||||
// return match ($status) {
|
||||
// 'Approved' => view('approval.success'),
|
||||
// 'Hold' => view('approval.hold-success'),
|
||||
// 'Rejected' => view('approval.reject-success'),
|
||||
// default => abort(500),
|
||||
// };
|
||||
// }
|
||||
|
||||
protected function updateStatus(Request $request, string $status, bool $returnView = true)
|
||||
{
|
||||
$requestId = $request->input('id');
|
||||
@@ -259,14 +204,36 @@ class CharacteristicApprovalController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$allowedMailStatusByLevel = [
|
||||
1 => 'Sent',
|
||||
2 => 'Sent-Mail2',
|
||||
3 => 'Sent-Mail3',
|
||||
];
|
||||
|
||||
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
if ($returnView) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => 'You are not authorized to act at this level',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Invalid approval level for current mail status',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
$statusColumn => $status,
|
||||
$remarkColumn => $request->input('remark'),
|
||||
$approvedAtColumn => Carbon::now(),
|
||||
];
|
||||
|
||||
if ($status == 'Approved') {
|
||||
$updateData[$approvedAtColumn] = Carbon::now();
|
||||
}
|
||||
// if ($status == 'Approved') {
|
||||
// $updateData[$approvedAtColumn] = Carbon::now();
|
||||
// }
|
||||
|
||||
foreach ($pendingRecords as $rec) {
|
||||
$rec->update($updateData);
|
||||
|
||||
@@ -2875,7 +2875,7 @@ class CharacteristicsController extends Controller
|
||||
// $pendingCharacteristics = [];
|
||||
|
||||
// foreach ($characteristics as $char) {
|
||||
// $charName = strtolower($char['characteristic_name']) ?? null;
|
||||
// $charName = strtoupper($char['characteristic_name']) ?? null;
|
||||
// $pendingExists = RequestCharacteristic::where('aufnr', $jobNo)
|
||||
// ->where('characteristic_name', $charName)
|
||||
// ->latest()
|
||||
@@ -2948,7 +2948,7 @@ class CharacteristicsController extends Controller
|
||||
// 'item_id' => $ItemId,
|
||||
// 'characteristic_approver_master_id' => $charId,
|
||||
// 'aufnr' => $jobNo,
|
||||
// 'characteristic_name' => strtolower($char['characteristic_name']),
|
||||
// 'characteristic_name' => strtoupper($char['characteristic_name']),//strtolower
|
||||
// 'current_value' => $char['current_value'],
|
||||
// 'update_value' => $char['update_value'],
|
||||
// 'created_by' => $userName,
|
||||
@@ -3037,7 +3037,7 @@ class CharacteristicsController extends Controller
|
||||
}
|
||||
|
||||
if ($charField == null || $charField == '') {
|
||||
$charField = 'nil';
|
||||
$charField = 'NIL';
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
@@ -3132,6 +3132,24 @@ class CharacteristicsController extends Controller
|
||||
|
||||
$MachineId = $machineAgaPlant->id;
|
||||
|
||||
$iCode = Item::where('code', $itemCode)->first();
|
||||
if (! $iCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$iCodeAgaPlant = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
if (! $iCodeAgaPlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' not found for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$ItemId = $iCodeAgaPlant->id;
|
||||
|
||||
$pCode = CharacteristicApproverMaster::where('plant_id', $plantId)->first();
|
||||
if (! $pCode) {
|
||||
return response()->json([
|
||||
@@ -3172,46 +3190,76 @@ class CharacteristicsController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$mNameAgaWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->first();
|
||||
if (! $mNameAgaWorkCenter) {
|
||||
$cField = CharacteristicApproverMaster::where('characteristic_field', $charField)->first();
|
||||
if (! $cField) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Machine name '{$machineName}' not found for the work center '{$workCenter}' in characteristic approver master!",
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$mNameAgaWorkCenterForPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
||||
if (! $mNameAgaWorkCenterForPlant) {
|
||||
$cFieldAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('plant_id', $plantId)->first();
|
||||
if (! $cFieldAgaPlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$mNameAndWorkCenter = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->first();
|
||||
if (! $mNameAndWorkCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$mNameAndWorkCenterAgaPlant = CharacteristicApproverMaster::where('machine_name', $machineName)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
||||
if (! $mNameAndWorkCenterAgaPlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Machine name '{$machineName}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$charId = $mNameAgaWorkCenterForPlant->id;
|
||||
|
||||
$iCode = Item::where('code', $itemCode)->first();
|
||||
if (! $iCode) {
|
||||
$cFieldAndWorkCent = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->first();
|
||||
if (! $cFieldAndWorkCent) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' not found!",
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found for the work center '{$workCenter}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$iCodeAgaPlant = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
if (! $iCodeAgaPlant) {
|
||||
$cFieldAndWorkCentAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->where('plant_id', $plantId)->first();
|
||||
if (! $cFieldAndWorkCentAgaPlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' not found for the plant code '{$plantCode}'!",
|
||||
'status_description' => "Master characteristic field value '{$charField}' and work center '{$workCenter}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$ItemId = $iCodeAgaPlant->id;
|
||||
$cFieldAndMach = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_name', $machineName)->first();
|
||||
if (! $cFieldAndMach) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found for the machine name '{$machineName}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$cFieldAndWorkCentAndMachAgaPlant = CharacteristicApproverMaster::where('characteristic_field', $charField)->where('machine_id', $MachineId)->where('machine_name', $machineName)->where('plant_id', $plantId)->first();
|
||||
if (! $cFieldAndWorkCentAndMachAgaPlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Master characteristic field value '{$charField}', work center '{$workCenter}', and machine name '{$machineName}' not found for the plant code '{$plantCode}' in characteristic approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$charId = $cFieldAndWorkCentAndMachAgaPlant->id;
|
||||
|
||||
$pendingCharacteristics = [];
|
||||
|
||||
foreach ($characteristics as $char) {
|
||||
$charName = strtolower($char['characteristic_name']) ?? null;
|
||||
$charName = strtoupper($char['characteristic_name']) ?? null;
|
||||
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('characteristic_name', $charName)->latest()->first();
|
||||
|
||||
if ($pendingExists) {
|
||||
@@ -3292,7 +3340,7 @@ class CharacteristicsController extends Controller
|
||||
'item_id' => $ItemId,
|
||||
'characteristic_approver_master_id' => $charId,
|
||||
'aufnr' => $jobNo,
|
||||
'characteristic_name' => strtolower($char['characteristic_name']),
|
||||
'characteristic_name' => strtoupper($char['characteristic_name']), // strtolower
|
||||
'current_value' => $char['current_value'],
|
||||
'update_value' => $char['update_value'],
|
||||
'created_by' => $userName,
|
||||
@@ -3720,6 +3768,8 @@ class CharacteristicsController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$workFlowId = strtoupper($workFlowId);
|
||||
|
||||
if (! $workFlowId) {
|
||||
|
||||
$records = RequestCharacteristic::with('approver')->where([
|
||||
@@ -3782,14 +3832,14 @@ class CharacteristicsController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (! str_ends_with(strtolower($filename), '.pdf')) {
|
||||
$filename .= '.pdf';
|
||||
}
|
||||
// if (! str_ends_with(strtolower($filename), '.pdf')) {
|
||||
// $filename .= '.pdf';
|
||||
// }
|
||||
|
||||
if (! Storage::disk('local')->exists($filePath)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pdf File not found for the provided work flow id number!',
|
||||
'status_description' => "Pdf File not found for the provided 'Work Flow ID' number!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
188
app/Http/Controllers/VehicleController.php
Normal file
188
app/Http/Controllers/VehicleController.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\VehicleEntry;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class VehicleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function storeVehicleEntry(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response('ERROR: Unauthorized', 403)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
|
||||
if(!$plantCode){
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (!ctype_digit((string) $plantCode)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => "plant code must be $plantCode a numeric value",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
$plantCod = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if(!$plantCod){
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Plant code $plantCode not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantId = $plantCod->id;
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$vehicleNo = $data['vehicle_number'] ?? '';
|
||||
$entryTimeRaw = $data['entry_time'] ?? '';
|
||||
$exitTimeRaw = $data['exit_time'] ?? '';
|
||||
$duration = $data['duration'] ?? '';
|
||||
$type = $data['type'] ?? '';
|
||||
|
||||
if(!$vehicleNo)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Vehicle number cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if (strlen($vehicleNo) < 8) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "vehicle number '$vehicleNo' must be at least 8 characters long",
|
||||
], 404);
|
||||
}
|
||||
else if(!$entryTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Entry time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$exitTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Exit time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$duration)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Duration cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$type)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "type cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
|
||||
VehicleEntry::insert([
|
||||
'plant_id' => $plantId,
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime,
|
||||
'duration' => $duration,
|
||||
'type' => $type,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'status_description' => 'Vehicle entry inserted successfully'
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,25 @@ use App\Models\InvoiceValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Str;
|
||||
|
||||
class InvoiceDataTable extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
protected $paginationTheme = 'tailwind';
|
||||
|
||||
public $invoiceData = [];
|
||||
|
||||
// public $invoiceRecords;
|
||||
|
||||
public $plantId = 0;
|
||||
|
||||
public $package = [];
|
||||
|
||||
public $packageCount = 0;
|
||||
|
||||
public string $invoiceNumber = '';
|
||||
@@ -47,7 +57,7 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public $panel_box_supplier;
|
||||
|
||||
public $panel_box_item_code;
|
||||
public $panel_box_code;
|
||||
|
||||
public $panel_box_serial_number;
|
||||
|
||||
@@ -176,10 +186,193 @@ class InvoiceDataTable extends Component
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
// {
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->plantId = $plantId;
|
||||
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
|
||||
// $this->resetPage();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// // IMPORTANT: keep scanned rows, otherwise count will not update
|
||||
// $this->invoiceRecords = InvoiceValidation::with('stickerMasterRelation')
|
||||
// ->where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->get();
|
||||
|
||||
// foreach ($this->invoiceRecords as &$row) {
|
||||
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// // Get item code
|
||||
// $row['code'] = StickerMaster::with('item')
|
||||
// ->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
|
||||
// $curStick = StickerMaster::find($row['sticker_master_id']);
|
||||
|
||||
// if ($curStick) {
|
||||
|
||||
// /** ---------------- REQUIRED STICKERS ---------------- */
|
||||
|
||||
// // PANEL BOX (capacitor)
|
||||
// if (!empty($curStick->panel_box_code)) {
|
||||
// $stickCount++;
|
||||
|
||||
// // Panel box scan = capacitor_scanned_status
|
||||
// if ($row['capacitor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Tube stickers
|
||||
// if (
|
||||
// $curStick->tube_sticker_motor == 1 ||
|
||||
// $curStick->tube_sticker_pump == 1 ||
|
||||
// $curStick->tube_sticker_pumpset == 1
|
||||
// ) {
|
||||
// if ($curStick->tube_sticker_motor == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (
|
||||
// $curStick->tube_sticker_pump == 1 ||
|
||||
// ($curStick->tube_sticker_pumpset != 1 &&
|
||||
// $curStick->tube_sticker_pump != 1 &&
|
||||
// $curStick->pack_slip_pump == 1)
|
||||
// ) {
|
||||
// $stickCount++;
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->tube_sticker_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Pack slips (only if no tube stickers)
|
||||
// elseif (
|
||||
// $curStick->pack_slip_motor == 1 ||
|
||||
// $curStick->pack_slip_pump == 1 ||
|
||||
// $curStick->pack_slip_pumpset == 1
|
||||
// ) {
|
||||
// if ($curStick->pack_slip_motor == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['motor_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->pack_slip_pump == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['pump_scanned_status'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($curStick->pack_slip_pumpset == 1) {
|
||||
// $stickCount++;
|
||||
// if ($row['scanned_status_set'] == 1) {
|
||||
// $scannedCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // SAFETY: never go negative
|
||||
// $this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
// }
|
||||
|
||||
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
|
||||
// }
|
||||
|
||||
// #[On('refreshInvoiceData')]
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
// {
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->plantId = $plantId;
|
||||
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
|
||||
// $this->resetPage();
|
||||
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// $records = InvoiceValidation::with('stickerMasterRelation')
|
||||
// ->where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->get();
|
||||
|
||||
// $this->packageCount = $records->sum(function ($record) {
|
||||
// $sm = $record->stickerMasterRelation;
|
||||
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// if ($sm) {
|
||||
|
||||
// if (strlen($sm->panel_box_code) > 0) $stickCount++;
|
||||
|
||||
// // if (!empty($sm->panel_box_code)) {
|
||||
// // $stickCount++;
|
||||
// // if (!empty($record->panel_box_serial_number)) {
|
||||
// // $scannedCount++;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // Tube stickers
|
||||
// if ($sm->tube_sticker_motor || $sm->tube_sticker_pump || $sm->tube_sticker_pumpset) {
|
||||
// $stickCount += $sm->tube_sticker_motor ? 1 : 0;
|
||||
// $stickCount += ($sm->tube_sticker_pump || ($sm->tube_sticker_pumpset != 1 && !$sm->tube_sticker_pump && $sm->pack_slip_pump)) ? 1 : 0;
|
||||
// $stickCount += $sm->tube_sticker_pumpset ? 1 : 0;
|
||||
// }
|
||||
// // Pack slips (only if tube stickers not applied)
|
||||
// elseif ($sm->pack_slip_motor || $sm->pack_slip_pump || $sm->pack_slip_pumpset) {
|
||||
// $stickCount += $sm->pack_slip_motor ? 1 : 0;
|
||||
// $stickCount += $sm->pack_slip_pump ? 1 : 0;
|
||||
// $stickCount += $sm->pack_slip_pumpset ? 1 : 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Already scanned
|
||||
// $scannedCount += $record->motor_scanned_status == 1 ? 1 : 0;
|
||||
// $scannedCount += $record->pump_scanned_status == 1 ? 1 : 0;
|
||||
// $scannedCount += $record->capacitor_scanned_status == 1 ? 1 : 0;
|
||||
// $scannedCount += $record->scanned_status_set == 1 ? 1 : 0;
|
||||
|
||||
// return max($stickCount - $scannedCount, 0);
|
||||
// });
|
||||
|
||||
// $this->dispatch($onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number');
|
||||
// }
|
||||
|
||||
public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->onCapFocus = $onCapFocus;
|
||||
@@ -187,78 +380,189 @@ class InvoiceDataTable extends Component
|
||||
$this->hasSearched = true;
|
||||
$this->materialInvoice = false;
|
||||
|
||||
// Eager load stickerMasterRelation and item
|
||||
$invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->get();
|
||||
|
||||
$this->invoiceData = [];
|
||||
$this->resetPage();
|
||||
$this->packageCount = 0;
|
||||
|
||||
foreach ($invoiceRecords as $record) {
|
||||
$records = InvoiceValidation::with('stickerMasterRelation')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->get();
|
||||
|
||||
$this->packageCount = $records->sum(function ($record) {
|
||||
|
||||
$sm = $record->stickerMasterRelation;
|
||||
|
||||
// Compute code
|
||||
$rowCode = $sm?->item?->code ?? 'N/A';
|
||||
if (! $sm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$stickCount = 0;
|
||||
$scannedCount = 0;
|
||||
|
||||
if ($sm) {
|
||||
// Panel box code
|
||||
if (Str::length($sm->panel_box_code) > 0) {
|
||||
if (! empty($sm->panel_box_code)) {
|
||||
$stickCount++;
|
||||
|
||||
if ($record->capacitor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
|
||||
if ($sm->tube_sticker_motor == 1) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Tube stickers logic
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
if (
|
||||
$sm->tube_sticker_pump == 1 ||
|
||||
($sm->tube_sticker_pumpset != 1 &&
|
||||
$sm->tube_sticker_pump != 1 &&
|
||||
$sm->pack_slip_pump == 1)
|
||||
) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
// Pack slip logic (only if tube sticker block didn't apply)
|
||||
elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
|
||||
if ($sm->tube_sticker_pumpset == 1) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
} elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pump == 1) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pumpset == 1) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Count already scanned
|
||||
$scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
$scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
return max($stickCount - $scannedCount, 0);
|
||||
});
|
||||
|
||||
// Increment packageCount
|
||||
$this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
$this->invoiceData[] = [
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'serial_number' => $record->serial_number,
|
||||
'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
'scanned_status' => $record->scanned_status ?? '',
|
||||
'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
'created_at' => $record->created_at,
|
||||
'operator_id' => $record->operator_id,
|
||||
'code' => $rowCode,
|
||||
'stickCount' => $stickCount,
|
||||
];
|
||||
}
|
||||
|
||||
if ($onCapFocus) {
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
} else {
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
$this->dispatch(
|
||||
$onCapFocus ? 'focus-capacitor-input' : 'focus-serial-number'
|
||||
);
|
||||
}
|
||||
|
||||
public function getInvoiceRecordsProperty()
|
||||
{
|
||||
return InvoiceValidation::with('stickerMasterRelation.item')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '');
|
||||
})
|
||||
// ->when($this->hasSearched, function ($query) {
|
||||
// $query->where('invoice_number', $this->invoiceNumber)
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->where('scanned_status', '=', '');
|
||||
// })
|
||||
->paginate(6);
|
||||
}
|
||||
|
||||
// public function loadData($invoiceNumber, $plantId, $onCapFocus = false)
|
||||
// {
|
||||
// $this->plantId = $plantId;
|
||||
// $this->invoiceNumber = $invoiceNumber;
|
||||
// $this->completedInvoice = false;
|
||||
// $this->isSerial = true;
|
||||
// $this->onCapFocus = $onCapFocus;
|
||||
// $this->emptyInvoice = false;
|
||||
// $this->hasSearched = true;
|
||||
// $this->materialInvoice = false;
|
||||
|
||||
// // Eager load stickerMasterRelation and item
|
||||
// $invoiceRecords = InvoiceValidation::with('stickerMasterRelation.item')
|
||||
// ->where('invoice_number', $invoiceNumber)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('scanned_status')
|
||||
// ->get();
|
||||
|
||||
// $this->invoiceData = [];
|
||||
// $this->packageCount = 0;
|
||||
|
||||
// foreach ($invoiceRecords as $record) {
|
||||
// $sm = $record->stickerMasterRelation;
|
||||
|
||||
// // Compute code
|
||||
// $rowCode = $sm?->item?->code ?? 'N/A';
|
||||
|
||||
// $stickCount = 0;
|
||||
// $scannedCount = 0;
|
||||
|
||||
// if ($sm) {
|
||||
// // Panel box code
|
||||
// if (Str::length($sm->panel_box_code) > 0) {
|
||||
// $stickCount++;
|
||||
// }
|
||||
// // Tube stickers logic
|
||||
// if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
// if ($sm->tube_sticker_motor == 1) $stickCount++;
|
||||
// if ($sm->tube_sticker_pump == 1 || ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)) $stickCount++;
|
||||
// if ($sm->tube_sticker_pumpset == 1) $stickCount++;
|
||||
// }
|
||||
// // Pack slip logic (only if tube sticker block didn't apply)
|
||||
// elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
// if ($sm->pack_slip_motor == 1) $stickCount++;
|
||||
// if ($sm->pack_slip_pump == 1) $stickCount++;
|
||||
// if ($sm->pack_slip_pumpset == 1) $stickCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Count already scanned
|
||||
// $scannedCount += ($record->motor_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->pump_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->capacitor_scanned_status == 1) ? 1 : 0;
|
||||
// $scannedCount += ($record->scanned_status_set == 1) ? 1 : 0;
|
||||
|
||||
// // Increment packageCount
|
||||
// $this->packageCount += max($stickCount - $scannedCount, 0);
|
||||
|
||||
// $this->invoiceData[] = [
|
||||
// 'sticker_master_id' => $record->sticker_master_id,
|
||||
// 'serial_number' => $record->serial_number,
|
||||
// 'motor_scanned_status' => $record->motor_scanned_status ?? '',
|
||||
// 'pump_scanned_status' => $record->pump_scanned_status ?? '',
|
||||
// 'capacitor_scanned_status' => $record->capacitor_scanned_status ?? '',
|
||||
// 'scanned_status_set' => $record->scanned_status_set ?? '',
|
||||
// 'scanned_status' => $record->scanned_status ?? '',
|
||||
// 'panel_box_supplier' => $record->panel_box_supplier ?? '',
|
||||
// 'panel_box_serial_number' => $record->panel_box_serial_number ?? '',
|
||||
// 'created_at' => $record->created_at,
|
||||
// 'operator_id' => $record->operator_id,
|
||||
// 'code' => $rowCode,
|
||||
// 'stickCount' => $stickCount,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// if ($onCapFocus) {
|
||||
// $this->dispatch('focus-capacitor-input');
|
||||
// } else {
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
// }
|
||||
|
||||
public function loadMaterialData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
@@ -323,10 +627,168 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public function cancelCapacitorInput()
|
||||
{
|
||||
$this->capacitorInput = null;
|
||||
$this->showCapacitorInput = false;
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
// public function processCapacitorInput()
|
||||
// {
|
||||
// $user = Filament::auth()->user();
|
||||
// $operatorName = $user->name;
|
||||
|
||||
// if (! $this->capacitorInput) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (! preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid Panel Box QR Format:')
|
||||
// ->body("Scan the valid panel box QR '$this->capacitorInput' to proceed!")
|
||||
// ->danger()
|
||||
// // ->duration(3000)
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
|
||||
// $this->capacitorInput = '';
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $parts = explode('/', $this->capacitorInput);
|
||||
// $supplier = $parts[0];
|
||||
// $itemCode = $parts[1];
|
||||
// $serialNumber = implode('/', array_slice($parts, 2)); // Keep rest of the string
|
||||
|
||||
// $existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) {
|
||||
// $query->where('code', $this->currentItemCode);
|
||||
// })
|
||||
// ->exists();
|
||||
|
||||
// if (! $existsInStickerMaster) {
|
||||
// Notification::make()
|
||||
// ->title('Unknown: Panel Box Code')
|
||||
// ->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
|
||||
// ->danger()
|
||||
// // ->duration(4000)
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// $this->capacitorInput = '';
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// foreach ($this->invoiceData as &$row) {
|
||||
|
||||
// if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
// $row['panel_box_supplier'] = $supplier;
|
||||
// $row['panel_box_code'] = $itemCode;
|
||||
// $row['panel_box_serial_number'] = $serialNumber;
|
||||
// $row['capacitor_scanned_status'] = 1;
|
||||
// // $row['scanned_status_set'] = true;
|
||||
|
||||
// $matchingValidation = InvoiceValidation::with('stickerMaster.item')
|
||||
// ->where('serial_number', $this->currentSerialNumber)
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->get()
|
||||
// ->first(function ($validation) {
|
||||
// return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
// });
|
||||
|
||||
// // dd($matchingValidation);
|
||||
|
||||
// if ($matchingValidation) {
|
||||
// $hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
// $hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
// $hasPumpSetQr = $matchingValidation->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
// // $hasCapacitorQr = $matchingValidation->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
// $hadMotorQr = $matchingValidation->motor_scanned_status ?? null;
|
||||
// $hadPumpQr = $matchingValidation->pump_scanned_status ?? null;
|
||||
// $hadPumpSetQr = $matchingValidation->scanned_status_set ?? null;
|
||||
// // $hadCapacitorQr = $matchingValidation->capacitor_scanned_status ?? null;
|
||||
|
||||
// $packCnt = 1;
|
||||
// $scanCnt = 1;
|
||||
// // if ($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
// if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr) {
|
||||
// $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
|
||||
|
||||
// $scanCnt = $hadMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||
// $scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
// $scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
// if ($packCnt === $scanCnt) {
|
||||
// $matchingValidation->update([
|
||||
// 'panel_box_supplier' => $supplier,
|
||||
// 'panel_box_code' => $itemCode,
|
||||
// 'panel_box_serial_number' => $serialNumber,
|
||||
// 'capacitor_scanned_status' => 1,
|
||||
// 'scanned_status' => 'Scanned',
|
||||
// 'operator_id' => $operatorName,
|
||||
// ]);
|
||||
// } else {
|
||||
// $matchingValidation->update([
|
||||
// 'panel_box_supplier' => $supplier,
|
||||
// 'panel_box_code' => $itemCode,
|
||||
// 'panel_box_serial_number' => $serialNumber,
|
||||
// 'capacitor_scanned_status' => 1,
|
||||
// 'operator_id' => $operatorName,
|
||||
// ]);
|
||||
// }
|
||||
// } else {
|
||||
// $matchingValidation->update([
|
||||
// 'panel_box_supplier' => $supplier,
|
||||
// 'panel_box_code' => $itemCode,
|
||||
// 'panel_box_serial_number' => $serialNumber,
|
||||
// 'capacitor_scanned_status' => 1,
|
||||
// 'scanned_status' => 'Scanned',
|
||||
// 'operator_id' => $operatorName,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// // Notification::make()
|
||||
// // ->title('Success: Capacitor QR')
|
||||
// // // ->title("Panel box code scanned: $itemCode")
|
||||
// // ->body("'Capacitor' QR scanned status updated, Scan next QR.")
|
||||
// // ->success() // commented
|
||||
// // ->seconds(2)
|
||||
// // ->send();
|
||||
|
||||
// $totalQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
|
||||
// $scannedQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count();
|
||||
// // $this->form->fill([
|
||||
// // 'plant_id' => $matchingValidation->plant_id,
|
||||
// // 'invoice_number' => $matchingValidation->invoice_number,
|
||||
// // 'serial_number' => null,
|
||||
// // 'total_quantity' => $totalQuantity,
|
||||
// // 'scanned_quantity'=> $scannedQuantity,
|
||||
// // ]);
|
||||
|
||||
// if ($totalQuantity === $scannedQuantity) {
|
||||
// Notification::make()
|
||||
// ->title('Completed: Serial Invoice')
|
||||
// ->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
// ->success()
|
||||
// ->seconds(2)
|
||||
// ->send();
|
||||
// $this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
// } else {
|
||||
// $this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id, false);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $this->showCapacitorInput = false;
|
||||
// $this->capacitorInput = '';
|
||||
// $this->dispatch('updateScannedQuantity');
|
||||
// // $this->loadData($this->invoiceNumber, $this->plantId);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// }
|
||||
|
||||
public function processCapacitorInput()
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
@@ -339,12 +801,14 @@ class InvoiceDataTable extends Component
|
||||
if (! preg_match('/^[^\/]+\/[^\/]+\/.+$/', $this->capacitorInput)) {
|
||||
Notification::make()
|
||||
->title('Invalid Panel Box QR Format:')
|
||||
->body('Scan the valid panel box QR code to proceed!')
|
||||
->body("Scan the valid panel box QR '$this->capacitorInput' to proceed!")
|
||||
->danger()
|
||||
// ->duration(3000)
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->capacitorInput = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -371,10 +835,19 @@ class InvoiceDataTable extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->invoiceData as &$row) {
|
||||
if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
$this->package = InvoiceValidation::with('stickerMasterRelation')
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('plant_id', $this->plantId)
|
||||
->get();
|
||||
|
||||
foreach ($this->package as &$row) {
|
||||
|
||||
$stickerCode = $row->stickerMasterRelation?->item?->code ?? null;
|
||||
$serialNo = $row->serial_number ?? null;
|
||||
|
||||
if ($stickerCode === $this->currentItemCode && $serialNo === $this->currentSerialNumber) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_item_code'] = $itemCode;
|
||||
$row['panel_box_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
$row['capacitor_scanned_status'] = 1;
|
||||
// $row['scanned_status_set'] = true;
|
||||
@@ -387,6 +860,8 @@ class InvoiceDataTable extends Component
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
});
|
||||
|
||||
// dd($matchingValidation);
|
||||
|
||||
if ($matchingValidation) {
|
||||
$hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null;
|
||||
$hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null;
|
||||
@@ -413,7 +888,7 @@ class InvoiceDataTable extends Component
|
||||
if ($packCnt === $scanCnt) {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
@@ -422,7 +897,7 @@ class InvoiceDataTable extends Component
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'operator_id' => $operatorName,
|
||||
@@ -431,7 +906,7 @@ class InvoiceDataTable extends Component
|
||||
} else {
|
||||
$matchingValidation->update([
|
||||
'panel_box_supplier' => $supplier,
|
||||
'panel_box_item_code' => $itemCode,
|
||||
'panel_box_code' => $itemCode,
|
||||
'panel_box_serial_number' => $serialNumber,
|
||||
'capacitor_scanned_status' => 1,
|
||||
'scanned_status' => 'Scanned',
|
||||
@@ -480,8 +955,15 @@ class InvoiceDataTable extends Component
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
// public function render()
|
||||
// {
|
||||
// return view('livewire.invoice-data-table');
|
||||
// }
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.invoice-data-table');
|
||||
return view('livewire.invoice-data-table', [
|
||||
'records' => $this->invoiceRecords,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class CharacteristicApproverMaster extends Model
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'machine_name',
|
||||
'characteristic_field',
|
||||
'name1',
|
||||
'mail1',
|
||||
'name2',
|
||||
@@ -23,8 +24,6 @@ class CharacteristicApproverMaster extends Model
|
||||
'duration1',
|
||||
'duration2',
|
||||
'duration3',
|
||||
'characteristic_field',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CharacteristicValue extends Model
|
||||
{
|
||||
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -45,4 +47,9 @@ class CharacteristicValue extends Model
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ClassCharacteristic extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -179,4 +182,9 @@ class ClassCharacteristic extends Model
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EbReading extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -66,4 +69,9 @@ class EbReading extends Model
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class GuardPatrolEntry extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -27,13 +30,24 @@ class GuardPatrolEntry extends Model
|
||||
|
||||
public function guardNames(): BelongsTo
|
||||
{
|
||||
//return $this->belongsTo(CheckPointName::class);
|
||||
// return $this->belongsTo(CheckPointName::class);
|
||||
return $this->belongsTo(GuardName::class, 'guard_name_id');
|
||||
}
|
||||
|
||||
public function checkPointNames(): BelongsTo
|
||||
{
|
||||
//return $this->belongsTo(CheckPointName::class);
|
||||
// return $this->belongsTo(CheckPointName::class);
|
||||
return $this->belongsTo(CheckPointName::class, 'check_point_name_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
// // Start of two months ago (first day of that month)
|
||||
// $startOfTwoMonthsAgo = now()->subMonthsNoOverflow(6)->startOfMonth();
|
||||
// // End of previous month (last day of last month)
|
||||
// $endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
|
||||
|
||||
// return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceDataValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
@@ -32,4 +35,9 @@ class InvoiceDataValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,45 +2,53 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceInTransit extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"receiving_plant",
|
||||
"receiving_plant_name",
|
||||
"invoice_number",
|
||||
"invoice_date",
|
||||
"item_code",
|
||||
"description",
|
||||
"quantity",
|
||||
"transport_name",
|
||||
"lr_bl_aw_number",
|
||||
"lr_bl_aw_date",
|
||||
"pending_days",
|
||||
"obd_number",
|
||||
"obd_date",
|
||||
"shipment_weight",
|
||||
"unit_price",
|
||||
"net_value",
|
||||
"total_item_amount",
|
||||
"tax_amount",
|
||||
"transport_mode",
|
||||
"vehicle_number",
|
||||
"e_waybill_number",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
'plant_id',
|
||||
'receiving_plant',
|
||||
'receiving_plant_name',
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
'item_code',
|
||||
'description',
|
||||
'quantity',
|
||||
'transport_name',
|
||||
'lr_bl_aw_number',
|
||||
'lr_bl_aw_date',
|
||||
'pending_days',
|
||||
'obd_number',
|
||||
'obd_date',
|
||||
'shipment_weight',
|
||||
'unit_price',
|
||||
'net_value',
|
||||
'total_item_amount',
|
||||
'tax_amount',
|
||||
'transport_mode',
|
||||
'vehicle_number',
|
||||
'e_waybill_number',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,37 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceOutValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
// protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"qr_code",
|
||||
"scanned_at",
|
||||
"scanned_by",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
'plant_id',
|
||||
'qr_code',
|
||||
'scanned_at',
|
||||
'scanned_by',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,28 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'sticker_master_id',
|
||||
'plant_id',
|
||||
'invoice_number',
|
||||
'invoice_number',
|
||||
'serial_number',
|
||||
'motor_scanned_status',
|
||||
'pump_scanned_status',
|
||||
'capacitor_scanned_status',
|
||||
'scanned_status_set',
|
||||
'scanned_status',
|
||||
'panel_box_code',
|
||||
'panel_box_supplier',
|
||||
'panel_box_serial_number',
|
||||
'load_rate',
|
||||
@@ -27,6 +31,8 @@ class InvoiceValidation extends Model
|
||||
'batch_number',
|
||||
'quantity',
|
||||
'operator_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -38,11 +44,14 @@ class InvoiceValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class);
|
||||
}
|
||||
|
||||
|
||||
public function stickerMasterRelation()
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
|
||||
}
|
||||
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,40 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class LocatorInvoiceValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'invoice_number',
|
||||
'invoice_number',
|
||||
'serial_number',
|
||||
'pallet_number',
|
||||
'locator_number',
|
||||
'scanned_status',
|
||||
'upload_status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
'pallet_number',
|
||||
'locator_number',
|
||||
'scanned_status',
|
||||
'upload_status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,39 +2,42 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MfmReading extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'apparent_energy_received',
|
||||
'apparent_energy_received',
|
||||
'reactive_energy_received',
|
||||
'active_energy_received',
|
||||
'active_power_r',
|
||||
'active_power_y',
|
||||
'active_power_b',
|
||||
'active_power_y',
|
||||
'active_power_b',
|
||||
'active_power_total',
|
||||
'voltage_ry',
|
||||
'voltage_yb',
|
||||
'voltage_ry',
|
||||
'voltage_yb',
|
||||
'voltage_br',
|
||||
'current_r',
|
||||
'current_y',
|
||||
'current_y',
|
||||
'current_b',
|
||||
'current_n',
|
||||
'voltage_r_n',
|
||||
'voltage_y_n',
|
||||
'voltage_r_n',
|
||||
'voltage_y_n',
|
||||
'voltage_b_n',
|
||||
'frequency',
|
||||
'power_factor_r',
|
||||
'frequency',
|
||||
'power_factor_r',
|
||||
'power_factor_y',
|
||||
'power_factor_b',
|
||||
'power_factor_total',
|
||||
'power_factor_total',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
@@ -48,4 +51,9 @@ class MfmReading extends Model
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,39 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PalletValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'pallet_number',
|
||||
'pallet_number',
|
||||
'serial_number',
|
||||
'pallet_status',
|
||||
'locator_number',
|
||||
'pallet_status',
|
||||
'locator_number',
|
||||
'locator_quantity',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProcessOrder extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -24,8 +27,8 @@ class ProcessOrder extends Model
|
||||
'rework_status',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -42,4 +45,9 @@ class ProcessOrder extends Model
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'item_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,29 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductionLineStop extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"shift_id",
|
||||
"line_id",
|
||||
"linestop_id",
|
||||
"from_datetime",
|
||||
"to_datetime",
|
||||
"stop_hour",
|
||||
"stop_min",
|
||||
"operator_id",
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'shift_id',
|
||||
'linestop_id',
|
||||
'from_datetime',
|
||||
'to_datetime',
|
||||
'stop_hour',
|
||||
'stop_min',
|
||||
'operator_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -48,5 +53,8 @@ class ProductionLineStop extends Model
|
||||
// return $this->belongsTo(LineStop::class, 'linestop_id');
|
||||
// }
|
||||
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,26 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductionPlan extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"shift_id",
|
||||
"created_at",
|
||||
"line_id",
|
||||
"plan_quantity",
|
||||
"production_quantity",
|
||||
"operator_id",
|
||||
'plant_id',
|
||||
'shift_id',
|
||||
'line_id',
|
||||
'plan_quantity',
|
||||
'production_quantity',
|
||||
'operator_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -34,4 +38,9 @@ class ProductionPlan extends Model
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,30 +4,33 @@ namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductionQuantity extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
public static $importing = false; // Add this flag
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"shift_id",
|
||||
"line_id",
|
||||
"item_id",
|
||||
"serial_number",
|
||||
"production_order",
|
||||
"operator_id",
|
||||
'plant_id',
|
||||
'shift_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'serial_number',
|
||||
'production_order',
|
||||
'operator_id',
|
||||
// "success_status",
|
||||
// "notok_at",
|
||||
// "no_of_employee",
|
||||
// "list_of_employee",
|
||||
"created_at",
|
||||
"updated_at"
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -66,8 +69,7 @@ class ProductionQuantity extends Model
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$productionPlan)
|
||||
{
|
||||
if (! $productionPlan) {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
|
||||
->where('shift_id', $productionQuantity->shift_id)
|
||||
->where('line_id', $productionQuantity->line_id)
|
||||
@@ -88,4 +90,9 @@ class ProductionQuantity extends Model
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,22 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class QualityValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'sticker_master_id',
|
||||
'plant_id',
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'production_order',
|
||||
'production_order',
|
||||
'serial_number_motor',
|
||||
'serial_number_pump',
|
||||
'serial_number_pumpset',
|
||||
@@ -56,4 +59,9 @@ class QualityValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestCharacteristic extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -48,7 +51,6 @@ class RequestCharacteristic extends Model
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
@@ -91,9 +93,8 @@ class RequestCharacteristic extends Model
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,30 +2,33 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ReworkLocatorInvoiceValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'invoice_number',
|
||||
'serial_number',
|
||||
'pallet_number',
|
||||
'locator_number',
|
||||
'scanned_status',
|
||||
'upload_status',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
'reworked_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'reworked_at',
|
||||
'invoice_number',
|
||||
'serial_number',
|
||||
'pallet_number',
|
||||
'locator_number',
|
||||
'scanned_status',
|
||||
'upload_status',
|
||||
'created_by',
|
||||
'scanned_by',
|
||||
'updated_by',
|
||||
'reworked_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'reworked_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -33,4 +36,8 @@ class ReworkLocatorInvoiceValidation extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class SerialValidation extends Model
|
||||
{
|
||||
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'sticker_master_id',
|
||||
'plant_id',
|
||||
'invoice_number',
|
||||
'invoice_number',
|
||||
'serial_number',
|
||||
'motor_scanned_status',
|
||||
'pump_scanned_status',
|
||||
@@ -44,4 +46,9 @@ class SerialValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(StickerMaster::class, 'sticker_master_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class StickerPrinting extends Model
|
||||
{
|
||||
//
|
||||
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -26,4 +27,9 @@ class StickerPrinting extends Model
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,30 +2,38 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TempLiveReading extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'register_data',
|
||||
'register_data',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
|
||||
public function mfmMeter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,66 +2,69 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TestingPanelReading extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'motor_testing_master_id',
|
||||
'machine_id',
|
||||
'output',
|
||||
'serial_number',
|
||||
'line_id',
|
||||
'motor_testing_master_id',
|
||||
'machine_id',
|
||||
'output',
|
||||
'serial_number',
|
||||
'winded_serial_number',
|
||||
'before_fr_volt',
|
||||
'before_fr_cur',
|
||||
'before_fr_pow',
|
||||
'before_fr_res_ry',
|
||||
'before_fr_res_yb',
|
||||
'before_fr_res_br',
|
||||
'before_fr_ir',
|
||||
'before_fr_ir_r',
|
||||
'before_fr_ir_y',
|
||||
'before_fr_ir_b',
|
||||
'before_fr_freq',
|
||||
'before_fr_speed',
|
||||
'after_fr_vol',
|
||||
'after_fr_cur',
|
||||
'after_fr_pow',
|
||||
'after_fr_ir_hot',
|
||||
'after_fr_ir_hot_r',
|
||||
'after_fr_ir_hot_y',
|
||||
'after_fr_ir_hot_b',
|
||||
'after_fr_ir_cool',
|
||||
'after_fr_ir_cool_r',
|
||||
'after_fr_ir_cool_y',
|
||||
'after_fr_ir_cool_b',
|
||||
'after_fr_freq',
|
||||
'after_fr_speed',
|
||||
'after_fr_leak_cur',
|
||||
'locked_rt_volt',
|
||||
'locked_rt_cur',
|
||||
'locked_rt_pow',
|
||||
'no_load_pickup_volt',
|
||||
'room_temperature',
|
||||
'hv_test',
|
||||
'batch_number',
|
||||
'batch_count',
|
||||
'result',
|
||||
'remark',
|
||||
'rework_count',
|
||||
'before_fr_volt',
|
||||
'before_fr_cur',
|
||||
'before_fr_pow',
|
||||
'before_fr_res_ry',
|
||||
'before_fr_res_yb',
|
||||
'before_fr_res_br',
|
||||
'before_fr_ir',
|
||||
'before_fr_ir_r',
|
||||
'before_fr_ir_y',
|
||||
'before_fr_ir_b',
|
||||
'before_fr_freq',
|
||||
'before_fr_speed',
|
||||
'after_fr_vol',
|
||||
'after_fr_cur',
|
||||
'after_fr_pow',
|
||||
'after_fr_ir_hot',
|
||||
'after_fr_ir_hot_r',
|
||||
'after_fr_ir_hot_y',
|
||||
'after_fr_ir_hot_b',
|
||||
'after_fr_ir_cool',
|
||||
'after_fr_ir_cool_r',
|
||||
'after_fr_ir_cool_y',
|
||||
'after_fr_ir_cool_b',
|
||||
'after_fr_freq',
|
||||
'after_fr_speed',
|
||||
'after_fr_leak_cur',
|
||||
'locked_rt_volt',
|
||||
'locked_rt_cur',
|
||||
'locked_rt_pow',
|
||||
'no_load_pickup_volt',
|
||||
'room_temperature',
|
||||
'hv_test',
|
||||
'batch_number',
|
||||
'batch_count',
|
||||
'result',
|
||||
'remark',
|
||||
'rework_count',
|
||||
'update_count',
|
||||
'output_flag',
|
||||
'tested_by',
|
||||
'updated_by',
|
||||
'tested_by',
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'scanned_at',
|
||||
'scanned_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -69,10 +72,11 @@ class TestingPanelReading extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
@@ -83,8 +87,13 @@ class TestingPanelReading extends Model
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function motorTestingMaster()
|
||||
public function motorTestingMaster()
|
||||
{
|
||||
return $this->belongsTo(MotorTestingMaster::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Models/VehicleEntry.php
Normal file
30
app/Models/VehicleEntry.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class VehicleEntry extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'vehicle_number',
|
||||
'entry_time',
|
||||
'exit_time',
|
||||
'duration',
|
||||
'type',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class WeightValidation extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -22,6 +25,8 @@ class WeightValidation extends Model
|
||||
'bundle_number',
|
||||
'picked_weight',
|
||||
'scanned_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -33,4 +38,13 @@ class WeightValidation extends Model
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
// $startOfTwoMonthsAgo = now()->subMonthsNoOverflow(3)->startOfMonth();
|
||||
// $endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
|
||||
|
||||
// return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
61
app/Observers/RequestCharacteristicObserver.php
Normal file
61
app/Observers/RequestCharacteristicObserver.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\SendApprover1MailJob;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class RequestCharacteristicObserver
|
||||
{
|
||||
/**
|
||||
* Handle the RequestCharacteristic "created" event.
|
||||
*/
|
||||
public function created(RequestCharacteristic $request): void
|
||||
{
|
||||
// Only if all statuses are NULL
|
||||
if (
|
||||
!is_null($request->approver_status1) ||
|
||||
!is_null($request->approver_status2) ||
|
||||
!is_null($request->approver_status3)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
SendApprover1MailJob::dispatch($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "updated" event.
|
||||
*/
|
||||
public function updated(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "deleted" event.
|
||||
*/
|
||||
public function deleted(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "restored" event.
|
||||
*/
|
||||
public function restored(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the RequestCharacteristic "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(RequestCharacteristic $requestCharacteristic): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
106
app/Policies/VehicleEntryPolicy.php
Normal file
106
app/Policies/VehicleEntryPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\VehicleEntry;
|
||||
use App\Models\User;
|
||||
|
||||
class VehicleEntryPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, VehicleEntry $vehicleentry): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete VehicleEntry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any VehicleEntry');
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
@@ -27,19 +26,20 @@ return new class extends Migration
|
||||
scanned_status_set TEXT DEFAULT NULL,
|
||||
scanned_status TEXT DEFAULT NULL,
|
||||
|
||||
panel_box_code TEXT DEFAULT NULL,
|
||||
panel_box_supplier TEXT DEFAULT NULL,
|
||||
panel_box_serial_number TEXT DEFAULT NULL,
|
||||
|
||||
load_rate INT NOT NULL DEFAULT (0),
|
||||
upload_status TEXT NOT NULL DEFAULT 'N',
|
||||
|
||||
|
||||
batch_number TEXT DEFAULT NULL,
|
||||
quantity INT DEFAULT NULL,
|
||||
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (plant_id, serial_number),
|
||||
@@ -48,7 +48,7 @@ return new class extends Migration
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN approver_type TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('characteristic_approver_masters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE invoice_validations
|
||||
ADD COLUMN panel_box_code TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
ALTER TABLE invoice_validations
|
||||
ADD COLUMN created_by TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
|
||||
$sql3 = <<<'SQL'
|
||||
ALTER TABLE invoice_validations
|
||||
ADD COLUMN updated_by TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('invoice_validations', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE vehicle_entries (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
vehicle_number TEXT DEFAULT NULL,
|
||||
entry_time TIMESTAMP,
|
||||
exit_time TIMESTAMP,
|
||||
duration INTERVAL,
|
||||
type TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('vehicle_entries');
|
||||
}
|
||||
};
|
||||
@@ -1,19 +1,126 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<h1 class="text-3xl font-bold mb-6">Welcome to CRI Digital Manufacturing IIOT</h1>
|
||||
<!-- HEADER -->
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-bold tracking-tight">
|
||||
CRI Digital Manufacturing IIoT Platform
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mt-2">
|
||||
Complete visibility, traceability, and control across your manufacturing operations
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-64 object-cover"
|
||||
>
|
||||
</div>
|
||||
<!-- BANNER -->
|
||||
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-72 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<p class="text-lg text-gray-600 mb-6">
|
||||
This dashboard provides real-time visibility into your manufacturing operations,
|
||||
enabling you to monitor production, track performance, and make data-driven decisions
|
||||
across plants and lines—all from one centralized platform.
|
||||
</p>
|
||||
<!-- INTRO -->
|
||||
<div class="max-w-4xl mb-10">
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
CRI Digital Manufacturing IIoT is built to deliver
|
||||
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
|
||||
across plants, lines, and production processes.
|
||||
</p>
|
||||
|
||||
<p class="text-lg text-gray-700">
|
||||
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
|
||||
complete tracking of materials, production orders, and finished goods—helping teams
|
||||
make faster, data-driven decisions with confidence.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- KEY PILLARS -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
|
||||
<p class="text-gray-600">
|
||||
Track materials, batches, and serials from input to dispatch.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">✅ Quality Assurance</h3>
|
||||
<p class="text-gray-600">
|
||||
Validate process data and ensure first-time-right production.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">⏱ On-Time Delivery</h3>
|
||||
<p class="text-gray-600">
|
||||
Identify delays early and meet production commitments.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
|
||||
<p class="text-gray-600">
|
||||
Monitor performance and take quick corrective actions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SUPPORT -->
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
|
||||
<p class="text-gray-700 mb-2">
|
||||
Our dedicated IIoT support team is available round-the-clock to ensure
|
||||
uninterrupted operations and quick issue resolution.
|
||||
</p>
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
|
||||
</p>
|
||||
{{-- <p class="text-lg font-medium text-gray-900">
|
||||
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p> --}}
|
||||
</div>
|
||||
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
|
||||
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
Our support structure is designed to ensure quick resolution based on the type
|
||||
of issue — whether it is on-site, application-related, or infrastructure-related.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
🏭 <strong>Plant & On-Site Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For plant visits, industry-level issues, and on-ground validation
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">8925899458 / 8925899459</span>
|
||||
</p>
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
💻 <strong>Application & Logic Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For website errors, logic issues, and application-level problems
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<!-- TEAM -->
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
|
||||
<div class="flex items-center gap-2">👤 Jothikumar</div>
|
||||
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
|
||||
<div class="flex items-center gap-2">👤 Dhanabalan</div>
|
||||
<div class="flex items-center gap-2">👤 Ranjith</div>
|
||||
<div class="flex items-center gap-2">👤 Srimathy</div>
|
||||
<div class="flex items-center gap-2">👤 Gokul</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
</x-filament-panels::page>
|
||||
|
||||
@@ -18,9 +18,29 @@
|
||||
@endif
|
||||
@endif
|
||||
</h2>
|
||||
<div class="mt-2">
|
||||
|
||||
<!-- Serial Number Search Bar -->
|
||||
|
||||
{{-- <div class="flex items-center space-x-2">
|
||||
<input
|
||||
type="text"
|
||||
wire:model.debounce.500ms="serialSearch"
|
||||
placeholder="Check Serial Number..."
|
||||
class="border border-gray-300 rounded px-3 py-1 focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500"
|
||||
/>
|
||||
<button
|
||||
wire:click="checkSerialNumber"
|
||||
class="bg-indigo-600 text-white px-3 py-1 rounded hover:bg-indigo-700"
|
||||
>
|
||||
Search
|
||||
</button>
|
||||
</div> --}}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<hr class="border-t-2 border-gray-300">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Modal for completed invoice--}}
|
||||
@@ -44,11 +64,11 @@
|
||||
@endif
|
||||
|
||||
{{-- Modal for serial invoice--}}
|
||||
@if ($hasSearched)
|
||||
{{-- @if ($hasSearched)
|
||||
<div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
|
||||
{{-- <table class="min-w-[1500px] text-sm text-center border border-gray-300"> --}}
|
||||
{{-- <table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300"> --}}
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<table class="min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
@@ -61,6 +81,7 @@
|
||||
<th class="border px-4 py-2">Scanned Status</th>
|
||||
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
<th class="border px-4 py-2">Panel Box Code</th>
|
||||
<th class="border px-4 py-2">Panel Box Supplier</th>
|
||||
<th class="border px-4 py-2">Panel Box Serial Number</th>
|
||||
</tr>
|
||||
@@ -78,6 +99,7 @@
|
||||
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? '' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['created_at'] ?? '' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['operator_id'] ?? '' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['panel_box_code'] ?? '' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? '' }}</td>
|
||||
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? '' }}</td>
|
||||
</tr>
|
||||
@@ -91,6 +113,61 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif --}}
|
||||
|
||||
|
||||
@if ($hasSearched)
|
||||
<div class="overflow-x-auto" style="height: 385px;">
|
||||
<table class="min-w-full text-sm text-center border border-gray-300">
|
||||
<table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300">
|
||||
<thead class="bg-gray-100 font-bold">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Material Code</th>
|
||||
<th class="border px-4 py-2">Serial Number</th>
|
||||
<th class="border px-4 py-2">Motor Scanned Status</th>
|
||||
<th class="border px-4 py-2">Pump Scanned Status</th>
|
||||
<th class="border px-4 py-2">Capacitor Scanned Status</th>
|
||||
<th class="border px-4 py-2">Scanned Status Set</th>
|
||||
<th class="border px-4 py-2">Scanned Status</th>
|
||||
<th class="border px-4 py-2 w-[300px] whitespace-nowrap">Time Stamp</th>
|
||||
<th class="border px-4 py-2">Operator ID</th>
|
||||
<th class="border px-4 py-2">Panel Box Code</th>
|
||||
<th class="border px-4 py-2">Panel Box Supplier</th>
|
||||
<th class="border px-4 py-2">Panel Box Serial Number</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@forelse ($records as $index => $record)
|
||||
<tr wire:key="inv-{{ $record->id }}" class="border-t">
|
||||
<td class="border px-2 py-2">{{ $records->firstItem() + $index }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->stickerMasterRelation?->item?->code ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->serial_number ?? 'N/A' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->motor_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->pump_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->capacitor_scanned_status ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status_set ? '1' : '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->scanned_status ?? '' }}</td>
|
||||
<td class="border px-2 py-2 whitespace-nowrap">{{ optional($record->created_at)->format('d-m-Y H:i:s') }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->operator_id ?? '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->panel_box_code ?? '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->panel_box_supplier ?? '' }}</td>
|
||||
<td class="border px-2 py-2">{{ $record->panel_box_serial_number ?? '' }}</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="12" class="py-4 text-gray-500">
|
||||
No data found for invoice <strong>{{ $invoiceNumber }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mt-3 flex justify-center">
|
||||
{{ $records->onEachSide(3)->links() }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Modal for Capacitor Input --}}
|
||||
@@ -128,6 +205,16 @@
|
||||
<script>
|
||||
document.getElementById('capacitorInput').focus();
|
||||
</script>
|
||||
{{-- <script>
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
@this.on('focus-capacitor-input', () => {
|
||||
setTimeout(() => {
|
||||
const el = document.getElementById('capacitorInput');
|
||||
if (el) el.focus();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
</script> --}}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ use App\Http\Controllers\ModuleProductionLineStopController;
|
||||
use App\Http\Controllers\ModuleProductionOrderDataController;
|
||||
use App\Http\Controllers\ObdController;
|
||||
use App\Http\Controllers\PalletController;
|
||||
// use App\Http\Controllers\PalletPrintController;
|
||||
use App\Http\Controllers\PdfController;
|
||||
use App\Http\Controllers\PlantController;
|
||||
use App\Http\Controllers\ProductionStickerReprintController;
|
||||
@@ -32,6 +33,7 @@ use App\Http\Controllers\StickerMasterController;
|
||||
// use App\Http\Controllers\TelegramController;
|
||||
use App\Http\Controllers\TestingPanelController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\VehicleController;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -75,7 +77,7 @@ Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrP
|
||||
|
||||
Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf');
|
||||
|
||||
// Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
|
||||
Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
|
||||
|
||||
// Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->where('palletNo', '.*')->name('download-qr1-pdf');
|
||||
Route::get('/download-qr1-pdf', [ProductionStickerReprintController::class, 'downloadQrPdf'])
|
||||
@@ -204,12 +206,14 @@ Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']);
|
||||
Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
|
||||
|
||||
// routes/api.php
|
||||
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave']);
|
||||
|
||||
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']);
|
||||
|
||||
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
||||
|
||||
// Route::get('/print-pallet/{pallet}/{plant}', [PalletPrintController::class, 'print'])
|
||||
// ->name('print.pallet');
|
||||
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave'])
|
||||
// ->name('characteristic.hold.save');
|
||||
Route::post('vehicle/entry', [VehicleController::class, 'storeVehicleEntry']);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
@@ -13,6 +11,11 @@ Artisan::command('auto:scheduler', function () {
|
||||
$this->call('custom:scheduler');
|
||||
})->everyMinute()->withoutOverlapping();
|
||||
|
||||
Schedule::command('model:prune --pretend')// , ['--model' => WeightValidation::class]
|
||||
->description('Deletable Old Records From Server ('.env('APP_URL').')')
|
||||
->dailyAt('07:00')
|
||||
->emailOutputTo(['digitalmanufacturingiiot@gmail.com', 'jothikumar.padmanaban@cripumps.com'], true);
|
||||
|
||||
// app()->booted(function () {
|
||||
// $schedule = app(Schedule::class);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CharacteristicApprovalController;
|
||||
use App\Http\Controllers\FileUploadController;
|
||||
// use App\Http\Controllers\FileUploadController;
|
||||
use App\Models\EquipmentMaster;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -41,11 +41,22 @@ Route::get('/approval/reject-success', function () {
|
||||
return view('approval.reject-success');
|
||||
})->name('approval.reject.success');
|
||||
|
||||
Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
||||
Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approveForm'])
|
||||
->name('characteristic.approve')
|
||||
->middleware('signed');
|
||||
|
||||
Route::post('/file-upload', [FileUploadController::class, 'upload'])->name('file.upload');
|
||||
Route::post('/characteristic/approve-save', [CharacteristicApprovalController::class, 'approveSave'])
|
||||
->name('characteristic.approve.save');
|
||||
|
||||
Route::get('/approval/approve-success', function () {
|
||||
return view('approval.approve-success');
|
||||
})->name('approval.approve.success');
|
||||
|
||||
// Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
||||
// ->name('characteristic.approve')
|
||||
// ->middleware('signed');
|
||||
|
||||
// Route::post('/file-upload', [FileUploadController::class, 'upload'])->name('file.upload');
|
||||
|
||||
// Route::get('/characteristic/hold', [CharacteristicApprovalController::class, 'hold'])
|
||||
// ->name('characteristic.hold')
|
||||
|
||||
Reference in New Issue
Block a user