<?php
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
?>
 <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    <img src="../themes/img/notification.png" alt="Notification" class="header-icon" width="30">
                    Notification
                </h1>
            </div>
        </div>

<div class="row">
            	
                
                
                
                             <div class="col-md-12">
                
                
				  <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Notification</h4>
                        </div>
                        <div class="panel-body">







<?php
if (isset($_GET['page']) && $_GET['page'] == "view") {
if(isset($_GET["kode"])){ $kode = anti_injection($_GET["kode"]); }



$query = "SELECT * FROM notifikasi  WHERE kode='".mysql_real_escape_string($kode)."' and username='$user_session'"; 
$result = mysql_query($query);
$rowc = mysql_fetch_array($result);
$tglne = formatgl($rowc['tgl']);

$username = $rowc['username'];
$judul = $rowc['judul'];
$isi = $rowc['isi'];
$badge = $rowc['badge'];

$kode = $rowc['kode'];
$status = $rowc['status'];
if($status == 0){
$db->update("notifikasi", "status='1'", "kode='".mysql_real_escape_string($kode)."'");
}

	    ?>
       	<h3><?php echo $judul;?></h3>
    <p><?php echo $isi;?></p>
    <div>
        <span class="<?php echo $badge;?>"><?php echo $tgl;?></span><div class="pull-right"><span class="label"></span> <span class="label"></span> <span class="label"></span> <span class="label"></span></div>
    </div> 
    <hr>                      
		
		
		
		
		
		
	<?php 
} else if (isset($_GET['page']) && $_GET['page'] == "delete") {
if(isset($_GET["kode"])){ $kode = anti_injection($_GET["kode"]); }
$db->delete("notifikasi", "kode='$kode'");
header("location: index.php?go=notif");
	exit;



?>	
		
		
		
		
		
		<?php

} else {
?>            














<table id="data-table" class="table table-bordered" cellspacing="0" width="100%">
                    
                    
              <thead>
                <tr>
             <th>Date</th>
                                    <th>Subject</th>
                                    <th>#</th>
                                    <th>#</th>
                                    <th>#</th>
                </tr>
              </thead>
              <tbody>
<?

	$db->select("no, username, judul, isi, tgl, kode, badge, jn, status", "notifikasi", "username='$user_session'", "tgl desc");
	
		while($row=$db->fetch_row()) {
		
if($row[4] == "0000-00-00 00:00:00"){
$dtpaid = "----";
}else{
$dtpaid = formatgl($row[4]);
}
if($row[8] == 0){
$styls = " style='font-weight:bold; color:#333333;'";
}else{
$styls = "";
}
?>				
			
                        <tr> 
                           <td><span class="<?php echo $row[6]; ?>">&nbsp;&nbsp;<i class="<?php echo $row[7]; ?>"></i>&nbsp;&nbsp;&nbsp;</span></td>
                            <td<?php echo $styls; ?>><?php echo $dtpaid; ?></td>
                            <td<?php echo $styls; ?>><?php echo $row[2]; ?></td>
                            <td style="font-weight:bold; color:#000;"><a href="index.php?go=notif&page=view&kode=<?php echo $row[5]; ?>"/><img src="../images/view.png" height="20" alt="" name="images" id="images" class="magnify" /></a></td>
                            <td align="center"><a href="index.php?go=notif&page=delete&kode=<?php echo $row[5]; ?>" onclick="return confirmAction77()"><img src="../images/icon-32-delete_resize.png" width="17" height="22" border="0" title="Delete" /></a></td>
                            
                        </tr>
                                                                    
        
	<?
		}
	?>
              </tbody>
            </table>
            <?php } ?>
</div></div></div></div>