<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<style>
 /* custom radio */
.radio {
    display: block;
    position: relative;
    padding-left: 30px;
    margin-top: -5px;
    cursor: pointer;
    font-size: 14px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
 
/* hide the browser's default radio button */
.radio input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}
 
/* create custom radio */
.radio .check {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 50%;
}
 
/* on mouse-over, add border color */
.radio:hover input ~ .check {
    border: 2px solid #2489C5;
}
 
/* add background color when the radio is checked */
.radio input:checked ~ .check {
    background-color: #2489C5;
    border:none;
}
 
/* create the radio and hide when not checked */
.radio .check:after {
    content: "";
    position: absolute;
    display: none;
}
 
/* show the radio when checked */
.radio input:checked ~ .check:after {
    display: block;
}
 
/* radio style */
.radio .check:after {
    top: 9px;
    left: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}
</style>
<?php if ($ac == '') { ?>
	<div class='row'>
		<div class='col-md-8'>
		<div class="card">
             <div class="card-header">
					<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel</h5>
                </div>				
                   <div class='card-body'>
                <div class="table-responsive">
                     <table style="font-size: 11px" id='example1'  class='table  table-hover'>
                        <thead>						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Mapel</th>
								<th width="15%">Kelas</th>
								<th></th>
                                
                            </tr>						
                        </thead>
                        <tbody>
						
                            <?php
							$hari=date('D');
							$tg=date('Y-m-d');
							$no = 0;
                              $query = mysqli_query($koneksi, "select * from jadwal_mapel WHERE guru='$_SESSION[id_user]' AND hari='$hari'");                            
                                while ($jadwal = mysqli_fetch_array($query)) {
							      $tanggal=date('d-m-Y',strtotime($jadwal['tanggal']));
							       $jumlah = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absen_mapel WHERE tanggal='$tg' AND idjadwal='$jadwal[id_jadwal]' "));							
                                      $no++;                         
                                        ?>
                                <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $jadwal['mapel'] ?></td>
									 <td><?= $jadwal['kelas'] ?></td>
									 
									  <td >
									   <?php if($jadwal['hari']==$hari AND $jumlah==0){ ?>
									   <button type="button" class="btn btn-sm btn-default" disabled><i class="fas fa-lock" ></i></button>
									  <button type="button" class="btn btn-sm btn-default" disabled><i class="fas fa-lock" ></i></button>
									 
									 <?php if($menu['absen_siswa']==0): ?>
									<a href="?pg=inputabsen&ac=input&jadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-sm btn btn-outline-primary" data-bs-placement="top" data-bs-toggle="tooltip" title="Input Absensi"><i class="fas fa-plus-circle"></i></a>
									<?php elseif($menu['absen_siswa']==1): ?>
									 <button data-id="<?= $jadwal['id_jadwal'] ?>" class="hapus btn-sm btn btn-outline-danger" data-bs-placement="top" data-bs-toggle="tooltip" title="Tarik Absen RFID"><i class="fas fa-sync"></i></button>
									 
									<?php else: ?>
										 <button type="button" class="btn btn-sm btn-default" disabled>
                                          <i class="fas fa-lock" ></i>
                                        </button>
										
										<?php endif; ?>
									
									 <?php }else{ ?>
									  <button class='btn btn-sm btn-outline-danger' onclick="frames['frameresult<?= $jadwal['id_jadwal'] ?>'].print()" data-bs-placement="top" data-bs-toggle="tooltip" title="Print"><i class='fa fa-print'></i></button>				
									  <iframe name='frameresult<?= $jadwal['id_jadwal'] ?>' src="sandik_absen/cetakabsen.php?idjadwal=<?= $jadwal['id_jadwal'] ?>" style='border:none;width:1px;height:1px;'></iframe>
									  <a href="sandik_absen/prosesabsenmapel.php?idjadwal=<?= $jadwal['id_jadwal'] ?>" class='btn btn-sm btn-outline-success' data-bs-placement="top" data-bs-toggle="tooltip" title="Download"><i class='fa fa-download'></i></a>				
                 					<button type="button" class="btn btn-sm btn-default" disabled><i class="fas fa-lock" ></i></button>
									 <?php if($menu['absen_siswa']==1): ?>
									 <a href="?pg=inputabsen&ac=tidakhadir&idjadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-sm btn btn-outline-primary" data-bs-placement="top" data-bs-toggle="tooltip" title="Input Tidak Hadir"><i class="fas fa-plus-circle"></i></a>
									 <?php endif; ?>
									     <?php } ?>
									   </td>
									     
											</tr>
								            <?php } ?>
															</tbody>
														</table>
														
													</div>
												</div>
						                        </div>
						                    </div>
						<script>
      $('#example1').on('click', '.hapus', function() {
        var id = $(this).data('id');
        console.log(id);
        swal({
            title: 'Are you sure?',
            text: 'Akan Tarik Data Absen!',
			type:'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Ya, Tarik'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: 'sandik_ptm/ambilrfid.php',
                    method: "POST",
                    data: 'id=' + id,
                    success: function(data) {
                       iziToast.info(
						{
							title: 'Sukses!',
							message: 'Absen RFID berhasil ditarik',
							titleColor: '#FFFF00',
							messageColor: '#fff',
							backgroundColor: 'rgba(0, 0, 0, 0.5)',
							 progressBarColor: '#FFFF00',
						  position: 'topRight'					  
						});
                        setTimeout(function() {
                            window.location.reload();
                        }, 2000);
                    }
                });
            }
            return false;
        })
		});
    </script>	
 
		 
		   <div class='col-md-4'>
		   <div class="card">
             <div class="card-header">
                    <h5 class='box-title'>Data Absensi</h5>
				</div>
            <div class='card-body'>
              <div class="row">
                            <?php
							$hari=date('D');
							$tg=date('Y-m-d');
                              $query = mysqli_query($koneksi, "select * from jadwal_mapel WHERE guru='$_SESSION[id_user]' AND hari='$hari'");                            
                                while ($jadwal = mysqli_fetch_array($query)) {
                              $jumlah = mysqli_fetch_array(mysqli_query($koneksi, "select SUM(IF(ket='H',1,0)) AS hadir,SUM(IF(ket='A',1,0)) AS alpha,SUM(IF(ket='I',1,0)) AS izin, 
							  SUM(IF(ket='S',1,0))AS sakit,idjadwal,tanggal  from absen_mapel WHERE idjadwal='$jadwal[id_jadwal]' AND tanggal='$tg'"));                            
                                                     
                                        ?>
        
       
						 <h5 class='card-title text-center'><?= $jadwal['kode'] ?> <?= $jadwal['kelas'] ?></h5>
						 <p>
			
								  <div class="col-md-6">
								 <div class="card widget widget-info-inline">
                                    <div class="card-header">
                                        <h5 class="card-title"><?=$jumlah['hadir'] ?><span class="badge badge-info badge-style-light">Hadir</span></h5>
								   </div>
                                    <div class="card-body">
                                        <div class="widget-info-container">
                                             <span class="widget-stats-title">
											  <a href="?pg=inputabsen&ac=hadir&jadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-link"> Edit <i class="fa fa-arrow-circle-right"></i></a>
											 </span>
                                         </div>   
                                    </div>
									 </div>
                                         </div>
								  <div class="col-md-6">
								 <div class="card widget widget-info-inline">
                                    <div class="card-header">
                                        <h5 class="card-title"><?=$jumlah['alpha'] ?><span class="badge badge-danger badge-style-light">Alpha</span></h5>
								   </div>
                                    <div class="card-body">
                                        <div class="widget-info-container">
                                             <span class="widget-stats-title">
											  <a href="?pg=inputabsen&ac=alpha&jadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-link"> Edit <i class="fa fa-arrow-circle-right"></i></a>
											 </span>
                                         </div>   
                                    </div>
									 </div>
                                         </div>
								 <div class="col-md-6">
					           <div class="card widget widget-info-inline">
                                    <div class="card-header">
                                        <h5 class="card-title"><?=$jumlah['sakit'] ?><span class="badge badge-warning badge-style-light">Sakit</span></h5>
								   </div>
                                    <div class="card-body">
                                        <div class="widget-info-container">
                                             <span class="widget-stats-title">
											  <a href="?pg=inputabsen&ac=sakit&jadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-link"> Edit <i class="fa fa-arrow-circle-right"></i></a>
											 </span>
                                         </div>   
                                    </div>
									 </div>
                                         </div>		 
                              <div class="col-md-6">
					           <div class="card widget widget-info-inline">
                                    <div class="card-header">
                                        <h5 class="card-title"><?=$jumlah['izin'] ?><span class="badge badge-dark badge-style-light">Izin</span></h5>
								   </div>
                                    <div class="card-body">
                                        <div class="widget-info-container">
                                             <span class="widget-stats-title">
											  <a href="?pg=inputabsen&ac=izin&jadwal=<?= $jadwal['id_jadwal'] ?>" class="btn-link"> Edit <i class="fa fa-arrow-circle-right"></i></a>
											 </span>
                                         </div>   
                                    </div>
									 </div>
                                         </div>		
                           
		<?php } ?>		
		 
<?php } elseif ($ac == 'input') { ?>
<?php $jadwal = fetch($koneksi,'jadwal_mapel',['id_jadwal'=>$_GET['jadwal']]); ?>
<?php if($menu['absen_siswa']==0){ ?>
 <div class='row'>
 <div class='col-md-12'>
  <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel <?= $jadwal['kode'] ?></h5>
                </div>
				
            <div class='card-body'>
			<form id="formabsen" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th width="10%" class="hidden-xs">NIS</th>
								<th width="10%" class="hidden-xs">NISN</th>								
								<th width="10%"class="hidden-xs">Kelas</th>
								<th>Nama</th>
								<th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								 <th width="5%">Hadir</th>
                            </tr>
						
                        </thead>
						
                        <tbody>
						 
                            <?php
							$tanggal=date('Y-m-d');
							$no = 0;
                            $query = mysqli_query($koneksi, "select * FROM siswa WHERE id_kelas='$jadwal[kelas]'");                            
							while ($siswa = mysqli_fetch_array($query)) {							
                                $no++;                             
                            ?>
							
                                <tr>
                                    <td><?= $no; ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['jadwal'] ?>" >
									<input type="hidden" name="blth[]" value="<?= date('m') ?>" >
									<input type="hidden" name="tahun[]" value="<?= date('Y') ?>" >
									<input type="hidden" name="kelas[]" value="<?= $siswa['id_kelas'] ?>" >
									</td>
                                    <td><?= $siswa['nis'] ?></td>
									 <td><?= $siswa['nisn'] ?></td>
									 <td><?= $siswa['id_kelas'] ?></td>
									<td><?= $siswa['nama'] ?></td>
									
									  <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A"><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S"><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I"><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="H" checked /><b>H</b>
									 <span class="check"></span>
									 </label>
								</td>			
											 
								</tr>
								<?php } ?>
								</tbody>
									</table>
									
								<div class='right '>
		                   <button type='submit'  class='btn btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
							 
								 </form>	

								</div>
									</div>
									</div>
											
									</div>
<script>
$('#formabsen').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_ptm/m_absen/crud_absen.php?pg=tambah_manual',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>		

<?php } ?>
<?php } elseif ($ac == 'hadir') { ?>
 <div class='row'>
 <div class='col-md-12'>
   <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel <?= $jadwal['kode'] ?></h5>
                </div>
		
            <div class='card-body'>
			<form id="formhadir" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th width="10%" class="hidden-xs">NIS</th>
								<th width="10%" class="hidden-xs">NISN</th>								
								<th width="10%"class="hidden-xs">Kelas</th>
								<th>Nama</th>
								<th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								 <th width="5%">Hadir</th>
                            </tr>
						
                        </thead>
						
                        <tbody>
						 
                            <?php
							$tanggal=date('Y-m-d');
							$no = 0;
                            $query = mysqli_query($koneksi, "select * FROM absen_mapel 
							JOIN siswa ON siswa.id_siswa=absen_mapel.idsiswa 
							WHERE absen_mapel.idjadwal='$_GET[jadwal]' AND absen_mapel.ket='H' AND absen_mapel.tanggal='$tanggal'");                            
							while ($siswa = mysqli_fetch_array($query)) {							
                                $no++;                             
                            ?>
							
                                <tr>
                                    <td><?= $no; ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['jadwal'] ?>" >
									</td>
                                    <td class="hidden-xs"><?= $siswa['nis'] ?></td>
									 <td class="hidden-xs"><?= $siswa['nisn'] ?></td>
									 <td class="hidden-xs"><?= $siswa['id_kelas'] ?></td>
									<td><?= $siswa['nama'] ?></td>
									
									  <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A"><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S"><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I"><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="H" checked /><b>H</b>
									 <span class="check"></span>
									 </label>
								</td>			
											 
								</tr>
								<?php } ?>
								</tbody>
									</table>
									
								<div class='right '>
		                   <button type='submit'  class='btn  btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
							
								 </form>	

								</div>
									</div>
									</div>
											
									</div>	
                 <script>
$('#formhadir').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_ptm/m_absen/crud_absen.php?pg=ubah_hadir',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>		

<?php } elseif ($ac == 'alpha') { ?>
 <div class='row'>
 <div class='col-md-12'>
   <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel <?= $jadwal['kode'] ?></h5>
                </div>
			
            <div class='card-body'>			
			<form id="formalpha" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th width="10%" class="hidden-xs">NIS</th>
								<th width="10%" class="hidden-xs">NISN</th>								
								<th width="10%"class="hidden-xs">Kelas</th>
								<th>Nama</th>
								<th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								 <th width="5%">Hadir</th>
                            </tr>
						
                        </thead>
						
                        <tbody>
						 
                            <?php
							$tanggal=date('Y-m-d');
							$no = 0;
                            $query = mysqli_query($koneksi, "select * FROM absen_mapel 
							JOIN siswa ON siswa.id_siswa=absen_mapel.idsiswa 
							WHERE absen_mapel.idjadwal='$_GET[jadwal]' AND absen_mapel.ket='A' AND absen_mapel.tanggal='$tanggal'");                            
							while ($siswa = mysqli_fetch_array($query)) {							
                                $no++;                             
                            ?>
							
                                <tr>
                                    <td><?= $no; ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['jadwal'] ?>" >
									</td>
                                    <td class="hidden-xs"><?= $siswa['nis'] ?></td>
									 <td class="hidden-xs"><?= $siswa['nisn'] ?></td>
									 <td class="hidden-xs"><?= $siswa['id_kelas'] ?></td>
									<td><?= $siswa['nama'] ?></td>
									
									  <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A" checked /><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S"><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I"><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="H" /><b>H</b>
									 <span class="check"></span>
									 </label>
								</td>			
											 
								</tr>
								<?php } ?>
								</tbody>
									</table>
									<div class='right '>
		                   <button type='submit'  class='btn  btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
								 </form>	

								</div>
									</div>
									</div>
											
									</div>	
                 <script>
$('#formalpha').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_ptm/m_absen/crud_absen.php?pg=ubah_hadir',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>		
               
<?php } elseif ($ac == 'sakit') { ?>
 <div class='row'>
 <div class='col-md-12'>
  <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel <?= $jadwal['kode'] ?></h5>
                </div>
			
            <div class='card-body'>
			<form id="formsakit" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th width="10%" class="hidden-xs">NIS</th>
								<th width="10%" class="hidden-xs">NISN</th>								
								<th width="10%"class="hidden-xs">Kelas</th>
								<th>Nama</th>
								<th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								 <th width="5%">Hadir</th>
                            </tr>
						
                        </thead>
						
                        <tbody>
						 
                            <?php
							$tanggal=date('Y-m-d');
							$no = 0;
                            $query = mysqli_query($koneksi, "select * FROM absen_mapel 
							JOIN siswa ON siswa.id_siswa=absen_mapel.idsiswa 
							WHERE absen_mapel.idjadwal='$_GET[jadwal]' AND absen_mapel.ket='S' AND absen_mapel.tanggal='$tanggal'");                            
							while ($siswa = mysqli_fetch_array($query)) {							
                                $no++;                             
                            ?>
							
                                <tr>
                                    <td><?= $no; ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['jadwal'] ?>" >
									</td>
                                    <td class="hidden-xs"><?= $siswa['nis'] ?></td>
									 <td class="hidden-xs"><?= $siswa['nisn'] ?></td>
									 <td class="hidden-xs"><?= $siswa['id_kelas'] ?></td>
									<td><?= $siswa['nama'] ?></td>
									
									  <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A" ><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S" checked /><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I"><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="H" /><b>H</b>
									 <span class="check"></span>
									 </label>
								</td>			
											 
								</tr>
								<?php } ?>
								</tbody>
									</table>
									<div class='right '>
		                   <button type='submit'  class='btn  btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
								 </form>	

								</div>
									</div>
									</div>
											
									</div>	
                 <script>
$('#formsakit').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_ptm/m_absen/crud_absen.php?pg=ubah_hadir',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>		

<?php } elseif ($ac == 'izin') { ?>
 <div class='row'>
 <div class='col-md-12'>
   <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel <?= $jadwal['kode'] ?></h5>
                </div>
			
            <div class='card-body'>
			<form id="formizin" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th width="10%" class="hidden-xs">NIS</th>
								<th width="10%" class="hidden-xs">NISN</th>								
								<th width="10%"class="hidden-xs">Kelas</th>
								<th>Nama</th>
								<th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								 <th width="5%">Hadir</th>
                            </tr>
						
                        </thead>
						
                        <tbody>
						 
                            <?php
							$tanggal=date('Y-m-d');
							$no = 0;
                            $query = mysqli_query($koneksi, "select * FROM absen_mapel 
							JOIN siswa ON siswa.id_siswa=absen_mapel.idsiswa 
							WHERE absen_mapel.idjadwal='$_GET[jadwal]' AND absen_mapel.ket='I' AND absen_mapel.tanggal='$tanggal'");                            
							while ($siswa = mysqli_fetch_array($query)) {							
                                $no++;                             
                            ?>
							
                                <tr>
                                    <td><?= $no; ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['jadwal'] ?>" >
									</td>
                                    <td class="hidden-xs"><?= $siswa['nis'] ?></td>
									 <td class="hidden-xs"><?= $siswa['nisn'] ?></td>
									 <td class="hidden-xs"><?= $siswa['id_kelas'] ?></td>
									<td><?= $siswa['nama'] ?></td>
									
									  <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A" ><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S" ><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I" checked /><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="H" /><b>H</b>
									 <span class="check"></span>
									 </label>
								</td>			
											 
								</tr>
								<?php } ?>
								</tbody>
									</table>
									<div class='right '>
		                   <button type='submit'  class='btn  btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
								 </form>	

								</div>
									</div>
									</div>
											
									</div>	
                 <script>
$('#formizin').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
        url: 'sandik_ptm/m_absen/crud_absen.php?pg=ubah_hadir',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>		

			

<?php } elseif ($ac == 'tidakhadir') { ?>

 <div class='row'>
 <div class='col-md-12'>
   <div class="card">
    <div class="card-header">
		<h5 class='card-title'><i class="fas fa-graduation-cap"></i> Absensi Mapel</h5>
                </div>
			
            <div class='card-body'>
			<form id="formtujuan" action=''>
		  <div class="table-responsive">
		  
                     <table style="font-size: 11px" id='mapel' class='table'>
                        <thead>
						
                            <tr>
                                <th width='5px'>
                                    #
                                </th>
                                <th>Nama</th>
								<th width="15%">Kelas</th>
                              <th width="5%">Alpha</th>
                               <th width="5%">Sakit</th>
                                 <th width="5%">Izin</th>
								
                            </tr>
						
                        </thead>
                        <tbody>
						 
                            <?php
							$kelas = fetch($koneksi,'jadwal_mapel',['id_jadwal'=>$_GET['idjadwal']]);
							$tanggal=date('Y-m-d');
                            $query = mysqli_query($koneksi, "select id_siswa,nama FROM siswa
                            WHERE id_kelas='$kelas[kelas]' AND NOT EXISTS 
							(SELECT * 
							 FROM absen_mapel 
							 WHERE siswa.id_siswa = absen_mapel.idsiswa AND absen_mapel.idjadwal='$_GET[idjadwal]'  AND  absen_mapel.tanggal='$tanggal')");
                            $no = 0; ?>
                           <?php while ($siswa = mysqli_fetch_array($query)) {
								
                                $no++;
                              
                            ?>
							
                                <tr>
                                    <td><?= $no; ?></td>
                                    <td><?= $siswa['nama'] ?>
									<input type="hidden" name="ids[]" value="<?= $siswa['id_siswa'] ?>" >
									<input type="hidden" name="idj[]" value="<?= $_GET['idjadwal'] ?>" >
									<input type="hidden" name="blth[]" value="<?= date('m') ?>" >
									<input type="hidden" name="tahun[]" value="<?= date('Y') ?>" >
									<input type="hidden" name="kelas[]" value="<?= $kelas['kelas'] ?>" >
									</td>
									 <td><?= $kelas['kelas'] ?></td>
                                    
                                     <td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="A" checked ><b>A</b>
									 <span class="check"></span>
									 </label>
								</td>
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="S"  /><b>S</b>
									 <span class="check"></span>
									 </label>
								</td>			 
								<td align="center">
                                     <label class="radio"><input type="radio" name="edis[]<?= $siswa['id_siswa'] ?>" value="I"><b>I</b>
									 <span class="check"></span>
									 </label>
								</td>								
								</tr>
								<?php } ?>
							</tbody>
							</table>
						<div class='right '>
		                   <button type='submit'  class='btn  btn-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                            </div>
								</form>	
                                  </div>
										</div>
											</div>										
									</div>
									<script>
$('#formtujuan').submit(function(e)
{
    e.preventDefault();
    var data = new FormData(this);
    
    $.ajax(
    {
        type: 'POST',
       url: 'sandik_ptm/m_absen/crud_absen.php?pg=tambah_manual',
        enctype: 'multipart/form-data',
        data: data,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data)
        {
            
            iziToast.info(
            {
                title: 'Sukses!',
                message: 'Absen berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
            });
            setTimeout(function()
            {
                window.location.replace('?pg=inputabsen');
            }, 2000);
            
        }
    });
    return false;
});
</script>			

			
									<?php } ?>

									
 							
				
           	