<?php

session_start();

//echo $costcent;

if($_SESSION['dbName']==""){
header("location:../index.php");
}
//if ($trs_id!='' and $transferdt_id=='')
//$transferdt_id=$trs_id;




include("config.inc.php");

include("function.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");



$actionmode = $_POST["actionmode"];
$notification_id = $_POST["notification_id"];
$xx = $_GET["xx"];

if($actionmode == 'update' && $notification_id!=''){

$query = "update notification set notification_checked = $xx where notification_id = $notification_id";
//echo $query ;
$result=mysql_query($query,$connection) or die(mysql_error($connection));
$notification_id='';
$actionmode='';
	
	header ("Location: ./Form_Notifications.php");
	exit;		
}

$mainmode = $_GET['mainmode']; 
if($actionmode == '' && $mainmode == 'openForm' ){
$tablename = $_GET['tablename'];
$desc_code = $_GET['desc_code'];
	echo "<form name='notifications' method='POST' >";
	if($tablename == 'STAFF'){
		echo "<input type='hidden' name='staffcode' value='$desc_code'>";
		$str = "staff.php";
	} else if($tablename == 'VEHICLE'){
		$query = "select vehicle_id from vehicle where vehicle_platenumber;";
		$res = mysql_query($query,$connection);
		$row = mysql_fetch_row($res);
		$vehicle_id = $row[0];
		$str = "Form_Vehicle.php?mode=edit&vehicle_id=$vehicle_id";
	}
	echo "</form>";
	echo "<script>";
	echo "document.notifications.action = '$str';";
	echo "document.notifications.submit();";
	echo "</script>";
	exit;			
}

?>