Skip to content

Commit

Permalink
feat: Tambah total status kehadiran di laporan
Browse files Browse the repository at this point in the history
Update config
  • Loading branch information
ikhsan3adi committed Jul 14, 2024
1 parent 23e02e5 commit ad1190d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Aplikasi Web Sistem Absensi Sekolah Berbasis QR Code adalah sebuah proyek yang b
> - Untuk mengubah identitas nama sekolah, buka file konfigurasi `app/Config/AbsensiSekolah.php` dan ubah pada:
>
> ```php
> public string $namaSekolah = 'SMK 1 Indonesia';
> const SCHOOL_NAME = 'SMK 1 Indonesia';
> ```
>
> - Ganti/replace logo sekolah di `public/assets/img/logo_sekolah.jpg`.
Expand Down
2 changes: 1 addition & 1 deletion app/Config/AbsensiSekolah.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class AbsensiSekolah extends BaseConfig
*
* Pengaturan untuk nama sekolah
*/
public string $namaSekolah = 'SMK 1 Indonesia';
const SCHOOL_NAME = 'SMK 1 Indonesia';
}
17 changes: 12 additions & 5 deletions app/Controllers/Admin/GenerateLaporan.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct()
$this->presensiSiswaModel = new PresensiSiswaModel();
$this->presensiGuruModel = new PresensiGuruModel();

$this->namaSekolah = (new ConfigAbsensiSekolah)->namaSekolah;
$this->namaSekolah = ConfigAbsensiSekolah::SCHOOL_NAME;
}

public function index()
Expand Down Expand Up @@ -76,7 +76,9 @@ public function generateLaporanSiswa()
return redirect()->to('/admin/laporan');
}

$kelas = $this->kelasModel->where(['id_kelas' => $idKelas])->join('tb_jurusan', 'tb_kelas.id_jurusan = tb_jurusan.id', 'left')->first();
$kelas = $this->kelasModel->where(['id_kelas' => $idKelas])
->join('tb_jurusan', 'tb_kelas.id_jurusan = tb_jurusan.id', 'left')
->first();

$bulan = $this->request->getVar('tanggalSiswa');

Expand Down Expand Up @@ -129,10 +131,12 @@ public function generateLaporanSiswa()
'namaSekolah' => $this->namaSekolah
];


if ($type == 'doc') {
$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');
$this->response->setHeader(
'Content-Disposition',
'attachment;Filename=laporan_absen_' . $kelas['kelas'] . " " . $kelas['jurusan'] . '_' . $begin->format('F-Y') . '.doc'
);

return view('admin/generate-laporan/laporan-siswa', $data);
}
Expand Down Expand Up @@ -205,7 +209,10 @@ public function generateLaporanGuru()

if ($type == 'doc') {
$this->response->setHeader('Content-type', 'application/vnd.ms-word');
$this->response->setHeader('Content-Disposition', 'attachment;Filename=laporan_absen_guru_' . $begin->format('F-Y') . '.doc');
$this->response->setHeader(
'Content-Disposition',
'attachment;Filename=laporan_absen_guru_' . $begin->format('F-Y') . '.doc'
);

return view('admin/generate-laporan/laporan-guru', $data);
}
Expand Down
40 changes: 38 additions & 2 deletions app/Views/admin/generate-laporan/laporan-guru.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,60 @@
<?php foreach ($tanggal as $value) : ?>
<th align="center"><?= $value->format('D'); ?></th>
<?php endforeach; ?>
<td colspan="4" align="center">Total</td>
</thead>
<tr>
<th id="rowSpan3" align="center">No</th>
<th id="rowSpan3" width="1000px">Nama</th>
<th align="center">No</th>
<th width="1000px">Nama</th>
<?php foreach ($tanggal as $value) : ?>
<th align="center"><?= $value->format('d'); ?></th>
<?php endforeach; ?>
<th align="center" style="background-color:lightgreen;">H</th>
<th align="center" style="background-color:yellow;">S</th>
<th align="center" style="background-color:yellow;">I</th>
<th align="center" style="background-color:red;">A</th>
</tr>

