<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
	

	<div class="page-header">
			<h2>Perusahaan</h2>
			<ol class="breadcrumb">

				<li><a href="dashboard.php"><i class="fa fa-home"> Home</i></a></li>
				<li class="active"><i class="fa fa-users"> Perusahaan  </i></li>
            </ol>
	</div>
<?php

if(isset($_POST['delete'])){
	$rs=mysql_query("Delete from perusahaan Where id_perusahaan='".$_POST['id_perusahaan']."'");
			if($rs)
			{
				 ?>
				<div class="row">
				<div class="col-xs-offset-2 col-md-8">
				<div class="alert alert-success  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Data Berhasil dihapus</center>
				</div></div></div>
	 
				<?php
			}
}

if(isset($_POST['aktivasi'])){
  $rs=mysql_query("UPDATE perusahaan SET aktif=1 WHERE id_perusahaan='".$_GET['id']."'");
      if($rs)
      {
         ?>
        <div class="row">
        <div class="col-xs-offset-2 col-md-8">
        <div class="alert alert-success  alert-dismissable">
        <button type="button" class="close" data-dismiss="alert">x</button>
        <center>Perusahaan Berhasil diaktivasi</center>
        </div></div></div>
   
        <?php
      }
}

if(isset($_POST['block'])){
  $rs=mysql_query("UPDATE perusahaan SET aktif=0 WHERE id_perusahaan='".$_GET['id']."'");
      if($rs)
      {
         ?>
        <div class="row">
        <div class="col-xs-offset-2 col-md-8">
        <div class="alert alert-success  alert-dismissable">
        <button type="button" class="close" data-dismiss="alert">x</button>
        <center>Perusahaan Berhasil diblokir</center>
        </div></div></div>
   
        <?php
      }
}

?>

<table id="tabel" class="table table-bordered display" cellspacing="0" width="100%">
		<thead>
		<tr class="success">
			<th width="5%">No</th>
        	<th width="25%">Nama</th>
          <th width="25%">Username</th>
            <th width="35%">Alamat</th>
            <th width="20%">Telepon</th>
            <th width="20%">Status</th>
            <th width="15%"><center>Aksi</center></th>
         
		</tr>
		</thead>

		<tbody>
		<?php
  		$nomor=0;
  		$rw=mysql_query("Select * from perusahaan");
  		while($s=mysql_fetch_array($rw))
  		{$nomor++;
        $alamat=substr($s['alamat'],0,10);
  		?>
   		<tr>
    		<td align="center"><?php echo $nomor; ?></td>
    		<td><?php echo $s['nama']; ?></td>
        <td><?php echo $s['username']; ?></td>
    		<td><?php echo $alamat;?></td>
    		<td><?php echo $s['telepon']; ?></td>
        <td>
          <center>
          <?php if ($s['aktif'] == 1) 
          {
            echo "<span class='label label-success'>Aktif</span>";
          }else{
            echo "<span class='label label-danger'>Tidak Aktif</span>";
          }
          ?>
        </center>
    		<td ><center>
          <?php
          if ($s['aktif'] == 0) 
          {
            ?>
              <form class="form-horizontal" role="form" method="post" action="dashboard.php?cat=web&page=perusahaan&id=<?php echo $s['id_perusahaan'];?>" enctype="multipart/form-data">
              <button type="submit" name="aktivasi" class="btn btn-success tooltipsku" data-placement="top" title="Aktivasi Perusahaan" ><i class="fa fa-check" ></i></button>
          </form>
            <?php
          }else{
            ?>
            <form class="form-horizontal" role="form" method="post" action="dashboard.php?cat=web&page=perusahaan&id=<?php echo $s['id_perusahaan'];?>" enctype="multipart/form-data">
              <button type="submit" name="block" class="btn btn-warning tooltipsku" data-placement="top" title="Blokir Perusahaan" ><i class="fa fa-ban" ></i></button>
          </form>
            <?php

          }
          ?>
          
          <button class="btn btn-default tooltipsku" type="button" data-placement="top" title="Lihat rincian" data-toggle="modal" data-target="#modal_edit<?php echo $s['id_perusahaan'];?>"><i class="fa fa-folder-open" >   </i></button>
    		<button class="btn btn-danger tooltipsku" type="button" data-placement="top" title="Hapus" data-toggle="modal" data-target="#modal_delete<?php echo $s['id_perusahaan'];?>"><i class="fa fa-trash" >   </i></button></td>
    		</center>
		</tr>
		<?php
 		 }
 		?>
		</tbody>
</table>
</div></div></div>

<?php
$rw=mysql_query("Select * from perusahaan");
while($s=mysql_fetch_array($rw)){
?>
<div id="modal_edit<?php echo $s['id_perusahaan'];?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Rincian Perusahaan</h4>
            </div>
            <div class="modal-body">
<form class="form-horizontal">
    <input type="hidden" class="form-control" id="id_perusahaan<?php echo $s['id_perusahaan'];?>" name="id_perusahaan" value="<?php echo $s['id_perusahaan'];  ?>" required > 
<div class="form-group">
    <center>  <label for="nama" class="col-sm-4 control-label" >Nama Perusahaan</label></center>
      <div class="col-md-7">
         <input type="text" class="form-control" id="nama<?php echo $s['id_perusahaan'];?>" name="nama" value="<?php echo $s['nama'];  ?>" required readonly> 
      </div>
   </div>
   <div class="form-group">
    <center>  <label for="alamat" class="col-sm-4 control-label">Alamat </label></center>
      <div class="col-md-7">
         <textarea rows="3" class="form-control" name="alamat" disabled> <?php echo $s['alamat'];  ?></textarea>
      </div>
   </div>
   <div class="form-group">
    <center>  <label for="email" class="col-sm-4 control-label">Email </label></center>
      <div class="col-md-6">
         <input type="text" class="form-control" id="email<?php echo $s['id_perusahaan'];?>" name="email" value="<?php echo $s['email'];  ?>" required readonly> 
      </div>
   </div>
   <div class="form-group">
    <center>  <label for="telepon" class="col-sm-4 control-label">Nomor Telepon </label></center>
      <div class="col-md-5">
         <input type="text" class="form-control" id="telepon<?php echo $s['id_perusahaan'];?>" name="telepon" value="<?php echo $s['telepon'];  ?>" required readonly> 
      </div>
   </div>
  
            </div>
 </form>
        </div>
    </div>
</div>
<?php
}
?>

<?php
$rw=mysql_query("Select * from perusahaan");
while($s=mysql_fetch_array($rw)){
?>
<div id="modal_delete<?php echo $s['id_perusahaan'];?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Konfirmasi </h4>
            </div>
            <div class="modal-body">
		

<form class="form-horizontal" role="form" method="post" action="dashboard.php?cat=web&page=perusahaan" enctype="multipart/form-data">
<div class="form-group">
    <div class="col-md-offset-1 col-md-10">
				<div class="alert alert-danger  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert"></button>
				<center>Apakah Anda Yakin akan Menghapus <strong style="color:red"> <?php echo $s['nama'];?></strong>?</center>
				</div></div>
   </div>

            </div>
              <input type="hidden" class="form-control" id="id_perusahaan<?php echo $s['id_perusahaan'];?>" name="id_perusahaan" value="<?php echo $s['id_perusahaan'];  ?>" required > 

  <div class="modal-footer">
        <button type="submit" name="delete" class="btn btn-danger">Hapus</button>
      </div>
            </form>
        </div>
    </div>
</div>
<?php
}
?>
</div>
</div>