<?php
session_start();
error_reporting(0);
include "config/koneksi.php";
include "config/library.php";
include "config/fungsi_indotgl.php";
include "config/fungsi_seo.php";
if (isset($_SESSION[id])) {
	if ($_SESSION['level'] == 'admin') {
		$iden = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM users where username='$_SESSION[id]'"));
		$nama =  $iden['nama_lengkap'];
		$level = 'Administrator';
		$foto = 'dist/img/user.png';
	}

	$idt = mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM identitas where npsn='10700295'"));
	
	$tampil = mysqli_query($conn, "SELECT rb_inventaris.*, kelas_siswa.nmKelas 
  FROM
  rb_inventaris 
  INNER JOIN kelas_siswa ON rb_inventaris.idKelas=kelas_siswa.idKelas
   where rb_inventaris.idKelas='$_GET[kelas]'");
           

	

	header("Content-type: application/vnd-ms-excel");
	header("Content-Disposition: attachment; filename=laporan_barang_" . date('dmyHis') . ".xls");
?>
	<table border="1">
  <thead>
            <tr>
              <th>No</th>
              <th>Nama Kelas</th>
              <th>Nama Inventaris</th>
              <th>Jumlah Inventaris</th>
             
            </tr>
          </thead>
          <tbody>
            <?php
             $no = 1;
            while ($r = mysqli_fetch_array($tampil)) {
              echo "<tr><td>$no</td>
                              <td>$r[nmKelas]</td>
                              <td>$r[nmBarang]</td>
                              <td>$r[jumlahBarang]</td>
                              ";
              echo "</tr>";
              $no++;
           
            }

            ?>
          </tbody>
	</table>
<?php
} else {
	include "login.php";
}
?>