
<?php


session_start();
if($HTTP_SESSION_VARS['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($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");


$querylog="SELECT RA_StatisticsReport as loginaccess, ExporttoExcel, Print 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);
}

	

	

$printaccess=$Print;


$querysetup ="select base1, base2, if(DefaultBase=1, base1, base2) as defaultcurr from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
$rowsetup=mysql_fetch_row($resultsetup);
$defaultcurr = $rowsetup[2];


// Setting Initial Values For Parameters
$querydate=" Select Date_Format(Min(Journal_date),'%d/%m/%Y') As DefaultFromDate, ".
           " Date_Format(Max(Journal_date),'%d/%m/%Y') As DefaultToDate, Date_Format(NOW(),'%d/%m/%Y') As DefaultAgingDate ".
		   " From JournalDt ";
$resultdate=mysql_query($querydate,$connection) or die(mysql_error());
$rowdate=mysql_fetch_row($resultdate);

if (!isset($fromdate))  $fromdate = $rowdate[0];
if (!isset($todate))    $todate = $rowdate[1];
if (!isset($agingdate)) $agingdate = $rowdate[2];
  

	

print <<< HERE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

<script language="JavaScript" src="CalendarPopup.js" ></script><!-- Date only with year scrolling -->
<script type="text/javascript" language="javascript">
<!--
function openListCustomers(frm){
	var str = "List_SorLedger.php?frm="+frm;
	window.open(str,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function PrintPrev(printaccess)
{
	var x = document.form1;
	var fromDate = x.fromDate.value;
	var toDate = x.toDate.value;
	var date_type = x.date_type.value;
	var order_By = x.order_By.value;
	var banks = x.banks.value;
	var activity=x.Activity.value;
	var fromLedger=x.from_client_code.value;
	var toLedger=x.to_client_code.value;
	var salesmen=x.salesmen.value;
	var orderSalesMan=0;
	if(x.OrderSalesman.checked){
		orderSalesMan=1;
	}
	
	var collected=0;
	if(x.collected.checked){
		collected=1;		
	}
	var uncollected=0;
	if(x.uncollected.checked){
		uncollected=1;		
	}
	
	var str = "Reports_ListOfChecks.php?fromDate="+fromDate+"&toDate="+toDate+"&date_type="+date_type+"&order_By="+order_By+"&banks="+banks+"&act="+activity+"&coll="+collected+"&uncoll="+uncollected+"&fromLedger="+fromLedger+"&toLedger="+toLedger+"&OrderSalesMan="+orderSalesMan+"&salesmen="+salesmen;
	window.open(str);
}

function ExportExcel()
{
	var x = document.form1;
	var fromDate = x.fromDate.value;
	var toDate = x.toDate.value;
	var date_type = x.date_type.value;
	var order_By = x.order_By.value;
	var banks = x.banks.value;
	var activity=x.Activity.value;
	var fromLedger=x.from_client_code.value;
	var toLedger=x.to_client_code.value;
	var salesmen=x.salesmen.value;
	var orderSalesMan=0;
	if(x.OrderSalesman.checked){
		orderSalesMan=1;
	}
	
	var collected=0;
	if(x.collected.checked){
		collected=1;		
	}
	var uncollected=0;
	if(x.uncollected.checked){
		uncollected=1;		
	}
	
	var str = "Exp_ListOfChecks.php?fromDate="+fromDate+"&toDate="+toDate+"&date_type="+date_type+"&order_By="+order_By+"&banks="+banks+"&act="+activity+"&coll="+collected+"&uncoll="+uncollected+"&fromLedger="+fromLedger+"&toLedger="+toLedger+"&OrderSalesMan="+orderSalesMan+"&salesmen="+salesmen;
	window.open(str);
}


function SelectTransOptions()
{
	var x = document.form1;
	
	if (x.alltrans.checked) {
		x.TransPV.checked= true;
		x.TransRV.checked= true;
		x.TransDV.checked= true;
		x.TransCV.checked= true;
		x.TransSI.checked= true;
		x.TransSR.checked= true;
		x.TransJS.checked= true;
		x.TransJP.checked= true;
		x.TransPI.checked= true;
		x.TransPR.checked= true;
	} else {
		x.TransPV.checked= false;
		x.TransRV.checked= false;
		x.TransDV.checked= false;
		x.TransCV.checked= false;
		x.TransSI.checked= false;
		x.TransSR.checked= false;
		x.TransJS.checked= false;
		x.TransJP.checked= false;
		x.TransPI.checked= false;
		x.TransPR.checked= false;
	}
}

function ClearPage() {
	x = document.form1;
	
	window.location ='Form_StatisticsReport.php';
	
}



-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>List of Checks</title>
<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>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
	<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>
</head>
<body>
HERE;

echo "<form id='form1' name='form1' method='post' action='$_SERVER[PHP_SELF]' >
		<input type='hidden' name='templateid' value='$templateid'>";
		
echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>List of Checks</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='30'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px' align='left'>";
		
	echo "<button type='reset' id='btnClear' name='btnClear' title='Clear'><span><span>Clear</span></span></button>";
	echo "<button type='button' id='btnPreview' name='btnPreview'  onClick=\"PrintPrev('".$printaccess."')\"; title='Preview'><span><span>Preview</span></span></button>";
	echo "<button type='button' id='btnExcel' name='btnExcel' onClick=\"ExportExcel()\"; title='Export Excel'><span><span>Export Excel</span></span></button>";

	
  
echo"	</td></tr></table>";
echo"</td></tr>";				

		
echo"<tr><td id='content-body'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
   <tr bgcolor='#F7F7F7'><td valign='top' align='left' colspan='10'>";						
	
echo '  <table border="0" align="center" valign="top" width="100%">';
$currDate = date("d/m/Y");

echo "<tr>
<td width=5%><span class='style8' style='font-size: 12px; color: #000000'>Date: From </span></td>
<td width=35%><input type='text' name='fromDate' id='fromDate' value='$currDate' /> <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></td>
<td width=25%><span class='style8' style='font-size: 12px; color: #000000'>Bank</span>&nbsp;&nbsp;&nbsp;&nbsp;
<select style='width: 150px' id='banks' name='banks'>
<option value=''></option>";
$query_banks  = "select bank_Name from banks";
$result_banks = mysql_query($query_banks, $connection); 
while($row_banks = mysql_fetch_array($result_banks)){
	extract($row_banks);
	echo "<option value='$bank_Name'>$bank_Name</option>";
}
echo"</select>
</td>
<td width=25%><span class='style8' style='font-size: 12px; color: #000000'><input type='radio' name='date_type' value='date' checked hidden> </span></td>
</tr>";

echo "<tr>
<td width=5%><span class='style8' style='font-size: 12px; color: #000000'>To </span></td>
<td width=35%><input type='text' name='toDate' id='toDate' value='$currDate' /> <A HREF=\"#\" onClick=\"displayCalendar(document.form1.toDate,'dd/mm/yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></td>
<td width=25%><span class='style8' style='font-size: 12px; color: #000000'>Activity</span>&nbsp;
<select style='width: 150px' id='Activity' name='Activity'>
<option value='1'>Checks For Collection</option><option value='2'>Checks For Payment</option></td>
<td width=25%><span class='style8' style='font-size: 12px; color: #000000'><input type='radio' name='date_type' value='chk_date' hidden> </span></td>
</tr>";
echo "<tr style='height: 25px;'>
<td width=100% colspan=4></td>
</tr>";
echo "<tr><td ><span class='style8' style='font-size: 12px; color: #000000'>Ledger From:</span></td>
<td><input type='text' name='from_client_code' id='from_client_code' style='width: 75px' /> <img src='img/btnopen.jpg' width=20 style='vertical-align: middle; cursor: pointer' onclick=\"openListCustomers(15)\" /> <input type='text' name='from_client_name' id='from_client_name' style='width: 250px' /></td><td><input type='checkbox' name='OrderSalesman' ><span class='style8' style='font-size: 12px; color: #000000'>Group by Salesman</span></td>";
echo"<td><select style='width: 100px' id='salesmen' name='salesmen'>
	<option value=''></option>";
$query_salesmen="SELECT Ledger_Number, Ledger_Name from salesmen";
	$result_salesmen = mysql_query($query_salesmen, $connection);
	while($row_salesmen = mysql_fetch_array($result_salesmen)){
		extract($row_salesmen);
		echo"<option value='$Ledger_Number'>$Ledger_Name</option>";
	}
echo "</td></tr>";
echo "<tr><td><span class='style8' style='font-size: 12px; color: #000000'>To:</span></td>
<td><input type='text' name='to_client_code' id='to_client_code' style='width: 75px' /> <img src='img/btnopen.jpg' width=20 style='vertical-align: middle; cursor: pointer' onclick=\"openListCustomers(16)\" /> <input type='text' name='to_client_name' id='to_client_name' style='width: 250px' /></td><td><input type='checkbox' name='collected' if='collected' ><span class='style8' style='font-size: 12px; color: #000000'>Collected</span>&nbsp;<input type='checkbox' name='uncollected' if='uncollected' checked><span class='style8' style='font-size: 12px; color: #000000'>Uncollected</span></td></tr>";
echo "<tr style='height: 25px;'>
<td width=100% colspan=4></td>
</tr>";

echo "<tr>
<td width=100% colspan=2><span class='style8' style='font-size: 12px; color: #000000'>Order By: <input type='radio' name='order_By' value='date' checked > Date <input type='radio' name='order_By' value='bank_and_date'> Bank & Date</span></td>
</tr>";

    
echo" <tr height='120'>";

echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";	
echo" </tr>";
/*
echo" 
    <tr height='30'>
      <td colspan='6' align='center' bgcolor='#F5F5F5'>
	  <input type='button' name='btnClear' value='Clear' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"ClearPage()\"; />
	  <input type='button' name='btnPreview' id='btnPreview' value='Preview' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"PrintPrev('".$printaccess."')\"; />
	  <input type='".$ExporttoExcelStatus."' name='btnExcel' id='btnExcel' value='Export Excel' style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;' onClick=\"ExportExcel()\";/>	  
      </td>
    </tr>*/
		echo"   </table></td></tr>"; 
	echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>"; 
 echo" </table>
 
</form>
</body>
</html>";




?>