<?php $i = 0; ?>

<?php foreach ($listGuru as $guru) : ?>
<?php
$jumlahHadir = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 1;
}));
$jumlahSakit = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 2;
}));
$jumlahIzin = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 3;
}));
$jumlahTidakHadir = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat']) return false;
if (is_null($a[$i]['id_kehadiran']) || $a[$i]['id_kehadiran'] == 4) return true;
return false;
}));
?>
<tr>
<td align="center"><?= $i + 1; ?></td>
<td><?= $guru['nama_guru']; ?></td>
<?php foreach ($listAbsen as $absen) : ?>
<?= kehadiran($absen[$i]['id_kehadiran'] ?? ($absen['lewat'] ? 5 : 4)); ?>
<?php endforeach; ?>
<td align="center">
<?= $jumlahHadir != 0 ? $jumlahHadir : '-'; ?>
</td>
<td align="center">
<?= $jumlahSakit != 0 ? $jumlahSakit : '-'; ?>
</td>
<td align="center">
<?= $jumlahIzin != 0 ? $jumlahIzin : '-'; ?>
</td>
<td align="center">
<?= $jumlahTidakHadir != 0 ? $jumlahTidakHadir : '-'; ?>
</td>
</tr>
<?php
$i++;
Expand Down
40 changes: 38 additions & 2 deletions app/Views/admin/generate-laporan/laporan-siswa.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,60 @@
<?php foreach ($tanggal as $value) : ?>
<td align="center"><b><?= $value->format('D'); ?></b></td>
<?php endforeach; ?>
<td colspan="4" align="center">Total</td>
</tr>
<tr>
<th id="rowSpan3" align="center">No</th>
<th id="rowSpan3" width="1000px">Nama</th>
<th align="center">No</th>
<th width="1000px">Nama</th>
<?php foreach ($tanggal as $value) : ?>
<th align="center"><?= $value->format('d'); ?></th>
<?php endforeach; ?>
<th align="center" style="background-color:lightgreen;">H</th>
<th align="center" style="background-color:yellow;">S</th>
<th align="center" style="background-color:yellow;">I</th>
<th align="center" style="background-color:red;">A</th>
</tr>

<?php $i = 0; ?>

<?php foreach ($listSiswa as $siswa) : ?>
<?php
$jumlahHadir = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 1;
}));
$jumlahSakit = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 2;
}));
$jumlahIzin = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat'] || is_null($a[$i]['id_kehadiran'])) return false;
return $a[$i]['id_kehadiran'] == 3;
}));
$jumlahTidakHadir = count(array_filter($listAbsen, function ($a) use ($i) {
if ($a['lewat']) return false;
if (is_null($a[$i]['id_kehadiran']) || $a[$i]['id_kehadiran'] == 4) return true;
return false;
}));
?>
<tr>
<td align="center"><?= $i + 1; ?></td>
<td><?= $siswa['nama_siswa']; ?></td>
<?php foreach ($listAbsen as $absen) : ?>
<?= kehadiran($absen[$i]['id_kehadiran'] ?? ($absen['lewat'] ? 5 : 4)); ?>
<?php endforeach; ?>
<td align="center">
<?= $jumlahHadir != 0 ? $jumlahHadir : '-'; ?>
</td>
<td align="center">
<?= $jumlahSakit != 0 ? $jumlahSakit : '-'; ?>
</td>
<td align="center">
<?= $jumlahIzin != 0 ? $jumlahIzin : '-'; ?>
</td>
<td align="center">
<?= $jumlahTidakHadir != 0 ? $jumlahTidakHadir : '-'; ?>
</td>
</tr>
<?php
$i++;
Expand Down

0 comments on commit ad1190d

Please sign in to comment.