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



$querylog="SELECT RI_Adjustment as loginaccess, print as printaccess, ExporttoExcel from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['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"); 
/*	
if ($ExporttoExcel==1)
	$ExporttoExcelStatus= 'button';
else
	$ExporttoExcelStatus= 'hidden';		*/


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

HERE;

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_Delivery,0) As Module_Delivery, ifNull(Module_Grn,0) As Module_Grn, ifNull(Module_DoubleUnit,0) As Module_DoubleUnit, ".
			 " ifNull(Module_SerialNo,0) As Module_SerialNo ".
			 " ,IfNull(Module_RestrictProjectReport,0) As Module_RestrictProjectReport".
             " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


$querylog=" select ifNull(FI_RepRestrictProject,0) As FI_RepRestrictProject, ifNull(FI_RepRestrictCostcenter,0) As FI_RepRestrictCostcenter, ".
		  " ifNull(FI_RepRestrictWarehouse,0) As FI_RepRestrictWarehouse, ifNull(FI_ShowCostPrice,0) As FI_ShowCostPrice ".
          " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."') ";
$resultlog=mysql_query($querylog) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

$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];

$base1 = $rowsetup[0];
$base2 = $rowsetup[1];

//Projects List
$queryproject=" select distinct project.project_code, project_name ".
              " from project left join ".$_SESSION['dbLabel'].".loginstk on project.project_code like concat(ifnull(loginstk.project_code,project.project_code),'%') ".
			  " where user_account='".$_SESSION['useraccount']."' ".
			  " and (loginstk.project_code is not null and loginstk.project_code != '') ".
			  " order by project.project_code";
$projectresult = mysql_query($queryproject,$connection) or die(mysql_error());
$projectexist   = mysql_num_rows($projectresult);
if ($projectexist == 0 || $FI_RepRestrictProject == 0)
    $queryproject=" select distinct project_code, project_name from project order by project_code ";
			  
$resultfromproject = mysql_query($queryproject,$connection) or die(mysql_error());
$projectrows       = mysql_num_rows($resultfromproject);
$resulttoproject   = mysql_query($queryproject,$connection) or die(mysql_error());

//Costcenter List
$querycostcent=" select distinct costcent.costcent_code, costcent_name ".
               " from costcent left join ".$_SESSION['dbLabel'].".loginstk on costcent.costcent_code like concat(ifnull(loginstk.costcent_code,costcent.costcent_code),'%') ".
			   " where user_account='".$_SESSION['useraccount']."' ".
			   " and (loginstk.costcent_code is not null and loginstk.costcent_code != '') ".
			   " order by costcent.costcent_code";
$costcentresult = mysql_query($querycostcent,$connection) or die(mysql_error());
$costcentexist  = mysql_num_rows($costcentresult);		  
if ($costcentexist == 0 || $FI_RepRestrictCostcenter == 0)
    $querycostcent=" select distinct costcent_code, costcent_name from costcent order by costcent_code ";			  
	
$resultfromcostcent= mysql_query($querycostcent,$connection) or die(mysql_error());
$costcentrows      = mysql_num_rows($resultfromcostcent);
$resulttocostcent  = mysql_query($querycostcent,$connection) or die(mysql_error());


//Get Default Project
$querydflproject="select project_code as defaultproject from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
	extract($rows);
}
	
//Get Default Coscenter
$querydflcostcent="select costcent_code as defaultcostcent from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
	extract($rows);
}

//Warehouse List
$querywarehouse=" select distinct warehouse.warehouse_code, warehouse_name ".
				" from warehouse where warehouse_code in (select warehouse_code from ".$_SESSION['dbLabel'].".loginstk ".
				"                                         where user_account='".$_SESSION['useraccount']."' ".
				"                                         and (loginstk.warehouse_code is not null and loginstk.warehouse_code != '') ) ".
				" order by warehouse.warehouse_code";
