Compare commits
22 Commits
89ffd958d9
...
12f2b25bcb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12f2b25bcb | ||
|
|
e4ffddbbe3 | ||
|
|
34972c1422 | ||
|
|
701cc43283 | ||
|
|
488cfa3b61 | ||
|
|
26c3fee797 | ||
|
|
7fd2810278 | ||
|
|
01f8eae2f7 | ||
|
|
1872b037da | ||
|
|
99d4a816dd | ||
|
|
9102c7f219 | ||
|
|
b3d12b0a29 | ||
|
|
3878359f81 | ||
|
|
d2be234d44 | ||
|
|
f060341fae | ||
|
|
d9727cfb96 | ||
|
|
2711758e2e | ||
|
|
f303d7b31b | ||
|
|
282635dcd8 | ||
|
|
118339128a | ||
|
|
1db54593c8 | ||
|
|
43d38d7b88 |
73
app/Filament/Exports/InvoiceValidationExporter.php
Normal file
73
app/Filament/Exports/InvoiceValidationExporter.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class InvoiceValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ExportColumn::make('capacitor_scanned_status')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status_set')
|
||||
->label('SCANNED STATUS SET'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('upload_status')
|
||||
->label('UPLOAD STATUS'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class ProductionQuantityExporter extends Exporter
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('CODE'),
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('line.name')
|
||||
|
||||
@@ -16,33 +16,60 @@ class StickerMasterExporter extends Exporter
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('item.code'),
|
||||
ExportColumn::make('plant.name'),
|
||||
ExportColumn::make('serial_number_motor'),
|
||||
ExportColumn::make('serial_number_pump'),
|
||||
ExportColumn::make('serial_number_pumpset'),
|
||||
ExportColumn::make('pack_slip_motor'),
|
||||
ExportColumn::make('pack_slip_pump'),
|
||||
ExportColumn::make('pack_slip_pumpset'),
|
||||
ExportColumn::make('name_plate_motor'),
|
||||
ExportColumn::make('name_plate_pump'),
|
||||
ExportColumn::make('name_plate_pumpset'),
|
||||
ExportColumn::make('tube_sticker_motor'),
|
||||
ExportColumn::make('tube_sticker_pump'),
|
||||
ExportColumn::make('tube_sticker_pumpset'),
|
||||
ExportColumn::make('warranty_card'),
|
||||
ExportColumn::make('part_validation1'),
|
||||
ExportColumn::make('part_validation2'),
|
||||
ExportColumn::make('part_validation3'),
|
||||
ExportColumn::make('part_validation4'),
|
||||
ExportColumn::make('part_validation5'),
|
||||
ExportColumn::make('panel_box_code'),
|
||||
ExportColumn::make('load_rate'),
|
||||
ExportColumn::make('bundle_quantity'),
|
||||
ExportColumn::make('material_type'),
|
||||
ExportColumn::make('created_at'),
|
||||
ExportColumn::make('updated_at'),
|
||||
ExportColumn::make('deleted_at'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
->label('SERIAL NUMBER MOTOR'),
|
||||
ExportColumn::make('serial_number_pump')
|
||||
->label('SERIAL NUMBER PUMP'),
|
||||
ExportColumn::make('serial_number_pumpset')
|
||||
->label('SERIAL NUMBER PUMPSET'),
|
||||
ExportColumn::make('pack_slip_motor')
|
||||
->label('PACK SLIP MOTOR'),
|
||||
ExportColumn::make('pack_slip_pump')
|
||||
->label('PACK SLIP PUMP'),
|
||||
ExportColumn::make('pack_slip_pumpset')
|
||||
->label('PACK SLIP PUMPSET'),
|
||||
ExportColumn::make('name_plate_motor')
|
||||
->label('NAME PLATE MOTOR'),
|
||||
ExportColumn::make('name_plate_pump')
|
||||
->label('NAME PLATE PUMP'),
|
||||
ExportColumn::make('name_plate_pumpset')
|
||||
->label('NAME PLATE PUMPSET'),
|
||||
ExportColumn::make('tube_sticker_motor')
|
||||
->label('TUBE STICKER MOTOR'),
|
||||
ExportColumn::make('tube_sticker_pump')
|
||||
->label('TUBE STICKER PUMP'),
|
||||
ExportColumn::make('tube_sticker_pumpset')
|
||||
->label('TUBE STICKER PUMPSET'),
|
||||
ExportColumn::make('warranty_card')
|
||||
->label('WARRANTY CARD'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('part_validation3')
|
||||
->label('PART VALIDATION 3'),
|
||||
ExportColumn::make('part_validation4')
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('material_type')
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,13 @@ class BlockImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->example('Block A')
|
||||
->label('Block Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -17,6 +17,7 @@ class CompanyImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Company Name')
|
||||
->example('C.R.I. Pumps Private Limited')
|
||||
->label('Company Name')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -17,22 +17,26 @@ class ItemImporter extends Importer
|
||||
ImportColumn::make('code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('Item Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('description')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Description')
|
||||
->example('Testing Model Description 1')
|
||||
->label('Description')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('hourly_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Hourly Quantity')
|
||||
->example('25')
|
||||
->label('Hourly Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -17,16 +17,19 @@ class LineImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Type')
|
||||
->example('Domestic Assembly')
|
||||
->label('Line Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -17,11 +17,13 @@ class LineStopImporter extends Importer
|
||||
ImportColumn::make('code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Code')
|
||||
->example('A1R')
|
||||
->label('Line Stop Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('reason')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Reason')
|
||||
->example('Power Shut Down')
|
||||
->label('Line Stop Reason')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -18,22 +18,26 @@ class PlantImporter extends Importer
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->rules(['required']), //, 'integer'
|
||||
ImportColumn::make('company')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Company Name')
|
||||
->example('C.R.I. Pumps Private Limited')
|
||||
->label('Company Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Address')
|
||||
->example('7/51-A, Keeranatham Road, Saravanampatty, Coimbatore - 641035')
|
||||
->label('Plant Address')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -17,46 +17,54 @@ class ProductionLineStopImporter extends Importer
|
||||
ImportColumn::make('from_datetime')
|
||||
->requiredMapping()
|
||||
->exampleHeader('From DateTime')
|
||||
->example('06-02-2025 00:00:00')
|
||||
->label('From DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('to_datetime')
|
||||
->requiredMapping()
|
||||
->exampleHeader('To DateTime')
|
||||
->example('06-02-2025 01:25:00')
|
||||
->label('To DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('stop_hour')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Stop Hour')
|
||||
->example('1')
|
||||
->label('Stop Hour')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('stop_min')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Stop Min')
|
||||
->example('25')
|
||||
->label('Stop Min')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('linestop')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Code')
|
||||
->example('A7R')
|
||||
->label('Line Stop Code')
|
||||
->relationship(resolveUsing:'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example('Day')
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -17,41 +17,48 @@ class ProductionPlanImporter extends Importer
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example('30-01-2025 16:44:00')
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plan_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plan Quantity')
|
||||
->example('500')
|
||||
->label('Plan Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('production_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Quantity')
|
||||
->example('501')
|
||||
->label('Production Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example('Day')
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example('30-01-2025 19:11:00')
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\ProductionQuantity;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductionQuantityImporter extends Importer
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class ProductionQuantityImporter extends Importer
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example('12-02-2025 15:51:00')
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('hourly_quantity')
|
||||
@@ -28,35 +30,41 @@ class ProductionQuantityImporter extends Importer
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing:'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example('12345678901234')
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example('Day')
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example('12-02-2025 15:51:00')
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
];
|
||||
@@ -82,4 +90,49 @@ class ProductionQuantityImporter extends Importer
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function processRow(array $row): Model
|
||||
{
|
||||
// Activate import flag
|
||||
ProductionQuantity::$importing = true;
|
||||
|
||||
try {
|
||||
// Create record with relationships
|
||||
$productionQuantity = ProductionQuantity::create([
|
||||
'created_at' => $row['created_at'],
|
||||
'item_id' => $this->resolveItemId($row['item']),
|
||||
'serial_number' => $row['serial_number'],
|
||||
'line_id' => $this->resolveLineId($row['line']),
|
||||
'shift_id' => $this->resolveShiftId($row['shift']),
|
||||
'plant_id' => $this->resolvePlantId($row['plant']),
|
||||
'updated_at' => $row['updated_at']
|
||||
]);
|
||||
} finally {
|
||||
// Always disable flag even if errors occur
|
||||
ProductionQuantity::$importing = false;
|
||||
}
|
||||
|
||||
return $productionQuantity;
|
||||
}
|
||||
|
||||
// Relationship resolvers
|
||||
private function resolveItemId(string $code): int
|
||||
{
|
||||
return \App\Models\Item::where('code', $code)->first()->id;
|
||||
}
|
||||
|
||||
private function resolveLineId(string $name): int
|
||||
{
|
||||
return \App\Models\Line::where('name', $name)->first()->id;
|
||||
}
|
||||
|
||||
private function resolveShiftId(string $name): int
|
||||
{
|
||||
return \App\Models\Shift::where('name', $name)->first()->id;
|
||||
}
|
||||
|
||||
private function resolvePlantId(string $name): int
|
||||
{
|
||||
return \App\Models\Plant::where('name', $name)->first()->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,39 +17,46 @@ class ShiftImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example('Day')
|
||||
->label('Shift Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->example('Block A')
|
||||
->label('Block Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('start_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Start Time')
|
||||
->example('08:00:00')
|
||||
->label('Start Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('duration')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Shift Duration')
|
||||
->example('11.30')
|
||||
->label('Shift Duration')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('end_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('End Time')
|
||||
->example('19:30:00')
|
||||
->label('End Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Status')
|
||||
->example('Active')
|
||||
->label('Active Status')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -17,124 +17,161 @@ class StickerMasterImporter extends Importer
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->label('Item Code')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->label('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
|
||||
ImportColumn::make('serial_number_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Serial Number Motor'),
|
||||
->exampleHeader('Serial Number Motor')
|
||||
->label('SERIAL NUMBER MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('serial_number_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number Pump'),
|
||||
->exampleHeader('Serial Number Pump')
|
||||
->label('SERIAL NUMBER PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('serial_number_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number PumpSet'),
|
||||
->exampleHeader('Serial Number PumpSet')
|
||||
->label('SERIAL NUMBER PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('pack_slip_motor')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Motor'),
|
||||
->exampleHeader('Pack Slip Motor')
|
||||
->label('PACK SLIP MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('pack_slip_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Pump'),
|
||||
->exampleHeader('Pack Slip Pump')
|
||||
->label('PACK SLIP PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('pack_slip_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip PumpSet'),
|
||||
->exampleHeader('Pack Slip PumpSet')
|
||||
->label('PACK SLIP PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('name_plate_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Motor'),
|
||||
->exampleHeader('Name Plate Motor')
|
||||
->label('NAME PLATE MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('name_plate_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Pump'),
|
||||
->exampleHeader('Name Plate Pump')
|
||||
->label('NAME PLATE PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('name_plate_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate PumpSet'),
|
||||
->exampleHeader('Name Plate PumpSet')
|
||||
->label('NAME PLATE PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('tube_sticker_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Motor'),
|
||||
->exampleHeader('Tube Sticker Motor')
|
||||
->label('TUBE STICKER MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('tube_sticker_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Pump'),
|
||||
->exampleHeader('Tube Sticker Pump')
|
||||
->label('TUBE STICKER PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('tube_sticker_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker PumpSet'),
|
||||
->exampleHeader('Tube Sticker PumpSet')
|
||||
->label('TUBE STICKER PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('warranty_card')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Warranty Card'),
|
||||
->exampleHeader('Warranty Card')
|
||||
->label('WARRANTY CARD')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('part_validation1')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 1')
|
||||
->exampleHeader('Part Validation 1'),
|
||||
->exampleHeader('Part Validation 1')
|
||||
->label('PART VALIDATION 1')
|
||||
->example('12345'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation2')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 2')
|
||||
->exampleHeader('Part Validation 2'),
|
||||
->exampleHeader('Part Validation 2')
|
||||
->label('PART VALIDATION 2')
|
||||
->example('23456'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation3')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 3')
|
||||
->exampleHeader('Part Validation 3'),
|
||||
->exampleHeader('Part Validation 3')
|
||||
->label('PART VALIDATION 3')
|
||||
->example('34567'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation4')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 4')
|
||||
->exampleHeader('Part Validation 4'),
|
||||
->exampleHeader('Part Validation 4')
|
||||
->label('PART VALIDATION 4')
|
||||
->example('45678'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation5')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 5')
|
||||
->exampleHeader('Part Validation 5'),
|
||||
->exampleHeader('Part Validation 5')
|
||||
->label('PART VALIDATION 5')
|
||||
->example('56789'),
|
||||
|
||||
|
||||
ImportColumn::make('panel_box_code')
|
||||
//->requiredMapping()
|
||||
->label('Panel Box Code')
|
||||
->exampleHeader('Panel Box Code'),
|
||||
->exampleHeader('Panel Box Code')
|
||||
->label('PANEL BOX CODE')
|
||||
->example('123456'),
|
||||
|
||||
|
||||
ImportColumn::make('load_rate')
|
||||
// ->requiredMapping()
|
||||
->label('Load Rate')
|
||||
->integer()
|
||||
->exampleHeader('Load Rate'),
|
||||
->exampleHeader('Load Rate')
|
||||
->label('LOAD RATE')
|
||||
->example('0'),
|
||||
|
||||
|
||||
ImportColumn::make('bundle_quantity')
|
||||
// ->requiredMapping()
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->exampleHeader('Bundle Quantity'),
|
||||
->exampleHeader('Bundle Quantity')
|
||||
->label('BUNDLE QUANTITY')
|
||||
->example(''),
|
||||
|
||||
|
||||
ImportColumn::make('material_type')
|
||||
// ->requiredMapping()
|
||||
->label('Material Type')
|
||||
->integer()
|
||||
->exampleHeader('Material Type'),
|
||||
->exampleHeader('Material Type')
|
||||
->label('MATERIAL TYPE')
|
||||
->example(''),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -8,49 +9,51 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
$selectedPlant = session('selected_plant', request()->input('filters.Plant'));
|
||||
return $form->schema([
|
||||
// Plant Filter
|
||||
Select::make('Plant')
|
||||
->options(Plant::pluck('name', 'id')) // Fetch plant names with their IDs
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) {
|
||||
session(['selected_plant' => $state]);
|
||||
session()->forget('selected_line');
|
||||
$set('Plant', $state);
|
||||
$set('Line', null);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
// Line Filter
|
||||
Select::make('Line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('Plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]); // Store in session
|
||||
$this->triggerChartUpdate(); // Notify chart to refresh
|
||||
}),
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->filtersForm->fill([
|
||||
'plant' => Plant::first()?->id // Default to first plant
|
||||
]);
|
||||
}
|
||||
|
||||
// Helper to check if both filters are set
|
||||
public function triggerChartUpdate(): void
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
if (session()->has('selected_plant') && session()->has('selected_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
return $form
|
||||
->statePath('filters') // Store form state in 'filters'
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]); // fixed typo
|
||||
$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
}),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
78
app/Filament/Pages/HourlyProduction.php
Normal file
78
app/Filament/Pages/HourlyProduction.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Tables\Concerns\HasFilters;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class HourlyProduction extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.hourly-production';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->filtersForm->fill([
|
||||
'plant' => Plant::first()?->id // Default to first plant
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
|
||||
// Line Filter
|
||||
Select::make('line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('selected_plant') && session()->has('selected_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Hourly Production Count';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production dashboard');
|
||||
}
|
||||
}
|
||||
73
app/Filament/Pages/InvoiceDashboard.php
Normal file
73
app/Filament/Pages/InvoiceDashboard.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class InvoiceDashboard extends Page
|
||||
{
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static ?string $navigationGroup = 'Invoice DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-dashboard';
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->filtersForm->fill([
|
||||
'plant' => Plant::first()?->id // Default to first plant
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Explicitly set where to store form data
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selec_plant' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
Select::make('invoice')
|
||||
->options([
|
||||
'serial_invoice' => 'Serial Invoice',
|
||||
'individual_material' => 'Individual Material Invoice',
|
||||
'bundle_material' => 'Bundle Material Invoice',
|
||||
])
|
||||
->label('Select Invoice')
|
||||
->reactive()
|
||||
->default(0)
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['select_invoice' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
})
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Invoice';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,9 +105,11 @@ class BlockResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
//->unique(ignoreRecord: true)
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -72,7 +72,8 @@ class CompanyResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\InvoiceValidationExporter;
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
@@ -25,6 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\View;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Livewire\Livewire;
|
||||
@@ -181,10 +183,8 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
@@ -193,13 +193,16 @@ class InvoiceValidationResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('stickerMaster.item.code')
|
||||
->label('Material Code')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status')
|
||||
->sortable(),
|
||||
@@ -875,6 +878,10 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
}
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Invoices')
|
||||
->color('warning')
|
||||
->exporter(InvoiceValidationExporter::class),
|
||||
])
|
||||
|
||||
->filters([
|
||||
|
||||
@@ -53,7 +53,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
public function getFormActions(): array
|
||||
{
|
||||
// return parent::getFormActions(); //return [];
|
||||
return [
|
||||
$this->getCancelFormAction(),
|
||||
];
|
||||
@@ -61,6 +60,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
public function processInvoice($invoiceNumber)
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
|
||||
$this->showCapacitorInput = false;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
@@ -73,7 +74,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
|
||||
$this->invoiceNumber = $this->form->getState()['invoice_number'] ?? $invoiceNumber;
|
||||
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
|
||||
|
||||
$invoiceType = null;
|
||||
//$this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
|
||||
@@ -143,7 +144,438 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if($updateStatus === '1')
|
||||
{
|
||||
dd('Material invoice update in progress...');
|
||||
//dd('Material invoice update in progress...');
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory . '/' . $filename;
|
||||
$fullPath = $disk->path($filePath);
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
// Now you can read/process the file here
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid updated 'Material Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
$missingQuantities = [];
|
||||
$invalidMatQuan = [];
|
||||
$validRowsFound = false;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
|
||||
if (empty($materialCode) && empty($materialQuantity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($materialCode)) {
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($materialQuantity)) {
|
||||
$missingQuantities[] = $materialCode;
|
||||
}
|
||||
else if(!is_numeric($materialQuantity))
|
||||
{
|
||||
$invalidMatQuan[] = $materialCode;
|
||||
}
|
||||
else if($materialQuantity == 0)
|
||||
{
|
||||
$invalidMatQuan[] = $materialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
$materialCodes[] = $materialCode;
|
||||
$validRowsFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$validRowsFound) {
|
||||
Notification::make()
|
||||
->title('Invalid Material Invoice')
|
||||
->danger() // This makes the notification red to indicate an error
|
||||
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
|
||||
->send();
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||
|
||||
if (!empty($uniqueInvalidCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Codes')
|
||||
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueMissingQuanCodes = array_unique($missingQuantities);
|
||||
|
||||
if (!empty($uniqueMissingQuanCodes)) {
|
||||
Notification::make()
|
||||
->title('Missing Material Quantity')
|
||||
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueMissingQuanCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueInvalidMatQuan = array_unique($invalidMatQuan);
|
||||
|
||||
if (!empty($uniqueInvalidMatQuan)) {
|
||||
Notification::make()
|
||||
->title('Invalid Material Quantity')
|
||||
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueInvalidMatQuan))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
if (!empty($missingCodes))
|
||||
{
|
||||
$missingCount = count($missingCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidCodes = $matchedItems
|
||||
->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
|
||||
if (!empty($invalidCodes))
|
||||
{
|
||||
$missingCount = count($invalidCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:<br>" . implode(', ', $invalidCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$nonNumericQtyCodes = [];
|
||||
$zeroQtyCodes = [];
|
||||
$notDivisibleCodes = [];
|
||||
|
||||
foreach ($matchedItems as $sticker)
|
||||
{
|
||||
$code = $sticker->item->code;
|
||||
$materialType = $sticker->material_type;
|
||||
|
||||
if ($materialType == 2)
|
||||
{
|
||||
$bundleQty = $sticker->bundle_quantity ?? 0;
|
||||
$totalExcelQty = 0;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty === 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) === 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Bundle Quantity')
|
||||
->body("$message<br>$codeList")
|
||||
->danger()
|
||||
->send();
|
||||
};
|
||||
|
||||
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
||||
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
||||
$showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
|
||||
|
||||
|
||||
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oldQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$newQuan = -1;
|
||||
|
||||
$inserted = 0;
|
||||
foreach ($matchedItems as $sticker)
|
||||
{
|
||||
if ($newQuan === -1)
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '');
|
||||
})
|
||||
->delete();
|
||||
|
||||
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
continue;
|
||||
}
|
||||
|
||||
$code = $sticker->item->code;
|
||||
$materialType = $sticker->material_type;
|
||||
// $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($code) { $query->where('plant_id', $this->plantId)->where('code', $code); })->first();
|
||||
|
||||
if ($materialType == 1)
|
||||
{
|
||||
$totalExcelQty = 0;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
$existQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)->count();
|
||||
|
||||
if ($existQty < $totalExcelQty)
|
||||
{
|
||||
$newQty = $totalExcelQty - $existQty;
|
||||
for ($i = 0; $i < $newQty; $i++)
|
||||
{
|
||||
if ($sticker) {
|
||||
InvoiceValidation::create([
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => 1,
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($materialType == 2)
|
||||
{
|
||||
$bundleQty = $sticker->bundle_quantity;
|
||||
$totalExcelQty = 0;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
$existQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)->count();
|
||||
|
||||
//for ($i = 0; $i < ($totalExcelQty/$bundleQty); $i++)
|
||||
$newTotQty = $totalExcelQty/$bundleQty;
|
||||
if ($existQty < $newTotQty)
|
||||
{
|
||||
$newQty = $newTotQty - $existQty;
|
||||
for ($i = 0; $i < $newQty; $i++)
|
||||
{
|
||||
if ($sticker) {
|
||||
InvoiceValidation::create([
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'quantity' => $bundleQty,
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Material invoice successfully updatad.")
|
||||
->success()
|
||||
->send();
|
||||
Notification::make()
|
||||
->title("Start the scanning process!")
|
||||
->body("'$inserted' new material invoice records were inserted.")
|
||||
->info()
|
||||
// ->success()
|
||||
->send();
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Update Failed: Material Invoice")
|
||||
->body("No new records were inserted for Material Invoice : '$invoiceNumber'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Updated Invoice Not Found')
|
||||
->body("Import the updated 'Material Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => 0,
|
||||
'scanned_quantity'=> 0,
|
||||
]);
|
||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -189,7 +621,362 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if($updateStatus === '1')
|
||||
{
|
||||
dd('Serial invoice update in progress...');
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory . '/' . $filename;
|
||||
$fullPath = $disk->path($filePath);
|
||||
|
||||
// Check if file exists //$disk->exists($filePath)
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
// dd('Serial invoice update in progress...');
|
||||
|
||||
// Now you can read/process the file here
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid updated 'Serial Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
$missingSerials = [];
|
||||
$invalidSerCodes = [];
|
||||
$duplicateSerials = [];
|
||||
$serialNumbers = [];
|
||||
$validRowsFound = false;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
|
||||
if (empty($materialCode) && empty($serialNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($materialCode))
|
||||
{
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($serialNumber)) {
|
||||
$missingSerials[] = $materialCode;
|
||||
}
|
||||
else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerCodes[] = $serialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (in_array($serialNumber, $serialNumbers))
|
||||
{
|
||||
$duplicateSerials[] = $serialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
$serialNumbers[] = $serialNumber;
|
||||
$materialCodes[] = $materialCode;
|
||||
$validRowsFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$validRowsFound) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Invoice')
|
||||
->danger() // This makes the notification red to indicate an error
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||
|
||||
if (!empty($uniqueInvalidCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Codes')
|
||||
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
if (!empty($missingCodes))
|
||||
{
|
||||
$missingCount = count($missingCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidCodes = $matchedItems
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
if (!empty($invalidCodes))
|
||||
{
|
||||
$missingCount = count($invalidCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' Material Invoice item codes found." : "'Material Invoice' item codes found:<br>" . implode(', ', $invalidCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueMissingSerials = array_unique($missingSerials);
|
||||
|
||||
if (!empty($uniqueMissingSerials)) {
|
||||
Notification::make()
|
||||
->title('Missing Serial Numbers')
|
||||
->body("The following item codes doesn't have valid serial number:<br>" . implode(', ', $uniqueMissingSerials))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueInvalidSerCodes = array_unique($invalidSerCodes);
|
||||
|
||||
if (!empty($uniqueInvalidSerCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers')
|
||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidSerCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueDupSerCodes = array_unique($duplicateSerials);
|
||||
|
||||
if (!empty($uniqueDupSerCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers')
|
||||
->body('The following serial numbers are already exist in invoice excel:<br>' . implode(', ', $uniqueDupSerCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$oldQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$newQuan = 0;
|
||||
|
||||
$inserted = 0;
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) // Skip header;
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where(function($query) {
|
||||
$query->whereNull('motor_scanned_status')->orWhere('motor_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('pump_scanned_status')->orWhere('pump_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('capacitor_scanned_status')->orWhere('capacitor_scanned_status', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status_set')->orWhere('scanned_status_set', '');
|
||||
})
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||
})
|
||||
->delete();
|
||||
|
||||
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
continue;
|
||||
}
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
|
||||
if (empty($materialCode) || empty($serialNumber)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sNoExist = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->pluck('serial_number')->first()->exists();
|
||||
|
||||
if($sNoExist) { continue; }
|
||||
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
|
||||
$query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode
|
||||
})->first();
|
||||
|
||||
if ($sticker) {
|
||||
InvoiceValidation::create([
|
||||
'sticker_master_id' => $sticker->id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $serialNumber,
|
||||
'operator_id'=> $operatorName,
|
||||
]);
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial invoice successfully updated.")
|
||||
->success()
|
||||
->send();
|
||||
|
||||
Notification::make()
|
||||
->title("Start the scanning process!")
|
||||
->body("'$inserted' new serial invoice records were inserted.")
|
||||
->info()
|
||||
// ->success()
|
||||
->send();
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
||||
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Update Failed: Serial Invoice")
|
||||
->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totalQuantity,
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Updated Invoice Not Found')
|
||||
->body("Import the updated 'Serial Invoice' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => 0,
|
||||
'scanned_quantity'=> 0,
|
||||
]);
|
||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -156,14 +156,17 @@ class ItemResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('hourly_quantity')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -153,11 +153,14 @@ class LineResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -103,9 +103,11 @@ class LineStopResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('reason')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -155,12 +155,14 @@ class PlantResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('address')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('company.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
|
||||
@@ -21,6 +21,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -297,6 +298,8 @@ class ProductionLineStopResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
@@ -376,6 +379,9 @@ class ProductionLineStopResource extends Resource
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
@@ -407,7 +413,6 @@ class ProductionLineStopResource extends Resource
|
||||
}),
|
||||
|
||||
//block
|
||||
|
||||
Select::make('Block')
|
||||
->label('Select Block')
|
||||
->options(fn (callable $get) =>
|
||||
@@ -418,7 +423,6 @@ class ProductionLineStopResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
//shift
|
||||
|
||||
Select::make('Shift')
|
||||
->label('Select Shift')
|
||||
->options(function (callable $get) {
|
||||
@@ -436,7 +440,6 @@ class ProductionLineStopResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
//line
|
||||
|
||||
Select::make('line')
|
||||
->label('Select line')
|
||||
->options(function (callable $get) {
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\Shift;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
@@ -477,6 +478,9 @@ class ProductionPlanResource extends Resource
|
||||
->reactive()
|
||||
->required()
|
||||
->readOnly(),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
@@ -514,10 +518,16 @@ class ProductionPlanResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('shift.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Item;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\Shift;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
@@ -46,7 +47,7 @@ class ProductionQuantityResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->columnSpan(2) //1
|
||||
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
||||
->default(function () {
|
||||
return optional(ProductionQuantity::latest()->first())->plant_id;
|
||||
@@ -98,6 +99,7 @@ class ProductionQuantityResource extends Resource
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('block_name')
|
||||
->label('Block')
|
||||
->required()
|
||||
// ->nullable()
|
||||
->columnSpan(1)
|
||||
@@ -151,6 +153,7 @@ class ProductionQuantityResource extends Resource
|
||||
Forms\Components\Select::make('shift_id')
|
||||
->relationship('shift', 'name')
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
// ->nullable()
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('block_name')) {
|
||||
@@ -202,6 +205,7 @@ class ProductionQuantityResource extends Resource
|
||||
Forms\Components\Select::make('line_id')
|
||||
->relationship('line', 'name')
|
||||
->required()
|
||||
->columnSpan(2)
|
||||
// ->nullable()
|
||||
// ->options(fn (callable $get) =>
|
||||
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||
@@ -288,12 +292,29 @@ class ProductionQuantityResource extends Resource
|
||||
// // ->autocapitalize('item_code'),
|
||||
// // //->columnSpanFull(),
|
||||
// Virtual field for code input (not stored in DB)
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->columnSpan(2)
|
||||
->disabled(function ($get) {
|
||||
return $get('item_code');
|
||||
})
|
||||
->default(function () {
|
||||
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||
$latestProductionOrder = ProductionQuantity::latest()->first()->production_order;
|
||||
return $latestProductionOrder ?? null;
|
||||
}),
|
||||
Forms\Components\TextInput::make('item_code')
|
||||
->label('Item Code')
|
||||
// ->required()
|
||||
->reactive()
|
||||
->columnSpan(2)
|
||||
->autofocus(true)
|
||||
->debounce(100)
|
||||
->disabled(function ($get) {
|
||||
return !$get('production_order');
|
||||
})
|
||||
// ->submitOnEnter()
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
$set('success_msg', null);
|
||||
@@ -672,6 +693,7 @@ class ProductionQuantityResource extends Resource
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial Number must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(800)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -686,6 +708,7 @@ class ProductionQuantityResource extends Resource
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial Number must be at least 9 digits.")
|
||||
->danger()
|
||||
->duration(800)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -811,6 +834,7 @@ class ProductionQuantityResource extends Resource
|
||||
Forms\Components\TextInput::make('recent_qr') //item_description
|
||||
->label('Last scanned QR')
|
||||
->reactive()
|
||||
->columnSpan(2)
|
||||
->default(function () {
|
||||
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||
@@ -831,8 +855,11 @@ class ProductionQuantityResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
|
||||
])
|
||||
->columns(6),
|
||||
->columns(12), //6
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -845,15 +872,20 @@ class ProductionQuantityResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shift.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
@@ -883,8 +915,8 @@ class ProductionQuantityResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ProductionQuantityImporter::class)
|
||||
->chunkSize(1000),
|
||||
->importer(ProductionQuantityImporter::class),
|
||||
// ->chunkSize(250),
|
||||
// ->maxRows(100000),
|
||||
ExportAction::make()
|
||||
->exporter(ProductionQuantityExporter::class),
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Filament\Resources\QualityValidationResource\RelationManagers;
|
||||
use App\Models\QualityValidation;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
@@ -21,6 +22,7 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\Relationship;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
|
||||
@@ -37,7 +39,7 @@ class QualityValidationResource extends Resource
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
->schema(components: [
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
@@ -51,6 +53,8 @@ class QualityValidationResource extends Resource
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
|
||||
Forms\Components\TextInput::make('item_id')
|
||||
->label('Item Code')
|
||||
@@ -1646,6 +1650,18 @@ class QualityValidationResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// public static function mutateFormDataBeforeCreate(array $data): array
|
||||
// {
|
||||
// $user =Filament::auth()->user();
|
||||
// dd($user);
|
||||
// if($user){
|
||||
// $data['operator_id'] = $user->name;
|
||||
// }
|
||||
// // $data['operator_id'] = Filament::auth()->user()->name;
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -12,7 +12,6 @@ class CreateQualityValidation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
@@ -270,16 +270,19 @@ class ShiftResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('start_time')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('end_time'),
|
||||
Tables\Columns\TextColumn::make('block.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -195,7 +195,7 @@ class StickerMasterResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('bundle_quantity', 1);
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
//$plantId = $get('plant_id');
|
||||
})
|
||||
@@ -205,8 +205,18 @@ class StickerMasterResource extends Resource
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->readOnly(fn (callable $get) => $get('material_type') !== "2")
|
||||
->nullable(),
|
||||
|
||||
->nullable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if($get('material_type') !== "2")
|
||||
{
|
||||
$set('bundle_quantity', null);
|
||||
}
|
||||
else if ($get('bundle_quantity') < 2)
|
||||
{
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
}),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_motor')
|
||||
->reactive()
|
||||
@@ -390,9 +400,11 @@ class StickerMasterResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_motor')
|
||||
->disabled(true)
|
||||
->sortable(),
|
||||
|
||||
@@ -11,6 +11,7 @@ use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class UserResource extends Resource
|
||||
@@ -46,6 +47,18 @@ class UserResource extends Resource
|
||||
->revealable()
|
||||
->required()
|
||||
->maxLength(255),
|
||||
// Forms\Components\Select::make('roles')
|
||||
// ->multiple()
|
||||
// ->relationship('roles', 'name'),
|
||||
Forms\Components\Select::make('roles')
|
||||
->relationship('roles', 'name')
|
||||
//->relationship(name: 'roles', titleAttribute: 'name')
|
||||
// ->saveRelationshipsUsing(function (Model $record, $state) {
|
||||
// $record->roles()->syncWithPivotValues($state, [config('permission.column_names.team_foreign_key') => getPermissionsTeamId()]);
|
||||
// })
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -58,6 +71,7 @@ class UserResource extends Resource
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->searchable(),
|
||||
|
||||
111
app/Filament/Widgets/CumulativeChart.php
Normal file
111
app/Filament/Widgets/CumulativeChart.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Line;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class CumulativeChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Production Line Count';
|
||||
|
||||
protected $listeners = ['cumulativeChart'];
|
||||
|
||||
|
||||
protected int|string|array $columnSpan = 12;
|
||||
protected function getData(): array
|
||||
{
|
||||
$selectedPlant = session('selected_plant') ?? session('select_plant');
|
||||
$activeFilter = $this->filter;
|
||||
|
||||
// Define 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 lines for selected plant
|
||||
$lines = Line::where('plant_id', $selectedPlant)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
|
||||
// Get total production per line in the date range
|
||||
$production = \DB::table('production_quantities')
|
||||
->select('line_id', \DB::raw('COUNT(*) as total_quantity'))
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->whereIn('line_id', array_keys($lines))
|
||||
->groupBy('line_id')
|
||||
->pluck('total_quantity', 'line_id')
|
||||
->toArray();
|
||||
|
||||
// Match quantities with lines (fill 0 if missing)
|
||||
$labels = [];
|
||||
$data = [];
|
||||
|
||||
foreach ($lines as $lineId => $lineName) {
|
||||
$labels[] = $lineName;
|
||||
$data[] = $production[$lineId] ?? 0;
|
||||
}
|
||||
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => match ($activeFilter) {
|
||||
'yesterday' => "Production Quantity (Yesterday)",
|
||||
'this_week' => "Weekly Production This Month",
|
||||
'this_month' => "Yesterday's Hourly Production",
|
||||
default => "Today's Production",
|
||||
},
|
||||
'data' => $data,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
protected function getFilters(): ?array
|
||||
{
|
||||
return [
|
||||
'today' => 'Today',
|
||||
'yesterday' => 'Yesterday',
|
||||
'this_week'=> 'This Week',
|
||||
'this_month'=> 'This Month',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true, //Start Y-axis from 0
|
||||
'ticks' => [
|
||||
'stepSize' => 0.5,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
197
app/Filament/Widgets/InvoiceChart.php
Normal file
197
app/Filament/Widgets/InvoiceChart.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class InvoiceChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Chart';
|
||||
|
||||
protected int|string|array $columnSpan = 12;
|
||||
|
||||
protected $listeners = ['invoiceChart'];
|
||||
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$selectedPlant =session('selec_plant');
|
||||
|
||||
$selectedInvoice = session('select_invoice');
|
||||
|
||||
$activeFilter = $this->filter;
|
||||
|
||||
if (!$selectedPlant || !$selectedInvoice) {
|
||||
return
|
||||
[
|
||||
'datasets' => [],
|
||||
'labels' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if ($activeFilter === 'yesterday') {
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
$endDate = now()->subDay()->endOfDay();
|
||||
$groupBy = 'EXTRACT(HOUR FROM invoice_validations.created_at)';
|
||||
}
|
||||
else if ($activeFilter === 'this_week') {
|
||||
$startDate = now()->startOfWeek(); // Monday 12:00 AM
|
||||
$endDate = now()->endOfWeek(); // Sunday 11:59 PM
|
||||
$groupBy = 'EXTRACT(DOW FROM invoice_validations.created_at)'; // Group by day of week
|
||||
}
|
||||
else if ($activeFilter === 'this_month') {
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
$groupBy = "FLOOR((EXTRACT(DAY FROM invoice_validations.created_at) - 1) / 7) + 1";
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->startOfDay();
|
||||
$endDate = now()->endOfDay();
|
||||
$groupBy = 'EXTRACT(HOUR FROM invoice_validations.created_at)';
|
||||
}
|
||||
|
||||
$fullyScannedInvoiceNumbers = \DB::table('invoice_validations')
|
||||
->select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END) = COUNT(*)")
|
||||
->pluck('invoice_number');
|
||||
|
||||
//query data
|
||||
$query = \DB::table('invoice_validations')
|
||||
->join('plants', 'invoice_validations.plant_id', '=', 'plants.id')
|
||||
->selectRaw("$groupBy AS time_unit, count(distinct invoice_validations.invoice_number) AS total_quantity")
|
||||
->whereBetween('invoice_validations.created_at', [$startDate, $endDate])
|
||||
->where('invoice_validations.plant_id', $selectedPlant)
|
||||
->whereIn('invoice_validations.invoice_number', $fullyScannedInvoiceNumbers)
|
||||
->when($selectedInvoice === 'serial_invoice', fn($q) =>
|
||||
$q->whereNotNull('invoice_validations.serial_number')
|
||||
->where('invoice_validations.serial_number', '!=', '')
|
||||
)
|
||||
->when($selectedInvoice === 'individual_material', fn($q) =>
|
||||
$q->where('invoice_validations.quantity', 1) // Only individual items
|
||||
)
|
||||
->when($selectedInvoice === 'bundle_material', fn($q) =>
|
||||
$q->where('invoice_validations.quantity', '>', 1) // Assume bundles have quantity > 1
|
||||
)
|
||||
->groupByRaw($groupBy)
|
||||
->orderByRaw($groupBy)
|
||||
->pluck('total_quantity', 'time_unit')
|
||||
->toArray();
|
||||
if ($activeFilter === 'this_month') {
|
||||
$weeksCount = ceil($endDate->day / 7); // Calculate total weeks dynamically
|
||||
$allWeeks = array_fill(1, $weeksCount, 0); // Initialize all weeks with 0
|
||||
$data = array_replace($allWeeks, $query); // Fill missing weeks with 0
|
||||
|
||||
// Generate dynamic week labels
|
||||
$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);
|
||||
}
|
||||
else if ($activeFilter === 'this_week') {
|
||||
// Correct week labels: ['Mon', 'Tue', ..., 'Sun']
|
||||
$labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
|
||||
// Initialize default data for all 7 days
|
||||
$data = array_fill(0, 7, 0);
|
||||
|
||||
// Fill in data from query results
|
||||
foreach ($query as $dow => $count) {
|
||||
$data[$dow] = $count;
|
||||
}
|
||||
|
||||
// Ensure days are ordered from Monday to Sunday
|
||||
$orderedData = [
|
||||
$data[1] ?? 0, // Monday
|
||||
$data[2] ?? 0, // Tuesday
|
||||
$data[3] ?? 0, // Wednesday
|
||||
$data[4] ?? 0, // Thursday
|
||||
$data[5] ?? 0, // Friday
|
||||
$data[6] ?? 0, // Saturday
|
||||
$data[0] ?? 0, // Sunday (move to last)
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hourly data (same as before)
|
||||
$allHours = array_fill(0, 24, 0);
|
||||
$data = array_replace($allHours, $query);
|
||||
|
||||
// Shift hours for proper display (8 AM to 7 AM)
|
||||
$shiftedKeys = array_merge(range(8, 23), range(0, 8));
|
||||
$orderedData = array_map(fn($hour) => $data[$hour], $shiftedKeys);
|
||||
|
||||
// Labels: ["8 AM", "9 AM", ..., "7 AM"]
|
||||
$labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys);
|
||||
}
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => match ($activeFilter) {
|
||||
'this_week' => "Daily imported excel file count",
|
||||
'this_month' => "Weekly imported excel file count", // Updated Label
|
||||
'yesterday' => "Yesterday's imported excel file count",
|
||||
default => "Today's imported excel file count",
|
||||
},
|
||||
'data' => $orderedData,
|
||||
'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||
'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
||||
'fill' => false,
|
||||
'tension' => 0.3,
|
||||
],
|
||||
],
|
||||
'labels' => $labels,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
public static function getDefaultName(): string
|
||||
{
|
||||
return 'invoice-chart';
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true, //Start Y-axis from 0
|
||||
'ticks' => [
|
||||
'stepSize' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
protected function getFilters(): ?array
|
||||
{
|
||||
return [
|
||||
'today' => 'Today',
|
||||
'yesterday' => 'Yesterday',
|
||||
'this_week'=> 'This Week',
|
||||
'this_month'=> 'This Month',
|
||||
];
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
// dd('Checking route:', request()->route()->getName());
|
||||
// to avoid showing the widget in other pages
|
||||
return request()->routeIs('filament.admin.pages.invoice-dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,7 @@ class ItemOverview extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Hourly Production';
|
||||
|
||||
// protected int|string|array $columnSpan = 'full';
|
||||
protected int|string|array $columnSpan = 12;
|
||||
protected int|string|array $columnSpan = '12';
|
||||
|
||||
protected static ?string $maxHeight = '350px';
|
||||
|
||||
@@ -146,20 +145,6 @@ class ItemOverview extends ChartWidget
|
||||
return 'line';
|
||||
}
|
||||
|
||||
// protected function getContent(): string
|
||||
// {
|
||||
// return '<div style="height: 100%;">' . $this->chart->render() . '</div>';
|
||||
// }
|
||||
// protected function getContent(): string
|
||||
// {
|
||||
// return <<<HTML
|
||||
// <div id="chart-container" style="height: 100vh; width: 100%;">
|
||||
// {$this->chart->render()}
|
||||
// </div>
|
||||
// HTML;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
@@ -173,15 +158,6 @@ class ItemOverview extends ChartWidget
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
// 'scales' => [
|
||||
// 'y' => [
|
||||
// 'beginAtZero' => true, //Start Y-axis from 0
|
||||
// 'ticks' => [
|
||||
// 'stepSize' => 0.5,
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -194,4 +170,10 @@ class ItemOverview extends ChartWidget
|
||||
'this_month'=> 'This Month',
|
||||
];
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
// Only show on HourlyProduction page
|
||||
return request()->routeIs('filament.pages.hourly-production');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class ProductionQuantity extends Model
|
||||
"line_id",
|
||||
"item_id",
|
||||
"serial_number",
|
||||
"production_order",
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
|
||||
@@ -32,6 +32,7 @@ class QualityValidation extends Model
|
||||
'part_validation3',
|
||||
'part_validation4',
|
||||
'part_validation5',
|
||||
'operator_id',
|
||||
];
|
||||
|
||||
public function stickerMaster(): BelongsTo
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Althinect\FilamentSpatieRolesPermissions\Concerns\HasSuperAdmin;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -12,7 +14,7 @@ use Spatie\Permission\Traits\HasRoles;
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, HasRoles, Notifiable, SoftDeletes; //
|
||||
use HasFactory, HasRoles, Notifiable, SoftDeletes, HasSuperAdmin;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -47,4 +49,9 @@ class User extends Authenticatable
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
// public function team(): BelongsTo
|
||||
// {
|
||||
// return $this->belongsTo(Team::class);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ class BlockPolicy
|
||||
*/
|
||||
public function update(User $user, Block $block): bool
|
||||
{
|
||||
return false;
|
||||
return $user->hasPermissionTo('update Block');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,8 @@ class BlockPolicy
|
||||
*/
|
||||
public function delete(User $user, Block $block): bool
|
||||
{
|
||||
return false;
|
||||
return $user->hasPermissionTo('delete Block');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +54,8 @@ class BlockPolicy
|
||||
*/
|
||||
public function restore(User $user, Block $block): bool
|
||||
{
|
||||
return false;
|
||||
return $user->hasPermissionTo('restore Block');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,6 +63,7 @@ class BlockPolicy
|
||||
*/
|
||||
public function forceDelete(User $user, Block $block): bool
|
||||
{
|
||||
return false;
|
||||
return $user->hasPermissionTo('force delete Block');
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
||||
106
app/Policies/CompanyPolicy.php
Normal file
106
app/Policies/CompanyPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
|
||||
class CompanyPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Company $company): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete Company');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any Company');
|
||||
}
|
||||
}
|
||||
106
app/Policies/InvoiceValidationPolicy.php
Normal file
106
app/Policies/InvoiceValidationPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\User;
|
||||
|
||||
class InvoiceValidationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, InvoiceValidation $invoicevalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete InvoiceValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any InvoiceValidation');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ItemPolicy.php
Normal file
106
app/Policies/ItemPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\Item;
|
||||
use App\Models\User;
|
||||
|
||||
class ItemPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Item $item): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete Item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any Item');
|
||||
}
|
||||
}
|
||||
106
app/Policies/LinePolicy.php
Normal file
106
app/Policies/LinePolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\Line;
|
||||
use App\Models\User;
|
||||
|
||||
class LinePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Line $line): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete Line');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any Line');
|
||||
}
|
||||
}
|
||||
106
app/Policies/LineStopPolicy.php
Normal file
106
app/Policies/LineStopPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\LineStop;
|
||||
use App\Models\User;
|
||||
|
||||
class LineStopPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, LineStop $linestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete LineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any LineStop');
|
||||
}
|
||||
}
|
||||
80
app/Policies/PermissionPolicy.php
Normal file
80
app/Policies/PermissionPolicy.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Spatie\Permission\Models\Permission;
|
||||
// use App\Models\SpatiePermissionModelsPermission;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class PermissionPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
// return false;
|
||||
return $user->hasPermissionTo('view permissions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Permission $permission): bool
|
||||
// public function view(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool
|
||||
{
|
||||
return $user->hasPermissionTo('view permissions');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->hasPermissionTo('create permissions');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Permission $permission): bool
|
||||
// public function update(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool
|
||||
{
|
||||
return $user->hasPermissionTo('edit permissions');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
//public function delete(User $user, Permission $permission): bool
|
||||
public function delete(User $user, Permission $permission): bool
|
||||
// public function delete(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool
|
||||
{
|
||||
return $user->hasPermissionTo('delete permissions');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Permission $permission): bool
|
||||
// public function restore(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool
|
||||
{
|
||||
return $user->hasPermissionTo('restore permissions');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Permission $permission): bool
|
||||
// public function forceDelete(User $user, SpatiePermissionModelsPermission $spatiePermissionModelsPermission): bool
|
||||
{
|
||||
return $user->hasPermissionTo('force-delete permissions');
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
106
app/Policies/PlantPolicy.php
Normal file
106
app/Policies/PlantPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
|
||||
class PlantPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Plant $plant): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete Plant');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any Plant');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ProductionLineStopPolicy.php
Normal file
106
app/Policies/ProductionLineStopPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ProductionLineStop;
|
||||
use App\Models\User;
|
||||
|
||||
class ProductionLineStopPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ProductionLineStop $productionlinestop): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ProductionLineStop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ProductionLineStop');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ProductionPlanPolicy.php
Normal file
106
app/Policies/ProductionPlanPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\User;
|
||||
|
||||
class ProductionPlanPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ProductionPlan $productionplan): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ProductionPlan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ProductionPlan');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ProductionQuantityPolicy.php
Normal file
106
app/Policies/ProductionQuantityPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\User;
|
||||
|
||||
class ProductionQuantityPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ProductionQuantity $productionquantity): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ProductionQuantity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ProductionQuantity');
|
||||
}
|
||||
}
|
||||
106
app/Policies/QualityValidationPolicy.php
Normal file
106
app/Policies/QualityValidationPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\User;
|
||||
|
||||
class QualityValidationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, QualityValidation $qualityvalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete QualityValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any QualityValidation');
|
||||
}
|
||||
}
|
||||
79
app/Policies/RolePolicy.php
Normal file
79
app/Policies/RolePolicy.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
// use App\Models\SpatiePermissionModelsRole;
|
||||
use App\Models\User;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class RolePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->hasPermissionTo('view roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Role $role): bool // Changed typehint
|
||||
// public function view(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('view roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->hasPermissionTo('create roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Role $role): bool // Changed typehint
|
||||
// public function update(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('edit roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Role $role): bool // Changed typehint
|
||||
// public function delete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('delete roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Role $role): bool // Changed typehint
|
||||
// public function restore(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('restore roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
// public function forceDelete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
public function forceDelete(User $user, Role $role): bool // Changed typehint
|
||||
{
|
||||
return $user->hasPermissionTo('force-delete roles');
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
106
app/Policies/ShiftPolicy.php
Normal file
106
app/Policies/ShiftPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\Shift;
|
||||
use App\Models\User;
|
||||
|
||||
class ShiftPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, Shift $shift): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete Shift');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any Shift');
|
||||
}
|
||||
}
|
||||
106
app/Policies/StickerMasterPolicy.php
Normal file
106
app/Policies/StickerMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class StickerMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, StickerMaster $stickermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete StickerMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any StickerMaster');
|
||||
}
|
||||
}
|
||||
106
app/Policies/UserPolicy.php
Normal file
106
app/Policies/UserPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, User $model): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any User');
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use URL;
|
||||
use App\Policies\RolePolicy;
|
||||
use App\Policies\PermissionPolicy;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
// use Doctrine\DBAL\Types\Type;
|
||||
|
||||
@@ -23,8 +27,12 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Gate::before(function ($user, $ability) {
|
||||
return $user->hasRole('Super Admin') ? true : null;
|
||||
// Gate::before(function ($user, $ability) {
|
||||
// return $user->hasRole('Super Admin') ? true : null;
|
||||
// });
|
||||
|
||||
Gate::before(function (User $user, string $ability) {
|
||||
return $user->isSuperAdmin() ? true: null;
|
||||
});
|
||||
|
||||
// URL::forceScheme('https');
|
||||
@@ -32,5 +40,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
// if (!Type::hasType('citext')) {
|
||||
// Type::addType('citext', \Doctrine\DBAL\Platforms\PostgreSqlPlatform::class);
|
||||
// }
|
||||
|
||||
Gate::policy(Role::class, RolePolicy::class);
|
||||
Gate::policy(Permission::class, PermissionPolicy::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Althinect\FilamentSpatieRolesPermissions\FilamentSpatieRolesPermissionsPlugin;
|
||||
use App\Filament\Pages\InvoiceDashboard;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Navigation\MenuItem;
|
||||
use Filament\Navigation\NavigationGroup;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
use Filament\Pages;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
@@ -20,6 +23,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Althinect\FilamentSpatieRolesPermissions\Middleware\SyncSpatiePermissionsWithFilamentTenants;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
@@ -27,7 +31,6 @@ class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
@@ -38,9 +41,9 @@ class AdminPanelProvider extends PanelProvider
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
|
||||
])
|
||||
|
||||
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
// ->widgets([
|
||||
// Widgets\AccountWidget::class,
|
||||
@@ -60,6 +63,9 @@ class AdminPanelProvider extends PanelProvider
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
])
|
||||
->tenantMiddleware([
|
||||
SyncSpatiePermissionsWithFilamentTenants::class,
|
||||
], isPersistent: true)
|
||||
->databaseNotifications()
|
||||
->plugin(FilamentSpatieRolesPermissionsPlugin::make());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
|
||||
ALTER TABLE production_line_stops
|
||||
ADD operator_id TEXT DEFAULT NULL;
|
||||
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
|
||||
ALTER TABLE production_plans
|
||||
ADD operator_id TEXT DEFAULT NULL;
|
||||
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
|
||||
$sql3 = <<<'SQL'
|
||||
|
||||
ALTER TABLE production_quantities
|
||||
ADD operator_id TEXT DEFAULT NULL;
|
||||
|
||||
SQL;
|
||||
|
||||
DB::statement($sql3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
|
||||
ALTER TABLE quality_validations
|
||||
ADD operator_id TEXT DEFAULT NULL;
|
||||
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
|
||||
ALTER TABLE production_quantities
|
||||
ADD production_order TEXT DEFAULT NULL;
|
||||
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
@@ -14,5 +14,6 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call(RoleSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(PermissionSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
40
database/seeders/PermissionSeeder.php
Normal file
40
database/seeders/PermissionSeeder.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$permissions = [
|
||||
'view permissions',
|
||||
'create permissions',
|
||||
'edit permissions',
|
||||
'delete permissions',
|
||||
'restore permissions',
|
||||
'force-delete permissions',
|
||||
// Add role permissions if needed
|
||||
'view roles',
|
||||
'create roles',
|
||||
'edit roles',
|
||||
'delete roles',
|
||||
'restore roles',
|
||||
'force-delete roles'
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::updateOrCreate(['name' => $permission]); //firstOrCreate
|
||||
}
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view production dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view invoice dashboard']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
@@ -12,9 +13,25 @@ class RoleSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Role::create([
|
||||
Role::updateOrCreate([
|
||||
'name' => 'Super Admin',
|
||||
'guard_name' => 'web',
|
||||
]);
|
||||
|
||||
// // newly added role
|
||||
// $role_admin = Role::create([
|
||||
// 'name' => 'admin',
|
||||
// 'guard_name' => 'web',
|
||||
// ]);
|
||||
// $permission_manage_users = Permission::firstOrCreate([
|
||||
// 'name' => 'manage users',
|
||||
// 'guard_name' => 'web',
|
||||
// ]);
|
||||
|
||||
// $role_admin->givePermissionTo($permission_manage_users);
|
||||
|
||||
// $user = User::find(10);
|
||||
|
||||
// $user->assignRole($role_admin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Hash;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
@@ -12,41 +13,101 @@ class UserSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$user1 = User::create([
|
||||
//updateOrCreate
|
||||
$user1 = User::updateOrCreate(
|
||||
// Unique identifier
|
||||
['email' => 'admin@cripumps.com'],
|
||||
|
||||
// Data to update/create
|
||||
[
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@cripumps.com',
|
||||
'password' => bcrypt('admin'),
|
||||
]);
|
||||
'password' => Hash::make('admin'),
|
||||
'updated_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
// $user1 = User::firstOrCreate([
|
||||
// 'name' => 'Admin',
|
||||
// 'email' => 'admin@cripumps.com',
|
||||
// 'password' => bcrypt('admin'),
|
||||
// ]);
|
||||
$user1->assignRole('Super Admin');
|
||||
|
||||
$user2 = User::create([
|
||||
$user2 = User::updateOrCreate(
|
||||
// Unique identifier
|
||||
['email' => 'jothi@cripumps.com'],
|
||||
|
||||
// Data to update/create
|
||||
[
|
||||
'name' => 'Jothi',
|
||||
'email' => 'jothi@cripumps.com',
|
||||
'password' => bcrypt('jothi@123'),
|
||||
]);
|
||||
'updated_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
// $user2 = User::firstOrCreate([
|
||||
// 'name' => 'Jothi',
|
||||
// 'email' => 'jothi@cripumps.com',
|
||||
// 'password' => bcrypt('jothi@123'),
|
||||
// ]);
|
||||
$user2->assignRole('Super Admin');
|
||||
|
||||
$user3 = User::create([
|
||||
$user3 = User::updateOrCreate(
|
||||
// Unique identifier
|
||||
['email' => 'dhana@cripumps.com'],
|
||||
|
||||
// Data to update/create
|
||||
[
|
||||
'name' => 'Dhana',
|
||||
'email' => 'dhana@cripumps.com',
|
||||
'password' => bcrypt('dhana@123'),
|
||||
]);
|
||||
'updated_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
// $user3 = User::firstOrCreate([
|
||||
// 'name' => 'Dhana',
|
||||
// 'email' => 'dhana@cripumps.com',
|
||||
// 'password' => bcrypt('dhana@123'),
|
||||
// ]);
|
||||
$user3->assignRole('Super Admin');
|
||||
|
||||
$user4 = User::create([
|
||||
$user4 = User::updateOrCreate(
|
||||
// Unique identifier
|
||||
['email' => 'ranjith@cripumps.com'],
|
||||
|
||||
// Data to update/create
|
||||
[
|
||||
'name' => 'Ranjith',
|
||||
'email' => 'ranjith@cripumps.com',
|
||||
'password' => bcrypt('ranjith@123'),
|
||||
]);
|
||||
'updated_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
// $user4 = User::firstOrCreate([
|
||||
// 'name' => 'Ranjith',
|
||||
// 'email' => 'ranjith@cripumps.com',
|
||||
// 'password' => bcrypt('ranjith@123'),
|
||||
// ]);
|
||||
$user4->assignRole('Super Admin');
|
||||
|
||||
$user5 = User::create([
|
||||
'name' => 'Srimathi',
|
||||
'email' => 'srimathi@cripumps.com',
|
||||
'password' => bcrypt('srimathi@123'),
|
||||
]);
|
||||
$user5->assignRole('Super Admin');
|
||||
$user5 = User::updateOrCreate(
|
||||
// Unique identifier
|
||||
['email' => 'srimathi@cripumps.com'],
|
||||
|
||||
User::factory()->count(5)->create();
|
||||
// Data to update/create
|
||||
[
|
||||
'name' => 'Srimathi',
|
||||
'password' => bcrypt('srimathi@123'),
|
||||
'updated_at' => now(),
|
||||
'created_at' => now()
|
||||
]
|
||||
);
|
||||
// $user5 = User::firstOrCreate([
|
||||
// 'name' => 'Srimathi',
|
||||
// 'email' => 'srimathi@cripumps.com',
|
||||
// 'password' => bcrypt('srimathi@123'),
|
||||
// ]);
|
||||
$user5->assignRole('Super Admin');
|
||||
// User::factory()->count(5)->create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Filters form --}}
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
|
||||
{{-- Chart Widget --}}
|
||||
@livewire(\App\Filament\Widgets\ItemOverview::class)
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
19
resources/views/filament/pages/invoice-dashboard.blade.php
Normal file
19
resources/views/filament/pages/invoice-dashboard.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
</div>
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\InvoiceChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user