[Operator] Kelengkapan menu Browse Kurikulum
This commit is contained in:
@@ -9,7 +9,6 @@ use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportRegistry;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use App\Support\Legacy\Reports\ReportSource;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -40,6 +39,11 @@ class LaporanController extends Controller
|
||||
|
||||
private const string XLSX_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
|
||||
/** Batas memori (byte) dan waktu (detik) selama membangun berkas Excel; lihat raiseExportLimits(). */
|
||||
private const int XLSX_MEMORY = 1024 * 1024 * 1024;
|
||||
|
||||
private const int XLSX_SECONDS = 180;
|
||||
|
||||
public function __construct(private readonly AcademicOverview $overview) {}
|
||||
|
||||
public function __invoke(Request $request, string $slug): View
|
||||
@@ -242,7 +246,8 @@ class LaporanController extends Controller
|
||||
'viewable' => $detail !== [],
|
||||
'detailColumns' => $detail,
|
||||
'crumbs' => ['Beranda' => route(auth()->user()->role->dashboardRoute())] + array_fill_keys(Catalog::trail($slug), null) + [$page['title'] => null],
|
||||
'note' => trim(($definition['note'] ?? '').($errors === [] ? '' : ' Lengkapi filter yang wajib diisi ('.implode(', ', array_map(fn (array $p): string => $p['label'], array_filter($params, fn (array $p): bool => isset($errors[$p['name']])))).') untuk menampilkan data.')) ?: null,
|
||||
// '' (bukan null) = tanpa catatan; null membuat bingkai memakai catatan prototipe bawaannya, padahal ini data asli
|
||||
'note' => trim(($definition['note'] ?? '').($errors === [] ? '' : ' Lengkapi filter yang wajib diisi ('.implode(', ', array_map(fn (array $p): string => $p['label'], array_filter($params, fn (array $p): bool => isset($errors[$p['name']])))).') untuk menampilkan data.')) ?: '',
|
||||
'empty' => ['icon' => 'document-chart-bar', 'title' => 'Belum ada data', 'description' => 'Data tampil setelah tabel sumbernya terisi.'],
|
||||
'url' => route('operator.laporan.data', $slug),
|
||||
'filters' => $filters,
|
||||
@@ -270,6 +275,20 @@ class LaporanController extends Controller
|
||||
return self::exportFormat($definition) === 'xlsx' ? 'Unduh (Excel)' : 'Unduh (CSV)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel dibangun seluruhnya di memori (PhpSpreadsheet), tidak dialirkan seperti CSV: sekitar 130 MB untuk 9 ribu baris
|
||||
* × 7 kolom, sekitar 390 MB dan 17 detik untuk 50 ribu baris. Batas bawaan PHP (128 MB, 30 detik) tidak cukup, jadi
|
||||
* dinaikkan hanya selama permintaan unduh ini; pemakaian sebenarnya tetap mengikuti besar laporan.
|
||||
*/
|
||||
private static function raiseExportLimits(): void
|
||||
{
|
||||
$limit = (string) ini_get('memory_limit');
|
||||
if ($limit !== '-1' && ini_parse_quantity($limit) < self::XLSX_MEMORY) {
|
||||
ini_set('memory_limit', (string) self::XLSX_MEMORY);
|
||||
}
|
||||
set_time_limit(self::XLSX_SECONDS);
|
||||
}
|
||||
|
||||
/** Varian tombol unduh: tosca untuk Excel, sekunder untuk CSV. */
|
||||
private static function downloadVariant(array $definition): string
|
||||
{
|
||||
@@ -297,6 +316,8 @@ class LaporanController extends Controller
|
||||
$name = $slug.'-'.now()->format('Ymd-His');
|
||||
|
||||
if (self::exportFormat($definition) === 'xlsx') {
|
||||
self::raiseExportLimits();
|
||||
|
||||
return Excel::download(new ReportExport($page['title'], $result->columns, $rows), $name.'.xlsx', ExcelWriter::XLSX, ['Content-Type' => self::XLSX_MIME]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user