<?php

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


include("config.inc.php");
include("Functions_Trans.php");
include("Forms_DataGrid1.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_ListofCheckBills as loginaccess 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);
}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");


$querylog=" select ifNull(ModifyVAT,0) As ModifyVAT, ".
		  " ifNull(Login_ModifyDiscount,0) As Login_ModifyDiscount, ifNull(Login_FastPrint,0) As Login_FastPrint , ifNull(Login_ModifySellingPrice,0) As Login_ModifySellingPrice ".
		  " 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);
}


$MainCompanyName=explode('_',$HTTP_SESSION_VARS['dbName']);  
$QueryDir = " Select Date_Format(StartFinancialDate,'%d/%m/%Y'),Date_Format(EndFinancialDate,'%Y-%m-%d') , Concat(CompanyName, '_', DirYear) As DirSchema ".
			" ,Date_Format(EndFinancialDate,'%d/%m/%Y') ".
			" From ".$HTTP_SESSION_VARS['dbLabel'].".Directories ". 	
			" Where  Upper(CompanyName) = Upper('".$MainCompanyName[0]."') ".
			" and Upper(Diryear) = Upper('".$MainCompanyName[1]."') ".
			" Order By DirYear ";
//echo $QueryDir;			
$ResultDir=mysql_query($QueryDir,$connection) or die(mysql_error());   
$RowsDir=mysql_fetch_row($ResultDir);
$StartFinancialDate = $RowsDir[0];
$EndFinancialDate = $RowsDir[1];
$EndFinancialDate1 = $RowsDir[3];

//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ifNull(Supplier_ValidateProject,0) As Supplier_ValidateProject, ".
             " 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);
}

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

//Read From PurchaseSetup Table
$queryPurchaseSetup="Select SupplierCur From PurchaseSetup";
$resultPurchaseSetup=mysql_query($queryPurchaseSetup,$connection) or die(mysql_error());
while($rowPurchaseSetup=mysql_fetch_array($resultPurchaseSetup)){
	extract($rowPurchaseSetup);
}


$querycurrency="select Currency_code from currency order by currency_code";
$resultcurrency=mysql_query($querycurrency,$connection) or die(mysql_error());



$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];}   
$mainaction = $_POST["mainaction"]; if ($mainaction == ""){$mainaction = $_GET["mainaction"];}   

if (empty($mainaction))	$mainaction = 'edit';

$message = ereg_replace("'"," ",$message);

print <<<HERE
<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"> 

<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/grid/animatedcollapse.js"></script>

<link type="text/css" href="js/calendar/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="js/calendar/jquery.datepick.js"></script>

<link type="text/css" href="js/grid/scripts/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="js/grid/scripts/jquery-ui.min.js"></script>

<script type="text/javascript">
animatedcollapse.addDiv('jason', 'fade=1,height=25px')
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
}

animatedcollapse.init()

</script>


<script type="text/javascript" language="javascript">
	
	
	$(document).ready(function() { 
		
	if (document.getElementById('txtLedgerNo[1]'))
		document.getElementById('txtLedgerNo[1]').focus();
		
	
		$(document).on('focusin', '.table-focus-g1', function() {
			AutoSaveRecordGrid(this.id,'SelectedRec','ModRec_G1','imgSubmitChecksCollection');
			selRecordColor(this,'SelectedRec','SelectedRecColor');
		});
		
		//Set Scroll Positions on Page Load
		scrollToPage();
		
		$(window).scroll(function(){
			scrollPage();
		});
		
	
	});
	
	$(document).ready(function() { 
		
		$(document).on('focus', '.date', function() {
			$('.date').datepick({showTrigger: '#calImg'});
		});	

	});
</script>


<script type="text/javascript">

function PrintPreview(type)
{

fromdate = document.checkscollected.fromdate.value;
todate = document.checkscollected.todate.value;
bank = document.checkscollected.bank.value;

x = document.checkscollected;

for (var i=0; i < x.duedate.length; i++)
	{
		if (x.duedate[i].checked)
		{
			var duedate = x.duedate[i].value;
		}
	}

	if (type==1)
		str = 'Rep_ChecksCollectionPreview.php?fromdate='+fromdate+'&todate='+todate+'&duedate='+duedate+'&bank='+bank;
	else 	
		str = 'Exp_ChecksCollectionPreview.php?fromdate='+fromdate+'&todate='+todate+'&duedate='+duedate+'&bank='+bank;
	window.open(str);
}


