<?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'];
    }
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');
}
?>
<title>Edit Bill Number</title>
<link rel = "icon" href = "https:../image/ims.png" type = "image/x-icon">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />		
<style>
	body{
		font-family:verdana;
	}
	.container{width:500px;margin: 0 auto;}
	h3{line-height:20px;font-size:20px;}
	input{display:block;width:350px;height:20px;margin:10px 0;}
	textarea{display:block;width:350px;margin:10px 0;}
	button{background:green; border:1px solid green;width:70px;height:30px;color:#ffffff}
</style>
<SCRIPT language=Javascript>
       <!--
    function isNumberKey(evt)
    {
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
          return true;
    }
</SCRIPT>
<script src='../js/jquery-3.1.1.min.js' type='text/javascript'></script>
<script src='../js/jquery-ui.min.js' type='text/javascript'></script>
<link href="../css/style.css" rel="stylesheet" />
<link href="../css/style1.css" rel="stylesheet" />
<link href='../css/jquery-ui.min.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../css/all.css">
<link href="../css/bootstrap.min.css" rel="stylesheet" />
<link href="../css/font-awesome.min.css" rel="stylesheet" />
<link href="../css/styleg.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.placeholder.label.js"></script>
<style>
    label {
        font-size: 15px;
        top: 11px;
        margin-bottom: .5rem;
        margin-left: 5px;
        font-weight:bold;
        display: inline-transparent;
    }
</style>
<?php
require('../config/dbcon.php');
require('../config/dbcon.php');
$query = "Select * from control_mst where description='BILL'";
$result =mysqli_query($connect, $query) or die ( mysqli_error());
$row = mysqli_fetch_array($result);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Update Record</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<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="min-width: <?php echo $width; ?>; width: auto; height: 62px; background-color: #007bff; font-size:24px;">
    <input style = "background-color: #007bff; font-size:24px; width:100px; height : 55px; margin-top : px;" type="button" onclick="location.href='../main/index';" value="Home">
    <h1 style="color:white; font-size:24px; margin-top: -40px;" class="text-primary" align="center">Edit Bill Number</h1>
    <h1 style="color:white; font-size:24px; margin-top : -40px;margin-right :20px;" class="text-primary" id="demo2" align="right"></h1>
</nav>
<?php
$status = "";
if(isset($_POST['new']) && $_POST['new']==1)
{
$update="update control_mst set srno = '".$_REQUEST['noofrow']."' where description='BILL'";
mysqli_query($connect, $update) or die(mysqli_error());
if($update)
	{	
		//header("Location: ../customer/view.php");
		echo 
		'<div style = "width: 99.4%;"  class="alert alert-success" role="alert">
			Number Of Row Successfully Updated
        </div>';
		header("Refresh: 3; ../main/index.php");
	}
	else
	{
		echo 
		'<div style = "width: 99.4%;"  class="alert alert-danger" role="alert">
			Number Of Row Not Updated
        </div>';
		header("Refresh: 3; ../main/index.php");
	}
}else {
?>
<div class="container" style = "min-width: <?php echo $width; ?>; width: auto;">
	<form name="form" method="post" action="">
	<input type="hidden" name="new" value="1" />
	<input name="noofrow" type="hidden" value="<?php echo $row['srno'];?>"/>
	<center>
		<tr>
			<label style="font-size:20px;font-weight:bold;min-width: <?php echo $width; ?>; width: auto;">Bill Number</label>			
			<input type="text" name="noofrow" style="font-size:20px;font-weight:bold; width: 400px; height:40px; text-align : center;" class="roundedCategory" onfocus="this.select();" onkeypress="return isNumberKey(event)" id="noofrow" value="<?php echo $row['srno'];?>" autocomplete = "off" required autofocus>
			<input type="submit" name="submit" class="btn btn-info" style="width:20%; font-size:18px; margin-top: -0px; background-color:#0066ff; height:40px; text-align: center"  value="Update" />
		<tr>
		
	</center>	
	</form>
	<?php } ?>
	<br />
</div>
</div>
</body>
<center>
<!--div style="margin-left : 30px; font-size:35px; color:blue; margin-right : 30px;">
This page is to modify the number of rows to show in all table of this inventory program.
</div-->
</center>
</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>