108 lines
2.9 KiB
PHP
108 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Exports\Concerns\ForcesTextColumns;
|
|
use App\Http\Controllers\Perhitungan\Remunerasi\KeseluruhanController;
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
|
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
|
|
class KeseluruhanExport implements FromArray, ShouldAutoSize, WithColumnFormatting, WithCustomValueBinder, WithHeadings, WithMapping, WithStyles
|
|
{
|
|
use ForcesTextColumns;
|
|
|
|
protected function nipColumns(): array
|
|
{
|
|
return ['C'];
|
|
}
|
|
|
|
private array $rows;
|
|
|
|
public function __construct(int $tahun, ?string $jenisPegawai, mixed $unit)
|
|
{
|
|
$this->rows = app(KeseluruhanController::class)->getRekapRows($tahun, $jenisPegawai, $unit);
|
|
}
|
|
|
|
public function array(): array
|
|
{
|
|
return $this->rows;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'No.',
|
|
'Nama',
|
|
'NIP',
|
|
'Jenis Pegawai',
|
|
'Unit Kerja',
|
|
'Jumlah P1',
|
|
'Jumlah P2',
|
|
'Jumlah THR',
|
|
'Jumlah R13',
|
|
'Jumlah Publikasi',
|
|
'Total',
|
|
];
|
|
}
|
|
|
|
public function map($row): array
|
|
{
|
|
static $no = 0;
|
|
$no++;
|
|
|
|
return [
|
|
$no,
|
|
$row['nama'],
|
|
$row['nip'],
|
|
$row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'),
|
|
$row['nama_unit'],
|
|
$row['jumlah_p1'],
|
|
$row['jumlah_p2'],
|
|
$row['jumlah_thr'],
|
|
$row['jumlah_r13'],
|
|
$row['jumlah_publikasi'],
|
|
$row['total'],
|
|
];
|
|
}
|
|
|
|
public function columnFormats(): array
|
|
{
|
|
$accountingFormat = '_("Rp"\ * #,##0.00_);_("Rp"\ * \-#,##0.00_);_("Rp"\ * "-"??_);_(@_)';
|
|
|
|
return [
|
|
'C' => '@',
|
|
'F' => $accountingFormat,
|
|
'G' => $accountingFormat,
|
|
'H' => $accountingFormat,
|
|
'I' => $accountingFormat,
|
|
'J' => $accountingFormat,
|
|
'K' => $accountingFormat,
|
|
];
|
|
}
|
|
|
|
public function styles(Worksheet $sheet)
|
|
{
|
|
return [
|
|
1 => [
|
|
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
|
'fill' => [
|
|
'fillType' => Fill::FILL_SOLID,
|
|
'startColor' => ['rgb' => '4472C4'],
|
|
],
|
|
'alignment' => [
|
|
'horizontal' => Alignment::HORIZONTAL_CENTER,
|
|
'vertical' => Alignment::VERTICAL_CENTER,
|
|
],
|
|
],
|
|
];
|
|
}
|
|
}
|