<?php
require('../config/dbcon.php');
    $query = "SELECT timeout from timeout_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$timeout = $row['timeout'];
    }
    $query = "select screenwidth from width_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$width = $row['screenwidth'];
    }
    $width = $width . "px";
    //$width = '2000';
session_start();
if(isset($_SESSION["user"]))
{
 if((time() - $_SESSION['last_time']) > $timeout) // Time in Seconds
 {
 header("location:../login/logout.php");
 }
 else
 {
 $_SESSION['last_time'] = time();
 //echo "<h1 align='center'>Welcome ".$_SESSION["user"]. "</h1>";
 //echo "<h3 align='center'>Automatic Logout after 1 minute of inactive</h3>";
 //echo "<p align='center'><a href='../login/logout.php'>Logout</a></p>";
 //echo "<p align='center'><a href='../main/welcome.php'>Welcome1</a></p>";
 }
}
else
{
 header('Location:../login/index.php');
}
?>

<html>
<head>
	<title>SSR-Main Menu</title>
</head>
<script type="text/javascript">
	function preventBack() {
		window.history.forward();
	}
	setTimeout("preventBack()", 0);
	window.onunload = function() {
		null
	};
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">  
<title>Main Menu</title>
<link rel = "icon" href = "https:../image/ims.png" type = "image/x-icon">
<link rel="stylesheet" href="../css/style2.css">
<script src="../js/script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="../css/font-awesome.min.css">
<link rel="stylesheet" href="../css/jquery-ui.css">
<link rel="stylesheet" href="../css/bootstrap-theme.min.css">
<script src="../js/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:100,200,400,500,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="stylepanel.css">
<link rel="stylesheet" href="cardstyles.css">
<style>
	*{
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}
	body{
		font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
		background-image: url(background-img.jpg);
		background-size: cover;
		background-attachment: fixed;
	}
	.navbar{
		height: 50px;
		width: 100%;
		padding: 9px 30px;
		background-color: #007bff;
		position: relative;
	}
	.navbar .nav-header{
		display: inline;
	}
	.navbar .nav-header .nav-logo{
		display: inline-block;
		margin-top: -7px;
	}
	.navbar .nav-links{
		display: inline;
		float: left;
		font-size: 18px;
	}
	 
	.navbar .nav-links .loginBtn{
		display: inline-block;
		padding: 5px 5px;
		margin-left: 20px;
		font-size: 17px;
		color: rgb(9, 14, 90);
	}
	.navbar .nav-links a {
		padding: 10px 12px;
		text-decoration: none;
		font-weight: 550;
		color: white;
	}
	/* Hover effects */
	.navbar .nav-links a:hover{
		background-color: rgba(0, 0, 0, 0.3);
	}
	 
	/* responsive navbar toggle button */
	.navbar #nav-check, .navbar .nav-btn{
		display: none;
	}
	 
	@media (max-width:700px) {
	.navbar .nav-btn{
		display: inline-block;
		position: absolute;
		top: 0px;
	right: 0px;
	}
	.navbar .nav-btn label {
		display: inline-block;
		width: 80px;
		height: 70px;
		padding: 25px;
	}
	.navbar .nav-btn label span {
		display: block;
		height: 10px;
		width: 25px;
		border-top: 3px solid #eee;
	}
	.navbar .nav-btn label:hover, .navbar #nav-check:checked ~ .nav-btn label {
		background-color: #007bff;
		transition: all 0.5s ease;
	}
	.navbar .nav-links{
		position: absolute;
		display: block;
		text-align: center;
		width: 50%;
		background-color: #007bff;
		transition: all 0.3s ease-in;
		overflow-y: hidden;
		top: 70px;
		right: 0px;
	}
	.navbar .nav-links a {
		display: block;
	}

	/* when nav toggle button not checked */
	.navbar #nav-check:not(:checked) ~ .nav-links {
		height: 0px;
	}

	/* when nav toggle button is checked */
	.navbar #nav-check:checked ~ .nav-links {
		height: calc(100vh - 70px);
		overflow-y: auto;
	}
	.navbar .nav-links .loginBtn {
		padding: 10px 40px ;
		margin: 20px;
		font-size:  18px;
		font-weight: bold;
		color: rgb(9, 14, 90);
	}
	/* Responsive dropdown code */
	.navbar .nav-links .dropdown, .navbar .nav-links .dropdown2 {
		float: none;
		width: 100%;
	}
	.navbar .nav-links .drop-content, .navbar .nav-links .drop-content2 {
		position: relative;
		background-color: #007bff;
		top: 0px;
		left: 0px;
	}
	/* Text color */
	.navbar .nav-links .drop-content a {
		color: rgb(9, 14, 90);
	}  
	 
	}
	 
	/* Dropdown menu CSS code */
	.dropdown{
		position: relative;
		display: inline-block;
	}
	.drop-content, .drop-content2 {
		display: none;
		position: absolute;
		background-color: #007bff;
		min-width: 300px;
		font-size: 16px;
		top: 34px;
		z-index: 1;
		box-shadow: 0px 10px 25px rgba(0, 0, 0, 0.4);
	}
	/* on hover show dropdown */
	.dropdown:hover .drop-content, .dropdown2:hover .drop-content2 {
		display: block;
	}
	/* drondown links */
	.drop-content a {
		padding: 12px 10px;
		border-bottom: 1px solid rgb(197, 197, 250);
		display: block;
		transition: all 0.5s ease !important;
	}
	.dropBtn .drop-content a:hover {
		background-color: #007bff;
	}
	.dropdown:hover .dropBtn, .dropdown2:hover .dropBtn2 {
		background-color: #007bff;
	}
	.dropdown2 .drop-content2 {
		position: absolute;
		left: 300px;
		top: 126px;
	}
	.dropBtn2 i {
		margin-left: 15px;
	}
