- 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>
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Models\ActivityLog;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
final class ActivityLogsExport implements BrandedReport
|
|
{
|
|
private const EVENT_LABELS = [
|
|
'created' => 'Tạo mới',
|
|
'updated' => 'Cập nhật',
|
|
'deleted' => 'Xóa',
|
|
'restored' => 'Khôi phục',
|
|
'login' => 'Đăng nhập',
|
|
'logout' => 'Đăng xuất',
|
|
];
|
|
|
|
public function __construct(private readonly Builder $query) {}
|
|
|
|
public function title(): string
|
|
{
|
|
return 'Lịch sử hoạt động';
|
|
}
|
|
|
|
public function query(): Builder
|
|
{
|
|
return $this->query->latest('id');
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'ID', 'Module', 'Hành động', 'Mô tả', 'Loại người thực hiện', 'Người thực hiện',
|
|
'Đối tượng', 'ID đối tượng', 'IP', 'Thiết bị', 'Dữ liệu cũ', 'Dữ liệu mới', 'Thời gian',
|
|
];
|
|
}
|
|
|
|
public function map($row): array
|
|
{
|
|
/** @var ActivityLog $row */
|
|
return [
|
|
$row->id,
|
|
$row->log_name,
|
|
self::EVENT_LABELS[$row->event] ?? $row->event,
|
|
$row->description,
|
|
$row->causer_type,
|
|
$row->causer_name,
|
|
$row->subject_type,
|
|
$row->subject_id,
|
|
$row->ip_address,
|
|
$row->user_agent,
|
|
$this->encodeValues($row->old_values),
|
|
$this->encodeValues($row->new_values),
|
|
$row->created_at?->format('d/m/Y H:i:s'),
|
|
];
|
|
}
|
|
|
|
public function moneyColumns(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
private function encodeValues(?array $values): ?string
|
|
{
|
|
if ($values === null || $values === []) {
|
|
return null;
|
|
}
|
|
|
|
return json_encode($values, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: null;
|
|
}
|
|
}
|