<?php 
//usleep(500000);
date_default_timezone_set('Asia/Jakarta');
$tgl=date('d-m-Y H:i:s');

require '../functions.php';


session_start();




if(!isset($_SESSION["login"]) ) {
	header("Location: ../login.php");
	exit;
}


$logkanwil=$_SESSION["logkanwil"]; 
$username=$_SESSION["username"]; 

$keyword = $_GET["keyword"];



	if($logkanwil=="KP")

	
				{
				    
	
		
	
	$query = "SELECT * FROM moni
            WHERE
          (noppb LIKE '%$keyword%' OR
          norange LIKE '%$keyword%' OR
          pengelola LIKE '%$keyword%' OR
          penempatan LIKE '%$keyword%' OR
          jn_pek LIKE '%$keyword%' OR
          vendor LIKE '%$keyword%' OR
          tgl_mulai LIKE '%$keyword%' OR
          tgl_akhir LIKE '%$keyword%' OR
          jm_1 LIKE '%$keyword%' OR
          jm_2 LIKE '%$keyword%' OR
          jm_3 LIKE '%$keyword%' OR
          jm_4 LIKE '%$keyword%' OR
          jm_5 LIKE '%$keyword%' OR
          jm_6 LIKE '%$keyword%' OR
          keterangan LIKE '%$keyword%') order by pengelola,vendor,jn_pek,penempatan";}
		    
				else
				    
		{$query = "SELECT * FROM moni		    
		    WHERE pengelola='$logkanwil' and
		    
		  
		  (noppb LIKE '%$keyword%' OR
          norange LIKE '%$keyword%' OR
          pengelola LIKE '%$keyword%' OR
          penempatan LIKE '%$keyword%' OR
          jn_pek LIKE '%$keyword%' OR
          vendor LIKE '%$keyword%' OR
          tgl_mulai LIKE '%$keyword%' OR
          tgl_akhir LIKE '%$keyword%' OR
          jm_1 LIKE '%$keyword%' OR
          jm_2 LIKE '%$keyword%' OR
          jm_3 LIKE '%$keyword%' OR
          jm_4 LIKE '%$keyword%' OR
          jm_5 LIKE '%$keyword%' OR
          jm_6 LIKE '%$keyword%' OR
          keterangan LIKE '%$keyword%') order by pengelola,vendor,jn_pek,penempatan";}
		  
		  
		  

$mahasiswa = query($query);




echo "$tgl, USER:$logkanwil/$username ";
?>

<br>


<a href="tambah.php">|Tambah Data|</a>
<a href="export_ke_excel/index.php">|Export Excel|</a>
<a href="registrasi.php">|Registrasi|</a>
<a href="gantipass.php">|Ganti Password|</a>
<a href="tabel_jn_pek.php">|Tabel Jn.Pek|</a>
<a href="tabel_vendor.php">|Tabel Vendor|</a>
<a href="tabel_kcu.php">|Tabel Penempatan|</a>
<a href="demografip.php">|P-Demografi|</a>
<a href="demografic.php">|C-Demografi|</a>
<a href="kirimemail.php">|Email MAD|</a>
<a href="logout.php"> |Logout|</a> 


<br><br>

<table border="1" cellpadding="10" cellspacing="0">

        <th>No.</th>
        
        
        <th>Action</th>
		<th>Penempatan</th>
		<th>Pengelola PPB</th>
		<th>No.PPB Induk</th>
		<th>No.PPB di Orange</th>
		<th>Vendor</th>
		<th>Tgl Mulai</th>
		<th>Tgl Akhir</th>
		<th>Jenis Pek.</th>
		<th>Jan</th>
		<th>Feb</th>
		<th>Mar</th>
		<th>Apr</th>
		<th>Mei</th>
		<th>Jun</th>
		<th>Keterangan</th>
		
        
	
    <?php $i = 1; ?>
    <?php foreach( $mahasiswa as $row ) : ?>
    
    <tr>
		<td><?= $i; ?></td>
		<td>
		
		
			<?php
				if($logkanwil<>"KP")
				{
					echo "";
				}
				else{
			?>
				|<a href="ubahadm.php?id=<?php echo $row["id"]; ?>">U</a>|
		
		
		<?php } ?>
		
		
		
		
		
		
			      |<a href="ubah.php?id=<?php echo $row["id"]; ?>">Ubah</a>|
			  <a href="hapus.php?id=<?php echo $row["id"]; ?>" onclick="return confirm('Anda yakin ...?')">Hapus</a></td>
    
		
    

    
		<td><?= $row["penempatan"]; ?></td>
		<td><?= $row["pengelola"]; ?></td>
		<td><?= $row["noppb"]; ?></td>
		<td><?= $row["norange"]; ?></td>
		<td><?= $row["vendor"]; ?></td>
		<td><?php echo date("d-m-Y", strtotime($row['tgl_mulai']));?></td>
		<td><?php echo date("d-m-Y", strtotime($row['tgl_akhir']));?></td>
		<td><?= $row["jn_pek"]; ?></td>
		<td><?php echo number_format($row['jm_1'],0,",","."); ?></td>
		<td><?php echo number_format($row['jm_2'],0,",","."); ?></td>
		<td><?php echo number_format($row['jm_3'],0,",","."); ?></td>
		<td><?php echo number_format($row['jm_4'],0,",","."); ?></td>
		<td><?php echo number_format($row['jm_5'],0,",","."); ?></td>
		<td><?php echo number_format($row['jm_6'],0,",","."); ?></td>
		
		

		<td><?= $row["keterangan"]; ?></td>
			
		
        
    </tr>
    <?php 
    $i++;
    

$aaa=$aaa+$row["jm_1"];
$bbb=$bbb+$row["jm_2"];
	

	

   ?>
    <?php endforeach; ?>
    
</table>

<br>
<table border="2" cellspacing="3" cellpadding="3">
<tr>



	    
</tr>
</table>


<br>
<table border="2" cellspacing="3" cellpadding="3">
<tr>
		

		<th>Jm TKAD Jan:</th>
	    <td><?= number_format($aaa,0,",","."); ?></td>
	
		<th>Jm TKAD Feb:</th>
	    <td><?= number_format($bbb,0,",","."); ?></td>



</tr>
</table>