</style>
<style>
    label {
        font-size: 15px;
        top: 11px;
        margin-bottom: .5rem;
        margin-left: 5px;
        font-weight:bold;
        display: inline-transparent;
    }
    .the_content{text-align:center !important;}
</style>
<style>
    body { min-height:  100vm; }
</style>
<body style="min-width: <?php echo $width; ?>; width:  auto;">
<div style="min-width: <?php echo $width; ?>; width:  auto;">
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary" style="height: 50px; min-width: <?php echo $width; ?>; width:  auto; background-color: #007bff; font-size:24px;">
        <div class="nav-links">
			<a href="index" href="javascript:void(0);">Home</a>
			<!-- Dropdown menu -->
			<div class="dropdown">
				<a class="dropBtn" href="javascript:void(0);">Masters 
					<i class="fa fa-angle-down"></i>
				</a>
				<div class="drop-content">
					<a href="../party/index">Party Master</a>
					<a href="../truck/index">Truck Master</a>
					<a href="../truckowner/index">Truck Owner Master</a>
					<a href="../supplier/index">Supplier Master</a>
				</div>
			</div>
			<div class="dropdown">
				<a class="dropBtn" href="javascript:void(0);">Transactions 
					<i class="fa fa-angle-down"></i>
				</a>
				<div class="drop-content">
					<a href="../loadingregister/index">Loading Register</a>
					<a href="../loadingedit/index">Loading Edit</a>
					<a href="../reprint/index">Re-Print Bills</a>
					<a href="../receipts/index">Receipts</a>
					<a href="../payments/index">Payments</a>
					<a href="../editbill/index">Edit Bill</a>
					<a href="../audit/index">Audit Report</a>
					<a href="../noofrows/index">Edit Bill Number</a>
				</div>
			</div>
    			<a class="dropBtn" href="../login/logout">LogOut</a>
        </div>
        
            <div style="color:white; font-size:24px; margin-top: 0px;" class="nav-header">
                <div class="nav-logo">
                    <a style="color:white; font-size:28px; margin-top: 50px; margin-left: 350px; text-decoration: none;" href="javascript:void(0);"> Main Menu</a>
                    <a id="demo2" style="color:white; font-size:28px; margin-top: 20px;  margin-left: 450px; text-decoration: none;" href="javascript:void(0);"></a>
                </div>
            </div>
        
    </nav>
</div>

</body>
</html>
<?php
	$date = new DateTime();
	$current_timestamp = $date->getTimestamp();
?>
<script>
    $(document).on('keyup', function(e) {
        if (e.key == "Escape"){
          window.location.href = "../main/index"
        }
    });
</script>
<script>
	flag_time = true;
	timer = '';
	setInterval(function(){phpJavascriptClock();},1000);
	
	function phpJavascriptClock()
	{
		if ( flag_time ) {
		timer = <?php echo $current_timestamp;?>*1000;
		}
		var d = new Date(timer);
		months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
		
		month_array = new Array('January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'Augest', 'September', 'October', 'November', 'December');
		
		day_array = new Array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
		
		currentYear = d.getFullYear();
		month = d.getMonth();
		var currentMonth = months[month];
		var currentMonth1 = month_array[month];
		var currentDate = d.getDate();
		currentDate = currentDate < 10 ? '0'+currentDate : currentDate;
		
		var day = d.getDay();
		current_day = day_array[day];
		var hours = d.getHours();
		var minutes = d.getMinutes();
		var seconds = d.getSeconds();
		
		var ampm = hours >= 12 ? 'PM' : 'AM';
		hours = hours % 12;
		hours = hours ? hours : 12; // the hour ’0′ should be ’12′
		minutes = minutes < 10 ? '0'+minutes : minutes;
		seconds = seconds < 10 ? '0'+seconds : seconds;
		var strTime = hours + ':' + minutes+ ':' + seconds + ' ' + ampm;
		timer = timer + 1000;
		document.getElementById("demo2").innerHTML='Date : ' + currentDate+'-' +(month+1)+'-' +currentYear + ' Time : ' + strTime ;
		flag_time = false;
	}

</script>