- IP pool: sheet import (xlsx/csv) matched by address, bulk allocate/revoke with notification email (ip_allocated/ip_revoked), ip_pool_logs history. - Orders/invoices: Excel export on branded template (BrandedReportWriter), shared billing filters, order item service info in list responses. - Web design quote Excel export; activity log export. - Service attachments with copy-to-invoice; deployment invoice attachments. - Customer email attachments stored on disk and attached by path. - Admin password change endpoint; user.fullname backfill migration; orders.user_id backfill from logs. - Disable deploy workflow until CI/CD is set up. - Ignore stored customer email and service attachment uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Enums\Order\OrderStatus;
|
|
use App\Exports\Concerns\FormatsBillingCells;
|
|
use App\Models\Order;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
final class OrdersExport implements BrandedReport
|
|
{
|
|
use FormatsBillingCells;
|
|
|
|
public function __construct(private readonly Builder $query) {}
|
|
|
|
public function title(): string
|
|
{
|
|
return 'Danh sách đơn hàng';
|
|
}
|
|
|
|
public function query(): Builder
|
|
{
|
|
return $this->query->latest('id');
|
|
}
|
|
|
|
public function moneyColumns(): array
|
|
{
|
|
return ['F', 'G', 'H'];
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Mã đơn hàng', 'Ngày đặt', 'Khách hàng', 'Email', 'Dịch vụ', 'Tạm tính', 'Giảm giá',
|
|
'Tổng tiền', 'Trạng thái', 'Phương thức thanh toán', 'Hoá đơn', 'Ghi chú', 'Ngày tạo',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param Order $order
|
|
*/
|
|
public function map($order): array
|
|
{
|
|
return [
|
|
$order->order_num,
|
|
$this->formatDate($order->date),
|
|
$order->customer?->fullname,
|
|
$order->customer?->email,
|
|
$this->describeServices($order),
|
|
(int) $order->sub_total,
|
|
(int) $order->discount_amount,
|
|
(int) $order->total,
|
|
OrderStatus::tryFrom((int) $order->status)?->label() ?? $order->status,
|
|
$order->payment?->name ?? $this->paymentMethodLabel($order->payment_method),
|
|
$order->invoices->pluck('invoice_number')->implode(', '),
|
|
$order->note,
|
|
$this->formatDate($order->created_at, 'd/m/Y H:i'),
|
|
];
|
|
}
|
|
}
|