Introduce a shipment status history system to audit status changes, including the reason for change and the user responsible. This includes a new `ShipmentStatusHistory` model and a bulk action in the Filament ShipmentResource to transition statuses. Enhance the rate import workflow by adding a downloadable Excel template and refactoring the `ImportRatesPage` to use the modern Filament form schema. - Add `ShipmentStatusHistory` model and migration - Add bulk `changeStatus` action to `ShipmentResource` - Add `source` field to tracking events - Implement `ShippingRatesTemplateExport` for rate template downloads - Refactor `ImportRatesPage` form implementation and UI - Add `statusHistories` relationship to `Shipment` model
78 lines
2.0 KiB
PHP
78 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\Exportable;
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
class ShippingRatesTemplateExport implements WithMultipleSheets
|
|
{
|
|
use Exportable;
|
|
|
|
public function sheets(): array
|
|
{
|
|
return [
|
|
new ExportRateSheet('Export Rate'),
|
|
new ExportRateSheet('Import Rate'),
|
|
new DocEcoSheet(),
|
|
];
|
|
}
|
|
}
|
|
|
|
class ExportRateSheet implements FromArray, WithTitle
|
|
{
|
|
public function __construct(protected string $title) {}
|
|
|
|
public function title(): string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function array(): array
|
|
{
|
|
$rows = [
|
|
['RATE TABLE — ' . strtoupper($this->title)],
|
|
['IFNEX Logistics'],
|
|
['Weight (kg)', 'Zone 1', 'Zone 2', 'Zone 3', 'Zone 4', 'Zone 5', 'Zone 6', 'Zone 7', 'Zone 8', 'Zone 9', 'Zone 10'],
|
|
[''],
|
|
];
|
|
|
|
$weights = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10,
|
|
10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5, 16, 16.5, 17, 17.5, 18, 18.5, 19, 19.5, 20,
|
|
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
|
45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
|
|
|
|
foreach ($weights as $w) {
|
|
$rows[] = array_merge([$w], array_fill(0, 10, ''));
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
}
|
|
|
|
class DocEcoSheet implements FromArray, WithTitle
|
|
{
|
|
public function title(): string
|
|
{
|
|
return 'DocEco';
|
|
}
|
|
|
|
public function array(): array
|
|
{
|
|
$rows = [
|
|
['Weight (kg)', 'Zone', 'Rate (AED)'],
|
|
];
|
|
|
|
$weights = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 50];
|
|
|
|
foreach ($weights as $w) {
|
|
$rows[] = [$w, 1, ''];
|
|
$rows[] = [$w, 2, ''];
|
|
$rows[] = [$w, 3, ''];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
} |