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


	<div class="page-header">
			<h2>Berita Nonaktif</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-newspaper-o"> Berita Nonaktif </i></li>
            </ol>
	</div>
	
<?php

if(isset($_POST['aktif'])){
  $status="1";
  $rs=mysql_query("Update berita SET status='$status' Where id_berita='".$_POST['id_berita']."'");
   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>Berita Berhasil diaktifkan</center>
        </div></div></div>
   
        <?php
      }
}

if(isset($_POST['nonaktif'])){
  $status="0";
  $rs=mysql_query("Update berita SET status='$status' Where id_berita='".$_POST['id_berita']."'");
   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>Berita Berhasil diaktifkan</center>
        </div></div></div>
   
        <?php
      }
}

if(isset($_POST['delete'])){
	$rs=mysql_query("Delete from berita Where id_berita='".$_POST['id_berita']."'");
			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>Berita Berhasil dihapus</center>
				</div></div></div>
	 
				<?php
			}
}

if(isset($_POST['tambah']))
{

    $gambar = $_FILES['gambar']['name'];
    move_uploaded_file($_FILES['gambar']['tmp_name'], "asset/img/berita/".$_FILES['gambar']['name']);
	$rs=mysql_query("Insert into berita (`judul`,`kategori`,`isi`,`gambar`) values ('".$_POST['judul']."','".$_POST['kategori']."','".$_POST['isi']."','$gambar')");
	if($rs)
	{
		?>
      <div class="row">
          <div class="col-md-offset-2 col-md-8">
          <div class="alert alert-success  alert-dismissable">
          <button type="button" class="close" data-dismiss="alert">x</button>
            <center>Berita Berhasil ditambahkan</center>
          
          </div></div></div>
    <?php
	}else
	{
		?>
      <div class="row">
          <div class="col-md-offset-2 col-md-8">
          <div class="alert alert-danger  alert-dismissable">
          <button type="button" class="close" data-dismiss="alert">x</button>
            <center>Terjadi kesalahan</center>
          
          </div></div></div>
    <?php
	}
  
}

if(isset($_POST['edit']))
{
    $gambar = $_FILES['gambar']['name'];
    move_uploaded_file($_FILES['gambar']['tmp_name'], "asset/img/berita/".$_FILES['gambar']['name']);

	$rs=mysql_query("Update berita SET judul='".$_POST['judul']."', kategori='".$_POST['kategori']."', isi='".$_POST['isi']."', gambar='$gambar' Where id_berita='".$_POST['id_berita']."'");
if($rs)
	{
		?>
    <div class="row">
          <div class="col-md-offset-2 col-md-8">
          <div class="alert alert-success  alert-dismissable">
          <button type="button" class="close" data-dismiss="alert">x</button>
            <center>Berita Berhasil diperbaharui</center>
          
          </div></div></div>
    <?php
	}else
	{
		?>
      <div class="row">
          <div class="col-md-offset-2 col-md-8">
          <div class="alert alert-danger  alert-dismissable">
          <button type="button" class="close" data-dismiss="alert">x</button>
            <center>Terjadi kesalahan</center>
          
          </div></div></div>
    <?php
	}
  
}

			

?>


<div class="col-md-12">
<div class="panel panel-danger">

<div class="panel-heading">
    <h4 align="center"><i class="fa fa-"> Berita Non Aktif </i></h4>
    </div>
    <div class="panel-body">
