<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<table class="table" id="tabel">
<thead>
<tr>
<th rowspan="2" data-b-a-s="thin">
No
</th>
<th rowspan="2" data-b-a-s="thin">
NIK
</th>
<th rowspan="2" data-b-a-s="thin" class="karyawan">
NAMA
</th>
<th rowspan="2" data-b-a-s="thin">
JABATAN
</th>
<th rowspan="2" data-b-a-s="thin">
DEPARTEMEN
</th>
<th rowspan="2" data-b-a-s="thin">
Co.
</th>
@foreach ($periods as $period)
<th>
{{ $period->format('Y-m-d') }}
</th>
@endforeach
<th colspan="13" style="background-color:#c6e0b4;" data-b-a-s="thin" data-fill-color="FFc6e0b4">
<center>Absensi</center>
</th>
<th style="background-color:#c6e0b4;" data-b-a-s="thin" data-fill-color="FFc6e0b4" rowspan="2">
Attendance Ratio
<br>
(Mtd)
</th>
<th rowspan="2">
Total Jam Kerja
</th>
<th rowspan="2">
Total Jam Lembur
</th>
</tr>
<tr>
@php
$colors = [
'H' => 'background-color:#0070c0;color:white;',
'I' => 'background-color:#b4c6e7;',
'S' => 'background-color:#c6efce;',
'C' => 'background-color:#b4c6e7;',
'FB' => 'background-color:#b4c6e7;',
'L' => 'background-color:#b4c6e7;',
'Off' => 'background-color:#ffeb9c;color:#c66c0e;',
'A' => 'background-color:#ffc7ce;color:#a60735;',
'NA' => 'background-color:#ffc7ce;color:#a60735;',
'S1' => 'background-color:#ffc7ce;color:#a60735;',
'I1' => 'background-color:#ffc7ce;color:#a60735;',
'I2' => 'background-color:#ffc7ce;color:#a60735;',
'Jumlah' => 'background-color:#c6e0b4;',
];
$colorsCode = [
'H' => 'FF0070c0',
'I' => 'FFb4c6e7',
'S' => 'FFc6efce',
'C' => 'FFb4c6e7',
'FB' => 'FFb4c6e7',
'L' => 'FFb4c6e7',
'Off' => 'FFffeb9c',
'A' => 'FFffc7ce',
'NA' => 'FFffc7ce',
'S1' => 'FFffc7ce',
'I1' => 'FFffc7ce',
'I2' => 'FFffc7ce',
'Jumlah' => 'FFc6e0b4',
];
$jumlahAbsen = [];
@endphp
@foreach ($periods as $period)
<th data-b-a-s="thin">
{{ $period->format('D') }}
</th>
@endforeach
@foreach ($colors as $key => $style)
@php
$jumlahAbsen[$key] = 0;
@endphp
<th style="{{ $style }}" data-fill-color="{{ $colorsCode[$key] }}" data-b-a-s="thin">
{{ $key }}
</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($karyawans as $no => $karyawan)
@php
$haris = Helper::checkJadwal($karyawan, $periode_awal, $periode_akhir);
@endphp
@foreach ($colors as $key => $style)
@php
$jumlahAbsen[$key] = 0;
@endphp
@endforeach
<tr>
<td data-b-a-s="thin">
{{ $no + 1 }}
</td>
<td data-b-a-s="thin">
{{ $karyawan->nik }}
</td>
<td data-b-a-s="thin" class="karyawan">
{{ $karyawan->nama }}
</td>
<td data-b-a-s="thin">
{{ @$karyawan->jabatan }}
</td>
<td data-b-a-s="thin">
{{ @$karyawan->departemen->nama_departemen }}
</td>
{{-- <td data-b-a-s="thin">{{ $karyawan->perusahaan->nama_perusahaan }}</td> --}}
<td data-b-a-s="thin">
{{($karyawan->perusahaans->count() > 0)?implode(", ",$karyawan->perusahaans->pluck('nama_perusahaan')->toArray()):""}}
</td>
@php
$totalJamKerja = 0;
$totalJamLembur = 0;
@endphp
@foreach ($periods as $key => $period)
@php
// $absensi = \App\Models\Absensi::where('karyawan_id', $karyawan->id)
// ->whereDate('tanggal_absen', $period->format('Y-m-d'))
// ->orderBy('tanggal_absen', 'desc')
// ->orderBy('created_at', 'desc')
// ->first();
$absensi = $karyawan->absensi->where('tanggal_absen', $period->format('Y-m-d'))->first();
$jamLembur = 0;
$jamKerja = 0;
if ($absensi) {
$riwayats = $absensi->riwayat_absensi;
$jadwals = array_reduce(
$riwayats->toArray(),
function ($carry, $item) {
$carry[$item['jadwal_kerja_id']] = $item['jadwal_kerja_id'];
return $carry;
},
[],
);
// $jadwals = $absensi->riwayat_absensi()->select('jadwal_kerja_id')->groupBy('jadwal_kerja_id')->pluck('jadwal_kerja_id');
foreach ($jadwals as $j) {
$ci = $riwayats
->whereIn('status', ['accept', 'due'])
->where('jadwal_kerja_id', $j)
->where('jenis_absen', 'check-in')
->first();
$co = $riwayats
->whereIn('status', ['accept', 'due'])
->where('jadwal_kerja_id', $j)
->where('jenis_absen', 'check-out')
->first();
if ($ci && $co) {
$time1 = strtotime($ci->tanggal_absen . ' ' . $ci->waktu_absen);
$time2 = strtotime($co->tanggal_absen . ' ' . $co->waktu_absen);
$time3 = strtotime($co->tanggal_absen . ' ' . @$haris[$j][$key]->jam_pulang);
$calculated = $time2 - $time1;
if ($calculated <= 0) {
$difference = 0;
} else {
$difference = round($calculated / 3600, 2);
}
$jamKerja += $difference;
if ($time2 > $time3 && $co->lembur) {
$calculated2 = abs($time3 - $time2);
if ($calculated2 <= 0) {
$difference2 = 0;
} else {
$difference2 = round($calculated2 / 3600, 2);
}
$jamLembur += $difference2;
}
}
}
}
$totalJamKerja += $jamKerja;
$totalJamLembur += $jamLembur;
$date = $period->format('Y-m-d');
$status = 'NA';
if ($absensi && $absensi->status_absen != null) {
$status = strtoupper($absensi->status_absen);
} else {
$jadwalKerjas = $karyawan->jadwal_kerja;
foreach ($jadwalKerjas as $jadwalKerja) {
if (isset($haris[$jadwalKerja->id][$key])) {
if ($haris[$jadwalKerja->id][$key]->status_kerja == 'day-off') {
$status = 'Off';
} elseif ($haris[$jadwalKerja->id][$key]->status_kerja == 'cuti') {
$status = 'C';
} elseif ($haris[$jadwalKerja->id][$key]->status_kerja == 'fb') {
$status = 'FB';
} elseif ($haris[$jadwalKerja->id][$key]->status_kerja == 'i1') {
$status = 'I1';
} elseif ($haris[$jadwalKerja->id][$key]->status_kerja == 'i2') {
$status = 'I2';
} elseif ($haris[$jadwalKerja->id][$key]->status_kerja == 'i') {
$status = 'I';
} else {
$status = 'A';
}
}
}
}
if($status == "OFF"){
$status = "Off";
}
$jumlahAbsen[$status] += 1;
@endphp
<td style="{{ $colors[$status] }}; padding:0;" data-fill-color="{{ $colorsCode[$status] }}"
data-b-a-s="thin">
<div style="text-align: center;">
<small>
{{ $status }}
</small>
<br>
@if (isset($absensi) && strtoupper($absensi->status_absen) != "A")
<small style="font-size: 10px;">
@foreach ($absensi->riwayat_absensi as $riwayat_absensi)
<span>
{{ $riwayat_absensi->jenis_absen }} :
{{ date('H:i', strtotime($riwayat_absensi->waktu_absen)) }}
</span>
<br>
@if ($riwayat_absensi->status_waktu == 'on-time')
<span class="badge bg-success" style="color:#92D050;">On Time</span>
@endif
@if ($riwayat_absensi->status_waktu == 'too-early')
<span class="badge bg-warning" style="color:#ebed62;">Too Early</span>
@endif
@if ($riwayat_absensi->status_waktu == 'late')
<span class="badge bg-danger" style="color:#d05050;">Late</span>
@endif
@if ($riwayat_absensi->lembur)
<br>
<span class="badge bg-info text-white">Lembur</span>
@endif
<br>
@endforeach
</small>
@endif
</div>
</td>
@endforeach
@foreach ($jumlahAbsen as $key => $jumlah)
@php
if ($key != 'Jumlah' && isset($jumlahAbsen['Jumlah'])) {
$jumlahAbsen['Jumlah'] += $jumlah;
}
@endphp
@endforeach
@foreach ($jumlahAbsen as $key => $jumlah)
<td data-b-a-s="thin">
{{ $jumlah }}
</td>
@endforeach
<td data-b-a-s="thin">
@php
$ttl = $jumlahAbsen['H'] + $jumlahAbsen['C'] + $jumlahAbsen['L'] + $jumlahAbsen['NA'];
if ($ttl <= 0) {
$mtd = 0;
} else {
$mtd = ($ttl / ($jumlahAbsen['Jumlah'] - $jumlahAbsen['Off'])) * 100;
}
@endphp
{{ round($mtd) }} %
</td>
<td data-b-a-s="thin">
{{ $totalJamKerja }}
</td>
<td data-b-a-s="thin">
{{ $totalJamLembur }}
</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]