<?php
function draw_fuel($connection,$carfuel_id){
	
	echo "<table width='1000px' border='0'>
		<col width='30px'><col width='30px'>
		<col width='150px'>
		<col width='150px'><col width='100px'>
		<col width='100px'><col width='150px'>
		<col width='250px'>
		<col width='30px'>
		<tr height='20px' class='Search-Label-bg'>
			<td  align='center' ><span class='style44'></span></td>
			<td  align='center' ><span class='style44'></td>			
			<td  align='center' ><span class='style44'>vehicle</td>			
			<td align='center'><span class='style44'>Date</span></td>
			<td align='center'><span class='style44'>Quantity</span></td>
			<td align='center'><span class='style44'>Amount</span></td>
			<td align='center'><span class='style44'>Total</span></td>
			<td align='center'><span class='style44'>Remark</span></td>
			<td  align='center' ><span class='style44'></span></td>
		</tr>";
	
	$carfueltype=" select date_format(f_date,'%d/%m/%Y'),f_qty,f_amount, f_total,f_remark,f_id ,car_fuel.vehicle_id, vehicle_platenumber ".
				 " from car_fuel left join vehicle on vehicle.vehicle_id = car_fuel.vehicle_id  where f_id='$carfuel_id'";

	$carfuelres=mysql_query($carfueltype, $connection);
	while($rowcarfuelres=mysql_fetch_row($carfuelres)){
		$newdate		= $rowcarfuelres[0];
		$newqty			= $rowcarfuelres[1];
		$newamount		= $rowcarfuelres[2];
		$newtotal		= $rowcarfuelres[3];
		$newremark		= $rowcarfuelres[4];
		$vehicle_id 	= $rowcarfuelres[6];
		$vehicle_platenumber = $rowcarfuelres[7];
	}
	echo "<tr height='20px'>";
		echo"<td align = 'center'></td>";
		echo"<td align = 'center' >	";
		echo "<input type='hidden' name='fuel_id' value='$carfuel_id'>";
			echo "<img src='img/undo-1.png' onmouseover=\"style.cursor='pointer'\" title=Clear' onclick=\"clearfields('$fueltype_id');\" style='cursor: pointer;' height='20' width='20'></span>
		</td>";
		
		if ($newdate==''){$newdate=date("d/m/Y");}
		echo "<td ><input type='hidden' value= '$vehicle_id'  name='vehicle_id' id='vehicle_id'>
			<input type='text' value= '$vehicle_platenumber'  name='vehicle_platenumber' id='vehicle_platenumber' style='width: 130px;' readonly>
			<img src='img/btnopen.jpg' title=' Select Project ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showvehiclelist(0); '  />
							
		
		</td>";
		echo "<td ><input type='text' value= $newdate name='newdate' id='newdate' style='width: 100px;'>
			<a HREF='#' onClick=\"displayCalendar(document.fueltype.newdate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >
			<image src='./img/cal.gif' border=0 align=center ></image></a></td>";
		echo "<td ><input type='text' value= '$newqty' name='newqty' id='newqty' style='width: 100px;'  onkeyup=\"calculatetotal(); return false;\" >
		
		
		</td>";
		echo "<td ><input type='text' value= '$newamount' name='newamount' id='newamount' style='width: 100px;' onkeyup=\"calculatetotal(); return false;\"></td>";
		echo "<td ><input type='text' value= '$newtotal' name='newtotal' id='newtotal' style='width:150px;' readonly></td>";
		echo "<td ><input type='text' value= '$newremark' name='newremark' id='newremark' style='width: 250px;' >
		
		
		</td>";
		
		echo"<td align = 'center' >
			<input id='imgSubmit_1' onclick=\"postchangecarfuel('$fueltype_id','$carfuel_id'); return false;\" title='Submit Record' style='width:20px; height:20px; vertical-align:bottom; cursor:pointer; outline:none; border:0px; background-image:url(img/confirm-1.png)' type='button'>
		</td>";
	echo "</tr>";
	
	
	echo "<tr height='15px'><td></td></tr>";
	
	echo "<div id ='fuelresults'></div>";
					////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	$carfueloftype="select date_format(f_date,'%d-%m-%Y'),f_qty,f_amount, f_total,f_remark,f_id, car_fuel.vehicle_id, vehicle_platenumber from car_fuel left join vehicle on vehicle.vehicle_id = car_fuel.vehicle_id ";
	//where fueltype_id='$fueltype_id'";

	
	$resultcarfueloftype=mysql_query($carfueloftype, $connection);
	$i=0;
	echo "<tr><td colspan='8'><div style='overflow-y: scroll;overflow-x: hidden;height:350px;'>
	<table border='0' cellspaving=0 cellpadding=0 width='1000px'>
			<col width='30px'><col width='30px'>
		<col width='150px'>
		<col width='150px'><col width='100px'>
		<col width='100px'><col width='150px'>
		<col width='250px'>
		<col width='30px'>";
		
	while($rowcarfuel=mysql_fetch_row($resultcarfueloftype)){
		
		if($i%2==0)
			$Color="background-color:#E6E6E6;";
		else			
			$Color="background-color:#F7F7F7;";	
		if($carfuel_id == $rowcarfuel[5]) $Color="background-color:#1e87a5;";
		
		echo "<tr height='20px' style='$Color'>";
		echo"<td align = 'center'><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\" name='' title='Delete' onclick=\" deletecarfuel('$rowcarfuel[5]','$fueltype_id');\"></td>";
		echo"<td align = 'center' ><img src='img/edit.png' onmouseover=\"style.cursor='pointer'\"  title='Save' onclick=\"getcarfuel('$rowcarfuel[5]','$fueltype_id');\"></td>";
		echo "<td >$rowcarfuel[7]</td>";
		echo "<td >$rowcarfuel[0]</td>";
		echo "<td >$rowcarfuel[1]</td>";
		echo "<td >$rowcarfuel[2]</td>";
		echo "<td >$rowcarfuel[3]</td>";
		echo "<td >$rowcarfuel[4]</td>";
	
		echo "<td></td>";
		echo "</tr>";
		$i++;
	}
	echo "</table></div></td></tr>";
		//////////////////////////////////////////////////////////////////////////////////
		echo "</table>";
	
}
?>