<?php include 'header.php'; ?>

<div class="content-wrapper">

  <section class="content-header">
    <h1>
      Kelas
    <!--  <small>Siswa Kelas</small>-->
    <!--</h1>-->
    <!--<ol class="breadcrumb">-->
    <!--  <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>-->
    <!--  <li class="active">Dashboard</li>-->
    <!--</ol>-->
  </section>

  <section class="content">
    <div class="row">
      <section class="col-lg-6">       
        <div class="box box-primary">

          <div class="box-header">
            <h3 class="box-title">Tentang kelas</h3>
            <a href="kelas.php" class="btn btn-primary btn-sm pull-right"><i class="fa fa-reply"></i> &nbsp Kembali</a> 
          </div>
          <div class="box-body">
            <?php 
            $id = $_GET['id'];              
            $kelas = mysqli_query($koneksi, "select * from kelas, jurusan, ta where kelas_ta=ta_id and kelas_jurusan=jurusan_id and kelas_id='$id'");
            $k = mysqli_fetch_assoc($kelas);
            $id_kelas = $k['kelas_id'];
            $id_ta = $k['kelas_ta'];
            ?>

            <div class="table-responsive">
              <table class="table table-bordered">
                <tr>
                  <th width="30%">Nama Kelas</th>
                  <td><?php echo $k['kelas_nama'] ?></td>
                </tr>
                <tr>
                  <th>Kelas</th>
                  <td><?php echo $k['jurusan_nama'] ?></td>
                </tr>
                <tr>
                  <th>Tahun Ajaran</th>
                  <td><?php echo $k['ta_nama'] ?></td>
                </tr>
              </table>
            </div>

          </div>

        </div>
      </section>
    </div>


    <div class="box box-primary">

     <div class="box-header">
      <h3 class="box-title">Siswa Kelas</h3>             
      <div class="btn-group pull-right">
        <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#modal_jurusan">
         <i class="fa fa-plus"></i> &nbsp Tambahkan Siswa Ke Kelas
       </button>
     </div>

     <!-- The Modal -->
     <div class="modal" id="modal_jurusan">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">

          <!-- Modal Header -->
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Pilih Siswa</h4>
          </div>

          <!-- Modal body -->
          <div class="modal-body">

            <div class="table-responsive">
              <table class="table table-bordered table-striped" id="table-datatable">
                <thead>
                  <tr>
                    <th width="1%">NO</th>
                    <th>NAMA</th>
                    <th>NIS</th>
                    <th>KELAS</th>
                    <th>STATUS</th>
                    <th width="10%">OPSI</th>
                  </tr>
                </thead>
                <tbody>
                  <?php 
                  $no=1;
                  $id = $_GET['id']; 
                  $data = mysqli_query($koneksi,"SELECT * FROM siswa, jurusan where siswa_jurusan=jurusan_id and siswa_id not in (select ks_siswa from kelas_siswa, kelas where ks_kelas=kelas_id and kelas_ta='$id_ta') order by siswa_id desc");
                  while($d = mysqli_fetch_array($data)){
                    ?>
                    <tr>
                      <td><?php echo $no++; ?></td>
                      <td><?php echo $d['siswa_nama']; ?></td>
                      <td><?php echo $d['siswa_nis']; ?></td>
                      <td><?php echo $d['jurusan_nama']; ?></td>
                      <td><?php echo $d['siswa_status']; ?></td>
                      <td>                        
                        <a class="btn btn-warning btn-sm" href="kelas_siswa_act.php?siswa=<?php echo $d['siswa_id'] ?>&kelas=<?php echo $id_kelas ?>"><i class="fa fa-check"></i> Pilih</a>
                      </td>
                    </tr>
                    <?php 
                  }
                  ?>
                </tbody>
              </table>
            </div>

          </div>

        </div>
      </div>
    </div>
  </div>
  <div class="box-body">
   <div class="table-responsive">
    <table class="table table-bordered table-striped" id="table-datatable">
      <thead>
        <tr>
          <th width="1%">NO</th>
          <th>NAMA</th>
          <th>NIS</th>
          <th>KELAS</th>
          <th>STATUS</th>
          <th width="10%">OPSI</th>
        </tr>
      </thead>
      <tbody>
        <?php 
        $no=1;
        $id = $_GET['id']; 
        $data = mysqli_query($koneksi,"SELECT * FROM siswa, jurusan where siswa_jurusan=jurusan_id and siswa_id in (select ks_siswa from kelas_siswa where ks_kelas='$id') order by siswa_id desc");
        while($d = mysqli_fetch_array($data)){
          ?>
          <tr>
            <td><?php echo $no++; ?></td>
            <td><?php echo $d['siswa_nama']; ?></td>
            <td><?php echo $d['siswa_nis']; ?></td>
            <td><?php echo $d['jurusan_nama']; ?></td>
            <td><?php echo $d['siswa_status']; ?></td>
            <td>                        
              <a class="btn btn-danger btn-sm" href="kelas_siswa_keluarkan.php?siswa=<?php echo $d['siswa_id'] ?>&kelas=<?php echo $id_kelas ?>"><i class="fa fa-close"></i> Keluarkan</a>
            </td>
          </tr>
          <?php 
        }
        ?>
      </tbody>
    </table>
  </div>
  </div>

</div>

</section>

</div>
<?php include 'footer.php'; ?>