<!DOCTYPE html>
<html>
<head>
<title>Load Data</title>
	<link href="style.css" rel="stylesheet" type="text/css" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
	<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
<div class="center">

<div class="header">
</div>

<div class="row">

<div class="col-3 right">
<div class="aside">
<?php include("tonsin.php");?>
<?php include("tonsintot.php");?>
</div>
</div>
<?php

$dbName = "G:\CBM\SC\data\D_SCALE.mdb";
if (!file_exists($dbName)) {
    die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;");

//select data from db
$sql = "SELECT `Load Data`.`Load No`,
				`Load Data`.`Crop Day`,
				`Load Data`.`Tract No`,
				`Load Data`.`Gross Wt`,
				`Load Data`.`In Tare`,
				`Load Data`.Tons,
				`Load Data`.`In Time`,
				`Load Data`.`Out Time`,
				INSCALE.farmer,
				INSCALE.REMTONs,
				INSCALE.hauled
		FROM `Load Data` RIGHT JOIN INSCALE ON `Load Data`.`Load No` = INSCALE.Load 
		WHERE `Crop Day` = ( SELECT Max(`Crop Day`)FROM `Load Data`)
		ORDER BY `Crop Day`, `Load No` DESC"; 
	
				
$result = $db->query($sql);
$tonsin = 0;
$tonsin2 = 0;
 
?>
<div class="col-6">
<table style="margin: 0px auto;">
    <tr>
		<th>
		<form action="search.php"> 
		<?php include("dayselect.php");?>
		<?php include("growerselect.php");?><br>
		<input id="option" type="checkbox" name="over" value="100000">
		<label for="option"><span></span>OVERLOAD</label>
		<input type="submit" value="Search" /> 
		</form>
		</th>
	</tr>
</table>
<table style="margin: 0px auto;" class="stat">
    <tr>
	     <th>Live Scale Load Data</th>
     </tr>
</table>	 
<table  class="stat">
   <thead>
    <tr>
		 <th>Load</th>
		 <th>Day</th>
		 <th>Tract</th>
		 <th>Grower</th>
         <th>Gross</th>
		 <th>Tare</th>
		 <th>Tons</th>
		 <th>Hauled</th>
		 <th>Remaining</th>
    </tr>
   </thead>
<?php
  while ($row = $result->fetch())
 {
	 echo "<tr>";
	     echo "<td>".$row [ 'Load No' ]."</td>";
		 echo "<td><b>".$row [ 'Crop Day' ]."</b></td>";
		 echo "<td>".$row [ 'Tract No' ]."</td>";
		 echo "<td>".$row [ 'farmer' ]."</td>";
		 echo "<td>".$row [ 'Gross Wt' ]." </td>";
		 echo "<td>".$row [ 'In Tare' ]." </td>";
		 echo "<td>".$row [ 'Tons' ]."</td>";
		 echo "<td>".$row [ 'hauled' ]." Tons</td>";
		 echo "<td>".$row [ 'REMTONs' ]." Tons</td>";
	 echo "</tr>";
 }
 
 //end

?>
</table>

</div>
<a href="#" class="back-to-top">Back to Top</a>
</div>
<?php include 'footer.php';?>
<script type="text/javascript">
// create the back to top button
$('body').prepend('<a href="#" class="back-to-top">Back to Top</a>');

var amountScrolled = 300;

$(window).scroll(function() {
	if ($(window).scrollTop() > amountScrolled) {
		$('a.back-to-top').fadeIn('slow');
	} else {
		$('a.back-to-top').fadeOut('slow');
	}
});

$('a.back-to-top, a.simple-back-to-top').click(function() {
	$('body').animate({
		scrollTop: 0
	}, 'fast');
	return false;
});
</script>
</body>
</html>