$resultwh = mysql_query($querywarehouse,$connection) or die(mysql_error());
$whexist   = mysql_num_rows($resultwh);
if ($whexist == 0 || $FI_RepRestrictWarehouse == 0)
	$querywarehouse="select warehouse_code,warehouse_name from warehouse order by warehouse_code";
	
$resultfromwarehouse=mysql_query($querywarehouse,$connection) or die(mysql_error());
$resulttowarehouse=mysql_query($querywarehouse,$connection) or die(mysql_error());
$resultfromtranswh=mysql_query($querywarehouse,$connection) or die(mysql_error());
$resulttotranswh=mysql_query($querywarehouse,$connection) or die(mysql_error());

//Item Groups List
$querygroup=" select distinct group_code,group_name ".
			" from grouping where group_code in (select group_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."') ".
			" order by group_code";
$resultgroup = mysql_query($querygroup,$connection) or die(mysql_error());
$groupexist   = mysql_num_rows($resultgroup);
if ($groupexist == 0)
	$querygroup="select distinct group_code,group_name from grouping order by group_code";
$resultfromgroup=mysql_query($querygroup,$connection) or die(mysql_error());
$resulttogroup=mysql_query($querygroup,$connection) or die(mysql_error());


//Item SubGroups List
$querysubgroup= " select distinct subgroup_code, subgroup_name ".
				" from subgroup where subgroup_code in (select subgroup_code from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."') ".
				" order by subgroup_code";
$resultsubgroup = mysql_query($querysubgroup,$connection) or die(mysql_error());
$subgroupexist   = mysql_num_rows($resultsubgroup);
if ($subgroupexist == 0)
	$querysubgroup="select distinct subgroup_code,subgroup_name from subgroup order by subgroup_code";
$resultfromsubgroup=mysql_query($querysubgroup,$connection) or die(mysql_error());
$resulttosubgroup=mysql_query($querysubgroup,$connection) or die(mysql_error());

//Item Category List
$querycategory= " select distinct category_code, category_name ".
				" from category  ".
				" order by category_code";
$resultfromcategory=mysql_query($querycategory,$connection) or die(mysql_error());
$resulttocategory=mysql_query($querycategory,$connection) or die(mysql_error());




