Skip to content

Commit

Permalink
Merge pull request #112 from ikhsan3adi/localized-laporan-date
Browse files Browse the repository at this point in the history
Format tanggal bahasa indonesia di laporan
  • Loading branch information
ikhsan3adi authored Jul 21, 2024
2 parents 1ccf9db + ad25412 commit b946c74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions app/Controllers/Admin/GenerateLaporan.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function generateLaporanSiswa()
$bulan = $this->request->getVar('tanggalSiswa');

// hari pertama dalam 1 bulan
$begin = new DateTime($bulan);
$begin = new Time($bulan, locale: 'id');
// tanggal terakhir dalam 1 bulan
$end = (new DateTime($begin->format('Y-m-t')))->modify('+1 day');
// interval 1 hari
Expand All @@ -107,7 +107,7 @@ public function generateLaporanSiswa()
$absenByTanggal['lewat'] = $lewat;

array_push($dataAbsen, $absenByTanggal);
array_push($arrayTanggal, $value);
array_push($arrayTanggal, Time::createFromInstance($value, locale: 'id'));
}
}

Expand All @@ -121,7 +121,7 @@ public function generateLaporanSiswa()

$data = [
'tanggal' => $arrayTanggal,
'bulan' => $begin->format('F'),
'bulan' => $begin->toLocalizedString('MMMM'),
'listAbsen' => $dataAbsen,
'listSiswa' => $siswa,
'jumlahSiswa' => [
Expand All @@ -138,7 +138,7 @@ public function generateLaporanSiswa()
$this->response->setHeader('Content-type', 'application/vnd.ms-word');
$this->response->setHeader(
'Content-Disposition',
'attachment;Filename=laporan_absen_' . $kelas['kelas'] . " " . $kelas['jurusan'] . '_' . $begin->format('F-Y') . '.doc'
'attachment;Filename=laporan_absen_' . $kelas['kelas'] . " " . $kelas['jurusan'] . '_' . $begin->toLocalizedString('MMMM-Y') . '.doc'
);

return view('admin/generate-laporan/laporan-siswa', $data);
Expand All @@ -163,7 +163,7 @@ public function generateLaporanGuru()
$bulan = $this->request->getVar('tanggalGuru');

// hari pertama dalam 1 bulan
$begin = new DateTime($bulan);
$begin = new Time($bulan, locale: 'id');
// tanggal terakhir dalam 1 bulan
$end = (new DateTime($begin->format('Y-m-t')))->modify('+1 day');
// interval 1 hari
Expand All @@ -185,7 +185,7 @@ public function generateLaporanGuru()
$absenByTanggal['lewat'] = $lewat;

array_push($dataAbsen, $absenByTanggal);
array_push($arrayTanggal, $value);
array_push($arrayTanggal, Time::createFromInstance($value, locale: 'id'));
}
}

Expand All @@ -199,7 +199,7 @@ public function generateLaporanGuru()

$data = [
'tanggal' => $arrayTanggal,
'bulan' => $begin->format('F'),
'bulan' => $begin->toLocalizedString('MMMM'),
'listAbsen' => $dataAbsen,
'listGuru' => $guru,
'jumlahGuru' => [
Expand All @@ -215,7 +215,7 @@ public function generateLaporanGuru()
$this->response->setHeader('Content-type', 'application/vnd.ms-word');
$this->response->setHeader(
'Content-Disposition',
'attachment;Filename=laporan_absen_guru_' . $begin->format('F-Y') . '.doc'
'attachment;Filename=laporan_absen_guru_' . $begin->toLocalizedString('MMMM-Y') . '.doc'
);

return view('admin/generate-laporan/laporan-guru', $data);
Expand Down
2 changes: 1 addition & 1 deletion app/Views/admin/generate-laporan/laporan-guru.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td></td>
<td></td>
<?php foreach ($tanggal as $value) : ?>
<th align="center"><?= $value->format('D'); ?></th>
<th align="center"><?= $value->toLocalizedString('E'); ?></th>
<?php endforeach; ?>
<td colspan="4" align="center">Total</td>
</thead>
Expand Down
4 changes: 2 additions & 2 deletions app/Views/admin/generate-laporan/laporan-siswa.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<tr>
<td></td>
<td></td>
<td colspan="<?= count($tanggal); ?>"><b>Hari/Tanggal</b></td>
<th colspan="<?= count($tanggal); ?>">Hari/Tanggal</th>
</tr>
<tr>
<td></td>
<td></td>
<?php foreach ($tanggal as $value) : ?>
<td align="center"><b><?= $value->format('D'); ?></b></td>
<td align="center"><b><?= $value->toLocalizedString('E'); ?></b></td>
<?php endforeach; ?>
<td colspan="4" align="center">Total</td>
</tr>
Expand Down

0 comments on commit b946c74

Please sign in to comment.