 <?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php if ($ac == '') { ?>
   
	<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<form action='?pg=rekapabsen&ac=kelas' method='POST'>
					<div class='form-group-sm'>
              
                <select name='kelas' id="kelas" class='form-control' required='true' style="width: 80%;">
                   <option value=''>--Pilih Kelas--</option>
                    <?php $qt = mysqli_query($koneksi, "SELECT * FROM siswa_ptm  GROUP BY id_kelas"); ?>
                        <?php while ($mt = mysqli_fetch_array($qt)) : ?>
                            <option value="<?= $mt['id_kelas'] ?>"><?= $mt['id_kelas'] ?></option>
                             <?php endwhile ?>
                              </select>  
							   </div>	
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-success' style="margin-top: -40px;" ><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					   </form>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			JOIN logface ON logface.idsiswa=siswa_ptm.id_siswa
			LEFT JOIN absensi ON absensi.faceid=logface.faceid");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'faceid' => $siswa['faceid']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
<?php } elseif ($ac == 'kelas') { ?>
	
<?php $kelas=$_POST['kelas']; ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa <?= $kelas ?></h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -90px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			JOIN logface ON logface.idsiswa=siswa_ptm.id_siswa
			LEFT JOIN absensi ON absensi.faceid=logface.faceid WHERE siswa_ptm.id_kelas='$kelas'");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'faceid' => $siswa['faceid']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
          <iframe id='loadframe' name='frameresult' src="m_cetak/cetakrekapsiswa.php?kelas=<?= $kelas ?>" style='display:none'></iframe>
 

<?php } elseif ($ac == 'peg') { ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Pegawai</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -90px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Pegawai</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from users
			JOIN logface ON logface.idguru=users.id_pengawas
			LEFT JOIN absensi ON absensi.faceid=logface.faceid");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE faceid='$siswa[faceid]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'faceid' => $siswa['faceid']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
  <iframe id='loadframe' name='frameresult' src="m_cetak/cetakrekappegawai.php" style='display:none'></iframe>
 
 <?php } elseif ($ac == 'rfidpeg') { ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Pegawai</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -90px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Pegawai</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from users
			JOIN datarfid ON datarfid.idpeg=users.id_pengawas
			LEFT JOIN absensi ON absensi.nokartu=datarfid.nokartu");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'nokartu' => $siswa['nokartu']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
  <iframe id='loadframe' name='frameresult' src="m_cetak/rekaprfidpegawai.php" style='display:none'></iframe>

 <?php } elseif ($ac == 'rfidsiswa') { ?>
 <div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<form action='?pg=rekapabsen&ac=rfid_kelas' method='POST'>
					<div class='form-group-sm'>
              
                <select name='kelas' id="kelas" class='form-control' required='true' style="width: 80%;">
                   <option value=''>--Pilih Kelas--</option>
                    <?php $qt = mysqli_query($koneksi, "SELECT * FROM siswa_ptm  GROUP BY id_kelas"); ?>
                        <?php while ($mt = mysqli_fetch_array($qt)) : ?>
                            <option value="<?= $mt['id_kelas'] ?>"><?= $mt['id_kelas'] ?></option>
                             <?php endwhile ?>
                              </select>  
							   </div>	
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-success' style="margin-top: -30px;" ><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					   </form>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			JOIN datarfid ON datarfid.idsiswa=siswa_ptm.id_siswa
			LEFT JOIN absensi ON absensi.nokartu=datarfid.nokartu");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'nokartu' => $siswa['nokartu']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
<?php } elseif ($ac == 'rfid_kelas') { ?>
	
<?php $kelas=$_POST['kelas']; ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa <?= $kelas ?></h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -50px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			JOIN datarfid ON datarfid.idsiswa=siswa_ptm.id_siswa
			LEFT JOIN absensi ON absensi.nokartu=datarfid.nokartu WHERE siswa_ptm.id_kelas='$kelas'");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE nokartu='$siswa[nokartu]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'nokartu' => $siswa['nokartu']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
          <iframe id='loadframe' name='frameresult' src="m_cetak/rekaprfidsiswa.php?kelas=<?= $kelas ?>" style='display:none'></iframe>
 

 
  <?php } elseif ($ac == 'pegmanual') { ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Pegawai</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -90px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Pegawai</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('m-Y');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from users
			
			LEFT JOIN absensi ON absensi.guru=users.id_pengawas WHERE users.level<>'admin' GROUP BY users.id_pengawas ORDER BY users.nama ASC");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'guru' => $siswa['id_pengawas']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
  <iframe id='loadframe' name='frameresult' src="m_cetak/rekappegawaimanual.php" style='display:none'></iframe>

  
 <?php } elseif ($ac == 'sismanual') { ?> 
  <div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					<form action='?pg=rekapabsen&ac=kelasQ' method='POST'>
					<div class='form-group-sm'>
              
                <select name='kelas' id="kelas" class='form-control' required='true' style="width: 80%;">
                   <option value=''>--Pilih Kelas--</option>
                    <?php $qt = mysqli_query($koneksi, "SELECT * FROM siswa_ptm  GROUP BY id_kelas"); ?>
                        <?php while ($mt = mysqli_fetch_array($qt)) : ?>
                            <option value="<?= $mt['id_kelas'] ?>"><?= $mt['id_kelas'] ?></option>
                             <?php endwhile ?>
                              </select>  
							   </div>	
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-success' style="margin-top: -40px;" ><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					   </form>
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('mY');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			LEFT JOIN absensi ON absensi.idsiswa=siswa_ptm.id_siswa");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'idsiswa' => $siswa['id_siswa']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
  <?php } elseif ($ac == 'kelasQ') { ?>
	
<?php $kelas=$_POST['kelas']; ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Siswa <?= $kelas ?></h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					<br>
					
					<div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger' style="margin-top: -90px;" onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						
						<div class='row'>
				 
			
	<div class='col-md-12'>
            <div class='box-body'>
			
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Siswa</th>
                <?php
			    
				$bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('mY');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
					<?php
					$date1 = date("D",strtotime("$tahun-$bulan-$i"));
					?>
                    <th>
                    <?php if($date1=='Sun')	{ ?>				
					<b style="color:red"><?= $i ?></b>
					<?php }else{ ?>
					<?= $i ?>
					<?php } ?>
					</th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from siswa_ptm
			LEFT JOIN absensi ON absensi.idsiswa=siswa_ptm.id_siswa WHERE siswa_ptm.id_kelas='$kelas'");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE idsiswa='$siswa[id_siswa]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td><?= ucwords(strtolower($siswa['nama'])) ?></td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                      
					$date2 = date("D",strtotime("$tahun-$bulan-$i"));
					
					  $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'idsiswa' => $siswa['id_siswa']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
						 <?php if($date2=='Sun'): ?>
                            <td style="color:red">X</td>
							<?php else: ?>
							<td></td>
							<?php endif; ?>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
          <iframe id='loadframe' name='frameresult' src="m_cetak/cetakrekapsiswamanual.php?kelas=<?= $kelas ?>" style='display:none'></iframe>
 
  <?php } elseif ($ac == 'pegqrcode') { ?>
<div class='row'>
        <div class='col-md-12'>
            <div class='panel panel-default'>
               <div class="panel-heading" style="height:45px">
			   <div class='box-tools pull-right'>
                <button type='submit'  class='btn btn-sm btn-danger'  onclick="frames['frameresult'].print()"><i class='fa fa-print'></i> Cetak</button>							 
                       	
					   </div>
                  <h4 class='box-title'><i class="fas fa-calendar"></i> Rekapitulasi Absensi Pegawai</h4></div>    
			  <div class='box-header with-border '>
			   <div class='box-tools pull-right '>
			   
			   <table>
			   <tr>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['sekolah'] ?></option>
               </select>
			   </div>
				</td>
			   <td>
			   <div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
              <option value=""><?= $setting['jenjang'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control'>
               <option value=""><?= $setting['kota'] ?></option>
               </select>
			   </div>
				</td>
				<td>
				<div class="form-group-sm">
			  <select name='jenjang' class='form-control' >
               <option value=""><?= $setting['kecamatan'] ?></option>
               </select>
			   </div>
				</td>
				</tr>					
			</table>
			</div>
			 <h4 class='box-title'></h4>
			  </div>
			  <div class="box-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true" >Absensi</a></li>
                        
                    </ul>
					
					<div class="tab-content">
                        <div class="tab-pane active" id="tab_1" >
						<br>
			<div class="panel panel-default">
            <div class='box-body'>
                <div class="table-responsive">
                    <table style="font-size: 12px" class="table table-sm">
                     
        <thead class="thead-dark">
            <tr>
                <th>NO</th>
                <th>Nama Pegawai</th>
                <?php
			    
				 $bulan=date('m');
				
				$tahun=date('Y');
				$blth=date('mY');
                	$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                    <th><?= $i ?></th>
                <?php } ?>
                <th>H</th>
                <th>S</th>
                <th>I</th>
                <th>A</th>
            </tr>
        </thead>
       
							 <tbody>
							
            <?php
			$query = mysqli_query($koneksi,"select * from users
			
			LEFT JOIN absensi ON absensi.guru=users.id_pengawas WHERE users.level<>'admin' GROUP BY users.id_pengawas ORDER BY users.nama ASC");
             $no = 0;
              while ($siswa = mysqli_fetch_array($query)) {
		$hadir= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='H' AND blth='$blth' "));
         $sakit= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='S' AND blth='$blth' "));
		 $izin= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='I' AND blth='$blth' "));
         $alpha= mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM absensi WHERE guru='$siswa[id_pengawas]' AND ket='A' AND blth='$blth' "));
			  $no++;
			?>
			
							<tr>
                                    <td><?= $no; ?></td>
                                    <td>
									<label class="btn btn-xs btn-default" onclick="frames['frameresult<?= $siswa['id_pengawas'] ?>'].print()"><?= ucwords(strtolower($siswa['nama'])) ?></label>
									 <iframe id='loadframe' name="frameresult<?= $siswa['id_pengawas'] ?>" src="m_cetak/detailabsen.php?id=<?= $siswa['id_pengawas'] ?>" style='display:none'></iframe>
			
									</td>
									
				<?php 
				
				$tanggal = cal_days_in_month(CAL_GREGORIAN, $bulan, $tahun);
                    for ($i = 1; $i < $tanggal + 1; $i++) { ?>
                        <?php $tanggalbaru = date('Y-m-d', mktime(0, 0, 0, $bulan, $i, $tahun));
                        $cekabsen = fetch($koneksi, 'absensi', ['tanggal' => $tanggalbaru, 'guru' => $siswa['id_pengawas']]);
                       if ($cekabsen) { ?>
					 
                            <td><b><?= $cekabsen['ket'] ?></b></td>
                        <?php } else { ?>
                            <td></td>
                        <?php } ?>
                    <?php } ?>
					
							  <td><?= $hadir; ?></td>
							  <td><?= $sakit; ?></td>
							 <td><?= $izin; ?></td>
							  <td><?= $alpha; ?></td>
							  
									 </tr>   
			  <?php } ?>
         
			 
        </tbody>
    </table>
                                    </div>
									</div>
									 </div>
									 </div>
                                      </div>
  <iframe id='loadframe' name='frameresult' src="m_cetak/rekappegawaimanual.php" style='display:none'></iframe>

  
			
	<?php } ?>
  
  