if ((!isset($fromproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1 && $Module_RestrictProjectReport==1)
	$fromproject = $defaultproject;
if ((!isset($toproject)) && $Module_Project == 1 && $FI_RepRestrictProject == 1 && $Module_RestrictProjectReport==1)
	$toproject = $defaultproject;
if ((!isset($fromcostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$fromcostcent = $defaultcostcent;	
if ((!isset($tocostcent)) && $Module_CostCenter == 1 && $FI_RepRestrictCostcenter == 1)	
	$tocostcent = $defaultcostcent;	

if (empty($fromdate)) $fromdate = displayToday();
if (empty($todate))   $todate   = displayToday();
	
print <<< HERE

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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 showlistLedger(str){
	window.open('select_ledger.php?item='+str);
}



function showlistSupplier(str){

  window.open('select_supplier.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 PrintPrev(printaccess,exp)
{
	width = screen.width - 10;
	height = screen.height - 66;
	var str='';
		
	//Getting Assigngroupby Values for level 3
	var ob = document.form1.assigngroupby;
	
	availgroupby = document.form1.availgroupby.value;
	
	adtype = document.form1.adtype.value;
	
	
	
	var showdetail = document.form1.adsum.value;
	var vcurr = document.form1.cur.value;
	var dbcd = document.form1.dbcd.value;
	
	varfromdate   = document.form1.fromdate.value;
	vartodate     = document.form1.todate.value;
	varfromitem   = document.form1.fromitem.value;
	vartoitem     = document.form1.toitem.value;
	
	if(document.form1.fromheatno)
	varfromheatno   = document.form1.fromheatno.value;
	else
	varfromheatno   ='';
	
	if(document.form1.toheatno)
	vartoheatno     = document.form1.toheatno.value;
	else vartoheatno='';
	
	varfromprj    = document.form1.fromproject.value;
	vartoprj      = document.form1.toproject.value;
	varfromcst    = document.form1.fromcostcent.value;
	vartocst      = document.form1.tocostcent.value;
	
	varfromgrp    = document.form1.fromgroup.value;
	vartogrp      = document.form1.togroup.value;
	varfromwrh    = document.form1.fromwarehouse.value;
	vartowrh      = document.form1.towarehouse.value;
	
	varfromsubgrp = document.form1.fromsubgroup.value;
	vartosubgrp   = document.form1.tosubgroup.value;
	varfromcat    = document.form1.fromcategory.value;
	vartocat      = document.form1.tocategory.value;
	
	varfromsupp    = document.form1.fromsupplier.value;
	vartosupp      = document.form1.tosupplier.value;
	varfromledger  = document.form1.fromledger.value;
	vartoledger	   = document.form1.toledger.value;
	
	if(document.getElementById("groupbydetail").checked){
		var vgroupbydetail = 1;
	
	} else var vgroupbydetail = 0;
	
	if(document.form1.period.checked)
	var period = 1;
	else var period = 0;
	
	var chkcost = 0;
	if (document.getElementById('chkcost').checked)
		chkcost = 1;
	
	var frommonth = document.form1.frommonth.value;
	var tomonth = document.form1.tomonth.value;
	var fromyear = document.form1.fromyear.value;
	var toyear = document.form1.toyear.value;
	
	if(showdetail == 1 ){
		if (exp==1)
			str='Exp_Adjustment';
		else	
			str='Rep_Adjustment';
	 	str =  str+'.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat+'&curr='+vcurr
			   +'&fromsupplier='+varfromsupp+'&tosupplier='+vartosupp+'&availgroupby='+availgroupby+'&adtype='+adtype+'&vgroupbydetail='+vgroupbydetail
			   +'&chkcost='+chkcost+'&dbcd='+dbcd+'&fromledger='+varfromledger+'&toledger='+vartoledger;
			   
    }
	else if(showdetail == 3 ){
		if (exp==1)
			str = 'Exp_AdjustmentbyItem';
		else
			str = 'Rep_AdjustmentbyItem';
		str =  str+'.php?fromdate='+varfromdate+'&todate='+vartodate+'&fromitem='+varfromitem+'&toitem='+vartoitem
			   +'&fromproject='+varfromprj+'&toproject='+vartoprj+'&fromcostcent='+varfromcst+'&tocostcent='+vartocst
			   +'&fromgroup='+varfromgrp+'&togroup='+vartogrp+'&fromwarehouse='+varfromwrh+'&towarehouse='+vartowrh
			   +'&fromsubgroup='+varfromsubgrp+'&tosubgroup='+vartosubgrp+'&fromcategory='+varfromcat+'&tocategory='+vartocat+'&showdetail='+showdetail
			   +'&availgroupby='+availgroupby+'&adtype='+adtype+'&vgroupbydetail='+vgroupbydetail+'&fromsupp='+varfromsupp+'&tosupp='+vartosupp
			   +'&period='+period+'&frommonth='+frommonth+'&tomonth='+tomonth+'&fromyear='+fromyear+'&toyear='+toyear;
	}	   
    
		  
	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 SelectPeriod() {
    var x= document.form1;
	
	if (x.period.checked)
	{
		x.fromdate.disabled = true;
		x.todate.disabled   = true;
		x.frommonth.disabled  = false;
		x.tomonth.disabled    = false;
		x.fromyear.disabled  = false;
		x.toyear.disabled    = false;
		
	} else 
	{
		x.fromdate.disabled = false;
		x.todate.disabled   = false;
		x.frommonth.disabled  = true;
		x.tomonth.disabled    = true;
		x.fromyear.disabled  = true;
		x.toyear.disabled    = true;
	}

}
function showlistProject(str) {
	window.open('List_SorProject.php?frm=29&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_SorCostcenter.php?frm=29&item='+str,'mywindow','width=850,height=550,,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function showlistitem(str){

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

function showlistsubgroups(str){
	window.open('List_SubGroup.php?str='+str,'List_SubGroup','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function showlistgroups(str){
	window.open('List_Grouping.php?str='+str,'List_Grouping','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}


function showlistcategory(str){
	window.open('List_Categories.php?str='+str,'categorywindow','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function showlistwarehouse(str){
	window.open('List_Warehouses.php?str='+str,'List_Warehouses','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

-->
</script>
<title>List of Adjustment</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]'>";

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'>Adjustment</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='clearbtn' name='clearbtn'  title='Clear Page'><span><span>Clear</span></span></button>";
	
	echo"<button type='button' id='preview' name='preview'  onClick=\"PrintPrev('".$printaccess."',0)\"; title='Preview'><span><span>Preview</span></span></button>";
		
	if ($ExporttoExcel==1){
		echo" <button type='button' id='btnExcel' name='btnExcel' onClick=\"PrintPrev('".$printaccess."',1)\"; 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 height="534" border="0" align="center" width="100%">';

echo" <tr>";	  
echo"   <td width='20%' height='19' colspan='2' align='left' bgcolor='#F5F5F5'><span class='style8'>Date</span></td> ";
echo"<td colspan='1' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>
	<input name='adtype' id='adtype' type='radio' value='1' checked></label>";
echo"All</span>";
echo"<br><span class='style8'><label>
	<input name='adtype' id='adtype' type='radio' value='2'></label>Stock In</span>";
echo"<br><span class='style8'><label>
	<input name='adtype' id='adtype' type='radio' value='3'></label>Stock Out</span>";
echo"<br><span class='style8'><label>
	<input name='adtype' id='adtype' type='radio' value='4'></label>Adjustment</span></td>";


echo"<td rowspan=3 valign=top><span class='style8'><label>
	<input name='adsum' id='adsum' type='radio' value='1' checked></label>List of Adjustment</span>";
echo"<br><span class='style8'><label>
	<input name='adsum' id='adsum' type='radio' value='3'></label>Summary Item</span>";
/*echo"<br><span class='style8'><label>
	<input name='adsum' id='adsum' type='radio' value='4'></label>Summary Detail</span>";
echo"<br><span class='style8'><label>
	<input name='adsum' id='adsum' type='radio' value='5'></label>Summary</span></td>";*/

	


echo"<td rowspan=4 valign=top colspan=7>";
echo" 	<table border='0' align='left' width='90%' cellpadding=0 cellspacing=1>";
echo"   <tr><td width='30%' valign='top' bgcolor='#F5F5F5'><span class='style8'>Group by:<br><br>";
echo"		<select name='availgroupby' multiple='multiple' size='8' style='width:250px;'>    
				<option value='1' name='None'>None</option>
				<option value='11' name='ItemCode'>Item Code</option>
				<option value='2' name='Project'>Project</option>
				<option value='3' name='Costcenter'>Costcenter</option>
				<option value='4' name='Warehouse'>Warehouse</option>
				<option value='5' name='Group'>Group</option>
				<option value='6' name='Subgroup'>Subgroup</option>
				<option value='7' name='Category'>Category</option>				
				<option value='10' name='Supplier'>Supplier</option>
			</select>";
			//<option value='8' name='Project/CostCenter'>Project/CostCenter</option>
			//<option value='9' name='CostCenter/Project'>CostCenter/Project</option>
echo"</td>";
echo "<td width='30%' valign='top' bgcolor='#F5F5F5'>&nbsp;</td>";
echo"</tr>";

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

echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'  valign='middle' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='15%'  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" </tr>";

echo" <tr>";
echo"   <td width='5%' valign='top' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='15%' 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=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center></image></A></span></td>";






echo" </tr>";
 

if($fromyear == '') $fromyear = date('Y');
if($toyear == '') $toyear = date('Y');

echo" <tr>";
echo"   <td valign='center'><span class='style8'><label>From</label></span></td>";
echo"   <td  valign='center'><select name='frommonth' disabled>    
			<option value='1' >January</option>
			<option value='2' >February</option>
			<option value='3' >March</option>
			<option value='4' >April</option>
			<option value='5' >May</option>
			<option value='6' >June</option>
			<option value='7' >July</option>
			<option value='8' >August</option>
			<option value='9' >September</option>
			<option value='10' >October</option>
			<option value='11' >November</option>
			<option value='12' >December</option>";
echo"   </select>";
echo"   <input type='text' name='fromyear' value='$fromyear'  maxlength='4' style='width:35px;' disabled></td>";	
echo "<td><span class='style8'><label><input type='checkbox' name='period' id='period' onclick=\"SelectPeriod();\"></label>Monthly</span></td>";
echo "<td><span class='style8'><label><input type='checkbox' name='chkcost' id='chkcost' value='0'></label>Show Cost</span><br>
	<input type='checkbox' name='groupbydetail' id='groupbydetail'><span class='style8'>Details</span></td>";
echo" </tr>";

echo"   <tr><td valign='center'><span class='style8'><label>To</label></span></td>";
echo"   <td valign='center'><select name='tomonth' disabled>    
			<option value='1' >January</option>
			<option value='2' >February</option>
			<option value='3' >March</option>
			<option value='4' >April</option>
			<option value='5' >May</option>
			<option value='6' >June</option>
			<option value='7' >July</option>
			<option value='8' >August</option>
			<option value='9' >September</option>
			<option value='10' >October</option>
			<option value='11' >November</option>
			<option value='12' >December</option>";
echo"   </select>";
echo"   <input type='text' name='toyear' value='$toyear'  maxlength='4' style='width:35px;' disabled>";			
echo"   </td><td><span class='style8'></span></td>
			<td><span class='style8'><input type='radio' name='cur' id='cur' value='$base1' checked>$base1 
				<br><input type='radio' name='cur' id='cur' value='$base2'>$base2</span></td></tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Item Code / Description</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Group Code</span></td>";
echo" </tr>";
   
echo" <tr>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%'  colspan='2' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='fromitem' type='text' id='fromitem' size='15' value='".$fromitem."' />
        <input name='fromitemdesc' type='text' id='fromitemdesc' size='35' value='".$fromitemdesc."' />
        <input name='btncode1' type='hidden' id='btncode1' value='...'  style='width:20px; height:20px; border:thin;' title='Select Item From' />
        </label>
		</span>
		<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item From ' 
             onClick='showlistitem(1); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label> 
		</td>";

echo"   <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>From ";			 
echo"   	<input type='text' name='fromgroup' id='fromgroup' value='$fromgroup' style='width:130px;'>
			<input type='text' name='fromgroup_name' id='fromgroup_name' value='$fromgroup_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistgroups('7');\"  /></span></label>";
echo"	</span></td>";					 
echo" </tr>";

echo" <tr>";	  
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%'  colspan='2' valign='middle' bgcolor='#F5F5F5' ><span class='style8'>";
echo"   <label>
        <input name='toitem' type='text' id='toitem' size='15' value='".$toitem."' />
        <input name='toitemdesc' type='text' id='toitemdesc' size='35' value='".$toitemdesc."' />
        <input name='btncode2' type='hidden' id='btncode2' value='...'  style='width:20px; height:20px; border:thin;' title='Select Item To' />
        </label>
      </span>
      <label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title=' Select Item To ' 
             onClick='showlistitem(2); '><img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label></td>";

echo"   <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>To ";			 
echo"  		<input type='text' name='togroup' id='togroup' value='$togroup' style='width:130px;'>
			<input type='text' name='togroup_name' id='togroup_name' value='$togroup_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Group ' width='15' height='15' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistgroups('8');\"  /></span></label>";
echo"	</span></td>";		
echo" </tr>";

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






echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Item SubGroup</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Item Category</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>From</span></td>";
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>
			<input type='text' name='fromsubgroup' id='fromsubgroup' value='$fromsubgroup' style='width:150px;'>
			<input type='text' name='fromsubgroup_name' id='fromsubgroup_name' value='$fromsubgroup_name' style='width:260px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select SubGroup ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistsubgroups('5');\"  /></span></label>";
echo"	</span></td>";		
		
echo"   <td width='50%'   align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>From ";
echo"   	<input type='text' name='fromcategory' id='fromcategory' value='$fromcategory' style='width:130px;'>
			<input type='text' name='fromcategory_name' id='fromcategory_name' value='$fromcategory_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Category ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistcategory('3');\" /></span></label>";
echo"	</span></td>";			
echo" </tr>";


echo" <tr>";
echo"   <td width='5%'   align='right' bgcolor='#F5F5F5' ><span class='style8'>To</span></td>";
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5' ><span class='style8'>
			<input type='text' name='tosubgroup' id='tosubgroup' value='$tosubgroup' style='width:150px;'>
			<input type='text' name='tosubgroup_name' id='tosubgroup_name' value='$tosubgroup_name' style='width:260px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select SubGroup ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistsubgroups('6');\"  /></span></label>";
			
		echo"</span></td>";	
		
echo"   <td width='50%'   align='right' bgcolor='#F5F5F5' colspan='3' ><span class='style8'>To";
echo"   	<input type='text' name='tocategory' id='tocategory' value='$tocategory' style='width:130px;'>
			<input type='text' name='tocategory_name' id='tocategory_name' value='$tocategory_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Category ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistcategory('4');\" /></span></label>";
echo"	</span></td>";
echo" </tr>";


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

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Project Code</span></td>";
echo"   <td colspan='3' bgcolor='#F5F5F5' align='left'><span class='style8'>Warehouse</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>";
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5'>
			<input name='fromproject' type='text' id='fromproject' style='width:130px;' value='".$fromproject."' />
			<input name='fromprojectdesc' type='text' id='fromprojectdesc' style='width:280px;' value='".$fromprojectdesc."' />
			<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title='Select Project' onClick='showlistProject(1); '>
			<img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
		</td>";


echo"   <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3' ><span class='style8'>From ";			 		
echo"   	<input type='text' name='fromwarehouse' id='fromwarehouse' value='$fromwarehouse' style='width:130px;'>
			<input type='text' name='fromwarehouse_name' id='fromwarehouse_name' value='$fromwarehouse_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Warehouse ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistwarehouse('14');\"  /></span></label>";
echo"	</span></td>";		
echo" </tr>";

echo" <tr>";
echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"   <td width='45%' colspan='2' bgcolor='#F5F5F5'>
			<input name='toproject' type='text' id='toproject' style='width:130px;' value='".$toproject."' />
			<input name='toprojectdesc' type='text' id='toprojectdesc' style='width:280px;' value='".$toprojectdesc."' />
			<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title='Select Project' onClick='showlistProject(3); '>
			<img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
		</td>";

echo"   <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>To  ";			 
echo"   	<input type='text' name='towarehouse' id='towarehouse' value='$towarehouse' style='width:130px;'>
			<input type='text' name='towarehouse_name' id='towarehouse_name' value='$towarehouse_name' style='width:180px;'>
			<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Warehouse ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistwarehouse('15');\"  /></span></label>";
		echo"</span></td>";
echo" </tr>";

echo" <tr>";
echo"   <td colspan='4' bgcolor='#F5F5F5'><span class='style8'>CostCenter Code</span></td>
		<td colspan='4' bgcolor='#F5F5F5'><span class='style8'>Supplier</span></td>";

echo" </tr>";

echo" <tr> ";
echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
		<td width='45%' colspan='2' bgcolor='#F5F5F5'>	
			<input name='fromcostcent' type='text' id='fromcostcent' style='width:130px;' value='".$fromcostcent."' />
			<input name='fromcostcentdesc' type='text' id='fromcostcentdesc' style='width:280px;' value='".$fromcostcentdesc."' />
			<label><img src='img/btnopen.jpg' width='15' height='20' border='0' title='Select CostCenter'  onClick=\"showlistCostcenter('1');\" /></label>
		</td>";

echo "	 <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>From </span>
			<input type='text' name='fromsupplier' id='fromsupplier' value='$fromsupplier' style='width:130px;'>
			<input type='text' name='fromsuppdesc' id='fromsuppdesc' value='$fromsuppdesc' style='width:180px;'>
			<label><img src='img/btnopen.jpg' width='15' height='20' border='0' title='Select CostCenter'  onClick=\"showlistSupplier('1');\" /></label>
		</td>";
		 		
echo" </tr>";

echo" <tr>";
echo"   <td width='5%' align='right' bgcolor='#F5F5F5'><span class='style8'>From</span></td>
		<td width='45%' colspan='2' bgcolor='#F5F5F5'>	
			<input name='tocostcent' type='text' id='tocostcent' style='width:130px;' value='".$tocostcent."' />
			<input name='tocostcentdesc' type='text' id='tocostcentdesc' style='width:280px;' value='".$tocostcentdesc."' />
			<label><span class='style11'><a href='javascript:void(0);' NAME='My Window Name' title='Select CostCenter' onClick='showlistCostcenter(4); '>
			<img src='img/btnopen.jpg' width='15' height='20' border='0' /></a> </span></label>
		</td>";
echo "	 <td width='50%'  align='right' bgcolor='#F5F5F5' colspan='3'><span class='style8'>To </span>
			<input type='text' name='tosupplier' id='tosupplier' value='$tosupplier' style='width:130px;'>
			<input type='text' name='tosuppdesc' id='tosuppdesc' value='$tosuppdesc' style='width:180px;'>
			<label><img src='img/btnopen.jpg' width='15' height='20' border='0' title='Select CostCenter'  onClick=\"showlistSupplier('2');\" /></label>
		</td>";
echo" </tr>";


echo" <tr height=18><td colspan='7'>&nbsp;</td></tr>";
 
 
echo"<tr>";
echo"	<td height='19'  colspan='6' align='left' bgcolor='#F5F5F5'><span class='style8'>Ledger Number/Name</span></td>";
echo"</tr>";
echo"<tr><td width='45%' colspan='3'  valign='top' bgcolor='#F5F5F5'><table border='0'>";
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>From</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromledger'  value='$fromledger' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='fromledgername'  value='$fromledgername' size='30'>
				<img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(1); return false'>";
echo"		</label></td>
		</tr>";		
echo"	<tr><td bgcolor='#F5F5F5'><span class='style8'>To</span></td>";
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='toledger'  value='$toledger' size='10'></label></td>";	
echo"		<td bgcolor='#F5F5F5' class='style8'><label><input type='text' name='toledgername'  value='$toledgername' size='30'>
				<img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(2); return false'>";
echo"		</label></td>
		</tr>";
echo "</table></td>";

echo"<td colspan='2' rowspan='3' valign='top' bgcolor='#F5F5F5'><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='1' checked></label>";
echo"Credit Accounts</span>";
echo"<br><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='2'></label>Debit Accounts</span>";
echo"<br><span class='style8'><label>
	<input name='dbcd' id='dbcd' type='radio' value='3'></label>Both</span></td>";
 




echo" <tr>";
echo"   <td colspan='7' bgcolor='#F5F5F5'><span class='style8'>&nbsp;</span></td>";
echo" </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>";

//Return Date in DD/MM/YYYY format
function displayFromDate($data){
	return "01/01/".substr($data, 6, 4);		
}
//Return Today's Date in DD/MM/YYYY format
function displayToday(){
	return strftime("%d")."/".strftime("%m")."/".strftime("%Y");
}
	  
?>