<table id="tabel" class="table table-bordered display" cellspacing="0" width="100%">
    <thead>
    <tr class="success">
      <th width="2%">No</th>
          <th>Judul</th>
            <th>Kategori</th>
            <th >ISI</th>
            <th width="10%"><center>Aksi</center></th>
         
    </tr>
    </thead>

    <tbody>
    <?php
      $nomor=0;
      $rw=mysql_query("Select * from berita where status='0'");
      while($s=mysql_fetch_array($rw))
      {$nomor++;
        $isi=substr($s['isi'],0,50);
      ?>
      <tr>
        <td align="center"><?php echo $nomor; ?></td>
        <td><?php echo $s['judul']; ?></td>
        <td><?php echo $s['kategori']; ?></td>
        <td><?php echo $isi; echo"..."; ?></td>
        <td ><center>
          <div class="btn-group" role="group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Aksi
      <span class="caret"></span>
    </button>
    <ul class="dropdown-menu">
     <li><a href="#" class="tooltipsku" data-placement="top" title="Aktivasi Berita" data-toggle="modal" data-target="#modal_aktif<?php echo $s['id_berita'];?>"><i class="fa fa-check" >   </i>  Aktivasi</a></li>
   
      <li><a href="#" class="tooltipsku" data-placement="top" title="Edit" data-toggle="modal" data-target="#modal_edit<?php echo $s['id_berita'];?>"><i class="fa fa-edit" >   </i> Edit</a></li>
      <li class="divider"></li>
      <li><a href="#" class="tooltipsku" data-placement="top" title="Hapus" data-toggle="modal" data-target="#modal_delete<?php echo $s['id_berita'];?>"><i class="fa fa-trash" >   </i>  Hapus</a></li>
    </ul>
  </div>
       </center></td>
    </tr>
    <?php
     }
    ?>
    </tbody>
</table>
</div>
</div>


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


<?php
$rw=mysql_query("Select * from berita");
while($s=mysql_fetch_array($rw)){
?>
<div id="modal_edit<?php echo $s['id_berita'];?>" 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">Ubah berita</h4>
            </div>
            <div class="modal-body">
<form class="form-horizontal" method="post" action="dashboard.php?cat=web&page=berita" role="form" enctype="multipart/form-data">
    <input type="hidden" class="form-control" id="id_berita<?php echo $s['id_berita'];?>" name="id_berita" value="<?php echo $s['id_berita'];  ?>" required > 
<div class="form-group">
    <center>  <label for="judul" class="col-sm-3 control-label" >Judul berita</label></center>
      <div class="col-md-7">
         <input type="text" class="form-clontrol" id="nama_berita<?php echo $s['id_berita'];?>" name="judul" value="<?php echo $s['judul'];  ?>" required > 
      </div>
   </div>
   <div class="form-group">
    <center>  <label for="kategori" class="col-sm-3 control-label" >Kategori</label></center>
      <div class="col-md-7">
         <input type="text" class="form-control" id="nama_proyek<?php echo $s['id_berita'];?>" name="kategori" value="<?php echo $s['kategori'];  ?>" required > 
      </div>
   </div>
   
   <div class="form-group">
    <center>  <label for="isi" class="col-sm-3 control-label">Isi Berita </label></center>
      <div class="col-md-8">
         <textarea type="text" class="form-control" id="mytextarea" name="isi" required > <?php echo $s['isi'];  ?></textarea>
      </div>
   </div>
    <div class="form-group">
    <center>  <label for="gambar" class="col-sm-3 control-label" >Gambar</label></center>
      <div class="col-md-5">
         <input type="file" class="form-control" name="gambar" required > 
      </div>
   </div>
  
            </div>
 
 <div class="modal-footer">
        <button type="submit" name="edit" class="btn btn-primary">Update</button>
      </div>
            </form>
        </div>
    </div>
</div>

<?php
}
?>

<?php
$rw=mysql_query("Select * from berita");
while($s=mysql_fetch_array($rw)){
?>
<div id="modal_delete<?php echo $s['id_berita'];?>" 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=berita" 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['judul'];?></strong>?</center>
				</div></div>
   </div>

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

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


<?php
$rw=mysql_query("Select * from berita");
while($s=mysql_fetch_array($rw)){
?>
<div id="modal_aktif<?php echo $s['id_berita'];?>" 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=berita" 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 Mengkativasi berita <strong style="color:red"> <?php echo $s['judul'];?></strong>?</center>
        </div></div>
   </div>

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

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