diff --git a/04_Laravel/app/Filament/Resources/ShipmentResource/Pages/ViewShipment.php b/04_Laravel/app/Filament/Resources/ShipmentResource/Pages/ViewShipment.php index 9f837bc..62a3983 100644 --- a/04_Laravel/app/Filament/Resources/ShipmentResource/Pages/ViewShipment.php +++ b/04_Laravel/app/Filament/Resources/ShipmentResource/Pages/ViewShipment.php @@ -26,6 +26,7 @@ class ViewShipment extends ViewRecord ->color('warning') ->url(fn ($record) => route('shipments.pdf.awb', $record)) ->openUrlInNewTab(), + Actions\Action::make('download_invoice') ->label('دانلود INVOICE') ->icon('heroicon-o-currency-dollar') diff --git a/04_Laravel/app/Imports/ShippingRatesImport.php b/04_Laravel/app/Imports/ShippingRatesImport.php index a2f5852..9cf4dbb 100644 --- a/04_Laravel/app/Imports/ShippingRatesImport.php +++ b/04_Laravel/app/Imports/ShippingRatesImport.php @@ -11,9 +11,6 @@ use Maatwebsite\Excel\Row; class ShippingRatesImport implements WithMultipleSheets { - /** - * تعریف شیت‌های مختلف فایل اکسل و کلاس‌های پردازش‌گر مربوطه - */ public function sheets(): array { return [ @@ -24,9 +21,6 @@ class ShippingRatesImport implements WithMultipleSheets } } -/** - * کلاس برای پردازش شیت‌های استاندارد نرخ‌ها (Export Rate و Import Rate) - */ class RateSheetImport implements OnEachRow, WithStartRow { protected int $imported = 0; @@ -35,43 +29,33 @@ class RateSheetImport implements OnEachRow, WithStartRow public function __construct(protected string $direction) {} - /** - * شروع خواندن از ردیف ۵ (۴ ردیف اول هدر هستند) - */ public function startRow(): int { return 5; } - /** - * پردازش هر ردیف از شیت - */ public function onRow(Row $row) { $rowIndex = $row->getIndex(); $cells = $row->toArray(); - // بررسی اعتبار ستون وزن (ستون اول) if (empty($cells[0]) || !is_numeric($cells[0])) { $this->skipped++; return; } try { - // تشخیص نوع سرویس (Doc یا Parcel) $type = $this->resolveType($rowIndex, $cells); - // استخراج و نرمال‌سازی قیمت‌های ۱۰ زون $zones = []; for ($i = 1; $i <= 10; $i++) { $val = str_replace([',', ' '], '', (string) ($cells[$i] ?? 0)); $zones['zone_' . $i] = is_numeric($val) ? (float) $val : 0; } - // ثبت یا به‌روزرسانی نرخ در دیتابیس ShippingRate::updateOrCreate( [ - 'direction' => $this->direction, // export یا import + 'direction' => $this->direction, 'type' => $type->value, 'weight' => (float) $cells[0], ], @@ -85,9 +69,6 @@ class RateSheetImport implements OnEachRow, WithStartRow } } - /** - * دریافت آمار عملیات ایمپورت - */ public function getStats(): array { return [ @@ -97,9 +78,6 @@ class RateSheetImport implements OnEachRow, WithStartRow ]; } - /** - * تشخیص نوع سرویس بر اساس محتوای ردیف - */ private function resolveType(int $rowIndex, array $cells): ShipmentType { $header = strtoupper((string) ($cells[3] ?? '')); @@ -112,14 +90,10 @@ class RateSheetImport implements OnEachRow, WithStartRow return ShipmentType::Parcel; } - // اگر نوع مشخص نبود، بر اساس شماره ردیف حدس می‌زنیم return $rowIndex < 10 ? ShipmentType::DocNormal : ShipmentType::Parcel; } } -/** - * کلاس برای پردازش شیت ساده‌تر نرخ‌ها (DocEco) - */ class SimpleRateSheetImport implements OnEachRow, WithStartRow { protected int $imported = 0; @@ -131,18 +105,11 @@ class SimpleRateSheetImport implements OnEachRow, WithStartRow protected string $direction = 'export' ) {} - - /** - * شروع خواندن از ردیف ۲ (۱ ردیف اول هدر است) - */ public function startRow(): int { return 2; } - /** - * پردازش هر ردیف از شیت - */ public function onRow(Row $row) { $cells = $row->toArray(); @@ -189,9 +156,6 @@ class SimpleRateSheetImport implements OnEachRow, WithStartRow } } - /** - * دریافت آمار عملیات ایمپورت - */ public function getStats(): array { return [ @@ -200,4 +164,4 @@ class SimpleRateSheetImport implements OnEachRow, WithStartRow 'errors' => $this->errors, ]; } -} \ No newline at end of file +}