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

    <div class="col-12">
    
    <div class="card mb-4">
    
      <div class="card-header pb-0">
        <h4 class="m-0">Daftar Administrator</h4>
      </div>
      <div class="card-body" 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']); } ?>
        <div class="table-responsive p-0">
        <table class="csstable responsive" id="tabel_data" width="100%" border="0" cellpadding="4" cellspacing="0">
            <thead>
                <tr>
                    <th width="20" class="no_sort">No</th>
                    <th width="354">Nama Lengkap</th>
                    <th width="398">Username</th>
                    <th width="190" class="no_sort">Terdaftar</th>
                    <th width="37" class="no_sort">
                        <a href="?p=administrator-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['nama']; ?></td>
                    <td><?php echo $data['username']; ?></td>
                    <td><?php echo date("d/m/Y", strtotime($data['terdaftar'])); ?></td>
                    <td>
                        <a href="?p=administrator-input&stat=ubah&id=<?php echo $data['id_administrator']; ?>" 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['username']; ?>" data-href="?p=administrator-input&stat=hapus&id=<?php echo $data['id_administrator']; ?>" 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>

<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">
                <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>