<?php
include_once "./class/kriteria.php";
$crud=new kriteria();
?>
<div class="row">

    <div class="col-12">
    
    <div class="card mb-4">
    
      <div class="card-header pb-0">
        <h4 class="m-0">Daftar Kriteria</h4>
      </div>
      <div class="card-body table-responsive" style="font-size: .8em;">
    
  <?php 
    if(@$_SESSION['con']!="") { ?>
    <div class="alert alert-success alert-dismissable" style="opacity:0.8; padding: 5px 10px;">
      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
      <i class="icon fa fa-check"></i>
      <?php 
      if(@$_SESSION['con']==1) { echo "Data berhasil ditambah."; }
      elseif(@$_SESSION['con']==2) { echo "Data berhasil diubah."; }
      elseif(@$_SESSION['con']==3) { echo "Data berhasil dihapus."; }
      ?>
    </div>
  <?php unset($_SESSION['con']); } ?>

        <table class="csstable responsive" id="tabel_data" width="100%" border="0" cellpadding="4" cellspacing="0">
            <thead>
                <tr>
                    <th width="5%" class="no_sort">No</th>
                    <th width="30%">Kriteria</th>                        
                    <th width="15%">Jenis</th>
                    <th width="15%">Masukan</th>       
                    <th width="30%">Keterangan</th>       
                    <th width="5%" class="no_sort">
                        <a href="?p=kriteria-input&stat=tambah" class="btn btn-primary btn-xs" style="margin-bottom:0px"><div style="width:30px;"><i class="fa fa-plus"></i></div></a>
                    </th>
                </tr>
            </thead>
            <tbody>
                <?php
                $no=0;
                $result = $crud->tampil();
                foreach ($result as $key => $data) {
                    $no++;
                ?>
                <tr>
                    <td><?php echo $no; ?></td>
                    <td><?php echo $data['kriteria']; ?></td>
                    <td><?php echo $lib->kriteria_jenis[$data['jenis']]; ?></td>
                    <td><?php echo $lib->kriteria_masukan[$data['masukan']]; ?></td>      
                    <td><?php echo $data['keterangan']; ?></td>
                    <td>
          <a href="?p=kriteria-input&stat=ubah&id=<?php echo $data['id_kriteria']; ?>" class="btn btn-success btn-xs" title="Ubah Data" style="padding: 5px 10px; margin-bottom:0px"><i class="fa fa-pen" style="font-size:0.8em"></i></a>
                        <a href="javascript:void(0);" class="btn btn-danger btn-xs openHapus" data-title=" <?php echo $data['kriteria']; ?>" data-href="?p=kriteria-input&stat=hapus&id=<?php echo $data['id_kriteria']; ?>" style="padding: 5px 10px; margin-bottom:0px"><i class="fa fa-trash" style="font-size:0.8em"></i></a>                          
        </td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
        
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="modalHapus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" style="text-align: left;">
                <h4 class="modal-title pull-left" id="myModalLabel">Hapus Data?</h4>
                <button type="button" class="close" data-bs-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>