<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");

$connection = mysql_connect($config['dbServer'] , $config['dbUser'] , $config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'] , $connection) or die("Could not find DB");

function draw_closingvat($connection){
	$bleft   = "border-left: 1px solid black";
	$bright	 = "border-right: 1px solid black";
	$btop	 = "border-top: 1px solid black";
	$bbottom = "border-bottom: 1px solid black";
	
	echo "<table border='0' cellpadding='0' cellspacing='0' align='left' valign='center' style='padding-left:40px;width:800px;' >";
	echo "<col width=40px><col width=120px><col width=300px><col width=300px><col width=40px>";
	echo "<tr height='30px' bgcolor='#faebd7'>
				<td style='$bleft;$bright;$btop;$bbottom;'></td>
				<td align='center' style='$bright;$btop;$bbottom;'><b>Transaction</b></td>
				<td align='center' style='$bright;$btop;$bbottom;'><b>Ledger Code</b></td>
				<td align='center' style='$bright;$btop;$bbottom;'><b>Ledger Group</b></td>
				<td style='$bright;$btop;$bbottom;'></td>
		  </tr>";
	$i=0;
	$queryTemp = "select Transaction, Debit_LedgerNumber as ledgercode, Credit_LedgerNumber as groupcode from closingtemplate where  upper(TRANSACTION_TYPE) = 'VAT' ";
	$resTemp = mysql_query($queryTemp, $connection);
	while ($rwTemp = mysql_fetch_array($resTemp)){
		
		echo "<tr height='30px' >
				<td align='center' style='$bleft;$bright;$bbottom;'><img src='img/delete.png' onmouseover=\"style.cursor='pointer'\"   title='Save' onclick=\"deleteTemp('$i');\" style='cursor: pointer;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='transaction[$i]' id='transaction[$i]' value='$rwTemp[0]' style='width:110px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='ledgercode[$i]' id='ledgercode[$i]' value='$rwTemp[1]' style='width:250px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='groupcode[$i]' id='groupcode[$i]' value='$rwTemp[2]' style='width:250px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" title='Save' onclick=\"insertTemp('$i');\" style='cursor: pointer;'></td>
			 </tr>";
		$i++;
	}
	
	echo "<tr height='30px' >
				<td align='center' style='$bleft;$bright;$bbottom;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='transaction[$i]' id='transaction[$i]' value='$transaction[$i]' style='width:110px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='ledgercode[$i]' id='ledgercode[$i]' value='$ledgercode[$i]' style='width:250px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><input type='text' name='groupcode[$i]' id='groupcode[$i]' value='$groupcode[$i]' style='width:250px; border:none;'></td>
				<td align='center' style='$bright;$bbottom;'><img src='img/confirm.png' onmouseover=\"style.cursor='pointer'\" title='Save' onclick=\"insertTemp('$i');\" style='cursor: pointer;'></td>
			 </tr>";
			 
	echo "</table>";
}
?>