<?php

namespace Modules\Lpj\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Modules\Lpj\Models\PenawaranTender;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;

class PenawaranTenderExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
{
    public function collection()
    {
        return PenawaranTender::all();
    }

    public function map($row): array
    {
        return [
            $row->id,
            $row->code,
            $row->nama_kjpp_sebelumnya,
            $row->biaya_kjpp_sebelumnya,
            $row->tanggal_penilaian_sebelumnya,
            $row->nomor_registrasi,
            $row->tujuan_penilaian_kjpp_id,
            $row->jenis_laporan_id,
            $row->start_date,
            $row->end_date,
            $row->catatan,
            $row->created_at
        ];
    }

    public function headings(): array
    {
        return [
            'ID',
            'Nomor Penawaran',
            'Nama KJPP Sebelumnya',
            'Biaya KJPP Sebelumnya',
            'Tanggal Penilaian Sebelumnya',
            'Nomor Registrasi',
            'Tujuan Penilaian KJPP ID',
            'Jenis Laporan ID',
            'Start Date',
            'End Date',
            'Catatan',
            'Created At'
        ];
    }

    public function columnFormats(): array
    {
        return [
            'A' => NumberFormat::FORMAT_NUMBER,
            'B' => NumberFormat::FORMAT_NUMBER,
            'E' => NumberFormat::FORMAT_DATE_DATETIME
        ];
    }
}