function createdepositchecks(filepath){

var x = document.checkscollected;

for (var i=0; i < x.filterby.length; i++)
	{
		if (x.filterby[i].checked)
		{
			var filterby = x.filterby[i].value;
		}
	}

project = document.checkscollected.txtProjectCode.value;
costcenter = document.checkscollected.txtCostCentCode.value;


if (document.checkscollected.postcomm.checked)
	var postcomm = 1 ;
else
	var postcomm = 0 ;
	
if (document.checkscollected.seplines.checked)
	var seplines = 1 ;
else
	var seplines = 0 ;

if (confirm ( "Are you sure you want to Create Deposit Checks?")){	

	
var x = document.checkscollected;

for (var i=0; i < 50000; i++)
	{
	
	if (document.getElementById('debit_ledgernumber['+i+']'))
		{	
			if (document.getElementById('chk_status['+i+']').value == 'r' && document.getElementById('debit_ledgernumber['+i+']').value == '') {
				document.getElementById('debit_ledgernumber[' +i+ ']').focus();
	
return;
				}
		}
		else i = 50000;
				
	}


$("#Loader").addClass("ajaxsaving"); 

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					var data = xmlhttp.responseText;
					ReloadGrid(filepath,'CH','','datagrid','','','ADD','','','','',0,'',function() {	
							$("#Loader").removeClass("ajaxsaving");					
										});
										
					document.getElementById('testdatagrid').innerHTML = data;
					
				}
		}
  }

xmlhttp.open("GET","Form_ChecksCollection_Actions.php?actionmode=createdepositchecks&filterby"+filterby+"&project="+project+"&costcenter="+costcenter+"&postcomm="+postcomm+"&seplines="+seplines,true);
xmlhttp.send();
}

}



function setcostcentercode(val,vfield1,btnname){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							document.getElementById(btnname).click();
						}
						
						//showsearchpage('itemcode',vfield1,vfield2,vfield3,vfield4,vfield5,vfield6,800,500);

				}
		}
  }

xmlhttp.open("GET","Form_ChecksCollection_Actions.php?vcostcentercode="+val+"&actionmode=checkcostcentercode",true);
xmlhttp.send();

}
function showlistProject(vtype,vtext1,vwidth,vheight,item){
  	var text1value = document.getElementById(vtext1).value;
	if (item=='')
		item = 3;
	win = window.open('List_Project.php?PProject_Code='+text1value+'&item='+item+'&vtype='+vtype+'&vtext1='+vtext1
						+'&text1value='+text1value, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	

	
}

function showlistCostcenter(vtype,vtext1,vwidth,vheight,item){
  	var text1value = document.getElementById(vtext1).value;
	
	if (item=='')
		item = 3;
	win = window.open('List_Costcenter.php?PCostcent_Code='+text1value+'&item='+item+'&vtype='+vtype+'&vtext1='+vtext1
						+'&text1value='+text1value, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	

	
}

function submitChecks(TrDtId,vrec,vmode,filepath){

var vDTId = TrDtId;

	if (vmode=='i')
			{		 
				var vactionmode = 'submitdt';
				vmode = 'submitrecord';
			}	
	else 	{
				var vactionmode = 'editdt';	
				vmode = 'editdt';
			}

var chk_bankdeposit = 'chk_bankdeposit['+vrec+']';
var chk_depositvaluedate = 'chk_depositvaluedate['+vrec+']';
var chk_status = 'chk_status['+vrec+']';
var journaldt_id1 = 'journaldt_id1['+vrec+']';
var chk_commission = 'chk_commission['+vrec+']';
var chk_commissioncur = 'chk_commissioncur['+vrec+']';
var chk_commissionacc = 'chk_commissionacc['+vrec+']';
var manual_no = 'manual_no['+vrec+']';
var journaldt_desc = 'journaldt_desc['+vrec+']';
var autoinc = 'autoinc['+vrec+']';
var chk_date = 'chk_date['+vrec+']';
var debit_ledgernumber = 'debit_ledgernumber['+vrec+']';


	
var value1 = document.getElementById(chk_bankdeposit).value;
var value2 = document.getElementById(chk_depositvaluedate).value;
var value3 = document.getElementById(chk_status).value;
var value4 = document.getElementById(journaldt_id1).value;
var value5 = document.getElementById(chk_commission).value;
var value6 = document.getElementById(chk_commissioncur).value;
var value7 = document.getElementById(chk_commissionacc).value;
var value8 = document.getElementById(manual_no).value;
var value9 = document.getElementById(journaldt_desc).value;
var value10 = document.getElementById(autoinc).value;
var value11 = document.getElementById(chk_date).value;
var value12 = document.getElementById(debit_ledgernumber).value;


//if (PreqId=='')
	var x =  document.checkscollected;
	var vMainMode = x.mainaction.value;
		

	var SubBtnID = 'imgSubmitChecksCollection['+vrec+']';
	var SubBtnObj = document.getElementById(SubBtnID);
	$(SubBtnObj).unbind('click');
	$(SubBtnObj).removeAttr("onclick");	

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
var trid = vDTId;

$("#Loader").addClass("ajaxsaving");  
xmlhttp.onreadystatechange=function()
  {  
    
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {	
				{ 		
					if (vmode=='submitrecord')
						{  					
						}	
					else {
							//document.getElementById('testdatagrid').innerHTML =  xmlhttp.responseText;
							 	
							ReloadGrid(filepath,'CH',trid,'datagrid','','','ADD','','','','',0,'',function() {
											var focusedvrec = parseInt(vrec) + 1;
											var focused = 'ledger_number['+focusedvrec+']';
											document.getElementById(focused).focus();
										});
						
						
						}
				}
		}
		
		
			
  }

xmlhttp.open("GET","Form_ChecksCollection_Actions.php?mainaction="+vMainMode+"&actionmode="+vMainMode+"&SDtId="+vDTId+"&mode="+vmode+
								"&value1="+value1+"&value2="+value2+"&value3="+value3+"&value4="+value4+"&value5="+value5+
								"&value6="+value6+"&value7="+value7+"&value8="+value8+"&value9="+value9+"&value10="+value10+"&value11="+value11+"&value12="+value12
								,true);
xmlhttp.send();   
}

function setaccountno(val,vfield1,vfield2,vgridname,btnname,btnname1,codedesc){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					if (resp==0)
						{
							if (codedesc==1)
								document.getElementById(btnname).click();
							else	
								document.getElementById(btnname1).click();
						}
						else	{							
								if (codedesc==1)
									document.getElementById(vfield2).value = resp;
								else	
									document.getElementById(vfield1).value = resp;
								}
				}
		}
  }


  if (codedesc==1)
	xmlhttp.open("GET","Form_ChecksCollection_Actions.php?vaccountno="+val+"&codedesc="+codedesc+"&actionmode=checkaccountno",true);
