<?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');
}
?>
<?php
    require('../config/dbcon.php');
    $query = "SELECT company_st_code from company_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$company_st_code = $row['company_st_code'];
    }
?>
<html>
<head>
	<title>IMS-Customer Master</title>
</head>
<script type="text/javascript">
	function preventBack() {
		window.history.forward();
	}
	setTimeout("preventBack()", 0);
	window.onunload = function() {
		null
	};
</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>
.container{
  max-width: 100%;
}
.formfield{
  position: relative;
  box-sizing: border-box;
  float: left;
  margin: auto;
  padding: 0px;
  border: 0px;
  font-size: 1em;
}
.formfield *{
  box-sizing: border-box;
  color: #007bff;
}
.formfield>input, .formfield>label{
  padding: 0.8em;
  margin: 0.5em;
  width: 100%;
}
.formfield>input{
  border: 1px solid #007bff;
  margin-left:-5px;
  border-radius: 1.5em;
  outline: none;
}
.formfield>label{
  position: absolute;
  margin-left:-10px;
  top: 0;
  bottom: 0;
  left: 0;
  color: #ccc;
}
input:focus + label, input:valid + label{
  color: #0E0E0E;
  font-size: 0.8em;
  width: auto;
  height: 1.3em;
  padding: 0px 0.5em 0px 0.5em;
  margin-left:-20px;
  /*outline: 1px solid red; /*for debugigng purposes only*/
  background: white;
  transition: 0.1s ease-in-out;
  top: -0.6em;
  left: 2em;
}
</style>
<style>
    body { min-height: 100vh; }
