<?php
 defined("BASEPATH") or exit("No direct access allowed");
 $query1 = mysqli_query($con,"select count(*) from grup order by tgl_bikin desc");
   $statusbc1 = mysqli_fetch_array($query1,MYSQLI_NUM);
   $jml1 = $statusbc1[0];
   
if (isset($_GET['hapus']) && is_numeric($_GET['hapus'])) {
		$hapus = $_GET['hapus'];
		
		mysqli_query($con,"DELETE FROM wacs WHERE id=$hapus");

		echo '
		 <!-- <div class="alert alert-success alert-dismissable" style="margin-top:20px">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon glyphicon glyphicon-remove"></i> Data dengan id '.$hapus.' Telah Dihapus
            </div> -->
            
         <script>
        	        swal("Good Job","berhasil menghapus data wa cs","success");
                </script>     
                
		';
		
	}
      

if( isset( $_REQUEST['aksi'] )){
		$aksi = $_REQUEST['aksi'];
		switch($aksi){
			case 'baru':
				include 'newW.php';
				break;
			case 'edit':
				include 'editW.php';
				break;
		}
} else { 
 
?>
<div class="section-header">

<div class="card-header">
    
          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="index.php?page=wacs"><i class="far fa-file"></i> WA CS</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i> List</li>
                      </ol>
                    </nav>

    <div class="card-body">
            <div class="alert alert-primary alert-has-icon p-4">
            <div class="alert-icon"><i class="far fa-lightbulb"></i></div>
            <div class="alert-body">
            <div class="alert-title">Petunjuk:</div>
            1. Buat data wa cs baru klik +WA CS. <br>
            2. Nomor WA harus valid. Cth: 082150651122.<br>
            3. Data WA CS ini bergantian (rotasi) saat prospek mengklik tombol WA dalam email. Jadi semua CS akan bergantian menerima chatting.
            </div>
            </div>
        </div> 
            
            <!-- /.box-header -->
            
                
				<form class="form-horizontal" role="form" action="index.php?page=wacs&aksi=baru" method="POST">
				<button class="btn btn-secondary">
				<span class="btn-label">
					<i class="fa fa-plus"></i>
				</span>
				Data WA CS
				</button>
				</form>
<div class="card-body">	
                <div class="table-responsive">
				<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>Action</th>
                            <th>Nama CS</th>
                            <th>WA CS</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                             <th>Action</th>
                             <th>Nama CS</th>
                            <th>WA CS</th>
                        </tr>
                    </tfoot>
                    <tbody>
                       <?php
                            
                            $qu=mysqli_query($con,"select * from wacs order by id desc");
                            while($data=mysqli_fetch_row($qu)){
                                
                                $eid= md5($data[0]);

                                echo "
                                <tr>
                                    <td>   
									<a type='button' class='btn btn-icon btn-round btn-default' href='index.php?page=wacs&aksi=edit&id=$data[0]' >EDIT</a>
									
									<a type='button' class='btn btn-icon btn-round btn-default' onclick='return konfirmasi()' href='?page=wacs&hapus=$data[0]'>DEL</a>
									
									</td>
									<td>
                                        $data[1] 
                                    </td>
									<td>
                                        $data[2] 
                                    </td>
                                </tr>
                                ";
                            }
                       ?>
                    </tbody>
                </table>
                </div>
                
 </div>
            <!-- /.box-body -->
        


<!-- /.row -->
<?php
}
?>