<?php


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

print <<< HERE

<HTML>
<HEAD>
<TITLE> Journal Type </TITLE>

<style type="text/css">

table.master th { font-size: 14px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
				  border-top: 2 solid #000000;
				  border-bottom: 1 solid #000000;
				 }
table.master td { font-size: 14px; 
                  font-family:Times-New-Roman;
                 }
				 
table.master td.reportfooter { font-size: 14px; 
							   font-weight: bold;
							   font-family:Times-New-Roman;
							   border-top: 1 solid #000000;
							  }
</style>


</HEAD>

<BODY>
HERE;

include("config.inc.php");



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

mysql_select_db($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");

						
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
	//User Access
$querylog=" select ifNull(login_belongstogrp,0) As FI_BelongsToGrp from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['useraccount']."' and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

$now=current_server_time($connection);
$dt=split(" ",$now[0]);
$printdate=split("-",$dt[0]);





	echo "<table border=0 width=100% cellspacing=0 cellpadding=0 class='master' >
		  <col width=100>
		  <col width=170>
		  <col width=150>
		  <col width=100>
		  <col width=80>
		  <col width=50>
		  <col width=50>
		  <col width=50>
		  <col width=50>";

	

	echo "<tr><td height='60'><img src='img/imgheader1.jpg' width='115' height='50' /></td><td align='center'><b><font size=5>Journal Type</font></td><td align='right' ><font size='2'><b>Printed&nbsp;Date&nbsp;&amp;&nbsp;Time:</b>&nbsp;&nbsp;"; 
	echo $printdate[2]."/".$printdate[1]."/".$printdate[0];
	echo "<br>".$dt[1]." ".$dt[2];
	echo "</font></td></tr>";

	echo "<tr >";
	echo "  <th align='left' >Type Name</th>";
	echo "  <th align='left' >Description</th>";  
	echo "  <th align='left' >Join Type Group</th>";   
	echo "  <th align='left' >Related Type</th>";
	echo "  <th align='left' >DBCD</th>";
	echo "  <th align='left' >Visible</th>";
	echo "  <th align='left' >Confirmed Visible</th>";
	echo "  <th align='left' >Type Cash</th>";
	echo "  <th align='left' >Show In Grouping</th>";	
	echo "</tr>";

	$query = "select TYPE_NAME, Type_Visible, Type_Desc, confirmed_visible, jourtype_group, Type_Cash, Related_Type, showin_grouping, Type_dbcd  from jourtype";


	$result= mysql_query($query, $connection);
	$totalrows= mysql_num_rows($result);
	
	
    while($row=mysql_fetch_array($result)){

		$Type_Name = $row[0];
		$jour_visible=$row[1];
		$Desc=$row[2];
		$jour_confirmvisible=$row[3];
		$Jour_TypeGroup=$row[4];
		$jour_typecash=$row[5];
		$jour_Type=$row[6];
		$jour_showgroup=$row[7];
		$dbcd=$row[8];
		
		echo "<tr>";
		echo "  <td align='left' >$Type_Name</td>";
		echo "  <td align='left' >$Desc</td>";
		echo "  <td align='left' >$Jour_TypeGroup</td>";
		echo "  <td align='left' >$jour_Type</td>";
		echo "  <td align='left' >$dbcd</td>";
		echo "  <td align='left' ><input type='checkbox' value='$jour_visible' ";if($jour_visible=='1'){echo'checked ';}echo"disabled></td>";
		echo "  <td align='left' ><input type='checkbox' value='$jour_confirmvisible' ";if($jour_confirmvisible=='1'){echo'checked ';}echo"disabled></td>";
		echo "  <td align='left' ><input type='checkbox' value='$jour_typecash' ";if($jour_typecash=='1'){echo'checked ';}echo"disabled></td>";
		echo "  <td align='left' ><input type='checkbox' value='$jour_showgroup' ";if($jour_showgroup=='1'){echo'checked ';}echo"disabled></td>";
		echo "</tr>";

	}

echo "<tr height='35'><td class='reportfooter'>Total Records: $totalrows </td></tr>";	
echo "</table>";
	
	

function current_server_time($connection){

  $string="Select date_format(NOW(),'%Y-%m-%d %h:%i %p') ";
  $result=mysql_query($string,$connection) or die(mysql_error());
  $now=mysql_fetch_row($result);

  return $now;
}

print <<< HERE

<script language=javascript>
if (typeof(window.print) != 'undefined')
{
    window.print();
}
</script>
</BODY>
</HTML>
HERE;
?>