<?php


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

include("config.inc.php");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");


$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");


$querylog="SELECT RA_TransactionJV as loginaccess, ExporttoExcel as exportaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['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);
	}
	//echo $loginaccess;
if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	
	

$querylog="select * from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['useraccount']."'";
$resultlog=mysql_query($querylog) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
extract($rows);

}
$printaccess=$Print;

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostcenterDt,0) As Module_CostCenterDt ".
			 " From Module ";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}



print <<< HERE


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<link rel="stylesheet" href="default.css" type="text/css" /></link>

<script language="JavaScript" src="CalendarPopup.js" ></script>
<script type="text/javascript" language="javascript">

function showlistclient(str){

  window.open('select_client.php?item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistProject(str){

  window.open('List_Project_Reports.php?frm=2&item='+str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistCostcenter(str){

  window.open('List_Costcenter_Reports.php?frm=2&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function PrintPreview(printaccess) {
	var str = '';
	x=document.form1;
	
	var fromdate = x.fromdate.value;
	var todate   = x.todate.value;
	var fromref= x.fromref.value;
    var toref= x.toref.value;
	var fromclient = x.fromclient.value;
    var toclient = x.toclient.value;
	var fromcostcent = x.fromcostcent.value;
	var fromproject = x.fromproject.value;
	
	for (var i=0; i < x.date.length; i++)
	{
		if (x.date[i].checked)
		{
			var vardate = x.date[i].value;
		}
	}
	  	
		for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
			var varcurrency = x.currency[i].value;
		}
	}
	
	varDetail = 0;
  if (x.Detail.checked)
    varDetail = 1;

		str = 'Rep_listofPurchasesJV.php?fromdate='+fromdate+'&todate='+todate+'&fromref='+fromref+'&toref='+toref+'&fromclient='+fromclient+'&toclient='+toclient+'&fromcostcent='+fromcostcent+'&fromproject='+fromproject+'&option='+vardate+'&varcurrency='+varcurrency+'&varDetail='+varDetail ;
	if (printaccess==1)
		window.open(str);
	else	
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
	
	 
}

function ExportExcel(printaccess) {
	var str = '';
	x=document.form1;
	
	var fromdate = x.fromdate.value;
	var todate   = x.todate.value;
	var fromref= x.fromref.value;
    var toref= x.toref.value;
	var fromclient = x.fromclient.value;
    var toclient = x.toclient.value;
	var fromcostcent = x.fromcostcent.value;
	var fromproject = x.fromproject.value;
	
	for (var i=0; i < x.date.length; i++)
	{
		if (x.date[i].checked)
		{
			var vardate = x.date[i].value;
		}
	}
	  	
		for (var i=0; i < x.currency.length; i++)
	{
		if (x.currency[i].checked)
		{
			var varcurrency = x.currency[i].value;
		}
	}
	
	varDetail = 0;
  if (x.Detail.checked)
    varDetail = 1;

		str = 'Exp_listofPurchasesJV.php?fromdate='+fromdate+'&todate='+todate+'&fromref='+fromref+'&toref='+toref+'&fromclient='+fromclient+'&toclient='+toclient+'&fromcostcent='+fromcostcent+'&fromproject='+fromproject+'&option='+vardate+'&varcurrency='+varcurrency+'&varDetail='+varDetail ;
	if (printaccess==1)
		window.open(str);
	else	
		window.open(str,"Report", "width=900,height=600,screenX=0,left=50,screenY=0,top=0,status=no,menubar=no,scrollbars=yes,resizable=yes");
	
	 
}

	
</script>


<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.style1 {
	color: #FF0000;
	font-family: "Times New Roman", Times, serif;
	font-size: 20px;
}
.style8 {font-size: 11px; color: #999999; font-weight: bold; }
.style11 {font-size: 11px}
body {
	margin-top: 0px;
}

</style>

<title>List Of Purchases JV</title>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20101112" media="screen"></link>
<script type="text/javascript" src="dhtmlgoodies_calendar.js?random=20100118"></script>

</head>
<body>
HERE;

echo "<form id='form1' name='form1' method='post' action='$_SERVER[PHP_SELF]'>";
echo "  <table border='0' align='center' width='100%'>";

echo "  <tr><td colspan='7' align='left' valign='top'>";

include_once("MenuBar.php");

print <<< HERE
       </td>
      </tr>
       <th height="15" colspan="7" align="left" valign="top"><span class="style3">List Of Purchases JV</span></th>
      </tr>

HERE;
	  
echo"<td width='25%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'> ";
echo"<label>";

if ($_POST['date']=="1" || $_POST['date']=="")
    echo "<input name='date' id='date' type='radio' value='1' checked />";
else	
    echo "<input name='date' id='date' type='radio' value='1' />";
	
echo"</label> ";
echo"Date</span></td>";
echo"<td width='25%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

if ($_POST['date']=="2" )
    echo "<input name='date' id='date' type='radio' value='2' checked />";
else	
   echo "<input name='date' id='date' type='radio' value='2' />";				

echo"</label>";
echo"Reference</span></td>";

echo"<td align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

echo"</label>";
echo"Currency </span></td>";

echo"<td  bgcolor='#F5F5F5'>";
echo"<span class='style8'><label>";
echo"<input name='Detail' type='checkbox' id='Detail' value='1'>";
echo"With Detail</label></span></td>";





echo"    <tr>";
echo"      <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"      <td width='20%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"      <input type='text' name='fromdate' value='$fromdate' maxlength='10' size='10'>";
echo"      <a href='#' onClick=\"displayCalendar(document.form1.fromdate,'dd/mm/yyyy',this); return false; \" name='anchor1' id='anchor1'><image src='./img/cal.gif' border=0 align=center></image></a></span></td>";




echo"      <td width='5%' align='center' bgcolor='#F5F5F5' class='style8'>From</td>";
echo"      <td width='20%' bgcolor='#F5F5F5' class='style8'><label>";
echo"      <input type='text' name='fromref' value='$fromref' size='10'>";
echo"      </label></td>";



echo"<td valign= 'top' align='left' bgcolor='#F5F5F5' rowspan='2' colspan='2'>";
echo"<span class='style8'><label>";
 echo "<input name='currency' id='currency' type='radio' value='1' checked />";
 echo"</label>";
echo"Currency</span>";


echo"<br><span class='style8'>";
echo"<label>";

   echo "<input name='currency' id='currency' type='radio' value='2' />";				
echo"</label>";
echo"NGN</span>";

echo"<br><span class='style8'>";
echo"<label>";

   echo "<input name='currency' id='currency' type='radio' value='3' />";				
echo"</label>";
echo"USD</span>";
echo"</td>";





echo"    <tr>";
echo"      <td width='5%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"      <td width='20%' valign='top' bgcolor='#F5F5F5'><span class='style8'>";
echo"      <input type='text' name='todate' value='$todate'  maxlength='10' size='10'>";
echo"      <A HREF=\"#\" onClick=\"displayCalendar(document.form1.todate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor2\" ID=\"anchor2\"><image src='./img/cal.gif' border=0 align=center></image></A>";
echo"      </span></td>";

echo"      <td width='5%' align='center' bgcolor='#F5F5F5' class='style8'>To</td>";
echo"      <td width='20%' bgcolor='#F5F5F5' class='style8'><label>";
echo"      <input type='text' name='toref'  value='$toref' size='10'>";
echo"      </label></td>";




echo"<tr bgcolor='#F7F7F7'>";
	
echo"<td width='35%' colspan='7' align='left' bgcolor='#F5F5F5'><span class='style8'>";
echo"<label>";

echo"</label>";
echo"CLIENT Code/Description </span></td>";

		echo "</td></tr>";
		
echo"<tr><td width='30%' colspan='7'  valign='top' bgcolor='#F5F5F5'><table border='0'>";

echo"<tr><td bgcolor='#F5F5F5'><span class='style8'>From &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></td>";

echo"<td bgcolor='#F5F5F5' class='style8'><label>";
echo"<input type='text' name='fromclient'  value='$fromclient' size='10'>";
echo"</label></td>";	

echo"<td bgcolor='#F5F5F5' class='style8'>&nbsp; &nbsp; &nbsp;   <label>";
echo"<input type='text' name='fromdesc'  value='$fromdesc' size='30'><img src='img/btnopen.jpg' title=' Select Client '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistclient(1); return false'>";
echo"</label></td></tr>";		

echo"<tr><td bgcolor='#F5F5F5'><span class='style8'>To &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></td>";

echo"<td bgcolor='#F5F5F5' class='style8'><label>";
echo"<input type='text' name='toclient'  value='$toclient' size='10'>";
echo"</label></td>";	

echo"<td bgcolor='#F5F5F5' class='style8'>&nbsp; &nbsp; &nbsp;   <label>";
echo"<input type='text' name='todesc'  value='$todesc' size='30'><img src='img/btnopen.jpg' title=' Select Client '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistclient(2); return false'>";
echo"</label></td></tr>";
echo "</td></tr></table>";




echo"<tr  bgcolor='#F7F7F7'>";

if ($Module_CostCenter==1 || $Module_CostCenterDt==1){
echo"<td width=8% bgcolor='#F5F5F5' <span class='style8'>CostCenter</span></td>";
echo"<td bgcolor='#F5F5F5' class='style8'><label>";
echo"<input type='text' name='fromcostcent' size='15' value='$fromcostcent' size='15'><img src='img/btnopen.jpg' title=' Select CostCenter '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistCostcenter(1); return false'>";
echo"</label>";	

} else {

echo"<td width=8% bgcolor='#F5F5F5' <span class='style8'>&nbsp;</span></td>";
echo"<td bgcolor='#F5F5F5' class='style8'><label>";
echo"<input type='hidden' name='fromcostcent' size='15' value='$fromcostcent' size='15'>";
echo"</label>";	
}

if ($Module_Project==1 || $Module_ProjectDt==1) {
	echo"<td width=5% bgcolor='#F5F5F5'> <span class='style8'>Project</span></td>";
	echo"<td colspan='4' bgcolor='#F5F5F5'> <span class='style8'><label>";
	echo"<input type='text' name='fromproject' size='15' value='$fromproject' size='15'><img src='img/btnopen.jpg' title=' Select Project '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(1); return false'>";
	echo"</label></span></td>";	
} else {
	echo"<td width=5% bgcolor='#F5F5F5'> &nbsp;</td>";
	echo"<td colspan='4' bgcolor='#F5F5F5'> <span class='style8'><label>";
	echo"<input type='hidden' name='fromproject' size='15' value='$fromproject' size='15'>";
	echo"</label></span></td>";	
}

echo"</tr>";
	


	echo "<tr>
      <td colspan='7' align='center' bgcolor='#F5F5F5'>
	  <input name='clearbtn' type='reset'  value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' />
	  <input name='preview' type='button' id='Preview' value='preview' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"PrintPreview('".$printaccess."')\"; />";
	  
if ($exportaccess==1)
	  echo "<input name='export' type='button' id='Export' value='Export' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"ExportExcel()\";/>";
	  
	  
   echo"   </td>
    </tr>
   
  </table>
 
</form>
</body>
</html>";


?>
