<div class='row'>
        <div class='col-md-5'>
           <div class="card">
             <div class="card-header">	
                  <h5 class='card-title'><i class="fas fa-calendar"></i> Absensi Pegawai</h5></div>    
			 
						<div class='card-body'>
									<form id="formabsen" action='' method='post'>
									<div class='box-body'>
									  <div class='form-group'>						                
                                        <label class="bold">Tanggal</label>
									   <input type="text"  name="tanggal" class="form-control" value="<?= date('Y-m-d') ?>" readonly >
                                                   
                                                </div>
												 <div class='form-group'>
                                                   <label class="bold">Nama Pegawai</label>
												   <select class="form-select" name="idpeg" required>
													 <option value="" selected="">Pilih Pegawai</option>
												<?php $q = mysqli_query($koneksi, "select * from users WHERE level<>'admin' ");
												while ($u = mysqli_fetch_array($q)) { ?>
													<option value="<?= $u['id_user'] ?>"><?= $u['nama'] ?></option>
												<?php } ?>
												</select>    
                                                </div>
												<div class='form-group-sm'>
                                                   <label class="bold">Kehadiran</label>
												   <select class="form-select" name="ket" required>
													 <option value="" selected="">Pilih Absen</option>
													  <option value="H">Hadir</option>
												      <option value="S">Sakit</option>
													   <option value="I">Izin</option>
													      <option value="A">Tanpa Keterangan</option>
												</select>    
                                                </div>
												</div>
                                               <p>
                                            <div class='right'>
                                                <button type='submit' name='submit' class='btn  btn-outline-primary'><i class='fa fa-check-circle'></i> Simpan</button>
                                            
                                        </div>
                                    </form>
                               </div>
                        </div>
                    </div>
	        <script>
  $('#formabsen').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'sandik_ptm/m_absen/crud_absen.php?pg=guru_manual',
            data: $(this).serialize(),
            beforeSend: function() {
                $('form button').on("click", function(e) {
                    e.preventDefault();
                });
            },
            success: function(data) {
                console.log(data);
                if (data == 'OK') {
                    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.reload();
                    }, 2000);
                } else {
                 iziToast.info(
            {
                title: 'GAGAL!',
                message: 'Absen sudah tercatat',
				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-7'>
            <div class="card">
             <div class="card-header">	
                    <h5 class='card-title'><i class="fas fa-globe"></i>Absen Pegawai</h5>
                   
                </div>
                <div class='card-body'>
                    <div class='table-responsive'>
                        <table style="font-size: 12px" id='example1' class='table'>
                            <thead>
                                <tr>
                                    <th style="text-align: center">No</th>
									 <th style="text-align: center" >Tanggal</th>
                                    <th style="text-align: center">Nama</th>  
                                     <th style="text-align: center" >Jam Absen</th> 
										<?php if($menu['absen_guru']<>0){ ?>
										<th style="text-align: center" width="5%">Pulang</th> 
										<?php } ?>
										<th style="text-align: center" width="10%">Ket</th>
                                </tr>
                            </thead>
							
							<tbody>
							
                                <?php
								$no = 0;
								$tanggal=date('Y-m-d');
							$query = mysqli_query($koneksi,"select * from users
			               LEFT JOIN absensi ON absensi.idguru=users.id_user WHERE absensi.tanggal='$tanggal'");
			             while ($absen = mysqli_fetch_array($query)) {	
                                $no++;
                            ?>
							 <tr>
                                    <td style="text-align: center"><?= $no; ?></td>
									 <td style="text-align: center"> <?= $absen['tanggal'] ?></td>
							        <td><?= $absen['nama'] ?></td>
									  <td style="text-align: center"><?= $absen['jam_masuk'] ?></td>
									  <?php if($menu['absen_guru']<>0){ ?>
									   <td style="text-align: center"><?= $absen['jam_pulang'] ?></td>
									   <?php } ?>
									    <td style="text-align: center">
										<?php if($absen['ket']=="H"){ ?>
										<b>Hadir</b>
										<?php } ?>
										<?php if($absen['ket']=="S"){ ?>
										<b>Sakit</b>
										<?php } ?>
										<?php if($absen['ket']=="I"){ ?>
										<b>Izin</b>
										<?php } ?>
										<?php if($absen['ket']=="A"){ ?>
										<b style="color : red;">Alpha</b>
										<?php } ?>
										</td>
										
                                  
                              		
							       </tr>
                            <?php } ?>
                        </tbody>
                        </table>
                    </div>
                    </div>
					</div>
                </div>
            </div>
        </div>
    </div>