else	
  if (codedesc==2)
	xmlhttp.open("GET","Form_ChecksCollection_Actions.php?vaccountname="+val+"&codedesc="+codedesc+"&actionmode=checkaccountno",true);  
  

xmlhttp.send();

}


function changestatus(stat){


$("#Loader").addClass("ajaxsaving");  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					document.getElementById('datagrid').innerHTML = xmlhttp.responseText;
					
				}
		}
  }


  
xmlhttp.open("GET","Form_ChecksCollection_Actions.php?chkstatus="+stat+"&actionmode=changestatus",true);
xmlhttp.send();

}	



function loadchecks(){

fromdate = document.checkscollected.fromdate.value;
todate = document.checkscollected.todate.value;

$("#Loader").addClass("ajaxsaving");  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					document.getElementById('datagrid').innerHTML = xmlhttp.responseText;
					
				}
		}
  }


  
xmlhttp.open("GET","Form_ChecksCollection_Actions.php?fromdate="+fromdate+"&todate="+todate+"&actionmode=loadchecks",true);
xmlhttp.send();

}	


function searchgrid(ev,vcolumnname,obj){

if (ev.keyCode != 13) {
 return;
 }
 
fromdate = document.checkscollected.fromdate.value;
todate = document.checkscollected.todate.value;

var searchedvalue ;

searchedvalue = obj.value;



$("#Loader").addClass("ajaxsaving");  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					document.getElementById('datagrid').innerHTML = xmlhttp.responseText;
					animatedcollapse.addDiv('jason', 'fade=1,height=25px')
					animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
							}
							animatedcollapse.init();
				}
		}
  }


  
xmlhttp.open("GET","Form_ChecksCollection_Actions.php?vcolumnname="+vcolumnname+"&searchedvalue="+searchedvalue+"&fromdate="+fromdate+"&todate="+todate+"&actionmode=searchgrid",true);
xmlhttp.send();

}	

function setprojectcode(val,vfield1,btnname){

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					var resp = data[1];
					
					if (resp==0)
						{
							document.getElementById(btnname).click();
						}
						

				}
		}
  }

