Compare commits
1 Commits
197184e2ed
...
gha-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfed40f535 |
30
.github/workflows/pint.yaml
vendored
Normal file
30
.github/workflows/pint.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Laravel Pint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
pint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Reinstall system libraries to ensure compatibility
|
||||
- name: Ensure system libraries are up-to-date
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --reinstall --yes git libc6
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "8.3"
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-interaction --prefer-dist --no-progress
|
||||
|
||||
# Run pint in test mode, check only files different from master branch
|
||||
- name: Run Laravel Pint in test mode
|
||||
run: vendor/bin/pint --test --diff=master
|
||||
@@ -280,8 +280,8 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$serialTableData = [];
|
||||
$materialTableData = [];
|
||||
@@ -293,16 +293,6 @@ class SendInvoiceReport extends Command
|
||||
: [$plantIdArg];
|
||||
|
||||
$no = 1;
|
||||
if (strtolower($schedule) == 'daily')
|
||||
{
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
foreach ($plantIds as $plantId) {
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
@@ -193,9 +193,6 @@ class SendProductionReport extends Command
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
//..
|
||||
|
||||
//.
|
||||
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
@@ -207,7 +204,7 @@ class SendProductionReport extends Command
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
if (strtolower($line->type) === 'fg line') {
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
@@ -223,7 +220,6 @@ class SendProductionReport extends Command
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'line' => $line->name,
|
||||
'type' => $line->type,
|
||||
'targetQuantity' => $targetQuantity,
|
||||
'productionQuantity' => $productionQuantity,
|
||||
];
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\DeviceMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class DeviceMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('DEVICE NAME'),
|
||||
ExportColumn::make('mac_address')
|
||||
->label('MAC ADDRESS'),
|
||||
ExportColumn::make('ip_address')
|
||||
->label('IP ADDRESS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your device master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmMeterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmMeter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('device.name')
|
||||
->label('DEVICE NAME'),
|
||||
ExportColumn::make('sequence')
|
||||
->label('SEQUENCE'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm meter export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -13,40 +13,20 @@ class MfmParameterExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('deviceName.name')
|
||||
->label('Device Name'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('mfmMeter.name')
|
||||
->label('MFM METER'),
|
||||
ExportColumn::make('register_id')
|
||||
->label('REGISTER ID'),
|
||||
ExportColumn::make('identifier')
|
||||
->label('IDENTIFIER'),
|
||||
ExportColumn::make('byte_to_convert')
|
||||
->label('BYTE TO CONVERT'),
|
||||
ExportColumn::make('type_to_convert')
|
||||
->label('TYPE TO CONVERT'),
|
||||
ExportColumn::make('decimal_to_display')
|
||||
->label('DECIMAL TO DISPLAY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
ExportColumn::make('plant.name'),
|
||||
ExportColumn::make('name'),
|
||||
ExportColumn::make('register_id'),
|
||||
ExportColumn::make('identifier'),
|
||||
ExportColumn::make('byte_to_convert'),
|
||||
ExportColumn::make('type_to_convert'),
|
||||
ExportColumn::make('decimal_to_display'),
|
||||
ExportColumn::make('created_at'),
|
||||
ExportColumn::make('updated_at'),
|
||||
ExportColumn::make('deleted_at'),
|
||||
ExportColumn::make('mfmMeter.name'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\DeviceMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class DeviceMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->label('Device Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mac_address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MAC Address')
|
||||
->example('00:1A:2B:3C:4D:5E')
|
||||
->label('MAC Address')
|
||||
->rules(['required', 'mac_address']),
|
||||
ImportColumn::make('ip_address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('IP Address')
|
||||
->label('IP Address')
|
||||
->rules(['required', 'ip']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?DeviceMaster
|
||||
{
|
||||
// return DeviceMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new DeviceMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your device master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmMeterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmMeter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('Device Name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->example('REG001')
|
||||
->label('Device Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sequence')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Sequence')
|
||||
->example('1')
|
||||
->label('Sequence')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Meter Name')
|
||||
->example('Display SSB')
|
||||
->label('Meter Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmMeter
|
||||
{
|
||||
// return MfmMeter::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmMeter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm meter import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,6 @@ class MfmParameterImporter extends Importer
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('deviceName')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->example('REG001')
|
||||
->label('Device Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Sequence')
|
||||
|
||||
@@ -726,27 +726,13 @@ class PalletFromLocator extends Page implements HasForms
|
||||
$month = now()->format('m');
|
||||
$prefix = "EP-{$year}{$month}";
|
||||
|
||||
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
|
||||
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
||||
if ($lastPallet1 && $lastPallet2) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
if (intval($serialPart1) > intval($serialPart2)) {
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
else if ($lastPallet1) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
if ($lastPallet) {
|
||||
$serialPart = substr($lastPallet->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
}
|
||||
else if ($lastPallet2) {
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
$newNumber = str_pad(intval($serialPart) + 1, strlen($serialPart), '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||
|
||||
@@ -320,44 +320,23 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(7)
|
||||
->maxLength(14)
|
||||
//->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 1])
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
||||
{
|
||||
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
|
||||
$set('production_order', null);
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('productionError', null);
|
||||
$set('production_order', $state);
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = $state;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('productionError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
|
||||
->hintColor('danger'),
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
//->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 1])
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = $state;
|
||||
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}),
|
||||
|
||||
// TextInput::make('item_code')
|
||||
// ->label('Item Code')
|
||||
@@ -613,7 +592,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
|
||||
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -632,7 +611,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
|
||||
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\TrendChartAnalysis;
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TrendChartAnalys extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.trend-chart-analys';
|
||||
|
||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
||||
|
||||
// use HasFiltersForm;
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
||||
$this->filtersForm->fill([
|
||||
'selected_plant' => null,
|
||||
'selected_meter' => null,
|
||||
'from_datetime' => null,
|
||||
'to_datetime' => null,
|
||||
'parameter' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
DateTimePicker::make('from_datetime')
|
||||
->label('From DateTime')
|
||||
->required()
|
||||
->before('to_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['from_datetime' => $formatted]);
|
||||
}),
|
||||
DateTimePicker::make('to_datetime')
|
||||
->label('To DateTime')
|
||||
->required()
|
||||
->after('from_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['to_datetime' => $formatted]);
|
||||
}),
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
// When plant changes, also reset meter_name
|
||||
$set('meter_name', null);
|
||||
session(['selected_meter' => null]);
|
||||
// dd($state);
|
||||
}),
|
||||
|
||||
Select::make('meter_name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Meter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_meter' => $state]);
|
||||
}),
|
||||
Select::make('parameter')
|
||||
->options([
|
||||
'Phase Voltage' => 'Phase Voltage',
|
||||
'Line Voltage' => 'Line Voltage',
|
||||
'Current' => 'Current',
|
||||
'Active Power' => 'Active Power',
|
||||
'Power Factor' => 'Power Factor',
|
||||
'Units' => 'Units',
|
||||
])
|
||||
->label('Select Parameter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['parameter' => $state]);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(5);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Trend Chart Analysis';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Trend Chart Analysis';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (TrendChartAnalysis::canView()) {
|
||||
$widgets[] = TrendChartAnalysis::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view ems trend chart analysis dashboard');
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\TrendLineChart;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use App\Models\MfmMeter;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TrendLineAnalysis extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.trend-line-analysis';
|
||||
|
||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
||||
$this->filtersForm->fill([
|
||||
'selected_plant' => null,
|
||||
'selected_meter' => null,
|
||||
'from_datetime' => null,
|
||||
'to_datetime' => null,
|
||||
'parameter' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
DateTimePicker::make('from_datetime')
|
||||
->label('From DateTime')
|
||||
->required()
|
||||
->before('to_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['from_datetime' => $formatted]);
|
||||
}),
|
||||
DateTimePicker::make('to_datetime')
|
||||
->label('To DateTime')
|
||||
->required()
|
||||
->after('from_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['to_datetime' => $formatted]);
|
||||
}),
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
// When plant changes, also reset meter_name
|
||||
$set('meter_name', null);
|
||||
session(['selected_meter' => null]);
|
||||
// dd($state);
|
||||
}),
|
||||
|
||||
Select::make('meter_name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Meter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_meter' => $state]);
|
||||
}),
|
||||
Select::make('parameter')
|
||||
->options([
|
||||
'Phase Voltage' => 'Phase Voltage',
|
||||
'Line Voltage' => 'Line Voltage',
|
||||
'Current' => 'Current',
|
||||
'Active Power' => 'Active Power',
|
||||
'Power Factor' => 'Power Factor',
|
||||
'Units' => 'Units',
|
||||
])
|
||||
->label('Select Parameter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['parameter' => $state]);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(5);
|
||||
}
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Trend Chart Analysis';
|
||||
// }
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Trend Chart Analysis';
|
||||
// }
|
||||
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (TrendLineChart::canView()) {
|
||||
$widgets[] = TrendLineChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view ems trend line analysis dashboard');
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\DeviceMasterExporter;
|
||||
use App\Filament\Imports\DeviceMasterImporter;
|
||||
use App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
|
||||
use App\Models\DeviceMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class DeviceMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Device Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('mac_address')
|
||||
->label('MAC Address'),
|
||||
Forms\Components\TextInput::make('ip_address')
|
||||
->label('IP Address'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(4),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Device Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mac_address')
|
||||
->label('MAC Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('ip_address')
|
||||
->label('IP Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(DeviceMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import device master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(DeviceMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export device master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDeviceMasters::route('/'),
|
||||
'create' => Pages\CreateDeviceMaster::route('/create'),
|
||||
'view' => Pages\ViewDeviceMaster::route('/{record}'),
|
||||
'edit' => Pages\EditDeviceMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDeviceMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDeviceMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDeviceMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewDeviceMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action as ActionsAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -148,16 +147,16 @@ class InvoiceValidationResource extends Resource
|
||||
->reactive()
|
||||
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || !empty($get('serial_number')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (!$get('plant_id'))
|
||||
if(!$get('plant_id'))
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get('update_invoice') == "1")
|
||||
if($get('update_invoice') === "1")
|
||||
{
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
|
||||
if ($totQuan <= 0)
|
||||
if($totQuan <= 0)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -167,9 +166,9 @@ class InvoiceValidationResource extends Resource
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
|
||||
|
||||
if ($totMQuan > 0)
|
||||
if($totMQuan > 0)
|
||||
{
|
||||
if ($totQuan == $scanMQuan)
|
||||
if ($totQuan === $scanMQuan)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -177,7 +176,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($totQuan == $scanSQuan)
|
||||
if ($totQuan === $scanSQuan)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -343,57 +342,15 @@ class InvoiceValidationResource extends Resource
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$invoicePlantId = $invoiceFirst->plant_id;
|
||||
if ($plantId != $invoicePlantId)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
if ($totQuan > 0 && $totQuan == $scanSQuan)
|
||||
if($totQuan == $scanSQuan && $totQuan > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
@@ -406,7 +363,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0)
|
||||
if((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
@@ -430,7 +387,7 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -441,17 +398,19 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
if (!empty($materialCode))
|
||||
{
|
||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (empty($serialNumber)) {
|
||||
$missingSerials[] = $materialCode;
|
||||
|
||||
}
|
||||
else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -493,6 +452,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!empty($uniqueMissingSerials)) {
|
||||
Notification::make()
|
||||
->title('Missing Serial Numbers')
|
||||
@@ -518,7 +478,7 @@ class InvoiceValidationResource extends Resource
|
||||
else if (!empty($duplicateSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->body('The following serial numbers are already exist in database:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
@@ -571,30 +531,30 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
// Check which codes have a material_type set (not null)
|
||||
$invalidCodes = $matchedItems
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
if (count($invalidCodes) > 10)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body('' . count($invalidCodes) . 'item codes found have material type.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid item codes found')
|
||||
->body('' . count($invalidCodes) . 'item codes found have material type.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (count($invalidCodes) > 0)
|
||||
else if(count($invalidCodes) > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid item codes found')
|
||||
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
@@ -606,7 +566,7 @@ class InvoiceValidationResource extends Resource
|
||||
// Save full file path to session
|
||||
session(['uploaded_invoice_path' => $fullPath]);
|
||||
Notification::make()
|
||||
->title('Serial invoice imported successfully.')
|
||||
->title('Serial invoice imported successfully.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
@@ -642,6 +602,7 @@ class InvoiceValidationResource extends Resource
|
||||
->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_material'];
|
||||
|
||||
@@ -658,52 +619,10 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
|
||||
Notification::make()
|
||||
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$invoicePlantId = $invoiceFirst->plant_id;
|
||||
if ($plantId != $invoicePlantId)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if ($totQuan > 0 && $totQuan == $scanMQuan)
|
||||
if($totQuan == $scanMQuan && $totQuan > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Material invoice already completed the scanning process for selected plant.')
|
||||
@@ -719,7 +638,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0)
|
||||
if((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
@@ -742,7 +661,7 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -752,13 +671,13 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
|
||||
if (!empty($materialCode)) {
|
||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($materialQuantity == 0)
|
||||
if($materialQuantity == 0)
|
||||
{
|
||||
$invalidMaterialQuan[] = $materialCode;
|
||||
}
|
||||
@@ -766,7 +685,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$missingQuantities[] = $materialCode;
|
||||
}
|
||||
else if (!is_numeric($materialQuantity))
|
||||
else if(!is_numeric($materialQuantity))
|
||||
{
|
||||
$invalidMatQuan[] = $materialCode;
|
||||
}
|
||||
@@ -901,7 +820,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (count($invalidCodes) > 0)
|
||||
else if(count($invalidCodes) > 0)
|
||||
{
|
||||
$invalidCodes = array_unique($invalidCodes);
|
||||
Notification::make()
|
||||
@@ -932,29 +851,29 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty == 0) {
|
||||
if ($totalExcelQty === 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) == 0) return;
|
||||
if (count($codes) === 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -1010,16 +929,6 @@ class InvoiceValidationResource extends Resource
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Radio::make('invoice_type')
|
||||
->label('Type ?')
|
||||
->boolean()
|
||||
->options([
|
||||
'Serial' => 'Serial',
|
||||
'Material' => 'Material'
|
||||
])
|
||||
->default('Serial')
|
||||
->inlineLabel(false)
|
||||
->inline(),
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
@@ -1029,7 +938,6 @@ class InvoiceValidationResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('sticker_master_id', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
TextInput::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
@@ -1054,31 +962,6 @@ class InvoiceValidationResource extends Resource
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->nullable()
|
||||
->options([
|
||||
'Scanned' => 'Scanned',
|
||||
'Pending' => 'Pending',
|
||||
])
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId)
|
||||
{
|
||||
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -1092,46 +975,10 @@ class InvoiceValidationResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
if (empty($data['invoice_type']))
|
||||
{
|
||||
Notification::make()
|
||||
->title('Please, choose invoice type to filter.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if ($data['invoice_type'] == 'Serial') {
|
||||
$query->whereNull('quantity');
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
//$query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||
$query->where(function ($query) use ($data) {
|
||||
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
|
||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
} elseif ($data['invoice_type'] == 'Material') {
|
||||
$query->whereNotNull('quantity');//->where('quantity', '>', 0)
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
$query->where(function ($query) use ($data) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
@@ -1152,10 +999,6 @@ class InvoiceValidationResource extends Resource
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
||||
->pluck('id')
|
||||
@@ -1181,15 +1024,6 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Code: ' . $itemCode;
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
@@ -1198,8 +1032,9 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
$indicators[] = 'Scanned Status: ' . $data['scanned_status'];
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Code: ' . $itemCode;
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Imports\ExcelImport;
|
||||
use App\Livewire\InvoiceDataTable;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
||||
@@ -75,22 +74,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
if ($plant)
|
||||
{
|
||||
$plantCode = $plant->code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$plantCode = null;
|
||||
}
|
||||
|
||||
//..GET SERIAL INVOICE API
|
||||
|
||||
|
||||
//..
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
|
||||
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
|
||||
@@ -133,7 +116,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scanMQuan,
|
||||
]);
|
||||
|
||||
if ($totQuan == $scanMQuan)
|
||||
if ($totQuan === $scanMQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Completed: Material Invoice")
|
||||
@@ -151,7 +134,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -164,7 +147,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if($updateStatus == '1')
|
||||
if($updateStatus === '1')
|
||||
{
|
||||
//'Material invoice update in progress...';
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
@@ -202,7 +185,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -407,7 +390,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -416,16 +399,16 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty == 0) {
|
||||
if ($totalExcelQty === 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
@@ -437,7 +420,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) == 0) return;
|
||||
if (count($codes) === 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -469,7 +452,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($matchedItems as $sticker)
|
||||
{
|
||||
if ($newQuan == -1 && !$hasQuanTyp)
|
||||
if ($newQuan === -1 && !$hasQuanTyp)
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '');
|
||||
@@ -478,7 +461,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
}
|
||||
else if ($newQuan == -1 && $hasQuanTyp)
|
||||
else if ($newQuan === -1 && $hasQuanTyp)
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '');
|
||||
@@ -498,7 +481,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -507,7 +490,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -539,7 +522,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -548,7 +531,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -581,7 +564,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -590,7 +573,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty;
|
||||
}
|
||||
}
|
||||
@@ -686,7 +669,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan != $newQuan)
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Material invoice successfully updatad.")
|
||||
@@ -712,13 +695,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -792,7 +775,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
||||
// $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if ($totQuan == $scanSQuan)
|
||||
if ($totQuan === $scanSQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Completed: Serial Invoice")
|
||||
@@ -810,7 +793,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -821,7 +804,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if($updateStatus == '1')
|
||||
if($updateStatus === '1')
|
||||
{
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -863,7 +846,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -1104,7 +1087,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) // Skip header;
|
||||
if ($index === 0) // Skip header;
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where(function($query) {
|
||||
@@ -1155,7 +1138,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan != $newQuan)
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial invoice successfully updated.")
|
||||
@@ -1182,13 +1165,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1300,7 +1283,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$uploadedFilename = pathinfo($fullPath, PATHINFO_FILENAME);
|
||||
|
||||
// Compare with invoice number
|
||||
if ($uploadedFilename != $invoiceNumber) {
|
||||
if ($uploadedFilename !== $invoiceNumber) {
|
||||
Notification::make()
|
||||
->title("Uploaded file name does not match the invoice number.")
|
||||
->danger()
|
||||
@@ -1343,7 +1326,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue;
|
||||
if ($index === 0) continue;
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
|
||||
@@ -1382,7 +1365,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if($invoiceType == 'M')
|
||||
if($invoiceType === 'M')
|
||||
{
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
@@ -1392,7 +1375,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -1595,7 +1578,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1604,23 +1587,23 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty == 0) {
|
||||
if ($totalExcelQty === 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) == 0) return;
|
||||
if (count($codes) === 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -1659,7 +1642,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1668,7 +1651,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1694,7 +1677,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1703,7 +1686,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1728,7 +1711,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1737,7 +1720,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1776,13 +1759,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1822,7 +1805,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($invoiceType == 'S')
|
||||
else if($invoiceType === 'S')
|
||||
{
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
@@ -1834,7 +1817,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -2094,7 +2077,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue;
|
||||
if ($index === 0) continue;
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -2140,13 +2123,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2218,9 +2201,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2272,7 +2255,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
if ($totMQuan > 0)
|
||||
{
|
||||
if ($totQuan == $scanMQuan)
|
||||
if ($totQuan === $scanMQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Material Invoice')
|
||||
@@ -2299,7 +2282,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -2776,7 +2759,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan == $scannedMQuantity)
|
||||
if($totQuan === $scannedMQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Material Invoice')
|
||||
@@ -2803,7 +2786,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2821,7 +2804,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($totQuan == $scanSQuan)
|
||||
if ($totQuan === $scanSQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -2848,7 +2831,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -3021,7 +3004,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadMotorQr == $hasMotorQr)
|
||||
else if($hadMotorQr === $hasMotorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Motor QR')
|
||||
@@ -3044,7 +3027,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->motor_scanned_status = 1;
|
||||
//if($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
//if($hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3055,7 +3038,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt == $scanCnt)
|
||||
if($packCnt === $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3084,7 +3067,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan == $scannedQuantity)
|
||||
if($totQuan === $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3102,7 +3085,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3131,7 +3114,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadPumpQr == $hasPumpQr)
|
||||
else if($hadPumpQr === $hasPumpQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump QR')
|
||||
@@ -3154,7 +3137,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->pump_scanned_status = 1;
|
||||
// if($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpSetQr === $hasPumpSetQr && ($hadCapacitorQr === '1' && $hasCapacitorQr))
|
||||
if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3165,7 +3148,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt == $scanCnt)
|
||||
if($packCnt === $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3194,7 +3177,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan == $scannedQuantity)
|
||||
if($totQuan === $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3212,7 +3195,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3243,7 +3226,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadCapacitorQr == '1' && $hasCapacitorQr)
|
||||
else if($hadCapacitorQr === '1' && $hasCapacitorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Capacitor QR')
|
||||
@@ -3302,7 +3285,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadPumpSetQr == $hasPumpSetQr)
|
||||
else if($hadPumpSetQr === $hasPumpSetQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump Set QR')
|
||||
@@ -3325,7 +3308,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->scanned_status_set = 1;
|
||||
// if($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && ($hadCapacitorQr === '1' && $hasCapacitorQr))
|
||||
if($hasMotorQr || $hasPumpQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3336,7 +3319,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt == $scanCnt)
|
||||
if($packCnt === $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3365,7 +3348,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan == $scannedQuantity)
|
||||
if($totQuan === $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3383,7 +3366,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\MfmMeterExporter;
|
||||
use App\Filament\Imports\MfmMeterImporter;
|
||||
use App\Filament\Resources\MfmMeterResource\Pages;
|
||||
use App\Filament\Resources\MfmMeterResource\RelationManagers;
|
||||
use App\Models\DeviceMaster;
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -17,8 +14,6 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class MfmMeterResource extends Resource
|
||||
{
|
||||
@@ -37,18 +32,6 @@ class MfmMeterResource extends Resource
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('device_master_id')
|
||||
//->relationship('device', 'name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->label('Device Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('sequence')
|
||||
->required(),
|
||||
@@ -66,20 +49,13 @@ class MfmMeterResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('devicemaster.name')
|
||||
->label('Device Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sequence')
|
||||
->label('Sequence')
|
||||
->sortable(),
|
||||
@@ -115,18 +91,6 @@ class MfmMeterResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(MfmMeterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import mfm meter');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(MfmMeterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export mfm meter');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,6 @@ class MfmParameterResource extends Resource
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('device_master_id')
|
||||
->label('Device Master')
|
||||
->relationship('deviceName', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->label('Mfm Meter')
|
||||
->relationship('mfmMeter', 'sequence')
|
||||
@@ -65,7 +61,7 @@ class MfmParameterResource extends Resource
|
||||
->default(1)
|
||||
->required(),
|
||||
])
|
||||
->columns(3),
|
||||
->columns(8),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -73,22 +69,14 @@ class MfmParameterResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deviceName.name')
|
||||
->label('Device Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Sequence')
|
||||
->alignCenter()
|
||||
|
||||
@@ -60,14 +60,11 @@ class MfmReadingResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Filament\Imports\PalletValidationImporter;
|
||||
use App\Filament\Resources\PalletValidationResource\Pages;
|
||||
use App\Filament\Resources\PalletValidationResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
@@ -90,29 +89,13 @@ class PalletValidationResource extends Resource
|
||||
$month = now()->format('m');
|
||||
$prefix = "EP-{$year}{$month}";
|
||||
|
||||
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
|
||||
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
||||
if ($lastPallet1 && $lastPallet2) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
if (intval($serialPart1) > intval($serialPart2)) {
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
else if ($lastPallet1) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
if ($lastPallet) {
|
||||
$serialPart = substr($lastPallet->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
}
|
||||
else if ($lastPallet2) {
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
$newNumber = str_pad(intval($serialPart) + 1, strlen($serialPart), '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||
@@ -538,7 +521,7 @@ class PalletValidationResource extends Resource
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$selectedPalletNumber = $data['pallet_list'];
|
||||
return redirect()->route('download-reprint-qr-pdf', ['palletNo' => $selectedPalletNumber]);
|
||||
return redirect()->route('download-qr-pdf', ['palletNo' => $selectedPalletNumber]);
|
||||
|
||||
})
|
||||
->visible(function() {
|
||||
|
||||
@@ -319,10 +319,8 @@ class ProductionQuantityResource extends Resource
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(7)
|
||||
->maxLength(14)
|
||||
->columnSpan(2)
|
||||
//->rules(['regex:/^[1-9][0-9]{6,}$/'])
|
||||
// ->rules(['regex:/^[1-9][0-9]{6,}$/'])
|
||||
// ->disabled(function ($get) {
|
||||
// return $get('item_code');
|
||||
// })
|
||||
@@ -334,35 +332,15 @@ class ProductionQuantityResource extends Resource
|
||||
return $latestProduction ? $latestProduction->production_order : null;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
||||
{
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
$set('serial_number', null);
|
||||
$set('production_order', null);
|
||||
$set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
|
||||
$set('validationError', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('production_order', $state);
|
||||
$set('prodOrdError', null);
|
||||
$set('validationError', null);
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('prodOrdError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('prodOrdError') ? $get('prodOrdError') : null)
|
||||
->hintColor('danger'),
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}),
|
||||
Forms\Components\TextInput::make('item_code')
|
||||
->label('Item Code')
|
||||
// ->required()
|
||||
@@ -1057,7 +1035,6 @@ class ProductionQuantityResource extends Resource
|
||||
$set('Shift', null);
|
||||
$set('Item', null);
|
||||
$set('sap_msg_status', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//line
|
||||
@@ -1073,10 +1050,7 @@ class ProductionQuantityResource extends Resource
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
->reactive(),
|
||||
|
||||
//block
|
||||
Select::make('Block')
|
||||
@@ -1093,7 +1067,6 @@ class ProductionQuantityResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Shift', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//shift
|
||||
@@ -1112,10 +1085,7 @@ class ProductionQuantityResource extends Resource
|
||||
->where('block_id', $blockId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
->reactive(),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
@@ -1163,37 +1133,6 @@ class ProductionQuantityResource extends Resource
|
||||
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
|
||||
->reactive(),
|
||||
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
$shiftId = $get('Shift');
|
||||
if (!$plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && $lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else// if ($plantId && $lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -1207,7 +1146,7 @@ class ProductionQuantityResource extends Resource
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['operator_id']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1239,10 +1178,6 @@ class ProductionQuantityResource extends Resource
|
||||
$query->where('sap_msg_status', $data['sap_msg_status']);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
if ($from = $data['created_from'] ?? null) {
|
||||
$query->where('created_at', '>=', $from);
|
||||
}
|
||||
@@ -1250,7 +1185,6 @@ class ProductionQuantityResource extends Resource
|
||||
if ($to = $data['created_to'] ?? null) {
|
||||
$query->where('created_at', '<=', $to);
|
||||
}
|
||||
|
||||
// return $query;
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
@@ -1284,10 +1218,6 @@ class ProductionQuantityResource extends Resource
|
||||
$indicators[] = 'SAP Message Status: ' . $data['sap_msg_status'];
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
|
||||
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -354,7 +354,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
|
||||
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -62,14 +62,10 @@ class TempLiveReadingResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
@@ -117,16 +113,6 @@ class TempLiveReadingResource extends Resource
|
||||
//
|
||||
];
|
||||
}
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
|
||||
public static function getHeading(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
|
||||
@@ -9,9 +9,4 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateTempLiveReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Create Live Readings';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,4 @@ class EditTempLiveReading extends EditRecord
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Edit Live Readings';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,4 @@ class ListTempLiveReadings extends ListRecords
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,4 @@ class ViewTempLiveReading extends ViewRecord
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'View Live Readings';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,553 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\MfmReading;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Support\RawJs;
|
||||
|
||||
class TrendChartAnalysis extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Trend Chart Analysis';
|
||||
|
||||
|
||||
protected static ?string $maxHeight = '420px';
|
||||
|
||||
|
||||
protected int|string|array $columnSpan = 12;
|
||||
|
||||
// Add a property to receive filters from parent or externally
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$fromDatetime = session('from_datetime');
|
||||
$toDatetime = session('to_datetime');
|
||||
$selectedPlant = session('selected_plant');
|
||||
$meterId = session('selected_meter');
|
||||
$parameter = session('parameter');
|
||||
|
||||
if (empty($fromDatetime) || empty($toDatetime) || empty($selectedPlant) || empty($meterId) || empty($parameter)) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$fromDateTime = Carbon::parse($fromDatetime);
|
||||
$toDateTime = Carbon::parse($toDatetime);
|
||||
|
||||
if ($fromDateTime->gt($toDateTime) || $fromDateTime->gt(now()) || $toDateTime->gt(now())) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$durationHours = $fromDateTime->diffInHours($toDateTime);
|
||||
//dd($durationHours);
|
||||
if ($durationHours < 1 || $durationHours > 24) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$intervalCount = $durationHours > 12 ? 12 : 10;
|
||||
$intervalMinutes = $durationHours > 12 ? 120 : floor(($durationHours * 60) / $intervalCount);
|
||||
|
||||
$labels = [];
|
||||
|
||||
if ($parameter == 'Phase Voltage') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$voltageRYSummary = $dataAggregation('voltage_ry');
|
||||
$voltageYBSummary = $dataAggregation('voltage_yb');
|
||||
$voltageBRSummary = $dataAggregation('voltage_br');
|
||||
$frequencySummary = $dataAggregation('frequency');
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'Voltage RY Min', 'Voltage RY Max', 'Voltage RY Avg',
|
||||
'Voltage YB Min', 'Voltage YB Max', 'Voltage YB Avg',
|
||||
'Voltage BR Min', 'Voltage BR Max', 'Voltage BR Avg',
|
||||
'Frequency Min', 'Frequency Max', 'Frequency Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$voltageRYSummary['min'], $voltageRYSummary['max'], $voltageRYSummary['avg'],
|
||||
$voltageYBSummary['min'], $voltageYBSummary['max'], $voltageYBSummary['avg'],
|
||||
$voltageBRSummary['min'], $voltageBRSummary['max'], $voltageBRSummary['avg'],
|
||||
$frequencySummary['min'], $frequencySummary['max'], $frequencySummary['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else if ($parameter == 'Line Voltage') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$voltageRNSummary = $dataAggregation('voltage_r_n');
|
||||
$voltageYNSummary = $dataAggregation('voltage_y_n');
|
||||
$voltageBNSummary = $dataAggregation('voltage_b_n');
|
||||
$frequencySummary = $dataAggregation('frequency');
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'Voltage RN Min', 'Voltage RN Max', 'Voltage RN Avg',
|
||||
'Voltage YN Min', 'Voltage YN Max', 'Voltage YN Avg',
|
||||
'Voltage BN Min', 'Voltage BN Max', 'Voltage BN Avg',
|
||||
'Frequency Min', 'Frequency Max', 'Frequency Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$voltageRNSummary['min'], $voltageRNSummary['max'], $voltageRNSummary['avg'],
|
||||
$voltageYNSummary['min'], $voltageYNSummary['max'], $voltageYNSummary['avg'],
|
||||
$voltageBNSummary['min'], $voltageBNSummary['max'], $voltageBNSummary['avg'],
|
||||
$frequencySummary['min'], $frequencySummary['max'], $frequencySummary['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else if ($parameter == 'Current') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$curR = $dataAggregation('current_r');
|
||||
$curY = $dataAggregation('current_y');
|
||||
$curB = $dataAggregation('current_b');
|
||||
$curN = $dataAggregation('current_n');
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'Current R Min', 'Current R Max', 'Current R Avg',
|
||||
'Current Y Min', 'Current Y Max', 'Current Y Avg',
|
||||
'Current B Min', 'Current B Max', 'Current B Avg',
|
||||
'Current N Min', 'Current N Max', 'Current N Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$curR['min'], $curR['max'], $curR['avg'],
|
||||
$curY['min'], $curY['max'], $curY['avg'],
|
||||
$curB['min'], $curB['max'], $curB['avg'],
|
||||
$curN['min'], $curN['max'], $curN['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else if ($parameter == 'Active Power') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$activePowR = $dataAggregation('active_power_r');
|
||||
$activePowY = $dataAggregation('active_power_y');
|
||||
$activePowB = $dataAggregation('active_power_b');
|
||||
$activePowTot = $dataAggregation('active_power_total');
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'ActivePow R Min', 'ActivePow R Max', 'ActivePow R Avg',
|
||||
'ActivePow Y Min', 'ActivePow Y Max', 'ActivePow Y Avg',
|
||||
'ActivePow B Min', 'ActivePow B Max', 'ActivePow B Avg',
|
||||
'ActivePow Tot Min', 'ActivePow Tot Max', 'ActivePow Tot Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$activePowR['min'], $activePowR['max'], $activePowR['avg'],
|
||||
$activePowY['min'], $activePowY['max'], $activePowY['avg'],
|
||||
$activePowB['min'], $activePowB['max'], $activePowB['avg'],
|
||||
$activePowTot['min'], $activePowTot['max'], $activePowTot['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else if ($parameter == 'Power Factor') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$powFacR = $dataAggregation('power_factor_r');
|
||||
$powFacY = $dataAggregation('power_factor_y');
|
||||
$powFacB = $dataAggregation('power_factor_b');
|
||||
$powFacTot = $dataAggregation('power_factor_total');
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'PowerFac R Min', 'PowerFac R Max', 'PowerFac R Avg',
|
||||
'PowerFac Y Min', 'PowerFac Y Max', 'PowerFac Y Avg',
|
||||
'PowerFac B Min', 'PowerFac B Max', 'PowerFac B Avg',
|
||||
'PowerFac Tot Min', 'PowerFac Tot Max', 'PowerFac Tot Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$powFacR['min'], $powFacR['max'], $powFacR['avg'],
|
||||
$powFacY['min'], $powFacY['max'], $powFacY['avg'],
|
||||
$powFacB['min'], $powFacB['max'], $powFacB['avg'],
|
||||
$powFacTot['min'], $powFacTot['max'], $powFacTot['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else if ($parameter == 'Units') {
|
||||
|
||||
// Helper function to get min, max, avg for a column with PostgreSQL casting
|
||||
$dataAggregation = function (string $column) use ($fromDateTime, $toDateTime, $meterId) {
|
||||
$min = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->min(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$max = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->max(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
$avg = MfmReading::whereBetween('created_at', [$fromDateTime, $toDateTime])
|
||||
->where('mfm_meter_id', $meterId)
|
||||
->avg(\Illuminate\Support\Facades\DB::raw("{$column}::double precision"));
|
||||
|
||||
return [
|
||||
'min' => round($min ?? 0, 2),
|
||||
'max' => round($max ?? 0, 2),
|
||||
'avg' => round($avg ?? 0, 2),
|
||||
];
|
||||
};
|
||||
|
||||
// Get aggregated data for all relevant columns
|
||||
$appEneRec = $dataAggregation('apparent_energy_received');
|
||||
$reaEneRec = $dataAggregation('reactive_energy_received');
|
||||
$actEneRec = $dataAggregation('active_energy_received');
|
||||
|
||||
|
||||
// Labels for each bar on X-axis (min, max, avg per column)
|
||||
$labels = [
|
||||
'AppEneRec Min', 'AppEneRec Max', 'AppEneRec Avg',
|
||||
'ReaEneRec Min', 'ReaEneRec Max', 'ReaEneRec Avg',
|
||||
'ActEneRec Min', 'ActEneRec Max', 'ActEneRec Avg',
|
||||
];
|
||||
|
||||
// Ordered data values matching labels above
|
||||
$dataValues = [
|
||||
$appEneRec['min'], $appEneRec['max'], $appEneRec['avg'],
|
||||
$reaEneRec['min'], $reaEneRec['max'], $reaEneRec['avg'],
|
||||
$actEneRec['min'], $actEneRec['max'], $actEneRec['avg'],
|
||||
];
|
||||
|
||||
// Colors by aggregation type: Min - yellow, Max - green, Avg - blue
|
||||
$aggregationColors = [
|
||||
'rgba(204, 163, 0, 0.8)', // Darker yellow (Min)
|
||||
'rgba(30, 120, 120, 0.8)', // Darker teal/green (Max)
|
||||
'rgba(30, 90, 140, 0.8)', // Darker blue (Avg)
|
||||
];
|
||||
|
||||
// Each set of 3 bars per column repeats the colors: min, max, avg
|
||||
$backgroundColorArray = [];
|
||||
foreach (range(1, 4) as $group) { // 4 column groups
|
||||
foreach ($aggregationColors as $color) {
|
||||
$backgroundColorArray[] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct chart data structure
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Phase Voltage & Frequency Stats',
|
||||
// Bar values array: 12 bars total (4 groups × 3 stats each)
|
||||
'data' => $dataValues,
|
||||
'backgroundColor' => $backgroundColorArray,
|
||||
'borderColor' => array_map(fn ($clr) => str_replace('0.6', '1', $clr), $backgroundColorArray),
|
||||
'borderWidth' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = [];
|
||||
$labels = [];
|
||||
$currentStart = $fromDateTime->copy();
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => ucfirst(str_replace('_', ' ', $parameter)),
|
||||
'data' => $data,
|
||||
'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
||||
'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||
'fill' => false,
|
||||
'tension' => 0.3,
|
||||
'pointRadius' => 5,
|
||||
'pointHoverRadius' => 7,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'plugins' => [
|
||||
'datalabels' => [
|
||||
'anchor' => 'start',
|
||||
'align' => 'start',
|
||||
'offset' => -15,
|
||||
'color' => '#000',
|
||||
'font' => [
|
||||
'weight' => 'bold',
|
||||
],
|
||||
'formatter' => RawJs::make('function(value) {
|
||||
return value;
|
||||
}'),
|
||||
],
|
||||
],
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true,
|
||||
'ticks' => [
|
||||
'stepSize' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\MfmReading;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class TrendLineChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Trend Line Analysis';
|
||||
|
||||
protected static ?string $maxHeight = '420px';
|
||||
|
||||
protected int|string|array $columnSpan = 12;
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$fromDatetime = session('from_datetime');
|
||||
$toDatetime = session('to_datetime');
|
||||
$selectedPlant = session('selected_plant');
|
||||
$meterId = session('selected_meter');
|
||||
$parameter = session('parameter');
|
||||
|
||||
if (empty($fromDatetime) || empty($toDatetime) || empty($selectedPlant) || empty($meterId) || empty($parameter)) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$fromDateTime = Carbon::parse($fromDatetime);
|
||||
$toDateTime = Carbon::parse($toDatetime);
|
||||
|
||||
if ($fromDateTime->gt($toDateTime) || $fromDateTime->gt(now()) || $toDateTime->gt(now())) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$durationHours = $fromDateTime->diffInHours($toDateTime);
|
||||
if ($durationHours < 1 || $durationHours > 24) {
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$intervalCount = $durationHours > 12 ? 12 : 10;
|
||||
$intervalMinutes = $durationHours > 12 ? 120 : floor(($durationHours * 60) / $intervalCount);
|
||||
|
||||
$labels = [];
|
||||
$columnMap = [];
|
||||
$datasetColors = [];
|
||||
$dataSeries = [];
|
||||
|
||||
// Determine columns and labels based on selected parameter
|
||||
switch ($parameter) {
|
||||
case 'Phase Voltage':
|
||||
$columnMap = [
|
||||
'voltage_ry' => 'Voltage RY Max',
|
||||
'voltage_yb' => 'Voltage YB Max',
|
||||
'voltage_br' => 'Voltage BR Max',
|
||||
'frequency' => 'Frequency Max',
|
||||
];
|
||||
$datasetColors = [
|
||||
'voltage_ry' => 'rgba(255, 99, 132, 1)', // red
|
||||
'voltage_yb' => 'rgba(54, 162, 235, 1)', // blue
|
||||
'voltage_br' => 'rgba(255, 206, 86, 1)', // yellow
|
||||
'frequency' => 'rgba(75, 192, 192, 1)', // teal
|
||||
];
|
||||
break;
|
||||
|
||||
case 'Line Voltage':
|
||||
$columnMap = [
|
||||
'voltage_r_n' => 'Voltage R-N Max',
|
||||
'voltage_y_n' => 'Voltage Y-N Max',
|
||||
'voltage_b_n' => 'Voltage B-N Max',
|
||||
'frequency' => 'Frequency Max',
|
||||
];
|
||||
$datasetColors = [
|
||||
'voltage_r_n' => 'rgba(153, 102, 255, 1)', // purple
|
||||
'voltage_y_n' => 'rgba(255, 159, 64, 1)', // orange
|
||||
'voltage_b_n' => 'rgba(0, 200, 83, 1)', // green
|
||||
'frequency' => 'rgba(75, 192, 192, 1)', // teal
|
||||
];
|
||||
break;
|
||||
case 'Current':
|
||||
$columnMap = [
|
||||
'current_r' => 'Current R Max',
|
||||
'current_y' => 'Current Y Max',
|
||||
'current_b' => 'Current B Max',
|
||||
'current_n' => 'Current N Max ',
|
||||
];
|
||||
$datasetColors = [
|
||||
'current_r' => 'rgba(153, 102, 255, 1)', // purple
|
||||
'current_y' => 'rgba(255, 159, 64, 1)', // orange
|
||||
'current_b' => 'rgba(0, 200, 83, 1)', // green
|
||||
'current_n' => 'rgba(75, 192, 192, 1)', // teal
|
||||
];
|
||||
break;
|
||||
|
||||
case 'Active Power':
|
||||
$columnMap = [
|
||||
'active_power_r' => 'Active Pow R Max',
|
||||
'active_power_y' => 'Active Pow Y Max',
|
||||
'active_power_b' => 'Active Pow B Max',
|
||||
'active_power_total' => 'Active Pow Tot Max ',
|
||||
];
|
||||
$datasetColors = [
|
||||
'active_power_r' => 'rgba(153, 102, 255, 1)', // purple
|
||||
'active_power_y' => 'rgba(255, 159, 64, 1)', // orange
|
||||
'active_power_b' => 'rgba(0, 200, 83, 1)', // green
|
||||
'active_power_total' => 'rgba(75, 192, 192, 1)', // teal
|
||||
];
|
||||
break;
|
||||
|
||||
case 'Power Factor':
|
||||
$columnMap = [
|
||||
'power_factor_r' => 'Power Fac R Max',
|
||||
'power_factor_y' => 'Power Fac Y Max',
|
||||
'power_factor_b' => 'Power Fac B Max',
|
||||
'power_factor_total' => 'Power Fac Tot Max ',
|
||||
];
|
||||
$datasetColors = [
|
||||
'power_factor_r' => 'rgba(153, 102, 255, 1)', // purple
|
||||
'power_factor_y' => 'rgba(255, 159, 64, 1)', // orange
|
||||
'power_factor_b' => 'rgba(0, 200, 83, 1)', // green
|
||||
'power_factor_total' => 'rgba(75, 192, 192, 1)', // teal
|
||||
];
|
||||
break;
|
||||
|
||||
case 'Units':
|
||||
$columnMap = [
|
||||
'apparent_energy_received' => 'AppEneRec Max',
|
||||
'reactive_energy_received' => 'ReacEneRec Max',
|
||||
'active_energy_received' => 'ActiveEneRec Max',
|
||||
];
|
||||
$datasetColors = [
|
||||
'apparent_energy_received' => 'rgba(153, 102, 255, 1)', // purple
|
||||
'reactive_energy_received' => 'rgba(255, 159, 64, 1)', // orange
|
||||
'active_energy_received' => 'rgba(0, 200, 83, 1)', // green
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
return [
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
}
|
||||
|
||||
// Initialize empty arrays for each data series
|
||||
foreach ($columnMap as $column => $label) {
|
||||
$dataSeries[$column] = [];
|
||||
}
|
||||
|
||||
$current = $fromDateTime->copy();
|
||||
while ($current < $toDateTime) {
|
||||
$next = $current->copy()->addMinutes($intervalMinutes);
|
||||
|
||||
$selectParts = [];
|
||||
foreach ($columnMap as $column => $label) {
|
||||
$selectParts[] = "MAX({$column}::double precision) as {$column}";
|
||||
}
|
||||
|
||||
$readings = MfmReading::where('mfm_meter_id', $meterId)
|
||||
->whereBetween('created_at', [$current, $next])
|
||||
->selectRaw(implode(', ', $selectParts))
|
||||
->first();
|
||||
|
||||
$labels[] = $current->format('H:i');
|
||||
|
||||
foreach ($columnMap as $column => $label) {
|
||||
$dataSeries[$column][] = round($readings->{$column} ?? 0, 2);
|
||||
}
|
||||
|
||||
$current = $next;
|
||||
}
|
||||
|
||||
// Construct dataset array
|
||||
$datasets = [];
|
||||
foreach ($columnMap as $column => $label) {
|
||||
$datasets[] = [
|
||||
'label' => $label,
|
||||
'data' => $dataSeries[$column],
|
||||
'borderColor' => $datasetColors[$column],
|
||||
'backgroundColor' => str_replace('1)', '0.2)', $datasetColors[$column]),
|
||||
'fill' => false,
|
||||
'tension' => 0.1,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => $datasets,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
@@ -1,811 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Illuminate\Http\Request;
|
||||
use Str;
|
||||
|
||||
class InvoiceValidationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function serialInvoice(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
if (!isset($data['plant_code']) || trim($data['plant_code']) == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['plant_code']) < 4 || !is_numeric($data['plant_code']) || !preg_match('/^[1-9]\d{3,}$/', $data['plant_code']))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
if (!isset($data['item_codes']) || !is_array($data['item_codes']) || count($data['item_codes']) == 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'item_codes is required and must be a non-empty array!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking invoice number for empty or invalid length
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? null;
|
||||
|
||||
if (!$invoiceNumber || trim($invoiceNumber) == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'invoice_number is required!'
|
||||
], 400);
|
||||
}
|
||||
else if (strlen(trim($invoiceNumber)) < 7)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'invoice number must contain at least 7 alphanumeric characters.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking item codes for invalid length
|
||||
|
||||
$invalidItem = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (!isset($item['item_code']) || strlen(trim($item['item_code'])) < 6) {
|
||||
$invalidItem[] = $item['item_code'] ?? '(missing item_code)';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalidItem)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item codes have invalid length (less than 6 characters)',
|
||||
'invalid_item_codes' => $invalidItem
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking item codes for invalid characters
|
||||
|
||||
$invalidItemCodes = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemCode = $item['item_code'] ?? '';
|
||||
$trimmedCode = trim($itemCode);
|
||||
if ($trimmedCode == '' || !ctype_alnum($trimmedCode))
|
||||
{
|
||||
$invalidItemCodes[] = $item;
|
||||
}
|
||||
}
|
||||
if (!empty($invalidItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item_code(s) contain invalid characters (only alphanumeric allowed).',
|
||||
'invalid_item_codes' => array_map(function($item) {
|
||||
return $item['item_code'] ?? '(missing item_code)';
|
||||
}, $invalidItemCodes)
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking serial numbers for length less than 9 characters
|
||||
|
||||
$invalidSerials = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (isset($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
if (strlen(trim($serial)) < 9)
|
||||
{
|
||||
$invalidSerials[] = $serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($invalidSerials)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following serial numbers have invalid length (less than 9 characters)',
|
||||
'invalid_serial_numbers' => $invalidSerials
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking serial numbers for invalid characters
|
||||
|
||||
$invalidSerialNumbers = [];
|
||||
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (isset($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
$trimmedSerial = trim($serial);
|
||||
if ($trimmedSerial == '' || !ctype_alnum($trimmedSerial)) {
|
||||
$invalidSerialNumbers[] = $serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalidSerialNumbers)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following serial number(s) contain invalid characters (only alphanumeric allowed).',
|
||||
'invalid_serial_numbers' => $invalidSerialNumbers
|
||||
], 400);
|
||||
}
|
||||
|
||||
//Duplicate item code within json payload
|
||||
$duplicateItemCode = [];
|
||||
$seenCodes = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$code = $item['item_code'] ?? null;
|
||||
if ($code == null) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($code, $seenCodes))
|
||||
{
|
||||
if (!in_array($code, array_column($duplicateItemCode, 'item_code'))) {
|
||||
$duplicateItemCode[] = $item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$seenCodes[] = $code;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($duplicateItemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Duplicate item_code found in request payload.",
|
||||
'duplicate_item_codes' => array_map(function($item) {
|
||||
return $item['item_code'] ?? '(missing item_code)';
|
||||
}, $duplicateItemCode)
|
||||
], 400);
|
||||
}
|
||||
|
||||
//Duplicate serial numbers within all item_codes
|
||||
$duplicateSno = [];
|
||||
$seenSerials = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
if (isset($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
if (in_array($serial, $seenSerials)) {
|
||||
if (!in_array($serial, $duplicateSno)) {
|
||||
$duplicateSno[] = $serial;
|
||||
}
|
||||
} else {
|
||||
$seenSerials[] = $serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($duplicateSno)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Duplicate serial number found in request payload.",
|
||||
'duplicate_serial_numbers' => $duplicateSno
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking invoice number against plant in invoice validation table
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->count();
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial invoice number : '$invoiceNumber' completed the scanning process. Scan the next 'Serial Invoice' to proceed!",
|
||||
], 400);
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $invoiceNumber)->first();
|
||||
$plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
if ($data['plant_code'] != $plantCode)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial invoice number : '$invoiceNumber' already exists for plant code : '$plantCode'. Pass the valid 'Plant Code' proceed!",
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//In item codes array serial numbers not exists
|
||||
$snoNotExist = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
if (!isset($item['item_code']) || !isset($item['serial_numbers']) || !is_array($item['serial_numbers']))
|
||||
{
|
||||
//$snoNotExist[] = $item;
|
||||
$snoNotExist[] = $item['item_code'] ?? '(missing item_code)';
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($snoNotExist)){
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "item_codes array must have an item_code and an array of serial_numbers below item code doesn't have serial number array.",
|
||||
'item_codes' => $snoNotExist
|
||||
], 400);
|
||||
}
|
||||
|
||||
$notFoundItemCodes = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemRecord = Item::where('code', $item['item_code'])->first();
|
||||
if (!$itemRecord) {
|
||||
$notFoundItemCodes[] = $item['item_code'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemId = $itemRecord->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($notFoundItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in items table",
|
||||
'item_codes' =>$notFoundItemCodes
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking Item Code aginst Plant in items table
|
||||
$plant = Plant::find($plantId);
|
||||
$notFouItePlant = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemRec = Item::where('code', $item['item_code'])
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
if (!$itemRec) {
|
||||
$notFouItePlant[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($notFouItePlant)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in items table for plant '" . ($plant ? $plant->name : 'Unknown'). "'",
|
||||
'item_codes' => $notFouItePlant
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
$notFouItemCodesStiMas = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
$itemRecord = Item::where('code', $item['item_code'])->first();
|
||||
if ($itemRecord) {
|
||||
$itemId = $itemRecord->id;
|
||||
$stickerMasterRecord = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (!$stickerMasterRecord) {
|
||||
$notFouItemCodesStiMas[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$notFouItemCodesStiMas[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($notFouItemCodesStiMas)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item code(s) were not found in sticker master table',
|
||||
'item_codes' => $notFouItemCodesStiMas
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
//..Checking Item Code in sticker master table aginst Plant
|
||||
|
||||
$notFouIteStickerPlant = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$stickerMasterRec = StickerMaster::where('item_id', $itemId)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
if (!$stickerMasterRec) {
|
||||
$notFouIteStickerPlant[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($notFouIteStickerPlant)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in sticker master table for plant'" . ($plant ? $plant->name : 'Unknown'). "'",
|
||||
'item_codes' => $notFouIteStickerPlant
|
||||
], 400);
|
||||
}
|
||||
|
||||
$invalidSerialMasType = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
$itemRecord = Item::where('code', $item['item_code'])->first();
|
||||
|
||||
$itemId = $itemRecord->id;
|
||||
|
||||
$stickerMaster = StickerMaster::where('item_id', $itemId)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNotNull('material_type')
|
||||
->where('material_type', '!=', 0)
|
||||
->first();
|
||||
|
||||
if ($stickerMaster) {
|
||||
$invalidSerialMasType[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($invalidSerialMasType)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item code(s) not belongs to serial invoice type in sticker master table',
|
||||
'item_codes' => $invalidSerialMasType
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$allSerialNumbers = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (isset($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
$allSerialNumbers[] = $serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check database for existing serial numbers for this plant
|
||||
$existingSerials = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', '!=', $invoiceNumber)
|
||||
->whereIn('serial_number', $allSerialNumbers)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
if (!empty($existingSerials)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'serial numbers already exist for this plant in database.',
|
||||
'duplicate_serial_numbers' => $existingSerials,
|
||||
], 400);
|
||||
}
|
||||
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where(function($query) {
|
||||
$query->whereNull('motor_scanned_status')->orWhere('motor_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('pump_scanned_status')->orWhere('pump_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('capacitor_scanned_status')->orWhere('capacitor_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status_set')->orWhere('scanned_status_set', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||
})
|
||||
->forceDelete(); //->delete();
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$stickerMasterId = $stickerMasterRecord->id;
|
||||
|
||||
if (!isset($item['serial_numbers']) || !is_array($item['serial_numbers'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
$exists = InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('serial_number', $serial)
|
||||
->first();
|
||||
if ($exists)
|
||||
{
|
||||
$exists->updated_at = now();
|
||||
$exists->save();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
InvoiceValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'item_code' => $item['item_code'],
|
||||
'serial_number' => $serial,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Serial Invoice imported successfully!'
|
||||
], 200);
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Failed to insert one or more serial invoice records: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$allSerialNumbers = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (isset($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
$allSerialNumbers[] = $serial;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check database for existing serial numbers for this plant
|
||||
$existingSerials = InvoiceValidation::where('plant_id', $plantId)
|
||||
->whereIn('serial_number', $allSerialNumbers)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
if (!empty($existingSerials)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'serial numbers already exist for this plant in database.',
|
||||
'duplicate_serial_numbers' => $existingSerials,
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..
|
||||
try
|
||||
{
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$stickerMasterId = $stickerMasterRecord->id;
|
||||
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
InvoiceValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'item_code' => $item['item_code'],
|
||||
'serial_number' => $serial,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Serial Invoice imported successfully!'
|
||||
], 200);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Failed to insert one or more serial invoice records: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function materialInvoice(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$data = $request->all();
|
||||
if (!isset($data['plant_code']) || trim($data['plant_code']) == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['plant_code']) < 4 || !is_numeric($data['plant_code']) || !preg_match('/^[1-9]\d{3,}$/', $data['plant_code']))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? null;
|
||||
|
||||
if (!$invoiceNumber || trim($invoiceNumber) == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'invoice_number is required!'
|
||||
], 400);
|
||||
}
|
||||
else if (strlen(trim($invoiceNumber)) < 7)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'invoice number must contain at least 7 alphanumeric characters.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking item codes for invalid length
|
||||
|
||||
$invalidItem = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (!isset($item['item_code']) || strlen(trim($item['item_code'])) < 6) {
|
||||
$invalidItem[] = $item['item_code'] ?? '(missing item_code)';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalidItem)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item codes have invalid length (less than 6 characters)',
|
||||
'invalid_item_codes' => $invalidItem
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking item codes for invalid characters
|
||||
|
||||
$invalidItemCodes = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemCode = $item['item_code'] ?? '';
|
||||
$trimmedCode = trim($itemCode);
|
||||
if ($trimmedCode == '' || !ctype_alnum($trimmedCode))
|
||||
{
|
||||
$invalidItemCodes[] = $item;
|
||||
}
|
||||
}
|
||||
if (!empty($invalidItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item_code(s) contain invalid characters (only alphanumeric allowed).',
|
||||
'invalid_item_codes' => array_map(function($item) {
|
||||
return $item['item_code'] ?? '(missing item_code)';
|
||||
}, $invalidItemCodes)
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking item codes in items table
|
||||
|
||||
$notFoundItemCodes = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemRecord = Item::where('code', $item['item_code'])->first();
|
||||
if (!$itemRecord) {
|
||||
$notFoundItemCodes[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
|
||||
$itemId = $itemRecord->id;
|
||||
if (!empty($notFoundItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in items table",
|
||||
'item_codes' =>$notFoundItemCodes
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking Item Code in sticker master table
|
||||
|
||||
$notFouItemCodesStiMas = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$stickerMasterRecord = StickerMaster::where('item_id', $itemId)->first();
|
||||
if (!$stickerMasterRecord) {
|
||||
$notFouItemCodesStiMas[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($notFouItemCodesStiMas)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item code(s) were not found in sticker master table',
|
||||
'item_codes' => $notFouItemCodesStiMas
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking Item Code aginst Plant in items table
|
||||
$plant = Plant::find($plantId);
|
||||
$notFouItePlant = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$itemRec = Item::where('code', $item['item_code'])
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
if (!$itemRec) {
|
||||
$notFouItePlant[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($notFouItePlant)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in items table for plant '" . ($plant ? $plant->name : 'Unknown'). "'",
|
||||
'item_codes' => $notFouItePlant
|
||||
], 400);
|
||||
}
|
||||
|
||||
//..Checking Item Code in sticker master table aginst Plant
|
||||
|
||||
$notFouIteStickerPlant = [];
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$stickerMasterRec = StickerMaster::where('item_id', $itemId)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
if (!$stickerMasterRec) {
|
||||
$notFouIteStickerPlant[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($notFouIteStickerPlant)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The following item code(s) were not found in sticker master table for plant'" . ($plant ? $plant->name : 'Unknown'). "'",
|
||||
'item_codes' => $notFouIteStickerPlant
|
||||
], 400);
|
||||
}
|
||||
|
||||
$invalidMaterialType = [];
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
$itemRecord = Item::where('code', $item['item_code'])->first();
|
||||
|
||||
$itemId = $itemRecord->id;
|
||||
|
||||
$stickerMaster = StickerMaster::where('item_id', $itemId)
|
||||
->where('plant_id', $plantId)
|
||||
->where(function($query) {
|
||||
$query->whereNull('material_type')
|
||||
->orWhere('material_type', 0);
|
||||
})
|
||||
->first();
|
||||
|
||||
if ($stickerMaster) {
|
||||
$invalidMaterialType[] = $item['item_code'];
|
||||
}
|
||||
}
|
||||
if (!empty($invalidMaterialType)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'The following item code(s) belongs to seial invoice type in sticker master table',
|
||||
'item_codes' => $invalidMaterialType
|
||||
], 400);
|
||||
}
|
||||
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$quantity = isset($item['item_quantity']) ? (int)$item['item_quantity'] : null;
|
||||
|
||||
InvoiceValidation::create([
|
||||
'plant_id' => $plantId,
|
||||
'item_code' => $item['item_code'],
|
||||
'item_quantity' => $quantity,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Invoice validation records inserted successfully.'
|
||||
], 200);
|
||||
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DeviceMaster;
|
||||
use App\Models\MfmMeter;
|
||||
use App\Models\MfmParameter;
|
||||
use App\Models\Plant;
|
||||
@@ -96,7 +95,6 @@ class MfmParameterController extends Controller
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$mfmParameterSeq = $request->header('mfm-meter-sequence');
|
||||
$deviceName = $request->header('device-name');
|
||||
|
||||
if (!$plantCode) {
|
||||
return response()->json([
|
||||
@@ -110,17 +108,9 @@ class MfmParameterController extends Controller
|
||||
'status_description' => "Mfm Parameter sequence value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
else if (!$deviceName) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Device name value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
$device = DeviceMaster::where('name', $deviceName)->first();
|
||||
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
@@ -128,11 +118,9 @@ class MfmParameterController extends Controller
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Find mfm_meter by sequence and plant_id
|
||||
$mfmMeter = MfmMeter::where('sequence', trim($mfmParameterSeq))
|
||||
->where('plant_id', $plant->id)
|
||||
->where('device_master_id', $device->id)
|
||||
->first();
|
||||
|
||||
if (!$mfmMeter) {
|
||||
@@ -145,7 +133,6 @@ class MfmParameterController extends Controller
|
||||
// Now fetch mfm_parameters for this plant and meter
|
||||
$mfmParameters = MfmParameter::where('plant_id', $plant->id)
|
||||
->where('mfm_meter_id', $mfmMeter->id)
|
||||
->where('device_master_id', $device->id)
|
||||
->get(['register_id', 'byte_to_convert', 'type_to_convert', 'decimal_to_display']);
|
||||
|
||||
$transformed = $mfmParameters->map(function ($item) {
|
||||
@@ -172,7 +159,7 @@ class MfmParameterController extends Controller
|
||||
if ($transformed->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "No MFM parameters found for the specified plant,meter and device name."
|
||||
'status_description' => "No MFM parameters found for the specified plant and meter."
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,17 +128,10 @@ class ModulePlantLineController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$normalizedChartName = strtolower(trim($chartName));
|
||||
|
||||
if ($normalizedChartName != 'production order count' && $normalizedChartName != 'production hourly count' && $normalizedChartName != 'production line stop count') {
|
||||
if (strtolower(trim($chartName)) != 'production hourly count') {
|
||||
array_unshift($nonFgLines, 'All Lines');
|
||||
}
|
||||
|
||||
|
||||
// if (strtolower(trim($chartName)) != 'production hourly count') {
|
||||
// array_unshift($nonFgLines, 'All Lines');
|
||||
// }
|
||||
|
||||
// Add "All Lines" to beginning and "FG Lines" at the end
|
||||
// array_unshift($nonFgLines, 'All Lines');
|
||||
// $nonFgLines[] = 'FG Line';
|
||||
|
||||
@@ -17,23 +17,23 @@ class PalletController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function downloadReprintQrPdf($palletNo)
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png();
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
return '
|
||||
$html = '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { margin: 0; padding: 0; width: 60mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
|
||||
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; page-break-after: always; }
|
||||
.qr-cell { width: 14mm; text-align: right; vertical-align: bottom; padding-left: 0mm; padding-top: 0mm; }
|
||||
.text-cell { text-align: left; vertical-align: middle; font-size: 20pt; padding-left: 1mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
|
||||
img.qr { width: 19mm; height: 19mm; display: block; }
|
||||
</style>
|
||||
<style>
|
||||
body { margin: 0; padding: 0; width: 60mm; height: 14mm; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
|
||||
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; }
|
||||
.qr-cell { width: 14mm; text-align: left; vertical-align: middle; padding-left: 6mm; padding-top: 2mm; }
|
||||
.text-cell { text-align: left; vertical-align: middle; font-size: 15pt; padding-left: 4mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
|
||||
img.qr { width: 18mm; height: 18mm; display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table class="sticker-table">
|
||||
@@ -46,89 +46,23 @@ class PalletController extends Controller
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
setTimeout(function () {
|
||||
window.close();
|
||||
}, 500); // Wait 0.5 seconds before closing
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
// $mpdf = new Mpdf([
|
||||
// 'mode' => 'utf-8',
|
||||
// 'format' => [60, 14],
|
||||
// 'margin_left' => 0,
|
||||
// 'margin_right' => 0,
|
||||
// 'margin_top' => 0,
|
||||
// 'margin_bottom' => 0,
|
||||
// // 'tempDir' => '/var/www/storage/mpdf-tmp',
|
||||
// ]);
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => 'utf-8',
|
||||
'format' => [60, 14],
|
||||
'margin_left' => 0,
|
||||
'margin_right' => 0,
|
||||
'margin_top' => 0,
|
||||
'margin_bottom' => 0,
|
||||
'tempDir' => '/var/www/storage/mpdf-tmp',
|
||||
]);
|
||||
|
||||
// $mpdf->WriteHTML($html);
|
||||
// // Output PDF to browser for printing
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
}
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png();
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$htmlBlock = '
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
</td>
|
||||
<td class="text-cell">
|
||||
' . htmlspecialchars($palletNo) . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { margin: 0; padding: 0; width: 60mm; height: auto; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
|
||||
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; page-break-after: always; }
|
||||
.qr-cell { width: 14mm; text-align: right; vertical-align: bottom; padding-left: -8mm; padding-top: 0mm; }
|
||||
.text-cell { text-align: left; vertical-align: middle; font-size: 22pt; padding-left: 1mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
|
||||
img.qr { width: 19mm; height: 19mm; display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
' . $htmlBlock . $htmlBlock . '
|
||||
<script>
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
setTimeout(function () {
|
||||
window.close();
|
||||
}, 1000); // Wait 1 second before closing
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
// $mpdf = new Mpdf([
|
||||
// 'mode' => 'utf-8',
|
||||
// 'format' => [60, 14],
|
||||
// 'margin_left' => 0,
|
||||
// 'margin_right' => 0,
|
||||
// 'margin_top' => 0,
|
||||
// 'margin_bottom' => 0,
|
||||
// // 'tempDir' => '/var/www/storage/mpdf-tmp',
|
||||
// ]);
|
||||
|
||||
// $mpdf->WriteHTML($html);
|
||||
// // Output PDF to browser for printing
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output('qr-label.pdf', 'I');
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\StickerMaster;
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Mpdf;
|
||||
use Mpdf\QrCode\Output;
|
||||
use Mpdf\QrCode\QrCode;
|
||||
|
||||
class ProductionStickerReprintController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
|
||||
$parts = explode('|', $palletNo);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// Retrieve the item record by item code
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (!$item) {
|
||||
abort(404, "Item with code {$itemCode} not found.");
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$production = ProductionQuantity::where('item_id', $itemId)
|
||||
->where('serial_number', $serial)
|
||||
->first();
|
||||
|
||||
if (!$production) {
|
||||
abort(404, "Production data for item code '{$itemCode}' with serial '{$serial}' not found.");
|
||||
}
|
||||
|
||||
$productionOrder = $production->production_order;
|
||||
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png();
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// Decide number of copies
|
||||
$copies = 1;
|
||||
|
||||
if ($sticker) {
|
||||
if ($sticker->serial_number_pump == 1) {
|
||||
// If pump is selected (regardless of motor), 2 copies
|
||||
$copies = 2;
|
||||
} elseif ($sticker->serial_number_motor == 1) {
|
||||
// Only motor selected, 1 copy
|
||||
$copies = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return '
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 60mm;
|
||||
height: 14mm;
|
||||
font-size: 10pt;
|
||||
font-family: Arial Narrow, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.sticker-table {
|
||||
width: 60mm;
|
||||
height: 14mm;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.text-cell {
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
font-size: 10pt;
|
||||
padding: 2mm 2mm 0 0;
|
||||
white-space: normal;
|
||||
font-weight: normal;
|
||||
line-height: 0.3;
|
||||
}
|
||||
|
||||
.text-row {
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
.serial {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.po-number {
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
width: 1%;
|
||||
}
|
||||
|
||||
.desc-row {
|
||||
font-weight: normal;
|
||||
font-size: 7pt;
|
||||
}
|
||||
|
||||
.qr-cell {
|
||||
width: 14mm;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
padding-left: 1mm;
|
||||
padding-top: 0mm;
|
||||
}
|
||||
|
||||
img.qr {
|
||||
width: 13mm;
|
||||
height: 13mm;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="print-container"></div>
|
||||
|
||||
<script>
|
||||
const copies = ' . $copies . ';
|
||||
const htmlBlock = `
|
||||
<table class="sticker-table">
|
||||
<tr>
|
||||
<td class="qr-cell">
|
||||
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
|
||||
</td>
|
||||
<td class="text-cell">
|
||||
<div class="text-row">
|
||||
<pre><span class="serial">' . htmlspecialchars($serial) . '</span> <span class="po-number">' . htmlspecialchars($productionOrder) . '</span></pre>
|
||||
</div>
|
||||
<div class="desc-row">
|
||||
' . htmlspecialchars($item->description) . '
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
`;
|
||||
|
||||
const container = document.getElementById("print-container");
|
||||
for (let i = 0; i < copies; i++) {
|
||||
container.insertAdjacentHTML("beforeend", htmlBlock);
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
setTimeout(function () {
|
||||
window.close();
|
||||
}, 500);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
|
||||
|
||||
// //Get sticker master data
|
||||
// $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// //Decide number of copies
|
||||
// $copies = 1; // default
|
||||
// if ($sticker) {
|
||||
// if ($sticker->serial_number_motor == 1) {
|
||||
// $copies = 1;
|
||||
// } elseif (is_null($sticker->serial_number_motor) && $sticker->serial_number_pump == 1) {
|
||||
// $copies = 2;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $mpdf = new Mpdf([
|
||||
// 'mode' => 'utf-8',
|
||||
// 'format' => [60, 14],
|
||||
// 'margin_left' => 0,
|
||||
// 'margin_right' => 0,
|
||||
// 'margin_top' => 0,
|
||||
// 'margin_bottom' => 0,
|
||||
// ]);
|
||||
|
||||
// for ($i = 0; $i < $copies; $i++) {
|
||||
// $mpdf->WriteHTML($html);
|
||||
// if ($i < $copies - 1) {
|
||||
// $mpdf->AddPage();
|
||||
// }
|
||||
// }
|
||||
|
||||
// $mpdf->Output('qr-label.pdf', 'I');
|
||||
// exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -81,9 +81,6 @@ class UserController extends Controller
|
||||
//$user = User::where('email', $email)->first();
|
||||
if (Hash::check($header_pass, $existUser->password)) {
|
||||
return response()->json([
|
||||
'created_at' => $existUser->created_at->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s'),
|
||||
'email' => $existUser->email,
|
||||
'roles' => $existUser->roles()->pluck('name')->toArray()
|
||||
], 200);
|
||||
} else {
|
||||
|
||||
@@ -19,8 +19,6 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public bool $completedInvoice = false;
|
||||
|
||||
public bool $isSerial = false;
|
||||
|
||||
public bool $emptyInvoice = false;
|
||||
|
||||
public bool $hasSearched = false;
|
||||
@@ -51,12 +49,11 @@ class InvoiceDataTable extends Component
|
||||
|
||||
public string $currentSerialNumber = '';
|
||||
|
||||
public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
|
||||
public function loadCompletedData($invoiceNumber, $plantId)
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = true;
|
||||
$this->isSerial = $isSerial;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
@@ -67,8 +64,8 @@ class InvoiceDataTable extends Component
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->emptyInvoice = true;
|
||||
$this->completedInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
@@ -78,10 +75,9 @@ class InvoiceDataTable extends Component
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->completedInvoice = false;
|
||||
$this->materialInvoice = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
@@ -117,11 +113,10 @@ class InvoiceDataTable extends Component
|
||||
{
|
||||
$this->plantId = $plantId;
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = false;
|
||||
$this->emptyInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->completedInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
// $this->showCapacitorInput = false;
|
||||
|
||||
//->where('serial_number', '!=', '')
|
||||
@@ -176,12 +171,13 @@ class InvoiceDataTable extends Component
|
||||
$this->currentSerialNumber = $serialNumber;
|
||||
$this->showCapacitorInput = true;
|
||||
// $this->capacitorInput = '';
|
||||
$this->completedInvoice = false;
|
||||
$this->isSerial = true;
|
||||
$this->emptyInvoice = false;
|
||||
$this->completedInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function cancelCapacitorInput()
|
||||
@@ -334,7 +330,7 @@ class InvoiceDataTable extends Component
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true);
|
||||
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class DeviceMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'name',
|
||||
'mac_address',
|
||||
'ip_address',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ class MfmMeter extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'device_master_id',
|
||||
'sequence',
|
||||
'name',
|
||||
'created_at',
|
||||
@@ -25,9 +24,4 @@ class MfmMeter extends Model
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
public function devicemaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DeviceMaster::class, 'device_master_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ class MfmParameter extends Model
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'device_master_id',
|
||||
'name',
|
||||
'register_id',
|
||||
'identifier',
|
||||
@@ -34,9 +33,4 @@ class MfmParameter extends Model
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
|
||||
public function deviceName(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DeviceMaster::class, 'device_master_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\DeviceMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class DeviceMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, DeviceMaster $devicemaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete DeviceMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any DeviceMaster');
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE device_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
name TEXT NOT NULL,
|
||||
mac_address TEXT DEFAULT NULL,
|
||||
ip_address TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
created_by TEXT NULL,
|
||||
|
||||
UNIQUE (name, plant_id),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('device_masters');
|
||||
}
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE mfm_meters
|
||||
ADD COLUMN device_master_id BIGINT NOT NULL,
|
||||
ADD CONSTRAINT mfm_meters_device_master_id_fkey
|
||||
FOREIGN KEY (device_master_id) REFERENCES device_masters(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE mfm_meters
|
||||
ADD UNIQUE (plant_id, device_master_id, name);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('mfm_meters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE mfm_parameters
|
||||
ADD COLUMN device_master_id BIGINT NOT NULL,
|
||||
ADD CONSTRAINT mfm_parameters_device_master_id_fkey
|
||||
FOREIGN KEY (device_master_id) REFERENCES device_masters(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('mfm_parameters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -141,8 +141,6 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view guard patrol hourly count dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view invoice serial quantity dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'create production sticker reprint page']);
|
||||
Permission::updateOrCreate(['name' => 'view ems trend line analysis dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view ems trend chart analysis dashboard']);
|
||||
|
||||
|
||||
//Send To Sap Permissions
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
|
||||
{{-- Heading label --}}
|
||||
<h2 class="text-xl font-semibold text-gray-800">
|
||||
STICKER RE-PRINT
|
||||
</h2>
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{-- {{ $this->filtersForm($this->form) }} --}}
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
|
||||
{{-- <input
|
||||
type="text"
|
||||
id="qr-scan-input"
|
||||
class="border border-gray-300 rounded px-4 py-2 text-sm w-full"
|
||||
placeholder="Scan QR Code & Press Enter"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
/> --}}
|
||||
<div class="mb-4">
|
||||
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
SCAN QR CODE
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
id="qr-scan-input"
|
||||
class="border border-gray-300 rounded px-4 py-2 text-sm w-full"
|
||||
placeholder="Scan QR Code & Press Enter"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const scanInput = document.getElementById('qr-scan-input');
|
||||
if (!scanInput) return;
|
||||
|
||||
scanInput.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
|
||||
const value = scanInput.value.trim();
|
||||
|
||||
if (value !== '') {
|
||||
Livewire.dispatch('handleQrScan', { value: value });
|
||||
scanInput.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
window.addEventListener('open-pdf', event => {
|
||||
const pdfUrl = event.detail.url;
|
||||
const win = window.open(pdfUrl, '_blank');
|
||||
if (!win) {
|
||||
console.warn('Popup blocked. Please allow popups for this site.');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\ItemOverview::class)
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
@@ -1,11 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Filters form --}}
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
|
||||
{{-- Chart widget --}}
|
||||
<x-filament-widgets::widgets :widgets="$this->getWidgets()" />
|
||||
|
||||
</div>
|
||||
|
||||
</x-filament-panels::page>
|
||||
@@ -1,10 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Filters form --}}
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
|
||||
{{-- Chart widget --}}
|
||||
<x-filament-widgets::widgets :widgets="$this->getWidgets()" />
|
||||
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
@@ -1,23 +1,7 @@
|
||||
|
||||
<div>
|
||||
<div class="mb-4">
|
||||
<h2 class="text-lg font-bold text-gray-800">
|
||||
@if ($hasSearched)
|
||||
SERIAL INVOICE DATA TABLE
|
||||
@elseif ($materialInvoice)
|
||||
MATERIAL INVOICE DATA TABLE
|
||||
@else
|
||||
@if ($completedInvoice)
|
||||
@if ($isSerial)
|
||||
SERIAL INVOICE DATA TABLE
|
||||
@else
|
||||
MATERIAL INVOICE DATA TABLE
|
||||
@endif
|
||||
@else
|
||||
INVOICE DATA TABLE
|
||||
@endif
|
||||
@endif
|
||||
</h2>
|
||||
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2>
|
||||
<div class="mt-2">
|
||||
<hr class="border-t-2 border-gray-300">
|
||||
</div>
|
||||
@@ -26,13 +10,7 @@
|
||||
{{-- Modal for completed invoice--}}
|
||||
@if ($completedInvoice)
|
||||
<div class="text-center text-red-500">
|
||||
<p>
|
||||
@if ($isSerial)
|
||||
Completed the scanning process for serial invoice number <strong>{{ $invoiceNumber }}</strong>.
|
||||
@else
|
||||
Completed the scanning process for material invoice number <strong>{{ $invoiceNumber }}</strong>.
|
||||
@endif
|
||||
</p>
|
||||
<p>Completed the scanning process for invoice number <strong>{{ $invoiceNumber }}</strong>.</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Plant</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2; white-space: nowrap;">Line</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Target Quantity</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Line Type</th>
|
||||
<th style="text-align: center; border: 1px solid #444; padding: 8px; background: #f2f2f2;">Production Quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -72,7 +71,6 @@
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['plant'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center; white-space: nowrap;">{{ $row['line'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['targetQuantity'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['type'] }}</td>
|
||||
<td style="border: 1px solid #444; padding: 8px; text-align: center;">{{ $row['productionQuantity'] }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\InvoiceValidationController;
|
||||
use App\Http\Controllers\MachineController;
|
||||
use App\Http\Controllers\MfmParameterController;
|
||||
use App\Http\Controllers\ModuleChartController;
|
||||
@@ -83,8 +82,6 @@ Route::get('sticker/get-master-type-data', [StickerMasterController::class, 'get
|
||||
|
||||
Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf');
|
||||
|
||||
Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf');
|
||||
|
||||
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
|
||||
|
||||
//Production Dashboard Controller
|
||||
@@ -132,10 +129,3 @@ Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get
|
||||
Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']);
|
||||
|
||||
Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
|
||||
|
||||
//Invoice Validation Controller
|
||||
|
||||
Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']);
|
||||
|
||||
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user