<?php
session_start();
require_once 'includes/database.php';
include 'includes/funcs.php';
if (!isset($_SESSION['reusername'])) { echo 'Sorry You Dont Have permissions to View this Page!'; exit();}
else {$user = $_SESSION['reusername'];}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <script type="text/javascript" src="js/jquery-1.10.2.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.10.4.custom.js"></script>
        <link rel="stylesheet" href="css/allcss.css" type="text/css" />
        <link rel="stylesheet" href="css/jquery-ui-1.10.4.custom.css" type="text/css" />
        <style>
            html, body {margin:0; padding:0; height:100%; width:100%; min-width:100%; min-height:100%; overflow:scroll;z-index: 100;}
        </style>
<script type="text/javascript">

$(function() {
	// dialog boxes
    $( "#dialog:ui-dialog" ).dialog( "destroy" );

		$( "#dialog-message" ).dialog({
			modal: true,
			width: 370,
			buttons: {
				Ok: function() {
					window.location.replace("desktop.php");
				}
			}
		});
});

</script>

</head>
    
<body>
<?php
if(isset($_REQUEST['j'])){
	$jcno = $_REQUEST['j'];
	$db=new MySQLDatabase();
	$db->open_connection();
	$query = "DELETE FROM jcards WHERE jcno = '$jcno';";
	$result = mysqli_query($db->connection, $query) or die(mysqli_error($db->connection) );
	$query = "UPDATE devstock SET jcno = 0 WHERE jcno = '$jcno';";
	$result = mysqli_query($db->connection, $query) or die(mysqli_error($db->connection) );
	echo '<div id="dialog-message" title="Delete Confirmation !">
	<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
	JobCard No.'.$jcno.' Deleted!</p></div>';
	$db->close_connection();
}	
?>

</body>


</html>