archive 14/06/2022
Tue Jun 14 2022 09:55:42 GMT+0000 (Coordinated Universal Time)
Saved by @GodFather #javascript
function renderIndexStudentAbsence2(data, total_non_daily) {
html = "";
totalData = 0;
statusPresence = "";
studentGroupOrCounselor = "";
studentGroupName = "";
totalDataGroup = Object.keys(data).length;
if (totalDataGroup === 1) {
studentGroupName = '|' + Object.keys(data).pop();
}
html += `
<div class="table-responsive table-report-period mt-4">
<table class="table">
<thead class="no-cell-hover">
<tr class="text-left">
${totalDataGroup === 1 ? `` : `<th class="text-left" rowspan="2">${isWikrama === "1" ? `Rayon` : `Rombel`}</th>`}
<th class="text-left" rowspan="2">No.</th>
<th class="text-left" rowspan="2">Nama</th>
<th class="text-center" colspan="2">Absensi Hari Ini</th>
${total_non_daily === 0 ? `` : `<th class="text-center" colspan="4">JP yang Tidak Dihadiri</th>`}
</tr>
<tr>
<th class="text-left">Status</th>
<th class="text-left">Keterangan</th>
${total_non_daily === 0 ? `` : `
<th class="text-left">JP ke-</th>
<th class="text-left">Status</th>
<th class="text-left">Pelajaran</th>
<th class="text-left">Guru Mapel</th>
`}
</tr>
</thead>
<tbody class="index-absence-student-loading-destop">`
$.each(data, function(key, value) {
totalJp = 0;
totalNumber = 1;
totalDaily = value.length;
let total = value.reduce((val, element) => {
return val + element.non_daily.length
}, 0);
var rowspanGroup = value.length + total;
// console.log({
// total,
// rowspanGroup,
// totalDaily
// });
$.each(value, function(key, value) {
if (value.non_daily.length !== 0) {
totalJp = value.non_daily.length;
}
})
totalDataStudent = value.length;
if (totalDataStudent > 1) {
totalJpFinal = totalJp * totalDataStudent + totalDataStudent;
} else {
totalJpFinal = totalJp * totalDataStudent;
}
totalRowGroup = 0;
if (totalJpFinal === 0) {
totalRowGroup = totalDataStudent;
} else {
totalRowGroup = totalJpFinal + 1;
}
if (totalDaily === 1) {
totalJpValue = 0;
$.each(value, function(index, value) {
if (value.daily.status === "SICK") {
statusPresence = "Sakit";
} else if (value.daily.status === "UNKNOWN") {
statusPresence = "Alpha";
} else {
statusPresence = "Izin";
}
if (isWikrama === "1") {
studentGroupOrCounselor =
`${value.name} ${value.nis} | ${value.student_group.name}`;
} else {
studentGroupOrCounselor = `${value.name} ${value.nis}`;
}
no = index + 1;
var lengthMonDaily = value.non_daily.length;
var rowspanStudent = lengthMonDaily + 1;
html += `
<tr>
${totalDataGroup === 1 ? `` : `<td class="text-left align-top" width="90px" rowspan="${rowspanGroup}">${key}</td>`}
`
html += `
<td class="text-right align-top" width="60px" rowspan="${totalJp + 1}">${no++}.</td>
<td class="text-left align-top" width="240px" rowspan="${totalJp + 1}">${studentGroupOrCounselor}</td>
<td class="text-left align-top" width="75px" rowspan="${totalJp + 1}">${statusPresence}</td>
<td class="text-left align-top" width="200px" rowspan="${totalJp + 1}">${value.daily.note === null || value.daily.note === "null" ? `<span class="font-w400 font-13 grey-6">Tidak ada keterangan.</span>` : `<span class="font-w400 font-13 black-1">${value.daily.note}</span>`}</td>
`
if (total_non_daily !== 0) {
if (value.non_daily.length === 0) {
html += `
<td class="text-left grey-6" width="60px" colspan="4">Jam pelajaran belum diatur. Hubungi Waka. Kurikulum untuk melakukan pengaturan sehingga guru dapat menginput absen per JP dan laporannya tampil pada halaman ini.</td>
`
} else {
value.non_daily.sort(function(a, b) {
var dateA = parseInt(a.school_hour.order),
dateB = parseInt(b.school_hour.order);
return dateA - dateB;
});
$.each(value.non_daily, function(key, value) {
statusJp = "";
if (value.status === "SICK") {
statusJp = "Sakit";
} else if (value.status === "UNKNOWN") {
statusJp = "Alpha";
} else {
statusJp = "Izin";
}
html += `
<tr>
<td class="text-left" width="60px">${value.school_hour.order}</td>
<td class="text-left cursor-pointer btn-edit-status-absence" width="75px">${statusJp}</td>
<td class="text-left" width="240px">${value.subject_name}</td>
<td class="text-left" width="240px">${value.teacher}</td>
</tr>
`
})
}
}
html += `</tr>`
})
} else {
html += `<tr>
${totalDataGroup === 1 ? `` : `<td class="text-left align-top" width="90px" rowspan="${rowspanGroup}">${key}</td>`}
</tr>`
totalJpValue = 0;
$.each(value, function(index, value) {
if (value.daily.status === "SICK") {
statusPresence = "Sakit";
} else if (value.daily.status === "UNKNOWN") {
statusPresence = "Alpha";
} else {
statusPresence = "Izin";
}
if (isWikrama === "1") {
studentGroupOrCounselor =
`${value.name} ${value.nis} | ${value.student_group.name}`;
} else {
studentGroupOrCounselor = `${value.name} ${value.nis}`;
}
no = index + 1;
var lengthMonDaily = value.non_daily.length;
var rowspanStudent = lengthMonDaily + 1;
if (value.non_daily.length === 0) {
html += `
<tr>
<td class="text-right align-top" width="60px">${no++}.</td>
<td class="text-left align-top" width="240px">${studentGroupOrCounselor}</td>
<td class="text-left align-top" width="75px">${statusPresence}</td>
<td class="text-left align-top" width="200px">${value.daily.note === null || value.daily.note === "null" ? `<span class="font-w400 font-13 grey-6">Tidak ada keterangan.</span>` : `<span class="font-w400 font-13 black-1">${value.daily.note}</span>`}</td>
`
if (total_non_daily !== 0) {
html += `
<td class="text-left grey-6" width="60px" colspan="4">Jam pelajaran belum diatur. Hubungi Waka. Kurikulum untuk melakukan pengaturan sehingga guru dapat menginput absen per JP dan laporannya tampil pada halaman ini.</td>
</tr>
`
}
} else {
html += `
<tr>
<td class="text-right align-top" width="60px" rowspan="${totalJp + 1}">${no++}.</td>
<td class="text-left align-top" width="240px" rowspan="${totalJp + 1}">${studentGroupOrCounselor}</td>
<td class="text-left align-top" width="75px" rowspan="${totalJp + 1}">${statusPresence}</td>
<td class="text-left align-top" width="200px" rowspan="${totalJp + 1}">${value.daily.note === null || value.daily.note === "null" ? `<span class="font-w400 font-13 grey-6">Tidak ada keterangan.</span>` : `<span class="font-w400 font-13 black-1">${value.daily.note}</span>`}</td>
</tr>
`
if (total_non_daily !== 0) {
if (value.non_daily.length === 0) {
html += `
<tr>
<td class="text-left grey-6" width="60px" colspan="4">Jam pelajaran belum diatur. Hubungi Waka. Kurikulum untuk melakukan pengaturan sehingga guru dapat menginput absen per JP dan laporannya tampil pada halaman ini.</td>
</tr>
`
} else {
value.non_daily.sort(function(a, b) {
var dateA = parseInt(a.school_hour.order),
dateB = parseInt(b.school_hour.order);
return dateA - dateB;
});
$.each(value.non_daily, function(key, value) {
statusJp = "";
if (value.status === "SICK") {
statusJp = "Sakit";
} else if (value.status === "UNKNOWN") {
statusJp = "Alpha";
} else {
statusJp = "Izin";
}
html += `
<tr>
<td class="text-left" width="60px">${value.school_hour.order}</td>
<td class="text-left cursor-pointer btn-edit-status-absence" width="75px">${statusJp}</td>
<td class="text-left" width="240px">${value.subject_name}</td>
<td class="text-left" width="240px">${value.teacher}</td>
</tr>
`
})
}
}
}
})
}
})
html += `
</tbody>
</table>
</div>
`
$('#name-student-group').html(studentGroupName);
return html;
}



Comments