</style>
<body style="width: 100%;">
<div style="width: <?php echo $width; ?>; align="center">
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary" style="height: 62px; width: <?php echo $width; ?>; 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">
        <input style = "background-color: #007bff; font-size:24px; height : 55px; margin-top : px;" type="button" onclick="exportToExcel('tblexportData', 'Export-data')" value="Export to Excel">
        <input style = "background-color: #007bff; font-size:24px; width:200px; height : 55px; margin-top : px;" type="button" onclick="location.href='../invoice/index';" value="Go to Invoice">
        <h1 style="color:white; font-size:24px; margin-top: -40px;" class="text-primary" align="center">Customer Master</h1>
        <h1 style="color:white; font-size:24px; margin-top : -40px;margin-right :20px;" class="text-primary" id="demo2" align="right"></h1>
    </nav>
	<div class="container" style="width: <?php echo $width; ?>; margin-left: 0px; margin-top: -10px;">
		<center>
		    <div style="width:11%;" class="formfield" id="acc_typefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" value="SDE" name="acc_type" id="acc_type" required>
        		<label style="font-size:15px; font-weight:bold;" alt="acc_type" for="acc_type" placeholder="acc_type">Acc_Type</label>
        	</div>
        	<div style="width:11%; margin-left: 10px;" class="formfield" id="customer_codefield">
        	    <input type="hidden" name="company_st_code" class="roundedCategory" id="company_st_code" value="<?php echo $company_st_code; ?>" autocomplete="off">
        		<input style="height:40px; font-size:16px; font-weight:bold; margin-left:0px;" type="text" name="customer_code" id="customer_code" required>
        		<label style="font-size:15px; font-weight:bold;" alt="customer_code" for="customer_code" placeholder="customer_code">Customer_Code</label>
        	</div>
        	<div  style="width:25%; margin-left: 10px;"class="formfield" id="customer_namefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left:0px;" type="text" name="customer_name" id="customer_name" required>
        		<label style="font-size:15px; font-weight:bold;" alt="customer_name" for="customer_name" placeholder="customer_name">Customer_Name</label>
        	</div>
        	<div  style="width:25%; margin-left: 10px;"class="formfield" id="customer_namefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left:0px;" type="text" name="cust_address_one" id="cust_address_one" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_address_one" for="cust_address_one" placeholder="cust_address_one">cust_address_one</label>
        	</div>
        	<div  style="width:25%; margin-left: 10px;"class="formfield" id="cust_address_twofield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left:0px;" type="text" name="cust_address_two" id="cust_address_two" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_address_two" for="cust_address_two" placeholder="cust_address_two">Cust_Address_Two</label>
        	</div>
		</center>
	</div>
	<div class="container" style="width: <?php echo $width; ?>; margin-left: 0px; margin-top: 0px;">
		<center>
	        <div style="width:22.5%;" class="formfield" id="cust_address_threefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_address_three" id="cust_address_three" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_address_three" for="cust_address_three" placeholder="cust_address_three">Cust_Address_Three</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="cust_placefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_place" id="cust_place" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_place" for="cust_place" placeholder="cust_place">Cust_Place</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="cust_pin_codefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_pin_code" id="cust_pin_code" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_pin_code" for="cust_pin_code" placeholder="cust_pin_code">Cust_Pin_Code</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="cust_st_codefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_st_code" id="cust_st_code" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_st_code" for="cust_st_code" placeholder="cust_st_code">Cust_St_Code</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="cust_st_namefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_st_name" id="cust_st_name" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_st_name" for="cust_st_name" placeholder="cust_st_name">Cust_St_Name</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="cust_gstnofield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_gstno" id="cust_gstno" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_gstno" for="cust_gstno" placeholder="cust_gstno">Cust_Gstno</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="cust_pan_nofield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_pan_no" id="cust_pan_no" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_pan_no" for="cust_pan_no" placeholder="cust_pan_no">Cust_Pan_No</label>
        	</div>
		</center>
	</div>
	<div class="container" style="width: <?php echo $width; ?>; margin-left: 0px; margin-top: 0px;">
		<center>
		    <div style="width:11%;" class="formfield" id="tax_codefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="tax_code" id="tax_code" required>
        		<label style="font-size:15px; font-weight:bold;" alt="tax_code" for="tax_code" placeholder="tax_code">Tax_Code</label>
        	</div>
        	<div style="width:11%; margin-left: 10px;" class="formfield" id="cust_aadhar_nofield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_aadhar_no" id="cust_aadhar_no" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_aadhar_no" for="cust_aadhar_no" placeholder="cust_aadhar_no">Cust_Aadhar_no</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="cont_personfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cont_person" id="cont_person" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cont_person" for="cont_person" placeholder="cont_person">Cont_Person</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="cust_phonefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_phone" id="cust_phone" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_phone" for="cust_phone" placeholder="cust_phone">Cust_Phone</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="cust_mobilefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_mobile" id="cust_mobile" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_mobile" for="cust_mobile" placeholder="cust_mobile">Cust_Mobile</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="cust_emailfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="cust_email" id="cust_email" required>
        		<label style="font-size:15px; font-weight:bold;" alt="cust_email" for="cust_email" placeholder="cust_email">Cust_Email</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="openingfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="number" name="opening" id="opening" required>
        		<label style="font-size:15px; font-weight:bold;" alt="opening" for="opening" placeholder="Opening">Opening</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="debitfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="number" name="debit" id="debit" required>
        		<label style="font-size:15px; font-weight:bold;" alt="debit" for="debit" placeholder="debit">Debit</label>
        	</div>
		</center>
	</div>
	<div class="container" style="width: <?php echo $width; ?>; margin-left: 0px; margin-top: 0px;">
		<center>
		    <div style="width:11%; margin-left: 0px;" class="formfield" id="creditfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="number" name="credit" id="credit" required>
        		<label style="font-size:15px; font-weight:bold;" alt="credit" for="credit" placeholder="credit">Credit</label>
        	</div>
        	<div style="width:11%; margin-left: 10px;" class="formfield" id="clbalancefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="number" name="clbalance" id="clbalance" required>
        		<label style="font-size:15px; font-weight:bold;" alt="clbalance" for="clbalance" placeholder="clbalance">Cl_Balance</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="transporter_namefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="transporter_name" id="transporter_name" required>
        		<label style="font-size:15px; font-weight:bold;" alt="transporter_name" for="transporter_name" placeholder="Transporter_Name">Transporter_Name</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="banknamefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="bankname" id="bankname" required>
        		<label style="font-size:15px; font-weight:bold;" alt="bankname" for="bankname" placeholder="bankname">bankname</label>
        	</div>
        	<div style="width:12%; margin-left: 10px;" class="formfield" id="bankaccnofield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="bankaccno" id="bankaccno" required>
        		<label style="font-size:15px; font-weight:bold;" alt="bankaccno" for="bankaccno" placeholder="bankaccno">bankaccno</label>
        	</div>
        	<div style="width:12.5%; margin-left: 10px;" class="formfield" id="bankaccnamefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="bankaccname" id="bankaccname" required>
        		<label style="font-size:15px; font-weight:bold;" alt="bankaccname" for="bankaccname" placeholder="bankaccname">bankaccname</label>
        	</div>
        	<div style="width:7.5%; margin-left: 10px;" class="formfield" id="ifsccodefield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="ifsccode" id="ifsccode" required>
        		<label style="font-size:15px; font-weight:bold;" alt="ifsccode" for="ifsccode" placeholder="ifsccode">ifsccode</label>
        	</div>
        	<div style="width:7.5%; margin-left: 10px;" class="formfield" id="due_daysfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="number" name="due_days" id="due_days" required>
        		<label style="font-size:15px; font-weight:bold;" alt="due_days" for="due_days" placeholder="due_days">due_days</label>
        	</div>
        	<div style="width:8.8%; margin-left: 10px;" class="formfield" id="remarksfield">
        		<input style="height:40px;font-size:16px; font-weight:bold; margin-left: 0px;" type="text" name="remarks" id="remarks" required>
        		<label style="font-size:15px; font-weight:bold;" alt="remarks" for="remarks" placeholder="remarks">remarks</label>
        	</div>
		</center>
	</div>
	<div style="margin-top : -10px; width:<?php echo $width; ?>" align="center">
		<input type="hidden" name="user_id" id="user_id" />
		<input style = "background-color: #007bff; height : 45px; margin-top : -8px;" type="button" name="action" id="action" value="Add">
	</div>
	<div style="width: <?php echo $width; ?>; margin-left : 10px; margin-top : 5px; height: 45px;" class=container">
		<div class="form-group">
		    <center>
    			<div class="input-group">
    			    <input style ="margin-left : 0px; width : 1600px; height:40px; font-size:20px; font-weight:bold;" name="search_text" id="search_text" type="text" placeholder="search" alt="search">
    			</div>
			</center>
		</div>		
	</div>
	<div style="margin-top : 0px; margin-left : 10px; width: <?php echo $width; ?> margin-right : 20px; font-size:20px; margin-left: 0px; margin-top: 0px;" id="result" class="table-responsive"></div>
	<div style="height: 60px; margin-left:0px; margin-top:0px; font-size:30px;" class="success"></div>
	<div style="height: 60px; margin-left:0px; margin-top:0px; font-size:30px;" class="error"></div>
</div>
</body>
</html>
<?php
	$date = new DateTime();
	$current_timestamp = $date->getTimestamp();
?>
<script type="text/javascript" src="app.js"></script>
<script>
document.getElementById('customer_code').readOnly = true;
    $(document).on('keyup', function(e) {
        if (e.key == "Escape"){
          window.location.href = "../main/index"
        }
    });
</script>