xmlhttp.open("GET","Form_ChecksCollection_Actions.php?vprojectcode="+val+"&actionmode=checkprojectcode",true);
xmlhttp.send();

}

function showsearchpage(vtype,vtext1,vtext2,vwidth,vheight){
	var text1value = document.getElementById(vtext1).value;

	win = window.open('List_AccountNo.php?PLedger_Number='+text1value+'&item=2&vtype='+vtype+'&vtext1='+vtext1+'&vtext2='+vtext2+'&text1value='+text1value, 'Search', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+vwidth+',height='+vheight+',top=100,left=100');		
	win.creator = self;
	win.focus();	
	}
	
function dokeychecksdt(e,obj,rowindx,columnslist,vbutname){

	//if (e.ctrlKey == false)
	//return;
	var vindx = rowindx;
	if (!e) { var e = window.Events;}
    var intKey = (window.Events) ? e.which : e.keyCode;


	var columnsarray=new Array();
	columnsarray = columnslist.split(",");
	var firstcell = columnsarray[0];
	var lastcell  = columnsarray[columnsarray.length-1];
	var arrayname = obj.id.split("[");

	if (( ((intKey == 37) || (intKey == 39)) && e.ctrlKey )  ||  (intKey == 13))
	{
		var cindx = columnsarray.indexOf(arrayname[0]);
		
		if (intKey == 37) { //left key
			var nextindx = Number(cindx) - 1;
		}
		if (intKey == 13 || intKey == 39) { //right key
			var nextindx = Number(cindx) + 1;
		}


		var nextitem = columnsarray[nextindx] + '[' + rowindx + ']' ;

		
		if (document.getElementById(nextitem)) {
			var nextobj = document.getElementById(nextitem);
			nextobj.focus();
			if(nextobj.type!='select-one')
			nextobj.select();
		}
		else { 
			var nextrow  = rowindx + 1;
			var nextcell = firstcell + '[' +  nextrow + ']';
				
			var imgname = 'imgSubmit' + vbutname + '[' +  rowindx + ']';
			
			document.getElementById(imgname).click();
			
			if (document.getElementById(nextcell) ) {
				document.getElementById(nextcell).focus();
				if(document.getElementById(nextcell).type!='select-one')
				document.getElementById(nextcell).select();
			}	
					
		}	
	}
	else if ( ((intKey == 38) || (intKey == 40)) && e.ctrlKey) {
		
		if (intKey == 38) 
			rowindx = rowindx - 1;
		if (intKey == 40) 
			rowindx = rowindx + 1;
			
		var nextitem =  arrayname[0] + '[' + rowindx + ']';
		if (document.getElementById(nextitem)) {
			var nextobj = document.getElementById(nextitem);
			nextobj.focus();
			if(nextobj.type!='select-one')
			nextobj.select();
		}	
	}

}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ChecksCollection</title>

<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">


<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style11 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}

