$(document).ready(function() {
tampil_data_dhmd();
$('#table_dhmd').DataTable();
tampil_data_mk();
$('#table_mk').DataTable();
$('#modal_table_dhmd').DataTable();
$('#modal_table_list_mhs').DataTable();
var max;
// Fungsi menampilkan data dhmd ke tabel
function tampil_data_dhmd() {
var user = $('#username_').html();
$.ajax({
type: 'ajax',
url: window.location.origin + '/dosen/get_dhmd_bydosen/'+user,
async: false,
dataType: 'json',
success: function(data) {
var html = '';
for (var i = 0; i < data.length; i++) {
if (data[i].status == '1') {
stat = 'Tervalidasi';
jenis = 'badge-primary'
}
else if (data[i].status == '0'){
stat = 'Belum Tervalidasi';
jenis = 'badge-danger'
}
var thn = data[i].kdstsemester.slice(0,4);
var thn2 = parseInt(data[i].kdstsemester.slice(0,4)) + 1;
var smster = '';
if(data[i].kdstsemester.slice(4,5) == '1') smster = 'ganjil';
else if(data[i].kdstsemester.slice(4,5) == '2') smster = 'genap';
html += '
';
}
$('#show_data_mk').html(html);
}
});
}
//Fungsi Modal Input BAP
$('#show_data_mk').on('click','.tombol-input-bap',function(){
var id = $(this).attr('data-idmk');
var nmk = $(this).attr('data-nmk');
var kelas = $(this).attr('data-kls');
var jadwal = $(this).attr('data-jdwl');
var sks = $(this).attr('data-sks');
var jam1 = $(this).attr('data-jam1');
var jam2 = $(this).attr('data-jam2');
var idjk = $(this).attr('data-idjk');
$('#modal-input-bap').modal('show');
$('#matkul-bap').val(id+'.'+nmk);
$('#form-kelas-bap').val(kelas);
if (jadwal != 'null') $('#form-jadwal-bap').val(jadwal);
$('#form-sks-bap').val(sks);
if (jam1 != 'null') $('#form-jam1-bap').val(jam1);
if (jam2 != 'null') $('#form-jam2-bap').val(jam2);
$.ajax({
type: 'get',
url: window.location.origin + '/dosen/get_countDhmd_byIDJK',
dataType: 'json',
data: {
idjk: idjk
},
success: function(data) {
if(data > 16){
document.querySelector("#form-pertemuan-bap").style.pointerEvents="none";
$('#tombol-submit').attr('disabled',true);
$('#pertemuan-text').attr('hidden',false);
}else{
$('#tombol-submit').attr('disabled',false);
$('#pertemuan-text').attr('hidden',true);
document.querySelector("#form-pertemuan-bap").style.pointerEvents="none";
}
$('#form-pertemuan-bap').val(data);
}
});
});
$('#jmlabsen').on('input',function(){
max = this.value;
if (max <=0) {
window.alert("Inputan minimal 1");
$('#jmlabsen').val("");
}else if (max >= 100){
window.alert("Inputan maksimal 100");
$('#jmlabsen').val("");
}else {
console.log(max);
$('#hadir').attr('disabled',false);
$('#hadir').val(max);
}
});
$('#hadir').on('input',function(){
var hadir = this.value;
if (hadir <=0) {
window.alert("Inputan minimal 1");
$('#hadir').val("");
}else if (hadir >= max){
window.alert("Inputan maksimal sesuai inputan jumlah mahasiswa");
$('#hadir').val("");
}else {
console.log(max);
}
});
//Fungsi Modal List MHS
$('#show_data_mk').on('click','.tombol-list-mhs',function(){
var nmk = $(this).attr('data-nmk');
var kelas = $(this).attr('data-kls');
var jadwal = $(this).attr('data-jdwl');
var kdmk = $(this).attr('data-idmk');
var idkls = $(this).attr('data-idkls');
$('#modal-list-mhs').modal('show');
$('#view-mhs-matkul').html(nmk);
$('#view-mhs-kelas').html(kelas);
$('#view-mhs-jadwal').html(jadwal);
tampil_data_view_mhs(kdmk,idkls);
});
function tampil_data_view_mhs(kdmk,idkelas) {
var user = $('#username_').html();
var kdstsemester = $('#stsemester_').html();
console.log(kdmk);
console.log(idkelas);
$.ajax({
type: 'ajax',
url: window.location.origin + '/dosen/get_mhs_absenmhs/'+kdmk+'/'+kdstsemester+'/'+idkelas,
async: false,
dataType: 'json',
success: function(data) {
console.log(data);
var html = '';
for (var i = 0; i < data.length; i++) {
html += '
' +
'
' + (i + 1) + '
' +
'
' + data[i].nmmhs + '
' +
'
' + data[i].nim + '
' +
'
';
}
$('#show_data_list_mhs').html(html);
}
});
}
//Fungsi Modal View BAP
$('#show_data_mk').on('click','.tombol-view-bap',function(){
var nmk = $(this).attr('data-nmk');
var kelas = $(this).attr('data-kls');
var jadwal = $(this).attr('data-jdwl');
var kdmk = $(this).attr('data-idmk');
$('#modal-view-bap').modal('show');
$('#view-bap-matkul').html(nmk);
$('#view-bap-kelas').html(kelas);
$('#view-bap-jadwal').html(jadwal);
tampil_data_view_bap(kdmk);
});
function tampil_data_view_bap(kdmk) {
var user = $('#username_').html();
$.ajax({
type: 'ajax',
url: window.location.origin + '/dosen/get_dhmd_bynidukdmk/'+user+'/'+kdmk,
async: false,
dataType: 'json',
success: function(data) {
var html = '';
for (var i = 0; i < data.length; i++) {
if (data[i].status == '1') {
stat = 'Tervalidasi';
jenis = 'badge-primary'
}
else if (data[i].status == '0'){
stat = 'Belum Tervalidasi';
jenis = 'badge-danger'
}
html += '