<?php
include("common/connection.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
 <script src="js/vendor/jquery-1.12.4.min.js"></script>
 <style>
     
body{
margin:0px;
padding:0px;
font-family: 'Roboto', sans-serif !important;
} 

.wrapper{
float:left;
width:100%;
}

.header_div{
float:left;
width:94%;
padding:10px 3%;
background-color:#006DF0;
text-align:left;
font-size:18px;
color:#fff;
font-weight:600;
margin-bottom:15px;
}

.form_maindiv{
float:left;
width:100%;
margin-bottom:10px;
}

.lable_div{
float:left;
width:100%;
padding-bottom:5px;
text-align:left;
font-size:14px;
color:#000;
font-weight:600;
}

.main_txtbox{
 float:left;
width:100%;   
}

.txtbox{
 float:left;
width:93% !important;
width:40px;
line-height:40px;
background-color:#f7f1f1;
border:1px solid #ece7e7;
text-align:left;
padding-left:3%;
padding-right:3%;
font-size:16px;
color:#000;
outline:0px;
}

.sub_btn{
float:right;
width:120px;
height:40px;
line-height:40px;
background-color:#006DF0;
text-align:center;
font-size:15px;
color:#fff;
font-weight:600;
border:0px;
outline:0px;
cursor:pointer;
margin-top:15px;
}
     
 </style>
</head>
<script>
	function generate_Invoice(per) 
	{
	//alert(per);
	//return false;
	var strt=$("#from_date").val();
	var end=$("#to_date").val();
	//alert(strt);
	//return false;
		$.ajax({
		url:"ajax_generate_invoice.php",
		type:"POST",
		data:'aggrement='+per+'&strt='+strt+'&end='+end,
		success:function(data)
		{
 			//alert(data);
			if(data=="0")
			{
				alert('Roaster not found for this date range');
				return false;
			}
			else if(data=="1")
			{
				alert('From Date should be graeter than previous Invoice Date');
				return false;
			}
			
			else
			{
			alert('Invoice generated successfully');
			window.parent.location.href="invoice_list.php";
			}
		}
		});
	 
	}
	</script>
<body>
    <div class="wrapper">
     <div class="header_div">Generate Invoice</div>
     <div class="form_maindiv">
         
       <div class="lable_div">From Date</div>  
       <div class="main_txtbox"> <input name="from_date" id="from_date" type="date" class="txtbox" autocomplete="off" /> </div>
         
     </div>
     
         <div class="form_maindiv">
         
       <div class="lable_div">To Date</div>  
       <div class="main_txtbox"> <input name="to_date" id="to_date" type="date" class="txtbox" autocomplete="off" /> </div>
         
     </div>
     
     <div class="form_maindiv"><input name="" type="button" name="submit" Value="Submit" class="sub_btn" onclick="generate_Invoice(<?php echo $_REQUEST['id'] ?>)" /></div>
        
    </div>
</body>
</html>