.style28 {color: #FFFFFF ;font-size: 10px;}

</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>
<form name='checkscollected' method='post' action=''>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='message' value='$message' size='200'>

HERE;




//$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

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'>Checks Collection</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"	</td></tr></table>";
echo"</td></tr>";				

		
echo"<tr><td id='content-body'>";

echo"<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
		<col width=12%>
		<col width=20%>
		<col width=20%>
		<col width=48%>
		";

print <<<HERE
		<tr><th height="30" colspan="9" align="left" valign="top"><span class="style1"></span></th></tr>
HERE;
echo"<tr><td>";
echo"<table cellpading=5 cellspacing=8>";
echo"<tr><td><span class='style1'>Filter by</span></td></tr>";
echo"<tr><td align='left'><input type='radio' name='filterby'  id='filterby'  onclick=\"changestatus('')\" checked value=''><span class='style1'> None</span></td></tr>";
echo"<tr><td align='left'><input type='radio' name='filterby'  id='filterby'  onclick=\"changestatus('c')\" value='c'><span class='style1'> Cleared (C)</span></td></tr>";
echo"<tr><td align='left'><input type='radio' name='filterby'  id='filterby'  onclick=\"changestatus('r')\"  value='r'><span class='style1'> Returned (R)</span></td></tr>";
echo"</table>";
echo"</td>";


echo"<td>";
echo"<table cellpading=5 cellspacing=8>";
echo"<tr><td colspan=2><span class='style1'>Load Check</span></td></tr>";


$fromdate = $StartFinancialDate ;
$todate = displayToday();


echo"<tr><td><span class='style1'>From</td><td><input type='text' name='fromdate'   class='".$ClassI." date'    value='$fromdate' style='width:100px'></td></tr>";
echo"<tr><td><span class='style1'>To</td><td><input type='text' name='todate'    class='".$ClassI." date'    value='$todate' style='width:100px'></td></tr>";
echo"<tr><td colspan=2><input type='button' $style name='load' onclick=\"loadchecks()\"  value='Load Not Collected Checks' onMouseOver=\"style.cursor='pointer'\" ></td></tr>";
echo"</table>";
echo"</td>";

echo"<td >";
echo"<table style='background-color:#D8D8D8' cellpading=5 cellspacing=9>";
echo"<tr><td><b>Post Checks Commission</b></td><td><input type='checkbox' name='postcomm' id='postcomm' checked></td></tr>";

echo"<tr><td><b>Seperate Lines</b></td><td><input type='checkbox' name='seplines' id='seplines' checked></td></tr>";


	$filepath = 'Forms_DataGrid1.php';
echo"<tr><td colspan=2  align=center><input type='button' name='depchecks' value='Create Deposit Checks' $style onclick=\"createdepositchecks('$filepath')\" onMouseOver=\"style.cursor='pointer'\" ></td></tr>";
echo"</table>";
echo"</td>";



echo"<td>";
echo"<table style='background-color:#D8D8D8' border='0'><col width=60><col width=150><col width=150>";
echo"<tr><td>Project</td><td><input type='text' name='txtProjectCode'  id='txtProjectCode' value='$txtProjectCode'  style='width:105px'   onchange=setprojectcode(this.value,'txtProjectCode','checksprojectimg')   >
<label><span class='style11'><img src='img/openlist.png' id='checksprojectimg' title=' Select Project ' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"   onclick=\"showlistProject('project','txtProjectCode','800','500',3)\"  /></span></label>
</td><td colspan='3' align='center'><b>Check to be collected</b></td></tr>";
echo"<tr><td>Costcenter</td><td><input type='text' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' style='width:105px'  onchange=setcostcentercode(this.value,'txtCostCentCode','imgcostcenterbtnheader') >
<label><span class='style11'><image src='img/openlist.png' title=' Select Costcenter ' id='imgcostcenterbtnheader' width='20' height='20' border='0' onMouseOver=\"style.cursor='hand'\"  
	onclick=\"showlistCostcenter('costcenter','txtCostCentCode','800','500',3) \"  $PreviewButtons/></span></label>
</td><td align='left' colspan='2'><input type=radio name='duedate' value='duedate'>Due Date</td><td rowspan=2 valign='top'><input type='button' name='preview' value='Preview' onMouseOver=\"style.cursor='hand'\" onclick='PrintPreview(1)'  $style><br><br>
																			<input type='button' name='xxcel' value='Excel' onclick='PrintPreview(2)'  onMouseOver=\"style.cursor='hand'\"  $style>
																			</td></tr>";
echo"<tr><td>Bank</td><td><input type='text' name='bank' id='bank' style='width:105px' onchange=setaccountno(this.value,'bank','','salesjv','salesjvdtimg','salesjvdtimg1[$i]',1)  >";
echo"&nbsp;<label><span class='style11'><img src='img/openlist.png' title=' Select Ledger ' id='salesjvdtimg' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\"  onclick=\"showsearchpage('bank','bank','','800','500')\"   /></span></label>";
echo"</td><td align='left' colspan='3'><input type=radio checked name='duedate' value='depositduedate'>Deposit Due Date</td></tr>";
echo"</table>";
echo"</td>";


echo"</tr>";


echo"   <tr ><td colspan='9' valign='top'>";


echo"	<div id='datagrid' class='' style='width:1200px;' >";

//Show Items Grid
ShowChecksCollectedGrid($connection,'JS',$txtPurchasesJVId,$DecimalBase);
				 
echo"	  </div>"; 
echo"   </td></tr>"; 

	echo"   <tr><td colspan='9' valign='top'>";

echo"	<div id='testdatagrid' class='' style='width:1090px;' >";


echo"	  </div>"; 

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

echo"   </table></td></tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>"; 	
echo" </table>  ";//end of last table menu






print <<<HERE
</form>
</body>

HERE;



function displayParadoxDate($data){
	
	$data = insertDate($data);
	return substr($data, 0, 4) ."-". substr($data, 4, 2) ."-".substr($data, 6, 2);
}


?>