Compare commits
62 Commits
e9d967e2c2
...
gha-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfed40f535 | ||
|
|
83f98d9e83 | ||
|
|
3d84661640 | ||
|
|
26ecaf49ef | ||
|
|
5fe2b74174 | ||
|
|
ce901e3b78 | ||
|
|
31ad036d0e | ||
|
|
c363faa357 | ||
|
|
a71864905e | ||
|
|
c75ac4781f | ||
|
|
c76cf1fb98 | ||
|
|
95a4ddf11e | ||
|
|
c309bed7d9 | ||
|
|
b2dc9e7024 | ||
|
|
bff2601ddc | ||
|
|
e80812b82e | ||
|
|
81c7812ef6 | ||
|
|
14b5f4ae8b | ||
|
|
eb31e6a406 | ||
|
|
740ceff0f8 | ||
|
|
ea1261fb01 | ||
|
|
74ad73622d | ||
|
|
a62220c9d0 | ||
|
|
a5036b7d6f | ||
|
|
27b8058ba8 | ||
|
|
58091726a4 | ||
|
|
6bdd210162 | ||
|
|
b9e3d463ed | ||
|
|
418e4fcf79 | ||
|
|
33881a3978 | ||
|
|
9d4cf0e3d9 | ||
|
|
72704a4a3f | ||
|
|
a34b55267d | ||
|
|
b6dcb93402 | ||
|
|
313dc012d5 | ||
|
|
2541300910 | ||
|
|
d1894e0d35 | ||
|
|
e5143a0ce8 | ||
|
|
b1674bba53 | ||
|
|
52a25fec8e | ||
|
|
dafe1ca458 | ||
|
|
af384faa7c | ||
|
|
c6f61fa19a | ||
|
|
aaa93e740b | ||
|
|
33acf73b5e | ||
|
|
ea5af41f7f | ||
|
|
c8ea502833 | ||
|
|
7e317f6e5f | ||
|
|
1465734acd | ||
|
|
642053653c | ||
|
|
27524c4d62 | ||
|
|
9fa4c0dd49 | ||
|
|
4d5b14fe69 | ||
|
|
b4ca4a9fcd | ||
|
|
484bc6d070 | ||
|
|
b153a53f4b | ||
|
|
658dea8e72 | ||
|
|
e934cdb193 | ||
|
|
d61c61879f | ||
|
|
4b597629aa | ||
|
|
9173dcb50a | ||
|
|
4a17892865 |
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
|
||||
@@ -127,15 +127,75 @@ class SendProductionReport extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$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);
|
||||
if (strtolower($scheduleType) == '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);
|
||||
}
|
||||
|
||||
$PlanstartDate = now()->setTime(8, 0, 0);
|
||||
$planendDate = now()->copy()->addDay()->setTime(7, 59, 0);
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
// ->sum('plan_quantity');
|
||||
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $fgTableData = []; // store FG Line related data
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// // ✅ Only get FG Lines
|
||||
// $fgLines = Line::where('plant_id', $plant->id)
|
||||
// ->where('type', 'FG Line')
|
||||
// ->get();
|
||||
|
||||
// foreach ($fgLines as $line) {
|
||||
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $fgTableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $validationCount,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
@@ -144,10 +204,17 @@ class SendProductionReport extends Command
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
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])
|
||||
->count();
|
||||
} else {
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
@@ -159,8 +226,11 @@ class SendProductionReport extends Command
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: show table in console
|
||||
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
|
||||
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
if (!empty($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
|
||||
43
app/Filament/Exports/MfmParameterExporter.php
Normal file
43
app/Filament/Exports/MfmParameterExporter.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmParameterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmParameter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
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'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm parameter 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;
|
||||
}
|
||||
}
|
||||
@@ -59,17 +59,19 @@ class ItemImporter extends Importer
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
$warnMsg = [];
|
||||
$iCode = trim($this->data['code']);
|
||||
$description = trim($this->data['description']);
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
// if (Str::length($this->data['uom']) <= 0) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
if (Str::length($this->data['description']) < 5) {
|
||||
if (Str::length($description) < 5) {
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
@@ -79,14 +81,14 @@ class ItemImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Item::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'category' => $this->data['category'],
|
||||
'description' => $this->data['description'],
|
||||
'category' => trim($this->data['category']),
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => $this->data['uom']
|
||||
'uom' => trim($this->data['uom'])
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
|
||||
@@ -129,7 +129,7 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || !ctype_alnum($serialNo)) {
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
|
||||
91
app/Filament/Imports/MfmParameterImporter.php
Normal file
91
app/Filament/Imports/MfmParameterImporter.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmParameterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmParameter::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('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Sequence')
|
||||
->example('1')
|
||||
->label('Mfm Meter Sequence')
|
||||
->relationship(resolveUsing:'sequence')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Parameter Name')
|
||||
->example('apparent_energy_received')
|
||||
->label('Parameter Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('register_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Register ID')
|
||||
->example('2715')
|
||||
->label('Register ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('identifier')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Identifier')
|
||||
->example('Kvah')
|
||||
->label('Identifier')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('byte_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Byte To Convert')
|
||||
->example('1')
|
||||
->label('Byte To Convert')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('type_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Type To Convert')
|
||||
->example('FLOAT32')
|
||||
->label('Type To Convert')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('decimal_to_display')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Decimal To Display')
|
||||
->example('2')
|
||||
->label('Decimal To Display')
|
||||
->rules(['required', 'integer']),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmParameter
|
||||
{
|
||||
// return MfmParameter::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmParameter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm parameter 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;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class PalletValidationImporter extends Importer
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($serialNo) < 9 || !ctype_alnum($serialNo)) {
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
|
||||
@@ -148,7 +148,7 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || !ctype_alnum($serialNo)) {
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class InvoiceFinder extends Page implements HasForms
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
TextInput::make('total_sno_quantity')
|
||||
->label('Total SNo. Quantity')
|
||||
->label('Invoice Quantity')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
|
||||
@@ -79,7 +79,7 @@ class InvoiceFinder extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
@@ -101,7 +101,7 @@ class InvoiceFinder extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' does not exist in locator invoice table!")
|
||||
->danger()
|
||||
->duration(2000)
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
@@ -128,7 +128,7 @@ class InvoiceFinder extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' already completed the scanning process..!")
|
||||
->success()
|
||||
->duration(2000)
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Locator;
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -144,7 +145,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -163,7 +164,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Remove Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -184,7 +185,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Locator Number')
|
||||
->body("Locator number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -204,7 +205,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Locator Number')
|
||||
->body("Locator number '$locatorNo' must be at least 7 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -229,7 +230,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Unknown: Locator Number')
|
||||
->body("Locator number '$locatorNo' does not exist in the master.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -262,7 +263,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->body("Scanned locator number '$locatorNo' does not have any locator serial numbers to store into the pallet.<br>
|
||||
Please scan a valid stored locator number to proceed.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -399,7 +400,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Add: Locator Serial Number')
|
||||
->body("Scanned locator serial number '$serialNo' successfully added into 'PALLET DATA' table.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -422,7 +423,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Remove: Locator Serial Number')
|
||||
->body("Scanned locator serial number '$removeserial' removed successfully from 'PALLET DATA' table.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -461,7 +462,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Add: Locator Serial Numbers')
|
||||
->body("Scanned locator number '$locatorNo' has '$serialLocator' locator serial numbers!<br>Successfully added into 'PALLET DATA' table.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -513,7 +514,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Locator Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -532,7 +533,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Remove Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -553,7 +554,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -567,13 +568,13 @@ class PalletFromLocator extends Page implements HasForms
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 9)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -593,7 +594,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -619,23 +620,53 @@ class PalletFromLocator extends Page implements HasForms
|
||||
|
||||
if ($serialLocator == '' || $serialLocator == null)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->send();
|
||||
$invoicesnoexists = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('serial_number', $serialNo)
|
||||
->where('scanned_status', '=','Scanned')
|
||||
->first();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => null,
|
||||
]);
|
||||
return;
|
||||
$invoiceNo = $invoicesnoexists?->invoice_number;
|
||||
|
||||
if ($invoicesnoexists)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif ($serialLocator->pallet_number != '' && $serialLocator->pallet_number != null)
|
||||
{
|
||||
@@ -643,7 +674,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' already exist in pallet number '".$serialLocator->pallet_number."'.<br>Scan the valid locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -653,7 +684,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
@@ -676,7 +707,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Locator Serials Not Found')
|
||||
->body("Add some locator serial numbers to proceed generate pallet..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -770,16 +801,16 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Success: Pallet Generated')
|
||||
->body("Pallet number '$newPalletNumber' completed the master packing successfully!")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(600)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => $locatorNo,
|
||||
'scan_serial_number' => $serialNo,
|
||||
'scan_remove_sno' => $removeSerial,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => 0,
|
||||
]);
|
||||
return;
|
||||
@@ -791,16 +822,16 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Failed: Pallet Generated')
|
||||
->body("No locator serial number records found to generate pallet..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => $locatorNo,
|
||||
'scan_serial_number' => $serialNo,
|
||||
'scan_remove_sno' => $removeSerial,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => 0,
|
||||
]);
|
||||
return;
|
||||
@@ -851,7 +882,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Locator Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -870,7 +901,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -891,7 +922,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -905,13 +936,13 @@ class PalletFromLocator extends Page implements HasForms
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($removeSno) < 9)
|
||||
else if (strlen($removeSno) < 9 || strlen($removeSno) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$removeSno' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -931,7 +962,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$removeSno' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -964,7 +995,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$removeSno' doesn't exist in 'PALLET DATA' table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
|
||||
@@ -20,6 +20,8 @@ use Route;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
|
||||
class ProductionQuantityPage extends Page implements HasForms
|
||||
{
|
||||
@@ -130,7 +132,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->live()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->default(function () {
|
||||
@@ -163,7 +164,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->label('Block')
|
||||
->required()
|
||||
// ->nullable()
|
||||
->live()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
@@ -174,7 +175,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
|
||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||
@@ -276,7 +276,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->live()
|
||||
->default(function () {
|
||||
return optional(ProductionQuantity::latest()->first())->line_id;
|
||||
})
|
||||
@@ -323,9 +322,9 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->live()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
//->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 1])
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
@@ -339,16 +338,16 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// }
|
||||
}),
|
||||
|
||||
TextInput::make('item_code')
|
||||
->label('Item Code')
|
||||
->columnSpan(1)
|
||||
->autofocus(true)
|
||||
->reactive()
|
||||
->live()
|
||||
->default(fn () => $this->clear_qr)
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processAllValues($event.target.value)',
|
||||
]),
|
||||
// TextInput::make('item_code')
|
||||
// ->label('Item Code')
|
||||
// ->columnSpan(1)
|
||||
// ->autofocus(true)
|
||||
// //->reactive()
|
||||
// ->live(onBlur: true) // avoids per-keystroke triggering
|
||||
// ->default(fn () => $this->clear_qr)
|
||||
// ->extraAttributes([
|
||||
// 'wire:keydown.enter' => 'processAllValues($event.target.value)',
|
||||
// ]),
|
||||
|
||||
Hidden::make('serial_number')
|
||||
->required(),
|
||||
@@ -362,7 +361,8 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
TextInput::make('recent_qr')
|
||||
->label('Last scanned QR')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
//->columnSpan(2)
|
||||
// ->default(function () {
|
||||
// // Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||
// $latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||
@@ -383,7 +383,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
|
||||
// })
|
||||
->default(fn () => $this->recQr)
|
||||
|
||||
->readOnly(true),
|
||||
|
||||
TextInput::make('id')
|
||||
@@ -392,11 +391,19 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
])
|
||||
->columns(7);
|
||||
// ->columns(6);
|
||||
->columns(['default' => 1, 'sm' => 7]);
|
||||
}
|
||||
|
||||
|
||||
// Method to process the value when Enter is pressed
|
||||
|
||||
#[On('handleQrScan')]
|
||||
public function handleQrScan($value)
|
||||
{
|
||||
$this->processAllValues($value);
|
||||
}
|
||||
|
||||
public function processAllValues($formQRData)
|
||||
{
|
||||
|
||||
@@ -417,36 +424,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$user = Filament::auth()->user(); //->name
|
||||
$operatorName = $user->name;
|
||||
$this->qrData = $formQRData;
|
||||
// dd($formData, $formQRData);
|
||||
// dd($this->form->getState()['serial_number']);
|
||||
|
||||
// try {
|
||||
// // Access the nested form data
|
||||
// $componentData = json_decode($formValues['components'][0]['snapshot'], true);
|
||||
// $formData = $componentData['data']['data'][0]; // Access first item in data array
|
||||
|
||||
// // Extract specific values
|
||||
// $this->qrData = $formQRData ?? $formData['item_code'];
|
||||
// $this->pId = $formData['plant_id'] ?? null;
|
||||
// $this->bId = $formData['block_name'] ?? null;
|
||||
// $this->sId = $formData['shift_id'] ?? null;
|
||||
// $this->lId = $formData['line_id'] ?? null;
|
||||
// $this->iId = $formData['item_id'] ?? null;
|
||||
// $this->succId = $formData['success_msg'] ?? null;
|
||||
// // $this->sNoId = $formData['serial_number'] ?? null;
|
||||
// $this->prodOrder = $formData['production_order'] ?? null;
|
||||
// $this->recQr = $formData['recent_qr'] ?? null;
|
||||
// $this->dispatch('plant-line-updated', $this->pId,$this->lId);
|
||||
// } catch (\Exception $e) {
|
||||
// //dd('Error parsing form data:', $e->getMessage(), $formValues);
|
||||
// Notification::make()
|
||||
// ->title("Error Parsing Form Data") // {$operatorName}
|
||||
// ->body($e->getMessage())
|
||||
// ->danger()
|
||||
// // ->persistent()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||
|
||||
@@ -456,7 +433,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
|
||||
}
|
||||
|
||||
|
||||
if (empty($formQRData)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1303,7 +1279,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
// 'item_code'=> null,
|
||||
//'item_code'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
@@ -1317,6 +1293,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->title("Valid QR Found") // {$operatorName}
|
||||
->body("Valid QR code scanned: {$this->qrData}.")
|
||||
->success()
|
||||
->duration(200)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1327,25 +1304,25 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// For example:
|
||||
$model = ProductionQuantity::create($formValues);
|
||||
|
||||
// dd('Production Updated Event Dispatched');
|
||||
// dd('Production Updated Event Dispatched');
|
||||
|
||||
$this->dispatch('productionUpdated');
|
||||
|
||||
// // Optionally, you can emit an event or perform a redirect after saving
|
||||
// $this->emit('formSaved', $model->id);
|
||||
}
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('select_plant') && session()->has('select_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('select_plant') && session()->has('select_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
|
||||
// Override the getTitle method
|
||||
public function getTitle(): string
|
||||
{
|
||||
return ''; // Return an empty string to remove the title
|
||||
}
|
||||
// Override the getTitle method
|
||||
public function getTitle(): string
|
||||
{
|
||||
return ''; // Return an empty string to remove the title
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -129,7 +128,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -151,7 +150,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please upload a file!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -175,7 +174,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Choose a proper Excel file')
|
||||
->body('The file must be an Excel file (xlsx, xls, csv).')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -197,7 +196,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('File not found after upload!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -234,7 +233,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
if ($serialNumber)
|
||||
{
|
||||
$excelSerials[] = $serialNumber;
|
||||
if (strlen($serialNumber) < 9) {
|
||||
if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20) {
|
||||
$invalidSerial[] = $serialNumber;
|
||||
} elseif (!ctype_alnum($serialNumber)) {
|
||||
$invalidSerial[] = $serialNumber;
|
||||
@@ -253,9 +252,9 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
if (count($uniqueInvalidSerial) > 0) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers are invalid, length should contain minimum of 9 digits alpha numeric values:<br>' . implode(', ', $uniqueInvalidSerial))
|
||||
->body('The following serial numbers are invalid, length should contain minimum of 9 digits (and maximum 20 digits) alpha numeric values:<br>' . implode(', ', $uniqueInvalidSerial))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -275,7 +274,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Invalid Locator Numbers Found')
|
||||
->body('The following locator numbers are invalid, length should contain minimum of 7 digits alpha numeric values:<br>' . implode(', ', $uniqueInvalidLocator))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -310,7 +309,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Duplicate Serial Numbers in Excel')
|
||||
->body('The following serial numbers are duplicated in the file:<br>' . implode(', ', $duplicates))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -336,7 +335,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Locators with Insufficient Space')
|
||||
->body('The following locators does not have space:<br>' . implode(', ', $locatorsWithQuantityTwo))
|
||||
->warning()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('open-confirm-modal', locatorNo: $locator, plantId: $plantId);
|
||||
@@ -356,7 +355,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist and cannot be imported:<br>' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('open-confirm-serial', locatorNo: $locator, plantId: $plantId);
|
||||
@@ -398,7 +397,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
if ($insertedCount > 0) {
|
||||
Notification::make()
|
||||
->title('Serial Locators imported successfully!')
|
||||
->body("{$insertedCount} locator serial number(s) have been imported.")
|
||||
->body("'{$insertedCount}' locator serial number(s) have been imported.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->send();
|
||||
@@ -419,7 +418,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Serial Locators imported Failed!')
|
||||
->body('No new serial number(s) found in the uploaded excel file..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -445,7 +444,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -467,7 +466,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please upload a file!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -491,7 +490,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Choose a proper Excel file')
|
||||
->body('The file must be an Excel file (xlsx, xls, csv).')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -513,7 +512,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('File not found after upload!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -571,7 +570,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist and cannot be imported: ' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('open-confirm-serial', locatorNo: $locator, plantId: $plantId);
|
||||
@@ -607,13 +606,12 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Storage::delete($fullPath);
|
||||
|
||||
if ($insertedCount > 0) {
|
||||
Notification::make()
|
||||
->title('Serial Locators imported successfully!')
|
||||
->body("{$insertedCount} locator serial number(s) have been imported.")
|
||||
->body("'{$insertedCount}' locator serial number(s) have been imported.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->send();
|
||||
@@ -634,7 +632,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Serial Locators imported Failed!')
|
||||
->body('No new serial number(s) found in the uploaded excel file..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -673,7 +671,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -695,7 +693,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please upload a file!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -719,7 +717,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Choose a proper Excel file')
|
||||
->body('The file must be an Excel file (xlsx, xls, csv).')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -741,7 +739,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('File not found after upload!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -826,7 +824,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
if ($insertedCount > 0) {
|
||||
Notification::make()
|
||||
->title('Serial Locators imported successfully!')
|
||||
->body("{$insertedCount} locator serial number(s) have been imported.")
|
||||
->body("'{$insertedCount}' locator serial number(s) have been imported.")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->send();
|
||||
@@ -845,7 +843,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title('Serial Locators imported Failed!')
|
||||
->body('No new serial number(s) found in the uploaded excel file..!')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -884,7 +882,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -903,15 +901,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter serial number and locator number to add data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -922,32 +920,32 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter serial number to add data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($scanSno) < 9)
|
||||
else if (strlen($scanSno) < 9 || strlen($scanSno) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' must be at least 9 digits.")
|
||||
->title("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -958,14 +956,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -977,7 +975,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter locator number to add data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -985,7 +983,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -994,7 +992,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' must be at least 7 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1002,7 +1000,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1017,7 +1015,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' does not exist in the master.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1025,7 +1023,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1036,7 +1034,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("No space available for locator number '{$scanLocator}'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1044,7 +1042,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1063,14 +1061,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in locator number '$palletRecord->locator_number'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1081,14 +1079,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1099,14 +1097,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number' with locator number '$palletRecord->locator_number'.")
|
||||
->warning()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1127,14 +1125,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in invoice number '$invoiceNo' and completed the scanning process.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1142,6 +1140,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$locatorQuantity = Locator::where('plant_id',$plantId)->where('locator_number', $scanLocator)->first();
|
||||
|
||||
$userName = Filament::auth()->user()->name;
|
||||
@@ -1170,8 +1169,8 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
}
|
||||
@@ -1180,7 +1179,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Failed to add serial number '$scanSno' into locator number '$scanLocator'!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill
|
||||
@@ -1196,8 +1195,6 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function viewLocator()
|
||||
{
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
@@ -1209,7 +1206,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -1228,7 +1225,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter atleast a serial number or locator number to view data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1243,18 +1240,18 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
}
|
||||
else if ($scanSno && $scanLocator)
|
||||
{
|
||||
if (strlen($scanSno) < 9) {
|
||||
if (strlen($scanSno) < 9 || strlen($scanSno) > 20) {
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' must be at least 9 digits.")
|
||||
->title("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1265,14 +1262,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1283,7 +1280,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' must be at least 7 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1291,7 +1288,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1305,7 +1302,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' does not exist in the master.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1313,7 +1310,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1331,14 +1328,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1354,15 +1351,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' and locator number '$scanLocator' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1374,15 +1371,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$serialNumberExists->pallet_number' with locator number '$serialNumberExists->locator_number'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1399,8 +1396,8 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1409,18 +1406,18 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
}
|
||||
else if ($scanSno)
|
||||
{
|
||||
if (strlen($scanSno) < 9) {
|
||||
if (strlen($scanSno) < 9 || strlen($scanSno) > 20) {
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' must be at least 9 digits.")
|
||||
->title("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1431,14 +1428,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1464,8 +1461,8 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1475,15 +1472,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1493,15 +1490,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$palletRecord->pallet_number' with locator number '$palletRecord->locator_number'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1521,14 +1518,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1539,14 +1536,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1560,7 +1557,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' must be at least 7 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1568,7 +1565,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1582,7 +1579,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' does not exist in the master.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1590,7 +1587,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1603,7 +1600,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1611,7 +1608,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1620,16 +1617,16 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
{
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->success()
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1649,7 +1646,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please select a plant first.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', 0);
|
||||
@@ -1668,15 +1665,15 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter serial number and locator number to delete data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1686,31 +1683,31 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter serial number to delete data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($scanSno) < 9) {
|
||||
else if (strlen($scanSno) < 9 || strlen($scanSno) > 20) {
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' must be at least 9 digits.")
|
||||
->title("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1721,14 +1718,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1739,7 +1736,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Please enter locator number to delete data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1747,7 +1744,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1757,7 +1754,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' must be at least 7 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1765,7 +1762,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1777,7 +1774,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Locator number '$scanLocator' does not exist in the master.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
@@ -1785,7 +1782,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1803,14 +1800,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' exists in invoice number '$invoiceNo' and completed the scanning process.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1829,14 +1826,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title("Serial number '$scanSno' already exists in pallet number '$palletExists->pallet_number'!<br>Please enter locator serial number to remove data.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => $scanLocator,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
@@ -1859,8 +1856,8 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_number' => $scanSno,
|
||||
'scan_locator' => $scanLocator,
|
||||
'scan_serial_number' => null,
|
||||
'scan_locator' => null,
|
||||
'upload_serial_locator' => null,
|
||||
]);
|
||||
return;
|
||||
@@ -1871,7 +1868,7 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
->title("Failed to remove serial number '$scanSno' from locator number '$scanLocator'!")
|
||||
//->title("Serial number '{$scanSno}' and Locator number '{$scanLocator}' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $scanLocator, $scanSno, $plantId);
|
||||
|
||||
@@ -121,12 +121,14 @@ class InvoiceValidationResource extends Resource
|
||||
->readOnly(fn (callable $get) => empty($get('invoice_number')))
|
||||
//->disabled(fn (Get $get) => empty($get('invoice_number')))
|
||||
->extraAttributes([
|
||||
'id' => 'serial_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('update_invoice', 0);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// if (!$invNo) { return; } else { }
|
||||
})
|
||||
->columnSpan(1),
|
||||
|
||||
@@ -65,7 +65,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', null);
|
||||
$set('sno_quantity', 0);
|
||||
$set('scan_quantity', 0);
|
||||
$set('pend_quantity', 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,7 +75,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', null);
|
||||
$set('sno_quantity', 0);
|
||||
$set('scan_quantity', 0);
|
||||
$set('pend_quantity', 0);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -92,14 +96,28 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->readOnly(fn (callable $get) => !$get('plant') || $get('pallet_number') || $get('serial_number'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$invNo = $get('invoice_number');
|
||||
$snoCount = 0;
|
||||
$pendingCount = 0;
|
||||
$scannedCount = 0;
|
||||
if (!$plantId) {
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
}
|
||||
else if ($invNo)
|
||||
{
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invNo)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
}
|
||||
$set('update_invoice', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', $snoCount);
|
||||
$set('scan_quantity', $scannedCount);
|
||||
$set('pend_quantity', $pendingCount);
|
||||
}),
|
||||
Forms\Components\TextInput::make('pallet_number')
|
||||
->label('Scan Pallet No')
|
||||
@@ -180,7 +198,18 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
'x-on:keydown.enter.prevent' => '$wire.processSerialNo()',
|
||||
]),
|
||||
Forms\Components\TextInput::make('sno_quantity')
|
||||
->label('SNo. Quantity')
|
||||
->label('Invoice Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
Forms\Components\TextInput::make('scan_quantity')
|
||||
->label('Scanned Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
Forms\Components\TextInput::make('pend_quantity')
|
||||
->label('Pending Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
//Forms\Components\View::make('forms.components.update-invoice-button'),
|
||||
@@ -268,7 +297,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' does not exist.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -290,7 +319,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' is not completed in masters")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -468,16 +497,16 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->label('Import Invoice')
|
||||
->form([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id')->toArray())
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
->options(Plant::pluck('name', 'id')->toArray())
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
|
||||
FileUpload::make('invoice_serial_number')
|
||||
->label('Invoice Serial Number')
|
||||
@@ -528,7 +557,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
@@ -554,7 +583,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -577,9 +606,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
if (!empty($uniqueSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
@@ -595,7 +624,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
@@ -609,7 +638,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
@@ -631,7 +660,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
|
||||
@@ -62,8 +62,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Plant Not Found')
|
||||
->body("Plant can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -71,7 +72,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -104,16 +107,19 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Locator Invoice')
|
||||
->body("Locator invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Locator Invoice' to proceed..!")
|
||||
->info()
|
||||
->duration(1000)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -149,15 +155,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice File Not Found')
|
||||
->body("Import the scanned 'Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -177,7 +186,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
@@ -188,10 +197,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -215,7 +226,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -238,60 +249,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
if (!empty($uniqueSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$duplicateSerialCodes = array_unique($duplicateSerials);
|
||||
|
||||
if (!empty($duplicateSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$validRowsFound) {
|
||||
Notification::make()
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
@@ -305,6 +265,63 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$duplicateSerialCodes = array_unique($duplicateSerials);
|
||||
|
||||
if (!empty($duplicateSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$validRowsFound) {
|
||||
Notification::make()
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -324,7 +341,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
@@ -339,6 +356,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -398,29 +417,35 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Success: Invoice inserted successfully.')
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
Notification::make()
|
||||
->title("Start the scanning process for imported invoice number '$invoiceNumber'!")
|
||||
->info()
|
||||
->duration(1000)
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->count();
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'update_invoice' => 0,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -454,23 +479,19 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Updated Invoice File Not Found')
|
||||
->body("Import the updated 'Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
]);
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -489,7 +510,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invalid Updated Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
@@ -500,10 +521,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -527,7 +550,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -550,9 +573,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
if (!empty($uniqueSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
@@ -565,7 +588,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -579,7 +604,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
@@ -593,7 +618,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -605,7 +632,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invalid Updated Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
@@ -615,10 +642,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -638,7 +667,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
@@ -651,7 +680,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -690,29 +721,35 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Success: Invoice updated successfully.')
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
Notification::make()
|
||||
->title("Start the scanning process for updated invoice number '$invoiceNumber'!")
|
||||
->info()
|
||||
->duration(1000)
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->count();
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'update_invoice' => 0,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -730,9 +767,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->count();
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -741,6 +780,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -755,13 +796,16 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Error: Locator invoice insertion (or updation).')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->count();
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
@@ -769,6 +813,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -812,17 +858,19 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!<br>Import the scanned 'Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -856,10 +904,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -867,16 +917,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
if ($palletNumber == '' || $palletNumber == null)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)
|
||||
->count();
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -886,19 +940,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
if (strlen($palletNumber) < 10)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -910,6 +965,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -925,7 +982,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -937,6 +994,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -960,7 +1019,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' does not completed the master packing!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -972,6 +1031,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1002,7 +1063,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned pallet number '$palletNumber' does not have invoice serial numbers.<br>Scan the valid exist pallet number to start the scanning process..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1014,6 +1075,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1043,7 +1106,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Partial Pallet Serial Numbers Found")
|
||||
->body($missingSerialsString)
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1055,6 +1118,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1110,7 +1175,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("All Serial numbers are moved into invoice from the pallet number '$palletNumber'.<br>Scan the next exist pallet number to start the scanning process..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
@@ -1138,11 +1203,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1150,6 +1217,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1159,6 +1230,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1200,7 +1273,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title($succMsgStr)
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
@@ -1228,11 +1301,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1240,6 +1315,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1249,6 +1328,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1295,7 +1376,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Scanned invoice number '$invoiceNumber' does not exist in invoice table!<br>Import the scanned 'Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
@@ -1304,7 +1385,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1338,10 +1421,12 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1349,16 +1434,21 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
if ($serialNumber == '' || $serialNumber == null)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1368,20 +1458,20 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
if (strlen($serialNumber) < 9)
|
||||
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body('Serial number should contain minimum 9 digits.')
|
||||
->body('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1392,6 +1482,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1402,9 +1494,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body('Serial number must contain alpha-numeric values only.')
|
||||
// ->body("Serial number '$serialNumber' must be at least 9 digits and alpha-numeric value only allowed!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1415,6 +1506,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1429,7 +1522,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Unknown: Serial Number")
|
||||
->body("Serial number '{$serialNumber}' does not exist in invoice number '$invoiceNumber'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1440,6 +1533,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1451,7 +1546,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Completed: Serial Number")
|
||||
->body("Serial number '{$serialNumber}' already completed the scanning process for the invoice number '$invoiceNumber'.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1462,6 +1557,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1483,7 +1580,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Unknown: Serial Number")
|
||||
->body("Serial number '{$serialNumber}' does not exist in pallet table.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1494,6 +1591,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1516,7 +1615,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Incompleted Pallet: Serial Number")//Pallet number '{$existPallNum}' does not completed the master packing!
|
||||
->body("Serial number '{$serialNumber}' exist in pallet number '$existPallNum' and it does not completed the master packing!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1527,6 +1626,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'pallet_number' => null,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1586,7 +1687,7 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title($succMsg)
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->get();
|
||||
@@ -1612,11 +1713,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'invoice_number' => null,
|
||||
'pallet_number' => null,
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => 0,
|
||||
'scan_quantity' => 0,
|
||||
'pend_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1624,14 +1727,21 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
@@ -1642,8 +1752,8 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
{
|
||||
Notification::make()
|
||||
->title("Failed to check Serial number '{$serialNumber}' existence.<br>Scan the valid serial number to proceed...")
|
||||
->success()
|
||||
->duration(1200)
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNumber, $plantId);
|
||||
@@ -1652,8 +1762,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'pallet_number' => null,
|
||||
'update_invoice' => 0,
|
||||
'serial_number' => null,
|
||||
'sno_quantity' => $snoCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
'pend_quantity' => $pendingCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
121
app/Filament/Resources/MfmMeterResource.php
Normal file
121
app/Filament/Resources/MfmMeterResource.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource\Pages;
|
||||
use App\Filament\Resources\MfmMeterResource\RelationManagers;
|
||||
use App\Models\MfmMeter;
|
||||
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;
|
||||
|
||||
class MfmMeterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmMeter::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')
|
||||
->relationship('plant', 'name')
|
||||
->label('Plant')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('sequence')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required(),
|
||||
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('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sequence')
|
||||
->label('Sequence')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Meter Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmMeters::route('/'),
|
||||
'create' => Pages\CreateMfmMeter::route('/create'),
|
||||
'view' => Pages\ViewMfmMeter::route('/{record}'),
|
||||
'edit' => Pages\EditMfmMeter::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmMeter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmMeter extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmMeters extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmMeter extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
176
app/Filament/Resources/MfmParameterResource.php
Normal file
176
app/Filament/Resources/MfmParameterResource.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\MfmParameterExporter;
|
||||
use App\Filament\Imports\MfmParameterImporter;
|
||||
use App\Filament\Resources\MfmParameterResource\Pages;
|
||||
use App\Filament\Resources\MfmParameterResource\RelationManagers;
|
||||
use App\Models\MfmParameter;
|
||||
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 MfmParameterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmParameter::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\Select::make('mfm_meter_id')
|
||||
->label('Mfm Meter')
|
||||
->relationship('mfmMeter', 'sequence')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Parameter Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('register_id')
|
||||
->label('Register ID')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('identifier')
|
||||
->label('Identifier')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('byte_to_convert')
|
||||
->label('Byte To Convert')
|
||||
->default(2)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('type_to_convert')
|
||||
->label('Type To Convert')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('decimal_to_display')
|
||||
->label('Decimal To Display')
|
||||
->default(1)
|
||||
->required(),
|
||||
])
|
||||
->columns(8),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Sequence')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Parameter Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('register_id')
|
||||
->label('Register ID')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('identifier')
|
||||
->label('Identifier')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('byte_to_convert')
|
||||
->label('Byte To Convert')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type_to_convert')
|
||||
->label('Type To Convert')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('decimal_to_display')
|
||||
->label('Decimal To Display')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(MfmParameterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import mfm parameter');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(MfmParameterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export mfm parameter');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmParameters::route('/'),
|
||||
'create' => Pages\CreateMfmParameter::route('/create'),
|
||||
'view' => Pages\ViewMfmParameter::route('/{record}'),
|
||||
'edit' => Pages\EditMfmParameter::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmParameter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmParameter extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmParameters extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmParameter extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
223
app/Filament/Resources/MfmReadingResource.php
Normal file
223
app/Filament/Resources/MfmReadingResource.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource\Pages;
|
||||
use App\Filament\Resources\MfmReadingResource\RelationManagers;
|
||||
use App\Models\MfmReading;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class MfmReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->relationship('mfmMeter', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('apparent_energy_received'),
|
||||
Forms\Components\TextInput::make('reactive_energy_received'),
|
||||
Forms\Components\TextInput::make('active_energy_received'),
|
||||
Forms\Components\TextInput::make('active_power_r'),
|
||||
Forms\Components\TextInput::make('active_power_y'),
|
||||
Forms\Components\TextInput::make('active_power_b'),
|
||||
Forms\Components\TextInput::make('active_power_total'),
|
||||
Forms\Components\TextInput::make('voltage_ry'),
|
||||
Forms\Components\TextInput::make('voltage_yb'),
|
||||
Forms\Components\TextInput::make('voltage_br'),
|
||||
Forms\Components\TextInput::make('current_r'),
|
||||
Forms\Components\TextInput::make('current_y'),
|
||||
Forms\Components\TextInput::make('current_b'),
|
||||
Forms\Components\TextInput::make('current_n'),
|
||||
Forms\Components\TextInput::make('voltage_r_n'),
|
||||
Forms\Components\TextInput::make('voltage_y_n'),
|
||||
Forms\Components\TextInput::make('voltage_b_n'),
|
||||
Forms\Components\TextInput::make('frequency'),
|
||||
Forms\Components\TextInput::make('power_factor_r'),
|
||||
Forms\Components\TextInput::make('power_factor_y'),
|
||||
Forms\Components\TextInput::make('power_factor_b'),
|
||||
Forms\Components\TextInput::make('power_factor_total'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Mfm Meter')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('apparent_energy_received')
|
||||
->label('Apparent Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('reactive_energy_received')
|
||||
->label('Reactive Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_energy_received')
|
||||
->label('Active Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_r')
|
||||
->label('Active Power R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_y')
|
||||
->label('Active Power Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_b')
|
||||
->label('Active Power B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_total')
|
||||
->label('Active Power Total')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_ry')
|
||||
->label('Voltage RY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_yb')
|
||||
->label('Voltage YB')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_br')
|
||||
->label('Voltage BR')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_r')
|
||||
->label('Current R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_y')
|
||||
->label('Current Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_b')
|
||||
->label('Current B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_n')
|
||||
->label('Current N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_r_n')
|
||||
->label('Voltage R N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_y_n')
|
||||
->label('Voltage Y N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_b_n')
|
||||
->label('Voltage B N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_r')
|
||||
->label('Power Factor R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_y')
|
||||
->label('Power Factor Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_b')
|
||||
->label('Power Factor B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_total')
|
||||
->label('Power Factor Total')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmReadings::route('/'),
|
||||
'create' => Pages\CreateMfmReading::route('/create'),
|
||||
'view' => Pages\ViewMfmReading::route('/{record}'),
|
||||
'edit' => Pages\EditMfmReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
125
app/Filament/Resources/ModuleListResource.php
Normal file
125
app/Filament/Resources/ModuleListResource.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource\Pages;
|
||||
use App\Filament\Resources\ModuleListResource\RelationManagers;
|
||||
use App\Models\ModuleList;
|
||||
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;
|
||||
|
||||
class ModuleListResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ModuleList::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Modules';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('module_name')
|
||||
->label('Module Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('dashboard_name')
|
||||
->label('DashBoard Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('filter_name')
|
||||
->label('Filter Name')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('module_name')
|
||||
->label('Module Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('dashboard_name')
|
||||
->label('DashBoard Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('filter_name')
|
||||
->label('Filter Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListModuleLists::route('/'),
|
||||
'create' => Pages\CreateModuleList::route('/create'),
|
||||
'view' => Pages\ViewModuleList::route('/{record}'),
|
||||
'edit' => Pages\EditModuleList::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateModuleList extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditModuleList extends EditRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListModuleLists extends ListRecords
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewModuleList extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Log;
|
||||
|
||||
@@ -62,8 +62,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number can't be empty")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
'plant_id' => $plantId,
|
||||
@@ -84,8 +85,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number is required to add.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -98,13 +100,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNumber) < 9)
|
||||
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number should contain minimum 9 digits.')
|
||||
->title('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -122,8 +125,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -148,8 +152,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : {$invoiceNumber}.<br>Scan the new serial number to add!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -174,7 +179,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
// Notification::make()
|
||||
// ->title("Scanned serial number '{$serialNumber}' exists in pallet table .<br>scan the valid serial number to proceed...")
|
||||
// ->danger()
|
||||
// ->duration(1200)
|
||||
// ->duration(5000)
|
||||
// ->send();
|
||||
// $this->form->fill([
|
||||
// 'serial_number' => null,
|
||||
@@ -193,7 +198,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' is already exists in pallet number '{$palletNumber}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
else if ($existingRecord && $existingRecord->pallet_number && $existingRecord->pallet_number != $palletNumber)
|
||||
@@ -201,7 +206,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already exists in pallet number '{$existingRecord->pallet_number}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
else if ($existingRecord && $existingRecord->locator_number)
|
||||
@@ -209,7 +214,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' is already exists in locator number '{$existingRecord->locator_number}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -279,7 +284,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Failed to insert scanned serial number '$serialNumber' into pallet table!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -300,7 +305,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
->title('Error: Serial not inserted.')
|
||||
->body("Something went wrong while inserting serial number '{$serialNumber}' into pallet table!\nScan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -376,7 +381,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' does not have serial numbers to save!<br>Add the valid serial number into pallet number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -402,7 +407,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' already completed the master packing!<br>Generate the new pallet number or choose from pending pallet list!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
@@ -433,7 +438,11 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()->title("Pallet number '$palletNumber' records saved successfully!")->success()->duration(800)->send();
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' records saved successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
@@ -460,7 +469,11 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()->title("Pallet number '$palletNumber' completed the master packing successfully!")->success()->duration(800)->send();
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' completed the master packing successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
@@ -502,7 +515,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Pallet number is required to remove.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -517,7 +530,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number is required to remove.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -532,12 +545,12 @@ class CreatePalletValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNumber) < 9)
|
||||
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number should contain minimum 9 digits.')
|
||||
->title('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -557,7 +570,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -583,7 +596,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number '{$invoiceExist->invoice_number}'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -607,7 +620,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number not exists in pallet table.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -634,8 +647,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number exist in pallet number '$palletExist->pallet_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -660,8 +674,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number exist in locator number '$locatorExist->locator_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -710,7 +725,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Failed to remove scanned serial number '$serialNumber' from pallet table!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -723,7 +738,6 @@ class CreatePalletValidation extends CreateRecord
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
|
||||
@@ -765,7 +779,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Pallet number is required.')
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
@@ -786,7 +800,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadLocator' ,'',$plantId);
|
||||
@@ -818,7 +832,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Already completed for pallet number $palletNumber!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
|
||||
@@ -1050,7 +1050,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
->body("Valid QR code scanned:<br>{$this->qrData}")
|
||||
->success()
|
||||
// ->persistent()
|
||||
->seconds(2)
|
||||
->duration(600)
|
||||
->send();
|
||||
|
||||
$formQRData = null;
|
||||
|
||||
@@ -172,8 +172,9 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
Notification::make()
|
||||
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$set('invoice_number', null);
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -209,8 +210,9 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
Notification::make()
|
||||
->title("Scanned pallet number '$palletNumber' does not completed the master packing!<br>Please, scan the valid completed pallet number to proceed...")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$set('scan_pallet_no', null);
|
||||
$set('update_pallet', null);
|
||||
return;
|
||||
|
||||
@@ -54,7 +54,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -83,7 +83,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -129,7 +129,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -148,13 +148,13 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) > 0 && strlen($serialNo) < 9)
|
||||
else if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -179,7 +179,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -252,7 +252,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Invoice Found')
|
||||
->body("Press 'Yes' and Press 'Enter' in Scan Invoice No to do rework for entire invoice.<br><br>Press 'No' to do rework against 'Pallet or Serial Number'..!")
|
||||
->info()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -278,7 +278,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -304,7 +304,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Choosed: Pallet Rework Type")
|
||||
->body("Scan valid pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -369,7 +369,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -398,7 +398,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -444,7 +444,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -470,7 +470,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -498,7 +498,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in scanned invoice number '$invoiceNo'!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -518,13 +518,13 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($serialNo) > 0 && strlen($serialNo) < 9)
|
||||
if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, $palletNo, $plantId, $reworkType);
|
||||
@@ -549,7 +549,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, $palletNo, $plantId, $reworkType);
|
||||
@@ -599,7 +599,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Pallet from Invoice')
|
||||
->body("Scanned pallet number '$palletNo' successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next pallet number to proceed..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$InvoiceSerialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->first();
|
||||
@@ -609,7 +609,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("All available serial numbers are successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next invoice number to proceed..!")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -651,7 +651,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -679,7 +679,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -705,7 +705,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -733,7 +733,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -773,7 +773,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Locator Pallet Found')
|
||||
->body("Scanned pallet number '$palletNo' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -794,13 +794,13 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($serialNo) > 0 && strlen($serialNo) < 9)
|
||||
if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -825,7 +825,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -881,7 +881,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Pallet Found')
|
||||
->body("Press 'Yes' and Press 'Enter' in Scan Pallet No to do re-master packing for entire pallet.<br><br>Press 'No' to do partial re-master packing against 'Serial Number'..!")
|
||||
->info()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -908,7 +908,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Completed')
|
||||
->body("Scanned pallet number '$palletNo' doesn't completed the master packing!<br><br>Please, scan the valid completed pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -933,7 +933,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -989,7 +989,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1018,7 +1018,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1064,7 +1064,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1089,7 +1089,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1109,13 +1109,13 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 9)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1140,7 +1140,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1168,7 +1168,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Serial Not Found')
|
||||
->body("Serial number '$serialNo' doesn't exist in scanned invoice number '$invoiceNo'!<br><br>Scan the valid exist 'Serial Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1218,7 +1218,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Serial from Invoice')
|
||||
->body("Scanned serial number '$serialNo' successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next serial number to proceed..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$InvoiceSerialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->first();
|
||||
@@ -1228,7 +1228,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("All available serial numbers are successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next invoice number to proceed..!")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1270,7 +1270,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1298,7 +1298,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1324,7 +1324,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1352,7 +1352,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1392,7 +1392,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Locator Pallet Found')
|
||||
->body("Scanned pallet number '$palletNo' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '' , '', $plantId, $reworkType);
|
||||
@@ -1419,7 +1419,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -1439,13 +1439,13 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 9)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 9 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -1470,7 +1470,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -1498,7 +1498,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Serial Not Found')
|
||||
->body("Serial number '$serialNo' doesn't exist in pallet number '$palletNo'!<br><br>Scan the valid exist 'Serial Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -1520,9 +1520,10 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($records as $row)
|
||||
{
|
||||
if ($PalletSerialNumbers->serial_number != null && $PalletSerialNumbers->serial_number != '' && $PalletSerialNumbers->serial_number != $serialNo)
|
||||
if ($row->serial_number != null && $row->serial_number != '' && $row->serial_number == $serialNo)
|
||||
{
|
||||
$row->forceDelete();
|
||||
continue;
|
||||
}
|
||||
|
||||
$row->pallet_status = null;
|
||||
@@ -1535,7 +1536,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Serial from Pallet')
|
||||
->body("Scanned serial number '$serialNo' successfully removed from pallet number '$palletNo'.<br><br>Please, scan the next pallet number to re-master packing..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$PalletSerialNumbers = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNo)->first();
|
||||
@@ -1545,7 +1546,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNo' successfully re-master packed.<br><br>Please, scan the next pallet number to re-master packing..!")
|
||||
->success()
|
||||
->duration(1000)
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1588,7 +1589,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Completed')
|
||||
->body("Pallet number '$palletNo' doesn't completed the master packing for scanned serial number '$serialNo'!<br><br>Please, scan the valid completed pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '' , '', $plantId, $reworkType);
|
||||
@@ -1613,7 +1614,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(1200)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
|
||||
134
app/Filament/Resources/TempLiveReadingResource.php
Normal file
134
app/Filament/Resources/TempLiveReadingResource.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
|
||||
use App\Models\MfmMeter;
|
||||
use App\Models\TempLiveReading;
|
||||
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;
|
||||
|
||||
class TempLiveReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TempLiveReading::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')
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->label('MFM Meter ID')
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return MfmMeter::where('plant_id', $plantId)
|
||||
->pluck('sequence', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('register_data')
|
||||
->label('Register Data')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('mfm_meter_id.sequence')
|
||||
// ->label('Sequence')
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('register_data')
|
||||
->label('Register Data')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTempLiveReadings::route('/'),
|
||||
'create' => Pages\CreateTempLiveReading::route('/create'),
|
||||
'view' => Pages\ViewTempLiveReading::route('/{record}'),
|
||||
'edit' => Pages\EditTempLiveReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTempLiveReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTempLiveReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTempLiveReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewTempLiveReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
205
app/Http/Controllers/MfmParameterController.php
Normal file
205
app/Http/Controllers/MfmParameterController.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\MfmMeter;
|
||||
use App\Models\MfmParameter;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MfmParameterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
public function get_mfm_parameterid(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);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
|
||||
if (!$plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
// $sequences = MfmMeter::where('plant_id', $plant->id)
|
||||
// ->whereNotNull('sequence')
|
||||
// ->distinct()
|
||||
// ->orderBy('sequence', 'asc')
|
||||
// ->pluck('sequence');
|
||||
$sequences = MfmMeter::where('plant_id', $plant->id)
|
||||
->whereNotNull('sequence')
|
||||
->pluck('sequence')
|
||||
->unique()
|
||||
->map(fn($s) => is_numeric($s) ? (int) $s : $s)
|
||||
->sort()
|
||||
->values();
|
||||
|
||||
if ($sequences->isEmpty())
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No sequences found for the given plant.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $sequences
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
public function get_mfm_parameter(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);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$mfmParameterSeq = $request->header('mfm-meter-sequence');
|
||||
|
||||
if (!$plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
else if (!$mfmParameterSeq) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Mfm Parameter sequence value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'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)
|
||||
->first();
|
||||
|
||||
if (!$mfmMeter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "MFM Meter with sequence '{$mfmParameterSeq}' not found for plant code '{$plantCode}'"
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Now fetch mfm_parameters for this plant and meter
|
||||
$mfmParameters = MfmParameter::where('plant_id', $plant->id)
|
||||
->where('mfm_meter_id', $mfmMeter->id)
|
||||
->get(['register_id', 'byte_to_convert', 'type_to_convert', 'decimal_to_display']);
|
||||
|
||||
$transformed = $mfmParameters->map(function ($item) {
|
||||
$array = $item->toArray();
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_null($value)) {
|
||||
$array[$key] = "";
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
});
|
||||
|
||||
//..if want to send all values in string
|
||||
// $transformed = $mfmParameters->map(function ($item) {
|
||||
// $array = $item->toArray();
|
||||
// foreach ($array as $key => $value) {
|
||||
// // Always cast to string (empty string if null)
|
||||
// $array[$key] = is_null($value) ? "" : strval($value);
|
||||
// }
|
||||
// return $array;
|
||||
// });
|
||||
|
||||
|
||||
if ($transformed->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "No MFM parameters found for the specified plant and meter."
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Success: return list
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $transformed
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
103
app/Http/Controllers/ModuleChartController.php
Normal file
103
app/Http/Controllers/ModuleChartController.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ModuleList;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleChartController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_moduleChart(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);
|
||||
}
|
||||
|
||||
$moduleName = $request->header('module-name');
|
||||
|
||||
if (empty($moduleName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Module Name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$exists = ModuleList::where('module_name', $moduleName)->exists();
|
||||
|
||||
if (!$exists) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Module Name '{$moduleName}' not found in system!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Fetch all unique dashboard names for the given module_name
|
||||
// $dashboardNames = ModuleList::where('module_name', $moduleName)
|
||||
// ->distinct()
|
||||
// ->pluck('dashboard_name');
|
||||
$dashboardNames = ModuleList::where('module_name', $moduleName)
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->unique('dashboard_name')
|
||||
->pluck('dashboard_name')
|
||||
->values(); // reset array keys
|
||||
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $dashboardNames
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
105
app/Http/Controllers/ModuleController.php
Normal file
105
app/Http/Controllers/ModuleController.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ModuleList;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
// public function show(string $id)
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public function get_module(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);
|
||||
}
|
||||
|
||||
$moduleName = $request->header('module-name');
|
||||
|
||||
if (empty($moduleName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Module Name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$headerValue = $request->header('module-name');
|
||||
|
||||
if ($headerValue != 'Module List') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid value for 'module-name' header!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$uniqueModules = ModuleList::select('module_name', 'created_at')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->unique('module_name')
|
||||
->pluck('module_name')
|
||||
->values();
|
||||
|
||||
if ($uniqueModules->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Module names not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $uniqueModules
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
106
app/Http/Controllers/ModuleFGLineController.php
Normal file
106
app/Http/Controllers/ModuleFGLineController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\ModuleList;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleFGLineController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_moduleFGFilter(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);
|
||||
}
|
||||
|
||||
$lineName = $request->header('line-name');
|
||||
|
||||
if (empty($lineName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
|
||||
if (!$line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line '{$lineName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($line->type !== 'FG Line') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line '{$lineName}' is not of type FG Line."
|
||||
], 400);
|
||||
}
|
||||
// Default logic to return filter names
|
||||
$filterNames = ModuleList::orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->unique('filter_name')
|
||||
->pluck('filter_name')
|
||||
->filter()
|
||||
->values();
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $filterNames
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
119
app/Http/Controllers/ModuleFilterController.php
Normal file
119
app/Http/Controllers/ModuleFilterController.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ModuleList;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleFilterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_moduleFilter(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);
|
||||
}
|
||||
|
||||
$lineName = $request->header('line-name');
|
||||
|
||||
if (empty($lineName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
// If 'line-name' is 'FG Lines', return actual FG Line names
|
||||
if (strtolower(trim($lineName)) == 'fg lines') {
|
||||
$fgLines = \App\Models\Line::where('type', 'FG Line')
|
||||
->orderBy('created_at', 'asc')
|
||||
->pluck('name');
|
||||
|
||||
if ($fgLines->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No FG Lines found!'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $fgLines
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Default logic to return filter names
|
||||
$filterNames = ModuleList::orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->unique('filter_name')
|
||||
->pluck('filter_name')
|
||||
->filter()
|
||||
->values();
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $filterNames
|
||||
], 200);
|
||||
|
||||
// $filterNames = ModuleList::orderBy('created_at', 'asc')
|
||||
// ->get()
|
||||
// ->unique('filter_name')
|
||||
// ->pluck('filter_name')
|
||||
// ->filter()
|
||||
// ->values();
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'status_description' => $filterNames
|
||||
// ], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
573
app/Http/Controllers/ModuleFilterDataController.php
Normal file
573
app/Http/Controllers/ModuleFilterDataController.php
Normal file
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ModuleFilterDataController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// public function get_moduleFilterData(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);
|
||||
// }
|
||||
|
||||
// $moduleName = $request->header('module-name');
|
||||
// $chartName = $request->header('chart-name');
|
||||
// $plantName = $request->header('plant-name');
|
||||
// $lineName = $request->header('line-name');
|
||||
// $filterName = $request->header('filter-name');
|
||||
|
||||
// $requiredHeaders = [
|
||||
// 'module-name',
|
||||
// 'chart-name',
|
||||
// 'plant-name',
|
||||
// 'line-name',
|
||||
// 'filter-name',
|
||||
// ];
|
||||
|
||||
// $missingHeaders = [];
|
||||
|
||||
// foreach ($requiredHeaders as $header) {
|
||||
// if (empty($request->header($header))) {
|
||||
// $missingHeaders[] = $header;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!empty($missingHeaders)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
// ], 400);
|
||||
// }
|
||||
|
||||
// // Fetch plant ID
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// // Fetch line ID
|
||||
// $line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
// if (!$line) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Line '{$lineName}' not found for plant '{$plantName}'"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $activeFilter = strtolower(trim($request->header('filter-name')));
|
||||
|
||||
// if ($activeFilter == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// }
|
||||
// elseif ($activeFilter == 'this week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// }
|
||||
// elseif ($activeFilter == 'this month') {
|
||||
// $startDate = now()->startOfMonth();
|
||||
// $endDate = now()->endOfMonth();
|
||||
// }
|
||||
// else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// }
|
||||
|
||||
// $rowCount = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'status_description' => $rowCount
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
// public function get_moduleFilterData(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);
|
||||
// }
|
||||
|
||||
// $requiredHeaders = [
|
||||
// 'module-name',
|
||||
// 'chart-name',
|
||||
// 'plant-name',
|
||||
// 'line-name',
|
||||
// 'filter-name',
|
||||
// ];
|
||||
|
||||
// $missingHeaders = [];
|
||||
|
||||
// foreach ($requiredHeaders as $header) {
|
||||
// if (empty($request->header($header))) {
|
||||
// $missingHeaders[] = $header;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!empty($missingHeaders)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
// $filterHeader = $request->header('filter-name');
|
||||
|
||||
// if (!in_array($filterHeader, $validFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $plantName = $request->header('plant-name');
|
||||
// $lineName = $request->header('line-name');
|
||||
// $filterName = strtolower(trim($request->header('filter-name')));
|
||||
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// // Set date filter range
|
||||
// if ($filterName == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// } elseif ($filterName == 'this week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// } elseif ($filterName == 'this month') {
|
||||
// $startDate = now()->startOfMonth();
|
||||
// $endDate = now()->endOfMonth();
|
||||
// } else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// }
|
||||
|
||||
// // Handle All Lines
|
||||
// if (strtolower(trim($lineName)) == 'all lines') {
|
||||
// $lines = Line::where('plant_id', $plant->id)->pluck('id', 'name');
|
||||
|
||||
// if ($lines->isEmpty()) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "No lines found for plant '{$plantName}'"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $lineCounts = [];
|
||||
|
||||
// foreach ($lines as $name => $id) {
|
||||
// $count = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $lineCounts[$name] = $count;
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'status_description' => $lineCounts
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
// // Handle single line
|
||||
// $line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
// if (!$line) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Line '{$lineName}' not found for plant '{$plantName}'"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $rowCount = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $chartName = $request->header('chart-name');
|
||||
|
||||
// if ($chartName == 'Production Hourly Count')
|
||||
// {
|
||||
|
||||
// if ($filterHeader == 'Today' || $filterHeader == 'Yesterday') {
|
||||
// $hourlyCounts = [];
|
||||
|
||||
// $hourStart = now()->startOfDay()->addHours(8); // Today 8:00 AM
|
||||
// if ($filterHeader == 'Yesterday') {
|
||||
// $hourStart->subDay(); // Yesterday 8:00 AM
|
||||
// }
|
||||
|
||||
// $hourEndFinal = $hourStart->copy()->addDay(); // +1 day = 24 hourly slots
|
||||
|
||||
// while ($hourStart < $hourEndFinal) {
|
||||
// $hourEnd = $hourStart->copy()->addHour();
|
||||
|
||||
// $label = $hourStart->format('g:i A') . ' to ' . $hourEnd->format('g:i A');
|
||||
|
||||
// $count = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$hourStart, $hourEnd])
|
||||
// ->count();
|
||||
|
||||
// $hourlyCounts[$label] = $count;
|
||||
|
||||
// $hourStart = $hourEnd;
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'hourly_data' => $hourlyCounts
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
// // THIS WEEK: group by weekdays (Mon to Sun)
|
||||
// if ($filterHeader == 'This Week') {
|
||||
// $dowCounts = ProductionQuantity::selectRaw('EXTRACT(DOW FROM created_at) as dow, COUNT(*) as total')
|
||||
// ->where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->groupBy('dow')
|
||||
// ->pluck('total', 'dow');
|
||||
|
||||
// $labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
// $data = array_fill(0, 7, 0);
|
||||
|
||||
// foreach ($dowCounts as $dow => $count) {
|
||||
// $data[$dow] = $count;
|
||||
// }
|
||||
|
||||
// // Reorder from Monday (1) to Sunday (0)
|
||||
// $orderedData = [
|
||||
// $data[1] ?? 0,
|
||||
// $data[2] ?? 0,
|
||||
// $data[3] ?? 0,
|
||||
// $data[4] ?? 0,
|
||||
// $data[5] ?? 0,
|
||||
// $data[6] ?? 0,
|
||||
// $data[0] ?? 0
|
||||
// ];
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'weekly_labels' => $labels,
|
||||
// 'weekly_counts' => $orderedData
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
// //THIS MONTH: group by weeks
|
||||
// if ($filterHeader == 'This Month') {
|
||||
// // Count records grouped by week number
|
||||
// $weekCounts = ProductionQuantity::selectRaw("FLOOR((EXTRACT(DAY FROM created_at) - 1) / 7) + 1 as week_number, COUNT(*) as total")
|
||||
// ->where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->groupBy('week_number')
|
||||
// ->pluck('total', 'week_number');
|
||||
|
||||
// $weeksCount = ceil($endDate->day / 7); // Total number of weeks in month
|
||||
// $allWeeks = array_fill(1, $weeksCount, 0);
|
||||
// $data = array_replace($allWeeks, $weekCounts->toArray());
|
||||
|
||||
// // Prepare labels like Week 1 (01 Jul - 07 Jul)
|
||||
// $labels = [];
|
||||
// for ($i = 1; $i <= $weeksCount; $i++) {
|
||||
// $weekStart = $startDate->copy()->addDays(($i - 1) * 7);
|
||||
// $weekEnd = $startDate->copy()->addDays($i * 7 - 1)->min($endDate);
|
||||
|
||||
// $labels[] = "Week $i ({$weekStart->format('d M')} - {$weekEnd->format('d M')})";
|
||||
// }
|
||||
|
||||
// $orderedData = array_values($data);
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'monthly_labels' => $labels,
|
||||
// 'monthly_counts' => $orderedData
|
||||
// ], 200);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($chartName == 'Production Line Count')
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'status_description' => $rowCount
|
||||
// ], 200);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function get_moduleFilterData(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);
|
||||
}
|
||||
|
||||
$requiredHeaders = [
|
||||
'module-name', 'chart-name', 'plant-name', 'line-name', 'filter-name'
|
||||
];
|
||||
|
||||
$missingHeaders = [];
|
||||
foreach ($requiredHeaders as $header) {
|
||||
if (empty($request->header($header))) {
|
||||
$missingHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missingHeaders)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
$filterHeader = $request->header('filter-name');
|
||||
|
||||
if (!in_array($filterHeader, $validFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$lineName = $request->header('line-name');
|
||||
$filterName = strtolower(trim($request->header('filter-name')));
|
||||
$chartName = $request->header('chart-name');
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$isAllLines = strtolower(trim($lineName)) == 'all lines';
|
||||
|
||||
if ($isAllLines) {
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
$fgLineIds = $lines->where('type', 'FG Line')->pluck('id')->toArray();
|
||||
$nonFgLineIds = $lines->where('type', '!=', 'FG Line')->pluck('id')->toArray();
|
||||
} else {
|
||||
$line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
if (!$line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line '{$lineName}' not found for plant '{$plantName}'"
|
||||
], 404);
|
||||
}
|
||||
$lineIds = [$line->id];
|
||||
$isFgLine = $line->type == 'FG Line';
|
||||
$baseTable = $isFgLine ? 'quality_validations' : 'production_quantities';
|
||||
}
|
||||
|
||||
if ($filterName == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
$groupBy = 'EXTRACT(HOUR FROM created_at)';
|
||||
} elseif ($filterName == 'this week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'EXTRACT(DOW FROM created_at)';
|
||||
} elseif ($filterName == 'this month') {
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
$groupBy = "FLOOR((EXTRACT(DAY FROM created_at) - 1) / 7) + 1";
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'EXTRACT(HOUR FROM created_at)';
|
||||
}
|
||||
|
||||
if ($chartName == 'Production Line Count' && $isAllLines) {
|
||||
$lineCounts = [];
|
||||
foreach ($lines as $line) {
|
||||
$table = ($line->type == 'FG Line') ? 'quality_validations' : 'production_quantities';
|
||||
$count = DB::table($table)
|
||||
->where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
$lineCounts[$line->name] = $count;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $lineCounts
|
||||
], 200);
|
||||
}
|
||||
|
||||
if (!$isAllLines)
|
||||
{
|
||||
$rowCount = DB::table($baseTable)
|
||||
->where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$query = DB::table($baseTable)
|
||||
->selectRaw("$groupBy AS time_unit, COUNT(*) AS total_quantity")
|
||||
->where('created_at', '>=', $startDate)
|
||||
->where('created_at', '<', $endDate)
|
||||
->where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->groupByRaw($groupBy)
|
||||
->orderByRaw($groupBy)
|
||||
->pluck('total_quantity', 'time_unit')
|
||||
->toArray();
|
||||
|
||||
if ($chartName == 'Production Hourly Count') {
|
||||
if ($filterName == 'this month') {
|
||||
$weeksCount = ceil($endDate->day / 7);
|
||||
$allWeeks = array_fill(1, $weeksCount, 0);
|
||||
$data = array_replace($allWeeks, $query);
|
||||
$labels = [];
|
||||
for ($i = 1; $i <= $weeksCount; $i++) {
|
||||
$weekStart = $startDate->copy()->addDays(($i - 1) * 7)->format('d M');
|
||||
$weekEnd = $startDate->copy()->addDays($i * 7 - 1)->min($endDate)->format('d M');
|
||||
$labels[] = "Week $i ($weekStart - $weekEnd)";
|
||||
}
|
||||
$orderedData = array_values($data);
|
||||
} elseif ($filterName == 'this week') {
|
||||
$labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
$data = array_fill(0, 7, 0);
|
||||
foreach ($query as $dow => $count) {
|
||||
$data[$dow] = $count;
|
||||
}
|
||||
$orderedData = [
|
||||
$data[1] ?? 0, $data[2] ?? 0, $data[3] ?? 0,
|
||||
$data[4] ?? 0, $data[5] ?? 0, $data[6] ?? 0,
|
||||
$data[0] ?? 0,
|
||||
];
|
||||
} else {
|
||||
$allHours = array_fill(0, 24, 0);
|
||||
$data = array_replace($allHours, $query);
|
||||
$shiftedData = [];
|
||||
foreach ($data as $hour => $count) {
|
||||
$nextHour = ($hour + 1) % 24;
|
||||
$shiftedData[$nextHour] = $count;
|
||||
}
|
||||
$shiftedKeys = array_merge(range(9, 23), range(0, 8));
|
||||
$orderedData = array_map(fn($hour) => $shiftedData[$hour] ?? 0, $shiftedKeys);
|
||||
$labels = array_map(function ($hour) {
|
||||
$prevHour = ($hour - 1 + 24) % 24;
|
||||
return date("g:i A", strtotime("$prevHour:00")) . ' to ' . date("g:i A", strtotime("$hour:00"));
|
||||
}, $shiftedKeys);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'datasets' => [[
|
||||
'label' => match ($filterName) {
|
||||
'this week' => $isFgLine ? 'Daily FG Count This Week' : 'Daily Production This Week',
|
||||
'this month' => $isFgLine ? 'Weekly FG Count This Month' : 'Weekly Production This Month',
|
||||
'yesterday' => $isFgLine ? "Yesterday's FG Count" : "Yesterday's Hourly Production",
|
||||
default => $isFgLine ? "Today's FG Count" : "Today's Hourly Production",
|
||||
},
|
||||
'data' => $orderedData
|
||||
]],
|
||||
'labels' => $labels,
|
||||
], 200);
|
||||
}
|
||||
|
||||
if ($chartName == 'Production Line Count') {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $rowCount
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
191
app/Http/Controllers/ModuleGuardDayCountController.php
Normal file
191
app/Http/Controllers/ModuleGuardDayCountController.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleGuardDayCountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_guardDay_countData(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$filterHeader = $request->header('filter-name');
|
||||
|
||||
if (empty($plantName) || empty($filterHeader)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Missing required headers: plant-name, or filter-name"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
if (!in_array($filterHeader, $validFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $selectedPlant = $plant->id;
|
||||
// $activeFilter = strtolower(trim($filterHeader));
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedPlant = $plant->id;
|
||||
$activeFilter = strtolower(trim($filterHeader));
|
||||
|
||||
// Set date range based on filter
|
||||
switch ($activeFilter) {
|
||||
case 'yesterday':
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
$endDate = now()->subDay()->endOfDay();
|
||||
break;
|
||||
case 'this week':
|
||||
$startDate = now()->startOfWeek();
|
||||
$endDate = now()->endOfWeek();
|
||||
break;
|
||||
case 'this month':
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
break;
|
||||
default: // today
|
||||
$startDate = now()->startOfDay();
|
||||
$endDate = now()->endOfDay();
|
||||
break;
|
||||
}
|
||||
|
||||
// Get all unique guard names for this plant
|
||||
$uniqueGuardNames = GuardPatrolEntry::join('guard_names', 'guard_patrol_entries.guard_name_id', '=', 'guard_names.id')
|
||||
->where('guard_patrol_entries.plant_id', $selectedPlant)
|
||||
->select('guard_names.id', 'guard_names.name')
|
||||
->groupBy('guard_names.id', 'guard_names.name')
|
||||
->orderBy('guard_names.name')
|
||||
->pluck('name')
|
||||
->toArray();
|
||||
|
||||
// Get all patrol entries within the date range, grouped by guard name
|
||||
$guardPatrols = GuardPatrolEntry::join('guard_names', 'guard_patrol_entries.guard_name_id', '=', 'guard_names.id')
|
||||
->where('guard_patrol_entries.plant_id', $selectedPlant)
|
||||
->whereBetween('guard_patrol_entries.patrol_time', [$startDate, $endDate])
|
||||
->select('guard_names.id', 'guard_names.name', 'guard_patrol_entries.patrol_time')
|
||||
->orderBy('guard_names.name')
|
||||
->orderBy('guard_patrol_entries.patrol_time')
|
||||
->get()
|
||||
->groupBy('name');
|
||||
|
||||
$guardTimeSums = [];
|
||||
|
||||
foreach ($guardPatrols as $guardName => $patrols) {
|
||||
$totalSeconds = 0;
|
||||
$prevTime = null;
|
||||
|
||||
foreach ($patrols as $patrol) {
|
||||
$currentTime = Carbon::parse($patrol->patrol_time);
|
||||
if ($prevTime) {
|
||||
$totalSeconds += abs($currentTime->diffInSeconds($prevTime));
|
||||
}
|
||||
$prevTime = $currentTime;
|
||||
}
|
||||
|
||||
$guardTimeSums[$guardName] = [
|
||||
'minutes' => round($totalSeconds / 60),
|
||||
'hours' => round($totalSeconds / 3600, 1),
|
||||
];
|
||||
}
|
||||
|
||||
// Prepare chart data
|
||||
$chartData = [];
|
||||
foreach ($uniqueGuardNames as $guardName) {
|
||||
if (in_array($activeFilter, ['today', 'yesterday'])) {
|
||||
$chartData[] = $guardTimeSums[$guardName]['minutes'] ?? 0;
|
||||
} else {
|
||||
$chartData[] = $guardTimeSums[$guardName]['hours'] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
// $chartData = array_map(function ($value) {
|
||||
// return ($value == 0 || is_null($value)) ? null : $value;
|
||||
// }, $chartData);
|
||||
|
||||
$chartData = array_map(function ($value) {
|
||||
return ($value == 0 || is_null($value)) ? "" : $value;
|
||||
}, $chartData);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => array_values($uniqueGuardNames),
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => match ($activeFilter) {
|
||||
'yesterday' => "Patrols by Guard (Yesterday) Minutes",
|
||||
'this week' => "Patrols by Guard (This Week) Hours",
|
||||
'this month' => "Patrols by Guard (This Month) Hours",
|
||||
default => "Patrols by Guard (Today) Minutes",
|
||||
},
|
||||
'data' => $chartData,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
173
app/Http/Controllers/ModuleGuardHourlyCountController.php
Normal file
173
app/Http/Controllers/ModuleGuardHourlyCountController.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CheckPointTime;
|
||||
use App\Models\GuardName;
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleGuardHourlyCountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_guardDay_hourlyData(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$dateHeader = $request->header('date'); // required: format Y-m-d
|
||||
$guardIdHeader = $request->header('guard-name'); // required: guard_name_id
|
||||
$timeHeader = $request->header('time-range'); // required: "08:00 - 10:00"
|
||||
|
||||
if (!$plantName || !$dateHeader || !$guardIdHeader || !$timeHeader) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missing one or more headers: plant-name, date, guard-name, time-range'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedPlant = $plant->id;
|
||||
//$selectedDate = $dateHeader;
|
||||
$selectedDate = Carbon::createFromFormat('d-m-Y', $dateHeader)->format('Y-m-d');
|
||||
// $selectedGuardId = $guardIdHeader;
|
||||
$guard = GuardName::where('name', $guardIdHeader)->first();
|
||||
|
||||
if (!$guard) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Guard '{$guardIdHeader}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedGuardId = $guard->id;
|
||||
|
||||
[$startTime, $endTime] = explode(' - ', $timeHeader);
|
||||
// $startFormatted = Carbon::parse("{$selectedDate} {$startTime}");
|
||||
// $endFormatted = Carbon::parse("{$selectedDate} {$endTime}");
|
||||
|
||||
// $startDateTime = $startFormatted->format('H:i:s');
|
||||
// $endDateTime = $endFormatted->format('H:i:s');
|
||||
try
|
||||
{
|
||||
[$startTime, $endTime] = explode(' - ', $timeHeader);
|
||||
$startDateTime = Carbon::parse("{$selectedDate} {$startTime}");
|
||||
$endDateTime = Carbon::parse("{$selectedDate} {$endTime}");
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid time-range format. Use HH:MM:SS - HH:MM:SS"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$patrols = GuardPatrolEntry::where('plant_id', $selectedPlant)
|
||||
->where('guard_name_id', $selectedGuardId)
|
||||
->whereBetween('patrol_time', [$startDateTime, $endDateTime])
|
||||
->orderBy('patrol_time')
|
||||
->get();
|
||||
|
||||
if ($patrols->count() < 2) {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => [],
|
||||
'datasets' => []
|
||||
]);
|
||||
}
|
||||
|
||||
$checkPointTimes = CheckPointTime::where('plant_id', $selectedPlant)
|
||||
->orderBy('sequence_number')
|
||||
->get(['sequence_number', 'min_cushioning', 'max_cushioning', 'check_point1_id', 'check_point2_id']);
|
||||
|
||||
$expectedSequence = [];
|
||||
foreach ($checkPointTimes as $row) {
|
||||
$expectedSequence[] = $row->check_point1_id;
|
||||
}
|
||||
if ($checkPointTimes->isNotEmpty()) {
|
||||
$expectedSequence[] = $checkPointTimes->last()->check_point2_id;
|
||||
}
|
||||
|
||||
$intervals = [];
|
||||
$labels = [];
|
||||
$currentSeqIndex = 0;
|
||||
|
||||
for ($i = 0; $i < $patrols->count() - 1; $i++) {
|
||||
$current = Carbon::parse($patrols[$i]->patrol_time);
|
||||
$next = Carbon::parse($patrols[$i + 1]->patrol_time);
|
||||
$interval = round($next->floatDiffInRealSeconds($current, true) / 60, 2);
|
||||
|
||||
$intervals[] = $interval;
|
||||
$labels[] = "Seq " . ($i + 1);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Interval (minutes)',
|
||||
'data' => array_map(fn($val) => $val ?: "", $intervals),
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
124
app/Http/Controllers/ModuleGuardNameController.php
Normal file
124
app/Http/Controllers/ModuleGuardNameController.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleGuardNameController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_guard_name_Data(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$dateHeader = $request->header('date');
|
||||
|
||||
if (!$plantName) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
else if (!$dateHeader) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Date value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedPlant = $plant->id;
|
||||
|
||||
try
|
||||
{
|
||||
$selectedDate = Carbon::createFromFormat('d-m-Y', $dateHeader)->format('Y-m-d');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid date format. Expected format: d-m-Y"
|
||||
], 400);
|
||||
}
|
||||
//$selectedDate = Carbon::createFromFormat('d-m-Y', $dateHeader)->format('Y-m-d');
|
||||
|
||||
$guardNames = GuardPatrolEntry::join('guard_names', 'guard_patrol_entries.guard_name_id', '=', 'guard_names.id')
|
||||
->where('guard_patrol_entries.plant_id', $selectedPlant)
|
||||
->whereDate('guard_patrol_entries.patrol_time', $selectedDate)
|
||||
->select('guard_names.name')
|
||||
->distinct()
|
||||
->orderBy('guard_names.name')
|
||||
->pluck('name');
|
||||
|
||||
if ($guardNames->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Guard names not found for the selected plant and date.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $guardNames,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
91
app/Http/Controllers/ModuleInvoiceDataController.php
Normal file
91
app/Http/Controllers/ModuleInvoiceDataController.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleInvoiceDataController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_invoiceData(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);
|
||||
}
|
||||
|
||||
$moduleName = $request->header('invoice-type-list');
|
||||
|
||||
if (empty($moduleName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invoice type can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$headerValue = $request->header('invoice-type-list');
|
||||
|
||||
if ($headerValue != 'Invoice Type List') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid value for 'invoice-type-list' header!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$invoiceTypes = ['All Invoice', 'Serial Invoice', 'Individual Invoice', 'Bundle Invoice'];
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $invoiceTypes
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
274
app/Http/Controllers/ModuleInvoiceQuantityController.php
Normal file
274
app/Http/Controllers/ModuleInvoiceQuantityController.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleInvoiceQuantityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// public function get_invoiceQuantityData(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);
|
||||
// }
|
||||
|
||||
// $plantName = $request->header('plant-name');
|
||||
// $filterHeader = $request->header('filter-name');
|
||||
// $invoiceHeader = $request->header('invoice-name');
|
||||
|
||||
// if (empty($plantName) || empty($invoiceHeader) || empty($filterHeader)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Missing required headers: plant-name, invoice-name, or filter-name"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
// if (!in_array($filterHeader, $validFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validInvoiceFilters = ['All Invoice', 'Serial Invoice', 'Individual Invoice', 'Bundle Invoice'];
|
||||
// if (!in_array($invoiceHeader, $validInvoiceFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid invoice-name value! Accepted values are: " . implode(', ', $validInvoiceFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $selectedPlant = $plant->id;
|
||||
// $activeFilter = strtolower(trim($filterHeader));
|
||||
// $selectedInvoice = strtolower(trim($invoiceHeader));
|
||||
|
||||
// // Set time range
|
||||
// if ($activeFilter == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// } elseif ($activeFilter == 'this week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// } elseif ($activeFilter == 'this month') {
|
||||
// $startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
// } else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// }
|
||||
|
||||
// $labels = [];
|
||||
// $datasets = [];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function get_invoiceQuantityData(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$filterHeader = $request->header('filter-name');
|
||||
$invoiceHeader = $request->header('invoice-name');
|
||||
|
||||
if (empty($plantName) || empty($invoiceHeader) || empty($filterHeader)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Missing required headers: plant-name, invoice-name, or filter-name"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
if (!in_array($filterHeader, $validFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validInvoiceFilters = ['All Invoice', 'Serial Invoice', 'Individual Invoice', 'Bundle Invoice'];
|
||||
if (!in_array($invoiceHeader, $validInvoiceFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid invoice-name value! Accepted values are: " . implode(', ', $validInvoiceFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedPlant = $plant->id;
|
||||
$activeFilter = strtolower(trim($filterHeader));
|
||||
$selectedInvoice = strtolower(trim($invoiceHeader));
|
||||
|
||||
// Set time range
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
} elseif ($activeFilter == 'this week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
} elseif ($activeFilter == 'this month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
$types = ['individual_invoice', 'serial_invoice', 'bundle_invoice'];
|
||||
if ($selectedInvoice != 'all invoice') {
|
||||
$types = [str_replace(' ', '_', $selectedInvoice)];
|
||||
}
|
||||
|
||||
$labels = ['Total Invoices', 'Scanned Invoices'];
|
||||
$datasets = [];
|
||||
|
||||
$totals = [];
|
||||
$scanneds = [];
|
||||
|
||||
foreach ($types as $type) {
|
||||
$query = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$startDate, $endDate]);
|
||||
|
||||
$completedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$startDate, $endDate]);
|
||||
|
||||
if ($type == 'individual_invoice') {
|
||||
$query->where('quantity', 1);
|
||||
$completedQuery->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '');
|
||||
} elseif ($type == 'serial_invoice') {
|
||||
$query->whereNull('quantity');
|
||||
$completedQuery->where('scanned_status', 'Scanned')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('quantity')->orWhere('quantity', 0);
|
||||
});
|
||||
} elseif ($type == 'bundle_invoice') {
|
||||
$query->where('quantity', '>', 1);
|
||||
$completedQuery->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '');
|
||||
}
|
||||
|
||||
$totals[] = $query->count();
|
||||
$scanneds[] = $completedQuery->count();
|
||||
}
|
||||
|
||||
// if (count($types) == 1) {
|
||||
// $datasets[] = [
|
||||
// 'label' => 'Invoices',
|
||||
// 'data' => [$totals[0], $scanneds[0]],
|
||||
// ];
|
||||
// }
|
||||
if (count($types) == 1)
|
||||
{
|
||||
$invoiceLabel = ucwords(str_replace('_invoice', '', str_replace('_', ' ', $types[0])));
|
||||
$datasets[] = [
|
||||
'label' => $invoiceLabel, // e.g., Serial Invoice
|
||||
'data' => [$totals[0], $scanneds[0]],
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$datasets[] = [
|
||||
'label' => 'Total Invoices',
|
||||
'data' => $totals,
|
||||
];
|
||||
$datasets[] = [
|
||||
'label' => 'Scanned Invoices',
|
||||
'data' => $scanneds,
|
||||
];
|
||||
$labels = array_map(function ($type) {
|
||||
return ucwords(str_replace('_invoice', '', str_replace('_', ' ', $type)));
|
||||
}, $types);
|
||||
}
|
||||
|
||||
foreach ($datasets as &$dataset) {
|
||||
$dataset['data'] = array_map(function ($value) {
|
||||
return $value ?? 0;
|
||||
}, $dataset['data']);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => $labels,
|
||||
'datasets' => $datasets,
|
||||
], 200);
|
||||
}
|
||||
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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
554
app/Http/Controllers/ModuleInvoiceTypeController.php
Normal file
554
app/Http/Controllers/ModuleInvoiceTypeController.php
Normal file
@@ -0,0 +1,554 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\ModuleList;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleInvoiceTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_invoiceFilter(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);
|
||||
}
|
||||
|
||||
$filterName = $request->header('filter-name');
|
||||
|
||||
if (empty($filterName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Filter Name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$headerValue = $request->header('filter-name');
|
||||
|
||||
if ($headerValue != 'Filter List') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid value for 'module-name' header!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$uniqueModules = ModuleList::select('filter_name', 'created_at')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->unique('filter_name')
|
||||
->pluck('filter_name')
|
||||
->values();
|
||||
|
||||
if ($uniqueModules->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Filter names not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $uniqueModules
|
||||
], 200);
|
||||
}
|
||||
|
||||
// public function get_invoiceCountData(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);
|
||||
// }
|
||||
|
||||
// $moduleName = $request->header('invoice-name');
|
||||
|
||||
// if (empty($moduleName))
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invoice name can't be empty!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $plantName = $request->header('plant-name');
|
||||
// $selectedInvoice = strtolower(trim($request->header('invoice-name')));
|
||||
// $activeFilter = strtolower(trim($request->header('filter-name')));
|
||||
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $selectedPlant = $plant->id;
|
||||
|
||||
// if (empty($selectedInvoice) || empty($selectedPlant) || empty($activeFilter)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Missing required headers: invoice-name, plant-name, or filter-name'
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
// $filterHeader = $request->header('filter-name');
|
||||
|
||||
// if (!in_array($filterHeader, $validFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validInvoiceFilters = ['All Invoice', 'Serial Invoice', 'Individual Invoice', 'Bundle Invoice'];
|
||||
// $filterInvoice = $request->header('invoice-name');
|
||||
|
||||
// if (!in_array($filterInvoice, $validInvoiceFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid invoice-name value! Accepted values are: " . implode(', ', $validInvoiceFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// if ($activeFilter == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// } elseif ($activeFilter == 'this week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// } elseif ($activeFilter == 'this month') {
|
||||
// $startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
// } else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// }
|
||||
|
||||
// $labels = [];
|
||||
// $datasets = [];
|
||||
|
||||
// if ($activeFilter == 'yesterday' || $activeFilter == 'today')
|
||||
// {
|
||||
|
||||
// // === Imported Invoices ===
|
||||
// $importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate]);
|
||||
|
||||
// if ($selectedInvoice == 'individual invoice') {
|
||||
// $importedQuery->where('quantity', 1);
|
||||
// } elseif ($selectedInvoice == 'serial invoice') {
|
||||
// $importedQuery->whereNull('quantity');
|
||||
// } elseif ($selectedInvoice == 'bundle invoice') {
|
||||
// $importedQuery->where('quantity', '>', 1);
|
||||
// }
|
||||
|
||||
// $importedCount = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
|
||||
|
||||
|
||||
// // === Completed Invoices ===
|
||||
// $completedQuery = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate]);
|
||||
|
||||
// if ($selectedInvoice == 'individual invoice') {
|
||||
// $completedQuery->where('quantity', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'serial invoice') {
|
||||
// $completedQuery->whereNull('quantity')
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'bundle invoice') {
|
||||
// $completedQuery->where('quantity', '>', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// }
|
||||
|
||||
// $completedCount = $completedQuery->count();
|
||||
|
||||
// $labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
// $datasets = [[
|
||||
// 'label' => 'Invoices',
|
||||
// 'data' => [$importedCount, $completedCount],
|
||||
// ]];
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// elseif ($activeFilter == 'this week') {
|
||||
// $labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
// $imported = array_fill(0, 7, 0);
|
||||
// $completed = array_fill(0, 7, 0);
|
||||
|
||||
// for ($i = 0; $i < 7; $i++) {
|
||||
// $dayStart = now()->startOfWeek()->addDays($i)->setTime(8, 0, 0);
|
||||
// $dayEnd = $dayStart->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||
|
||||
// $completedQuery = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('updated_at', [$dayStart, $dayEnd]);
|
||||
|
||||
// if ($selectedInvoice == 'individual invoice') {
|
||||
// $importedQuery->where('quantity', 1);
|
||||
// $completedQuery->where('quantity', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'serial invoice') {
|
||||
// $importedQuery->whereNull('quantity');
|
||||
// $completedQuery->whereNull('quantity')
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'bundle invoice') {
|
||||
// $importedQuery->where('quantity', '>', 1);
|
||||
// $completedQuery->where('quantity', '>', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// }
|
||||
|
||||
// $imported[$i] = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
// $completed[$i] = $completedQuery->count();
|
||||
// }
|
||||
|
||||
// $datasets = [
|
||||
// ['label' => 'Imported Invoices', 'data' => $imported],
|
||||
// ['label' => 'Completed Invoices', 'data' => $completed],
|
||||
// ];
|
||||
// }
|
||||
|
||||
// elseif ($activeFilter == 'this month') {
|
||||
// $startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
// $endOfMonth = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $labels = [];
|
||||
// $imported = [];
|
||||
// $completed = [];
|
||||
|
||||
// $weekStart = $startOfMonth->copy();
|
||||
// while ($weekStart < $endOfMonth) {
|
||||
// $weekEnd = $weekStart->copy()->addDays(7);
|
||||
// $label = $weekStart->format('M') . ' (' . $weekStart->format('j') . '-' . $weekEnd->subDay()->format('j') . ')';
|
||||
// $labels[] = $label;
|
||||
|
||||
// $importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||
|
||||
// $completedQuery = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $selectedPlant)
|
||||
// ->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
||||
|
||||
// if ($selectedInvoice == 'individual invoice') {
|
||||
// $importedQuery->where('quantity', 1);
|
||||
// $completedQuery->where('quantity', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'serial invoice') {
|
||||
// $importedQuery->whereNull('quantity');
|
||||
// $completedQuery->whereNull('quantity')
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
// } elseif ($selectedInvoice == 'bundle invoice') {
|
||||
// $importedQuery->where('quantity', '>', 1);
|
||||
// $completedQuery->where('quantity', '>', 1)
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
// }
|
||||
|
||||
// $imported[] = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
// $completed[] = $completedQuery->count();
|
||||
|
||||
// $weekStart = $weekEnd;
|
||||
// }
|
||||
|
||||
// $datasets = [
|
||||
// ['label' => 'Imported Invoices', 'data' => $imported],
|
||||
// ['label' => 'Completed Invoices', 'data' => $completed],
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // Clean zero values to null
|
||||
// foreach ($datasets as &$dataset) {
|
||||
// $dataset['data'] = array_map(function ($value) {
|
||||
// return ($value === null) ? 0 : $value;
|
||||
// }, $dataset['data']);
|
||||
// }
|
||||
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'labels' => $labels,
|
||||
// 'datasets' => $datasets,
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function get_invoiceCountData(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$filterHeader = $request->header('filter-name');
|
||||
$invoiceHeader = $request->header('invoice-name');
|
||||
|
||||
if (empty($plantName) || empty($invoiceHeader) || empty($filterHeader)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Missing required headers: plant-name, invoice-name, or filter-name"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
if (!in_array($filterHeader, $validFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validInvoiceFilters = ['All Invoice', 'Serial Invoice', 'Individual Invoice', 'Bundle Invoice'];
|
||||
if (!in_array($invoiceHeader, $validInvoiceFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid invoice-name value! Accepted values are: " . implode(', ', $validInvoiceFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$selectedPlant = $plant->id;
|
||||
$activeFilter = strtolower(trim($filterHeader));
|
||||
$selectedInvoice = strtolower(trim($invoiceHeader));
|
||||
|
||||
// Set time range
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
} elseif ($activeFilter == 'this week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
} elseif ($activeFilter == 'this month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
$datasets = [];
|
||||
|
||||
// Map types for All Invoice
|
||||
$invoiceTypes = $selectedInvoice == 'all invoice'
|
||||
? [
|
||||
'Individual Invoice' => fn($q) => $q->where('quantity', 1),
|
||||
'Serial Invoice' => fn($q) => $q->whereNull('quantity'),
|
||||
'Bundle Invoice' => fn($q) => $q->where('quantity', '>', 1)
|
||||
]
|
||||
: [
|
||||
ucfirst($selectedInvoice) => match ($selectedInvoice) {
|
||||
'individual invoice' => fn($q) => $q->where('quantity', 1),
|
||||
'serial invoice' => fn($q) => $q->whereNull('quantity'),
|
||||
'bundle invoice' => fn($q) => $q->where('quantity', '>', 1),
|
||||
}
|
||||
];
|
||||
|
||||
foreach ($invoiceTypes as $labelPrefix => $queryModifier) {
|
||||
if ($activeFilter == 'yesterday' || $activeFilter == 'today') {
|
||||
$importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$startDate, $endDate]);
|
||||
|
||||
$queryModifier($importedQuery);
|
||||
$importedCount = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
|
||||
$completedQuery = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$startDate, $endDate]);
|
||||
|
||||
if ($selectedInvoice == 'serial invoice' || $labelPrefix == 'Serial Invoice') {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
} else {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
}
|
||||
|
||||
$completedCount = $completedQuery->count();
|
||||
|
||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
$datasets[] = [
|
||||
'label' => "$labelPrefix",
|
||||
'data' => [$importedCount, $completedCount],
|
||||
];
|
||||
}
|
||||
|
||||
elseif ($activeFilter == 'this week') {
|
||||
$labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
$imported = array_fill(0, 7, 0);
|
||||
$completed = array_fill(0, 7, 0);
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$dayStart = now()->startOfWeek()->addDays($i)->setTime(8, 0, 0);
|
||||
$dayEnd = $dayStart->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||
$queryModifier($importedQuery);
|
||||
$imported[$i] = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
|
||||
$completedQuery = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd]);
|
||||
|
||||
if ($selectedInvoice == 'serial invoice' || $labelPrefix == 'Serial Invoice') {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
} else {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
}
|
||||
|
||||
$completed[$i] = $completedQuery->count();
|
||||
}
|
||||
|
||||
$datasets[] = ['label' => "$labelPrefix Imported", 'data' => $imported];
|
||||
$datasets[] = ['label' => "$labelPrefix Completed", 'data' => $completed];
|
||||
}
|
||||
|
||||
elseif ($activeFilter == 'this month') {
|
||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(8, 0, 0);
|
||||
$labels = [];
|
||||
$imported = [];
|
||||
$completed = [];
|
||||
|
||||
$weekStart = $startOfMonth->copy();
|
||||
while ($weekStart < $endOfMonth) {
|
||||
$weekEnd = $weekStart->copy()->addDays(7);
|
||||
$label = $weekStart->format('M') . ' (' . $weekStart->format('j') . '-' . $weekEnd->subDay()->format('j') . ')';
|
||||
$labels[] = $label;
|
||||
|
||||
$importedQuery = InvoiceValidation::where('plant_id', $selectedPlant)
|
||||
->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||
$queryModifier($importedQuery);
|
||||
$imported[] = $importedQuery->distinct('invoice_number')->count('invoice_number');
|
||||
|
||||
$completedQuery = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
||||
|
||||
if ($selectedInvoice == 'serial invoice' || $labelPrefix == 'Serial Invoice') {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)");
|
||||
} else {
|
||||
$queryModifier($completedQuery)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)");
|
||||
}
|
||||
|
||||
$completed[] = $completedQuery->count();
|
||||
$weekStart = $weekEnd;
|
||||
}
|
||||
|
||||
$datasets[] = ['label' => "$labelPrefix Imported", 'data' => $imported];
|
||||
$datasets[] = ['label' => "$labelPrefix Completed", 'data' => $completed];
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure 0 instead of null
|
||||
foreach ($datasets as &$dataset) {
|
||||
$dataset['data'] = array_map(fn($val) => $val === null ? 0 : $val, $dataset['data']);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => $labels,
|
||||
'datasets' => $datasets,
|
||||
]);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
94
app/Http/Controllers/ModulePlantController.php
Normal file
94
app/Http/Controllers/ModulePlantController.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModulePlantController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_modulePlant(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
|
||||
if (empty($plantName))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$headerValue = $request->header('plant-name');
|
||||
|
||||
if ($headerValue != 'Plant List') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid value for 'plant-name' header!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantNames = Plant::orderBy('created_at', 'asc')
|
||||
->pluck('name')
|
||||
->values();
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $plantNames
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
177
app/Http/Controllers/ModulePlantLineController.php
Normal file
177
app/Http/Controllers/ModulePlantLineController.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModulePlantLineController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// public function get_modulePlantLine(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);
|
||||
// }
|
||||
|
||||
// $plantName = $request->header('plant-name');
|
||||
|
||||
// if (empty($plantName))
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant Name can't be empty!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $lineNames = Line::where('plant_id', $plant->id)
|
||||
// ->orderBy('created_at', 'asc')
|
||||
// ->pluck('name');
|
||||
|
||||
// if ($lineNames->isEmpty()) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "No lines found for plant '{$plantName}'"
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// // Prepend 'All Lines'
|
||||
// $lineNames->prepend('All Lines')->values();
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'status_description' => $lineNames,
|
||||
// ], 200);
|
||||
|
||||
// }
|
||||
|
||||
public function get_modulePlantLine(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$chartName = $request->header('chart-name');
|
||||
|
||||
if (empty($plantName)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (empty($chartName)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Chart name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Load only lines NOT equal to FG Line
|
||||
$nonFgLines = Line::where('plant_id', $plant->id)
|
||||
//->where('type', '!=', 'FG Line')
|
||||
->orderBy('created_at', 'asc')
|
||||
->pluck('name')
|
||||
->toArray();
|
||||
|
||||
if (empty($nonFgLines)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "No non-FG lines found for plant '{$plantName}'"
|
||||
], 404);
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $nonFgLines,
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
107
app/Http/Controllers/ModuleProductionFGLineController.php
Normal file
107
app/Http/Controllers/ModuleProductionFGLineController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModuleProductionFGLineController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function get_moduleFGFilterList(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);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$FGName = $request->header('fg-lines');
|
||||
|
||||
if (empty($plantName)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (empty($FGName)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "FG line name can't be empty!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$fgLines = Line::where('plant_id', $plant->id)
|
||||
->where('type', $FGName)
|
||||
->pluck('name'); // Only get line names
|
||||
|
||||
if ($fgLines->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "No FG lines found for the selected plant and line!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $fgLines,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
171
app/Http/Controllers/ModuleProductionLineStopController.php
Normal file
171
app/Http/Controllers/ModuleProductionLineStopController.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ModuleProductionLineStopController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
public function get_moduleProductionLineStop(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);
|
||||
}
|
||||
|
||||
$requiredHeaders = ['module-name', 'chart-name', 'plant-name', 'line-name', 'filter-name'];
|
||||
|
||||
$missingHeaders = [];
|
||||
foreach ($requiredHeaders as $header) {
|
||||
if (empty($request->header($header))) {
|
||||
$missingHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missingHeaders)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$lineName = $request->header('line-name');
|
||||
$filterName = strtolower(trim($request->header('filter-name')));
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
if (!$line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line '{$lineName}' not found for plant '{$plantName}'"
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Set time range
|
||||
if ($filterName == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
} elseif ($filterName == 'this week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
} elseif ($filterName == 'this month') {
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
$query = DB::table('production_line_stops')
|
||||
->join('line_stops as ls', 'production_line_stops.linestop_id', '=', 'ls.id')
|
||||
->join('lines', 'production_line_stops.line_id', '=', 'lines.id')
|
||||
->join('plants', 'production_line_stops.plant_id', '=', 'plants.id')
|
||||
->select(
|
||||
'ls.code',
|
||||
'ls.reason',
|
||||
DB::raw("SUM(production_line_stops.stop_hour) as total_stop_hours"),
|
||||
DB::raw("SUM(production_line_stops.stop_min) as total_stop_minutes")
|
||||
)
|
||||
->where('plants.id', $plant->id)
|
||||
->where('lines.id', $line->id)
|
||||
->whereBetween('production_line_stops.created_at', [$startDate, $endDate])
|
||||
->groupBy('ls.code', 'ls.reason')
|
||||
->get();
|
||||
|
||||
if ($query->isEmpty()) {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => ['No Data'],
|
||||
'data' => [1],
|
||||
], 200);
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
$data = [];
|
||||
$totalStopMinutes = 0;
|
||||
|
||||
foreach ($query as $row) {
|
||||
$stopHours = $row->total_stop_hours;
|
||||
$stopMinutes = $row->total_stop_minutes;
|
||||
$visualTotal = $stopHours + ($stopMinutes / 100);
|
||||
|
||||
$labels[] = "{$row->code} - {$row->reason}";
|
||||
$data[] = $visualTotal;
|
||||
|
||||
$totalStopMinutes += ($stopHours * 60) + $stopMinutes;
|
||||
}
|
||||
|
||||
// Calculate available runtime
|
||||
$remainingMinutes = 1440 - $totalStopMinutes;
|
||||
$runtimeHours = floor($remainingMinutes / 60);
|
||||
$runtimeMinutes = $remainingMinutes % 60;
|
||||
$runtimeVisual = $runtimeHours + ($runtimeMinutes / 100);
|
||||
|
||||
$labels[] = 'Available Runtime';
|
||||
$data[] = $runtimeVisual;
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'labels' => $labels,
|
||||
'data' => $data,
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
402
app/Http/Controllers/ModuleProductionOrderDataController.php
Normal file
402
app/Http/Controllers/ModuleProductionOrderDataController.php
Normal file
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ModuleProductionOrderDataController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// public function get_moduleProductionOrder(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);
|
||||
// }
|
||||
|
||||
// $requiredHeaders = [
|
||||
// 'module-name',
|
||||
// 'chart-name',
|
||||
// 'plant-name',
|
||||
// 'line-name',
|
||||
// 'production-order',
|
||||
// 'filter-name',
|
||||
// ];
|
||||
|
||||
// $missingHeaders = [];
|
||||
|
||||
// foreach ($requiredHeaders as $header) {
|
||||
// if (empty($request->header($header))) {
|
||||
// $missingHeaders[] = $header;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!empty($missingHeaders)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
// $filterHeader = $request->header('filter-name');
|
||||
|
||||
// if (!in_array($filterHeader, $validFilters)) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $plantName = $request->header('plant-name');
|
||||
// $lineName = $request->header('line-name');
|
||||
// $orderValue = $request->header('production-order');
|
||||
// $filterName = strtolower(trim($request->header('filter-name')));
|
||||
|
||||
// $plant = Plant::where('name', $plantName)->first();
|
||||
// if (!$plant) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Plant '{$plantName}' not found!"
|
||||
// ], 404);
|
||||
// }
|
||||
// $line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
|
||||
// if (!$line) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Line not found!'
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $lineType = $line->type;
|
||||
|
||||
// if ($lineType === 'FG Line')
|
||||
// {
|
||||
// $table = 'quality_validations';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $table = 'production_quantities';
|
||||
// }
|
||||
|
||||
// // Time Range
|
||||
// if ($filterName == 'yesterday') {
|
||||
// $startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
// $endDate = now()->setTime(8, 0, 0);
|
||||
// $groupBy = "EXTRACT(HOUR FROM $table.created_at)";
|
||||
// } elseif ($filterName == 'this week') {
|
||||
// $startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
// $endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
// $groupBy = "EXTRACT(DOW FROM $table.created_at)";
|
||||
// } elseif ($filterName == 'this month') {
|
||||
// $startDate = now()->startOfMonth();
|
||||
// $endDate = now()->endOfMonth();
|
||||
// $groupBy = "FLOOR((EXTRACT(DAY FROM $table.created_at) - 1) / 7) + 1";
|
||||
// } else {
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// $groupBy = "EXTRACT(HOUR FROM $table.created_at)";
|
||||
// }
|
||||
|
||||
// $query = \DB::table($table)
|
||||
// ->join('plants', "$table.plant_id", '=', 'plants.id')
|
||||
// ->join('lines', "$table.line_id", '=', 'lines.id')
|
||||
// ->selectRaw("$groupBy AS time_unit, count(*) AS total_quantity")
|
||||
// ->whereBetween("$table.created_at", [$startDate, $endDate])
|
||||
// ->where('plants.id', $plant->id)
|
||||
// ->where('lines.id', $line->id)
|
||||
// ->where("$table.production_order", $orderValue)
|
||||
// ->groupByRaw($groupBy)
|
||||
// ->orderByRaw($groupBy)
|
||||
// ->pluck('total_quantity', 'time_unit')
|
||||
// ->toArray();
|
||||
|
||||
// if ($filterName == 'this month') {
|
||||
// $weeksCount = ceil($endDate->day / 7);
|
||||
// $allWeeks = array_fill(1, $weeksCount, 0);
|
||||
// $data = array_replace($allWeeks, $query);
|
||||
|
||||
// $labels = [];
|
||||
// for ($i = 1; $i <= $weeksCount; $i++) {
|
||||
// $weekStart = $startDate->copy()->addDays(($i - 1) * 7)->format('d M');
|
||||
// $weekEnd = $startDate->copy()->addDays($i * 7 - 1)->min($endDate)->format('d M');
|
||||
// $labels[] = "Week $i ($weekStart - $weekEnd)";
|
||||
// }
|
||||
|
||||
// $orderedData = array_values($data);
|
||||
// } elseif ($filterName === 'this week') {
|
||||
// $labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
// $data = array_fill(0, 7, 0);
|
||||
// foreach ($query as $dow => $count) {
|
||||
// $data[$dow] = $count;
|
||||
// }
|
||||
|
||||
// $orderedData = [
|
||||
// $data[1] ?? 0, $data[2] ?? 0, $data[3] ?? 0,
|
||||
// $data[4] ?? 0, $data[5] ?? 0, $data[6] ?? 0,
|
||||
// $data[0] ?? 0,
|
||||
// ];
|
||||
// } else {
|
||||
// $allHours = array_fill(0, 24, 0);
|
||||
// $data = array_replace($allHours, $query);
|
||||
|
||||
// $shiftedData = [];
|
||||
// foreach ($data as $hour => $count) {
|
||||
// $nextHour = ($hour + 1) % 24;
|
||||
// $shiftedData[$nextHour] = $count;
|
||||
// }
|
||||
|
||||
// $shiftedKeys = array_merge(range(9, 23), range(0, 8));
|
||||
// $orderedData = array_map(fn($hour) => $shiftedData[$hour] ?? 0, $shiftedKeys);
|
||||
// $labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys);
|
||||
// }
|
||||
|
||||
// $orderedData = array_map(function ($value) {
|
||||
// return ($value == 0 || is_null($value)) ? null : $value;
|
||||
// }, $orderedData);
|
||||
|
||||
// return response()->json([
|
||||
// 'status_code' => 'SUCCESS',
|
||||
// 'datasets' => [
|
||||
// [
|
||||
// 'label' => match ($filterName) {
|
||||
// 'this week' => $lineType == 'FG Line' ? "Daily Fg Production Order Count This Week" : "Daily Production Order Count This Week",
|
||||
// 'this month' => $lineType == 'FG Line' ? "Weekly Fg Production Order Count This Month" : "Weekly Production Order Count This Month",
|
||||
// 'yesterday' => $lineType == 'FG Line' ? "Yesterday's Hourly Fg Order Count Production" : "Yesterday's Hourly Order Count Production",
|
||||
// default => $lineType == 'FG Line' ? "Today's Hourly Fg Production Order Count" : "Today's Hourly Production Order Count",
|
||||
// },
|
||||
// 'data' => $orderedData,
|
||||
// 'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||
// 'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
||||
// 'fill' => false,
|
||||
// 'tension' => 0.3,
|
||||
// ]
|
||||
// ],
|
||||
// 'labels' => $labels
|
||||
// ], 200);
|
||||
// }
|
||||
|
||||
public function get_moduleProductionOrder(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);
|
||||
}
|
||||
|
||||
$requiredHeaders = [
|
||||
'module-name', 'chart-name', 'plant-name',
|
||||
'line-name', 'production-order', 'filter-name'
|
||||
];
|
||||
|
||||
$missingHeaders = [];
|
||||
foreach ($requiredHeaders as $header) {
|
||||
if (empty($request->header($header))) {
|
||||
$missingHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missingHeaders)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missing required headers: ' . implode(', ', $missingHeaders)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$filterHeader = $request->header('filter-name');
|
||||
$validFilters = ['Today', 'Yesterday', 'This Week', 'This Month'];
|
||||
if (!in_array($filterHeader, $validFilters)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid filter-name value! Accepted values are: " . implode(', ', $validFilters)
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantName = $request->header('plant-name');
|
||||
$lineName = $request->header('line-name');
|
||||
$orderVal = $request->header('production-order');
|
||||
$filter = strtolower($filterHeader);
|
||||
|
||||
$plant = Plant::where('name', $plantName)->first();
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant '{$plantName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->where('plant_id', $plant->id)->first();
|
||||
if (!$line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line '{$lineName}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineType = $line->type;
|
||||
$table = ($lineType == 'FG Line') ? 'quality_validations' : 'production_quantities';
|
||||
|
||||
if ($filter == 'today' || $filter == 'yesterday') {
|
||||
$hourlyCounts = [];
|
||||
|
||||
$hourStart = $filter == 'today'
|
||||
? now()->setTime(8, 0, 0)
|
||||
: now()->subDay()->setTime(8, 0, 0);
|
||||
$hourEndFinal = $hourStart->copy()->addDay();
|
||||
|
||||
while ($hourStart < $hourEndFinal) {
|
||||
$hourEnd = $hourStart->copy()->addHour();
|
||||
$label = $hourStart->format('g:i A') . ' to ' . $hourEnd->format('g:i A');
|
||||
|
||||
$count = DB::table($table)
|
||||
->where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->where('production_order', $orderVal)
|
||||
->whereBetween('created_at', [$hourStart, $hourEnd])
|
||||
->count();
|
||||
|
||||
$hourlyCounts[$label] = $count;
|
||||
$hourStart = $hourEnd;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => $filter == 'yesterday'
|
||||
? "Yesterday's Hourly Production Order Count"
|
||||
: "Today's Hourly Production Order Count",
|
||||
'data' => $hourlyCounts
|
||||
]
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Weekly or Monthly
|
||||
if ($filter == 'this week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = "EXTRACT(DOW FROM $table.created_at)";
|
||||
} else {
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
$groupBy = "FLOOR((EXTRACT(DAY FROM $table.created_at) - 1) / 7) + 1";
|
||||
}
|
||||
|
||||
$query = DB::table($table)
|
||||
->where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->where('production_order', $orderVal)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->selectRaw("$groupBy as group_key, COUNT(*) as total")
|
||||
->groupByRaw("group_key")
|
||||
->pluck('total', 'group_key')
|
||||
->toArray();
|
||||
|
||||
if ($filter == 'this week') {
|
||||
$labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
$data = array_fill(0, 7, 0);
|
||||
|
||||
foreach ($query as $dow => $count) {
|
||||
$data[$dow] = $count;
|
||||
}
|
||||
|
||||
$orderedData = [
|
||||
$data[1] ?? 0, $data[2] ?? 0, $data[3] ?? 0,
|
||||
$data[4] ?? 0, $data[5] ?? 0, $data[6] ?? 0,
|
||||
$data[0] ?? 0,
|
||||
];
|
||||
} else {
|
||||
$weeksCount = ceil($endDate->day / 7);
|
||||
$allWeeks = array_fill(1, $weeksCount, 0);
|
||||
$data = array_replace($allWeeks, $query);
|
||||
|
||||
$labels = [];
|
||||
for ($i = 1; $i <= $weeksCount; $i++) {
|
||||
$weekStart = $startDate->copy()->addDays(($i - 1) * 7)->format('d M');
|
||||
$weekEnd = $startDate->copy()->addDays($i * 7 - 1)->min($endDate)->format('d M');
|
||||
$labels[] = "Week $i ($weekStart - $weekEnd)";
|
||||
}
|
||||
|
||||
$orderedData = array_values($data);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => match ($filter) {
|
||||
'this week' => $lineType == 'FG Line'
|
||||
? "Daily Fg Production Order Count This Week"
|
||||
: "Daily Production Order Count This Week",
|
||||
'this month' => $lineType == 'FG Line'
|
||||
? "Weekly Fg Production Order Count This Month"
|
||||
: "Weekly Production Order Count This Month",
|
||||
},
|
||||
'data' => $orderedData
|
||||
]
|
||||
],
|
||||
'labels' => $labels ?? []
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ class PalletController extends Controller
|
||||
<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: 5mm; padding-top: 2mm; }
|
||||
.text-cell { text-align: left; vertical-align: middle; font-size: 12pt; padding-left: 7mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
|
||||
img.qr { width: 10mm; height: 10mm; display: block; }
|
||||
.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>
|
||||
|
||||
@@ -27,6 +27,126 @@ class StickerMasterController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function get_master_type(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);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$itemCode = $request->header('item-code');
|
||||
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
}
|
||||
else if ($itemCode == null || $itemCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid item code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
|
||||
if (!$stickerMaster)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
$serial_number_motor = $stickerMaster->serial_number_motor ?? null;
|
||||
$serial_number_pump = $stickerMaster->serial_number_pump ?? null;
|
||||
|
||||
if ($serial_number_motor != 1 && $serial_number_pump != 1) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The Item Code '$itemCode' does not have serial pump or serial motor selected!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$serialInfo = [];
|
||||
|
||||
if ($serial_number_motor == 1 && $serial_number_pump == 1)
|
||||
{
|
||||
$serialInfo[] = 'Serial Pump';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($serial_number_motor == 1) {
|
||||
$serialInfo[] = 'Serial Motor';
|
||||
}
|
||||
if ($serial_number_pump == 1) {
|
||||
$serialInfo[] = 'Serial Pump';
|
||||
}
|
||||
}
|
||||
|
||||
$output = [
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => implode(', ', $serialInfo),
|
||||
];
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
@@ -175,6 +175,9 @@ class InvoiceDataTable extends Component
|
||||
$this->completedInvoice = false;
|
||||
$this->hasSearched = false;
|
||||
$this->materialInvoice = false;
|
||||
$this->dispatch('focus-capacitor-input');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function cancelCapacitorInput()
|
||||
@@ -339,6 +342,7 @@ class InvoiceDataTable extends Component
|
||||
}
|
||||
$this->showCapacitorInput = false;
|
||||
$this->capacitorInput = '';
|
||||
$this->dispatch('focus-serial-number');
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
27
app/Models/MfmMeter.php
Normal file
27
app/Models/MfmMeter.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MfmMeter extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'sequence',
|
||||
'name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
36
app/Models/MfmParameter.php
Normal file
36
app/Models/MfmParameter.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MfmParameter extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'name',
|
||||
'register_id',
|
||||
'identifier',
|
||||
'byte_to_convert',
|
||||
'type_to_convert',
|
||||
'decimal_to_display',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function mfmMeter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
}
|
||||
51
app/Models/MfmReading.php
Normal file
51
app/Models/MfmReading.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MfmReading extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'apparent_energy_received',
|
||||
'reactive_energy_received',
|
||||
'active_energy_received',
|
||||
'active_power_r',
|
||||
'active_power_y',
|
||||
'active_power_b',
|
||||
'active_power_total',
|
||||
'voltage_ry',
|
||||
'voltage_yb',
|
||||
'voltage_br',
|
||||
'current_r',
|
||||
'current_y',
|
||||
'current_b',
|
||||
'current_n',
|
||||
'voltage_r_n',
|
||||
'voltage_y_n',
|
||||
'voltage_b_n',
|
||||
'frequency',
|
||||
'power_factor_r',
|
||||
'power_factor_y',
|
||||
'power_factor_b',
|
||||
'power_factor_total',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function mfmMeter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
}
|
||||
19
app/Models/ModuleList.php
Normal file
19
app/Models/ModuleList.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ModuleList extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'module_name',
|
||||
'dashboard_name',
|
||||
'filter_name',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
}
|
||||
31
app/Models/TempLiveReading.php
Normal file
31
app/Models/TempLiveReading.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TempLiveReading extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'mfm_meter_id',
|
||||
'register_data',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function mfmMeter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MfmMeter::class, 'mfm_meter_id');
|
||||
}
|
||||
}
|
||||
106
app/Policies/MfmMeterPolicy.php
Normal file
106
app/Policies/MfmMeterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\MfmMeter;
|
||||
use App\Models\User;
|
||||
|
||||
class MfmMeterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, MfmMeter $mfmmeter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete MfmMeter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any MfmMeter');
|
||||
}
|
||||
}
|
||||
106
app/Policies/MfmParameterPolicy.php
Normal file
106
app/Policies/MfmParameterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\MfmParameter;
|
||||
use App\Models\User;
|
||||
|
||||
class MfmParameterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, MfmParameter $mfmparameter): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete MfmParameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any MfmParameter');
|
||||
}
|
||||
}
|
||||
106
app/Policies/MfmReadingPolicy.php
Normal file
106
app/Policies/MfmReadingPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\MfmReading;
|
||||
use App\Models\User;
|
||||
|
||||
class MfmReadingPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, MfmReading $mfmreading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete MfmReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any MfmReading');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ModuleListPolicy.php
Normal file
106
app/Policies/ModuleListPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ModuleList;
|
||||
use App\Models\User;
|
||||
|
||||
class ModuleListPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ModuleList $modulelist): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ModuleList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ModuleList');
|
||||
}
|
||||
}
|
||||
106
app/Policies/TempLiveReadingPolicy.php
Normal file
106
app/Policies/TempLiveReadingPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\TempLiveReading;
|
||||
use App\Models\User;
|
||||
|
||||
class TempLiveReadingPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, TempLiveReading $templivereading): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete TempLiveReading');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any TempLiveReading');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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 module_lists (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
module_name TEXT NOT NULL,
|
||||
dashboard_name TEXT NOT NULL,
|
||||
filter_name TEXT NOT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
created_by TEXT NULL,
|
||||
updated_by TEXT NULL,
|
||||
|
||||
UNIQUE (module_name, dashboard_name, filter_name)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('module_lists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE mfm_meters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
|
||||
sequence TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
created_by TEXT NULL,
|
||||
|
||||
UNIQUE (plant_id, sequence),
|
||||
UNIQUE (plant_id, name),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mfm_meters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE temp_live_readings (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
mfm_meter_id BIGINT NOT NULL,
|
||||
|
||||
register_data TEXT NOT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
created_by TEXT NULL,
|
||||
|
||||
UNIQUE (created_at, mfm_meter_id),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (mfm_meter_id) REFERENCES mfm_meters (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('temp_live_readings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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 mfm_parameters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
mfm_meter_id BIGINT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
|
||||
register_id TEXT NOT NULL,
|
||||
identifier TEXT NOT NULL,
|
||||
|
||||
byte_to_convert INT NOT NULL,
|
||||
type_to_convert TEXT NOT NULL,
|
||||
decimal_to_display INT NOT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (plant_id, mfm_meter_id, name),
|
||||
UNIQUE (plant_id, mfm_meter_id, register_id),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (mfm_meter_id) REFERENCES mfm_meters (id)
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mfm_parameters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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 mfm_readings (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
mfm_meter_id BIGINT NOT NULL,
|
||||
|
||||
apparent_energy_received TEXT DEFAULT NULL,
|
||||
reactive_energy_received TEXT DEFAULT NULL,
|
||||
active_energy_received TEXT DEFAULT NULL,
|
||||
active_power_r TEXT DEFAULT NULL,
|
||||
active_power_y TEXT DEFAULT NULL,
|
||||
active_power_b TEXT DEFAULT NULL,
|
||||
active_power_total TEXT DEFAULT NULL,
|
||||
voltage_ry TEXT DEFAULT NULL,
|
||||
voltage_yb TEXT DEFAULT NULL,
|
||||
voltage_br TEXT DEFAULT NULL,
|
||||
current_r TEXT DEFAULT NULL,
|
||||
current_y TEXT DEFAULT NULL,
|
||||
current_b TEXT DEFAULT NULL,
|
||||
current_n TEXT DEFAULT NULL,
|
||||
voltage_r_n TEXT DEFAULT NULL,
|
||||
voltage_y_n TEXT DEFAULT NULL,
|
||||
voltage_b_n TEXT DEFAULT NULL,
|
||||
frequency TEXT DEFAULT NULL,
|
||||
power_factor_r TEXT DEFAULT NULL,
|
||||
power_factor_y TEXT DEFAULT NULL,
|
||||
power_factor_b TEXT DEFAULT NULL,
|
||||
power_factor_total TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
UNIQUE (plant_id, created_at, mfm_meter_id),
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (mfm_meter_id) REFERENCES mfm_meters (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('mfm_readings');
|
||||
}
|
||||
};
|
||||
@@ -124,6 +124,12 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'create serial locator page']);
|
||||
Permission::updateOrCreate(['name' => 'view reprint pallet number']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import mfm parameter']);
|
||||
Permission::updateOrCreate(['name' => 'view export mfm parameter']);
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import mfm meter']);
|
||||
Permission::updateOrCreate(['name' => 'view export mfm meter']);
|
||||
|
||||
//Dashboard Permissions
|
||||
Permission::updateOrCreate(['name' => 'view invoice dashboard']); //invoice dashboard
|
||||
Permission::updateOrCreate(['name' => 'view production hourly count dashboard']); //hourly production
|
||||
@@ -134,6 +140,8 @@ class PermissionSeeder extends Seeder
|
||||
Permission::updateOrCreate(['name' => 'view guard patrol day count dashboard']);
|
||||
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']);
|
||||
|
||||
|
||||
//Send To Sap Permissions
|
||||
Permission::updateOrCreate(['name' => 'view quality data send to sap']);
|
||||
|
||||
@@ -7,10 +7,55 @@
|
||||
{{ $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 = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\ItemOverview::class)
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -159,3 +159,28 @@
|
||||
input.focus(); // Set focus to the input field
|
||||
});
|
||||
</script> --}}
|
||||
<script>
|
||||
window.addEventListener('focus-capacitor-input', () => {
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('capacitorInput');
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
|
||||
window.addEventListener('focus-serial-number', () => {
|
||||
setTimeout(() => {
|
||||
const container = document.getElementById('serial_number_input');
|
||||
const input = container?.querySelector('input'); // gets the actual input inside
|
||||
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -32,13 +32,8 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="9" class="px-4 py-4 text-center text-gray-500">
|
||||
No records found.
|
||||
</td>
|
||||
</tr>
|
||||
@if ($hasSearched)
|
||||
<tr>
|
||||
<td colspan="9" class="px-4 py-4 text-center text-red-600 font-semibold">
|
||||
@if ($hasSearched)
|
||||
<td colspan="9" class="px-4 py-4 text-center text-gray-900 font-semibold">
|
||||
@if ($locatorNumber && $serialNumber)
|
||||
Serial Number "{{ $serialNumber }}" and Locator Number "{{ $locatorNumber }}" not found.
|
||||
@elseif ($locatorNumber)
|
||||
@@ -49,8 +44,12 @@
|
||||
No records found.
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
@else
|
||||
<td colspan="9" class="px-4 py-4 text-center text-gray-900 font-semibold">
|
||||
No records found.
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\MachineController;
|
||||
use App\Http\Controllers\MfmParameterController;
|
||||
use App\Http\Controllers\ModuleChartController;
|
||||
use App\Http\Controllers\ModuleController;
|
||||
use App\Http\Controllers\ModuleFGLineController;
|
||||
use App\Http\Controllers\ModuleFilterController;
|
||||
use App\Http\Controllers\ModuleFilterDataController;
|
||||
use App\Http\Controllers\ModuleGuardDayCountController;
|
||||
use App\Http\Controllers\ModuleGuardHourlyCountController;
|
||||
use App\Http\Controllers\ModuleGuardNameController;
|
||||
use App\Http\Controllers\ModuleInvoiceDataController;
|
||||
use App\Http\Controllers\ModuleInvoiceQuantityController;
|
||||
use App\Http\Controllers\ModuleInvoiceTypeController;
|
||||
use App\Http\Controllers\ModulePlantController;
|
||||
use App\Http\Controllers\ModulePlantLineController;
|
||||
use App\Http\Controllers\ModuleProductionFGLineController;
|
||||
use App\Http\Controllers\ModuleProductionLineStopController;
|
||||
use App\Http\Controllers\ModuleProductionOrderDataController;
|
||||
use App\Http\Controllers\ObdController;
|
||||
use App\Http\Controllers\PalletController;
|
||||
use App\Http\Controllers\PlantController;
|
||||
use App\Http\Controllers\ProductionStickerReprintController;
|
||||
use App\Http\Controllers\StickerMasterController;
|
||||
use App\Http\Controllers\TestingPanelController;
|
||||
use App\Http\Controllers\UserController;
|
||||
@@ -60,5 +78,54 @@ Route::get('machine/get-all-data', [MachineController::class, 'get_all_data']);
|
||||
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
Route::get('sticker/get-master-type-data', [StickerMasterController::class, 'get_master_type']);
|
||||
|
||||
Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf');
|
||||
|
||||
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
|
||||
|
||||
//Production Dashboard Controller
|
||||
|
||||
Route::get('get/module-name/data', [ModuleController::class, 'get_module']);
|
||||
|
||||
Route::get('get/modulechart-name/data', [ModuleChartController::class, 'get_moduleChart']);
|
||||
|
||||
Route::get('get/moduleplant-name/data', [ModulePlantController::class, 'get_modulePlant']);
|
||||
|
||||
Route::get('get/module-plantline-name/data', [ModulePlantLineController::class, 'get_modulePlantLine']);
|
||||
|
||||
Route::get('get/module-line-filter-name/data', [ModuleFilterController::class, 'get_moduleFilter']);
|
||||
|
||||
Route::get('get/module-fgline-filter-list/data', [ModuleProductionFGLineController::class, 'get_moduleFGFilterList']);
|
||||
|
||||
Route::get('get/module-fgline-filter-name/data', [ModuleFGLineController::class, 'get_moduleFGFilter']);
|
||||
|
||||
Route::get('get/module-filter-value/data', [ModuleFilterDataController::class, 'get_moduleFilterData']);
|
||||
|
||||
Route::get('get/module-production-order/data', [ModuleProductionOrderDataController::class, 'get_moduleProductionOrder']);
|
||||
|
||||
Route::get('get/module-production-linestop/data', [ModuleProductionLineStopController::class, 'get_moduleProductionLineStop']);
|
||||
|
||||
//Invoice Dashboard Controller
|
||||
|
||||
Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']);
|
||||
|
||||
Route::get('get/module-invoice-filter/data', [ModuleInvoiceTypeController::class, 'get_invoiceFilter']);
|
||||
|
||||
Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class, 'get_invoiceCountData']);
|
||||
|
||||
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
|
||||
|
||||
//Guard Dashboard Controller
|
||||
|
||||
Route::get('get/module-guard-day/data', [ModuleGuardDayCountController::class, 'get_guardDay_countData']);
|
||||
|
||||
Route::get('get/module-guard-hourly/data', [ModuleGuardHourlyCountController::class, 'get_guardDay_hourlyData']);
|
||||
|
||||
Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get_guard_name_Data']);
|
||||
|
||||
//Power house controller
|
||||
|
||||
Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']);
|
||||
|
||||
Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
|
||||
|
||||
@@ -44,7 +44,10 @@ Artisan::command('inspire', function () {
|
||||
}
|
||||
|
||||
//Invoice report scheduling
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')->get();
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceRules as $rule) {
|
||||
$type = $rule->schedule_type;
|
||||
|
||||
Reference in New Issue
Block a user