<?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 FA_AccountType as loginaccess 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");
	
	
	
	
//Read From Setup Table							
$querysetup= " select grid_color1, grid_color2,maxperpage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
	
//User Access
$querylog=" select ifNull(FA_AccountTypeApp,0) As FA_AccountTypeApp, ifNull(FA_AccountTypeDel,0) As FA_AccountTypeDel, ".
          " ifNull(FA_AccountTypeMod,0) As FA_AccountTypeMod 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);
}

//Access Mode On Insert/Edit/Delete
$InsMode = '';
if ($FA_AccountTypeApp == 0)
	$InsMode = ' disabled ';
	
if(!isset($mainmode))
$mainmode='';


//if($mainmode=='editmode' or $mainmode=='view' ){

	$query_edit=" select Acctype.Acctype_increment, Acctype_code, Acctype_name, Acctype_ledger, Project.project_code, Project.project_name,  ifNull(Acctype_SameLength,0), Ledger.Ledger_Number, Ledger.Ledger_Name,Acctype_Type,DepreciationPer ".
				" from Acctype Left Join Project on Acctype.project_code = Project.project_code ".
				" Left Join Ledger on Acctype.Acctype_ledger = Ledger.Ledger_Number ".
				" where Acctype.Acctype_increment='".$Acctype_increment."'";

	//echo $query_edit;
	$resultedit = mysql_query($query_edit, $connection);
	while($row=mysql_fetch_array($resultedit)){
        
		$Acctype_increment=$row[0];
		$Acctype_code=$row[1];
		$Acctype_name=$row[2];
		$ledger_code=$row[7];
		$ledger_name=$row[8];
		$project_code=$row[4];
		$project_name=$row[5];
		$Acctype_SameLength=$row[6];
		$AccountType=$row[9];
		$deprec_perc=$row[10];
	}
	$mainmode='edit';
//}

if($mainmode=='') $mainmode='insert';


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"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<script type="text/javascript" language="javascript">

function CheckSameLength() {
	if(document.AccType.SameLength.checked){
		document.AccType.Acctype_SameLength.value=1;

	}
	else
	{
		document.AccType.Acctype_SameLength.value=0;

	}
}

function showlistProject(str){

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

function showlistLedger(str){

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

function editmode () {
	document.AccType.mainmode.value='edit';
	document.AccType.action="Form_AccType.php?mainmode=edit";
	document.AccType.submit();
}

function AddAccType() {

			document.AccType.mainmode.value='insert';
			document.AccType.action="Form_AccType.php";
				document.AccType.submit();
}



function SubmitRecord(option) {
	var deprec_perc=document.AccType.deprec_perc.value;
	var deprec_perc1=deprec_perc*1/1;
	
	if (document.AccType.Acctype_code.value=='' )
	{
		alert('Unable to save : check missing field Code ');
		document.AccType.Acctype_code.focus();
		
	}
		
	else 
	if (document.AccType.Acctype_name.value=='' )
	{
		alert('Unable to save : check missing field Name ');
		document.AccType.Acctype_name.focus();
	
	}
	
	else 
	if (document.AccType.ledger_code.value=='' )
	{
		alert('Unable to save : check missing field Ledger ');
		document.AccType.ledger_code.focus();	
		
	}
	
	else 
	if (document.AccType.project_code.value=='' )
	{
		alert('Unable to save : check missing field Project ');
		document.AccType.project_code.focus();	
		
	}
	
	else 
	if (document.AccType.type_name.value=='' && option == 2)
	{
		alert('Unable to save : check missing field detail Name ');
		document.AccType.type_name.focus();	
		
	}
	else
	if (document.AccType.ledger_number.value=='' && option == 2)
	{
		alert('Unable to save : check missing field Group Related ');
		document.AccType.ledger_number.focus();	
	
	}
	else
	if (deprec_perc1!=deprec_perc)
	{
		alert('Unable to save : Fill Digits in Depreciation % ');
		document.AccType.deprec_perc.focus();	
	}
	
		
	else {
		if (option == 2)
			document.AccType.actionmode.value='submitsetup';
		
		
		document.AccType.action="Form_AccType_Actions.php";
		document.AccType.submit();
		
	}


}

function DeleteDetail(AccTypeSetupInc){

	if (confirm ( "Are you sure you want to Delete record?"))
	{
	
		document.AccType.AccTypeSetupInc.value = AccTypeSetupInc;
		document.AccType.actionmode.value = 'deletesetup';
		
		document.AccType.action="Form_AccType_Actions.php";
		document.AccType.submit();
		
	}	

}

function UpdateDetail(AccTypeSetupInc){
	vMainMode = document.AccType.mainmode.value;
	vAccTypeInc = document.AccType.Acctype_increment.value;
	document.AccType.AccTypeSetupInc.value = AccTypeSetupInc;
	document.AccType.actionmode.value = 'editdt';
		
	document.AccType.action="Form_AccType.php?mainmode="+vMainMode+"&actionmode=editdt";
	document.AccType.submit();

}


function ClearPage(){
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		
		x.mainmode.value='';
		x.actionmode.value='';
		x.message.value='';
		x.action='Form_AccType.php';
		x.submit();
	}	
}

function cleardetail() {
	x = document.AccType;
	
	x.AccTypeSetupInc.value='';
	x.type_name.value='';
	x.ledger_number.value='';
	x.ledger_activity.value='1';
	
	x.submit();

}

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.AccType;
	x.Acctype_increment.value='';
	x.Acctype_code.value='';
	x.Acctype_name.value='';
    x.project_code.value='';
	x.project_name.value='';	
	x.Acctype_SameLength.value='';
	x.ledger_code.value='';
	x.ledger_name.value='';
	x.message.value='';
	x.type_name.value='';
	x.ledger_number.value='';
	x.deprec_perc.value='';
	x.AccountType.value='';
	
	x.mainmode.value='';
	x.actionmode.value='';
}

/*
function SearchForAccType(){
    ClearForm('All');
    x = document.AccType;
    win = window.open('Form_AccTypeSearch.php', 'Form_AccTypeSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=775,height=450,top=100,left=100');		
	win.creator = self;
	win.focus();		
			
}*/

   function PrintPreview() {
	var str = '';
	
	str = 'Form_AccTypePreview.php';
	window.open(str);

}

function SetAcc(AccId){
	
	document.AccType.Acctype_increment.value=AccId;
	document.AccType.message.value='';
	document.AccType.actionmode.value='';
	//cleardetail();
	document.AccType.mainmode.value='editmode';
	document.AccType.submit();
}

function SetNextPage(startrange,perpage){
	document.AccType.action='Form_AccType.php?startrange='+startrange+'&perpage='+perpage;
	document.AccType.submit();
}

function SetPrvPage(startrange,perpage){
	document.AccType.action='Form_AccType.php?startrange='+startrange+'&perpage='+perpage;
	document.AccType.submit();
}

function SearchForSup(){
	x = document.AccType;
	document.AccType.action='Form_AccType.php?startrange=0';
	document.AccType.submit();
}

function ClearKeyword(){
	x = document.AccType;
	x.txtKeyword.value='';
	document.AccType.action='Form_AccType.php?startrange=0';
	document.AccType.submit();
}

function submitenter(myfield,e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   	document.AccType.action='Form_AccType.php?startrange=0';
	document.AccType.submit();
  
   return false;
   }
else
   return true;
}

function confirm_delete(Code) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		window.event.returnValue = true;
		document.AccType.mainmode.value='delete';	
		
		document.AccType.action='Form_AccType_Actions.php?AccTypeInc='+Code;
		document.AccType.submit();
	}
					
}

function set_limit(){

	perpage=document.AccType.perpage.value;
	document.AccType.action='Form_AccType.php?perpage='+perpage+'&startrange=0';
	document.AccType.submit();
}

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

<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;
}
.style1 {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}
.style27 {color: #999999 ;font-size: 10px;}
.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>
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="tabs.css">

<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
</head>
<body >
<form name='AccType' method='post'>
<input type=hidden name='mainmode' value='$mainmode'>
<input type=hidden name='actionmode' value='$actionmode'>
<input type=hidden name='message' value='$message'>
<input type=hidden name='Acctype_increment' value='$Acctype_increment'>

HERE;


if($mainmode==''){
$status='disabled';
$dis='disabled';

}


if($mainmode=='view'){

$status='readonly';
$dis='disabled';

}


if($mainmode=='insert')
$status='';

$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'>ACCOUNT TYPE</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='38'  height='34' >&nbsp;</td>
				<td valign='middle' height='34' width='720px'>";
echo"		<button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>Clear Page</span></span></button>";


echo"		<button type='button' id='btnPost' name='btnPost' onclick='SubmitRecord(1); return false;' title='Save Changes' $Insmode><span><span>Save</span></span></button>
<button  type='button'  value='Print' onclick='PrintPreview();return false;' title='print' ><span><span>Print</span></span></button>";


				
echo"   </td><td align='left' width='250px'>
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:105px;' onKeyPress='return submitenter(this,event)'>
	<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForSup(); return false;' title='Search Account Type'><span><span>Find</span></span></button>
<button type='button' id='btnClear' name='btnClear' onclick='ClearKeyword(); return false;' title='Clear Keyword'><span><span>Clear</span></span></button>";
	


echo"</td><td align='left'><span class='style1'><b>Results/page</b></span>
	 <span class='style1'><select name='perpage' id='perpage' value='$perpage' onchange=set_limit();>";
	 
	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
		
	for($i=10;$i<=$maxperpage;$i=$i+10){
		if($i==$perpage)
			echo "<option value='$i'  selected>$i</option>";
		else echo "<option value='$i'>$i</option>";
		
	} 

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


echo"<tr><td id='content-body'>";				
echo"<table border='0'  align='center' valign='top'  class='tablecontent' >
	<col width=65%>";

echo"   <tr bgcolor='#F7F7F7' ><td valign='top' align='left'>";	 
	  
echo"  
        <table border='0' style='table-layout:fixed' align='left' valign='top'>
      <col width=110> 
      <col width=180> ";

echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Code&nbsp;<span class='style26'>*</span></span></td>";
echo"<td colspan='2' height='20'>";

if (empty($Acctype_code))
	echo "<input type='text' name='Acctype_code'  value='".htmlspecialchars($Acctype_code, ENT_QUOTES)."' style='font-size:12px; width:120px; height:18px;'  $status maxlength='20' />";
else
	echo " <span class='style1'><b>$Acctype_code</b></span><input type='hidden' name='Acctype_code'  value='".htmlspecialchars($Acctype_code, ENT_QUOTES)."'  />";	

echo"</td>";


	
	echo"</tr>";

echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Name&nbsp;<span class='style26'>*</span></span></td>";
echo"<td colspan='2'><input type='text' name='Acctype_name' value='".htmlspecialchars($Acctype_name, ENT_QUOTES)."' style='font-size:12px; width:408px; height:18px;'  $status maxlength='50' /></td></tr>";


echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Ledger&nbsp;<span class='style26'>*</span></span></td>";
echo"<td><input type='text' name='ledger_code' value='".htmlspecialchars($ledger_code, ENT_QUOTES)."' style='font-size:12px; width:110px; height:18px;'  $status maxlength='15' readonly/>";

if($mainmode!='view' && $mainmode!='')
	echo"&nbsp;<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(2); return false' /></span></label></td>";

echo"<td><input type='text' name='ledger_name' value='".htmlspecialchars($ledger_name, ENT_QUOTES)."' readonly size='31' style='font-size:12px; width:261px; height:18px;'></td></tr>";	


echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Project Code&nbsp;<span class='style26'>*</span></span></td>";
echo"<td><input type='text' name='project_code' value='".htmlspecialchars($project_code, ENT_QUOTES)."' style='font-size:12px; width:110px; height:18px;'  $status maxlength='15' readonly/>";

if($mainmode!='view' && $mainmode!='')
	echo"&nbsp;<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Project '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistProject(5); return false' /></span></label></td>";

echo"<td><input type='text' name='project_name' value='".htmlspecialchars($project_name, ENT_QUOTES)."' readonly size='31' style='font-size:12px; width:261px; height:18px;'></td></tr>";	
	
$SameLengthMode = '';
if (empty($Acctype_SameLength)) $Acctype_SameLength = 0;
if($Acctype_SameLength== 1) $SameLengthMode = '  checked  ';
echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Same Length</span></td>";
echo"	  <td valign='center' align='left' width=5%><span class='style1'><input type=checkbox name='SameLength' onclick='CheckSameLength()' $SameLengthMode $dis> 
		  <input type='hidden' name='Acctype_SameLength' value='$Acctype_SameLength' /></td>";
		  echo"<td rowspan='3' valign='top' align='left'>
<table border=0 width=97.5% bgcolor='#d2d2d2'>
    <tr><td><span class='style1'><b><u>N.B : Activity</u></b></td></tr>
	<tr height=20px><td><span class='style1'>1- Checks for Collection </td><td><span class='style1'> 2- Checks for Payment </td></tr>
	<tr height=20px><td><span class='style1'>3- Bills for Collection  </td><td><span class='style1'>4- Bills for Payment </td></tr>
	<tr height=20px><td><span class='style1'>5- Clients </td><td><span class='style1'> 6- Suppliers</td></tr> </table></td></tr> ";


echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Type</span></td>";
echo"	  <td valign='center' align='left'><span class='style1'><select name='AccountType' $dis style='width:120px;'>

<option value='0' ";if($AccountType==0) echo " selected ";echo">Default</option>
<option value='1' ";if($AccountType==1) echo " selected ";echo">Fixed Assets</option></select></td></tr> ";
		
echo"<tr bgcolor='#F7F7F7' height='25px'><td valign='center' align='left' ><span class='style1'>Depreciation %</span></td>";
echo"	  <td valign='center' align='left'><input type='text' name='deprec_perc' value='".htmlspecialchars($deprec_perc, ENT_QUOTES)."' style='font-size:12px; width:120px; height:18px;'  $status maxlength='15' /></td></tr> ";
		
echo"</tr>";	
echo"<tr height='20'><td>&nbsp;</td></tr>";

if($actionmode=='editdt'){

	$querydt = " select AccTypeSetupInc, Type_Code, GeneratedType_Name, Ledger_Number, Ledger_activity ".
			   " from acctypesetup ".
			   " where acctypesetup.AccTypeSetupInc='".$AccTypeSetupInc."'";

	//echo $querydt;
	$resultdt = mysql_query($querydt, $connection);
	while($rowdt=mysql_fetch_array($resultdt)){
        
		$type_name=$rowdt[2];
		$ledger_number=$rowdt[3];
		$ledger_activity=$rowdt[4];

	}
	
}

echo"<tr><td valign='top' colspan=4>";
echo "<table style='table-layout:fixed' border=0>
		<col width=20>
		<col width=20>
		<col width=200>
		<col width=200>
		<col width=70>
		<col width=150>";
		
		
echo "<tr bgcolor='#F7F7F7'><td>&nbsp;</td><td>&nbsp;</td><td align='center'><span class='style27'>Name&nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>Group Related&nbsp;<span class='style26'>*</span></span></td>
		<td><span class='style27'>Activity</span></td>
		<td>&nbsp;</td>
      </tr>";
							

echo "<tr bgcolor='#F7F7F7'><td>&nbsp;</td><td>&nbsp;<input type='hidden' name ='AccTypeSetupInc' value='$AccTypeSetupInc'></td>
		<td><input type='text' name='type_name'  value='".htmlspecialchars($type_name, ENT_QUOTES)."' $status maxlength='50' size='25'></td>
		<td><input type='text' name='ledger_number'  value='".htmlspecialchars($ledger_number, ENT_QUOTES)."' $status maxlength='100' size='20'>";
if($mainmode!='view' && $mainmode!='')
	echo"&nbsp;<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Ledger '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistLedger(3); return false' /></span></label></td>";

if ($ledger_activity == 1) $S1 = ' selected ';	
if ($ledger_activity == 2) $S2 = ' selected ';
if ($ledger_activity == 3) $S3 = ' selected ';
if ($ledger_activity == 4) $S4 = ' selected ';
if ($ledger_activity == 5) $S5 = ' selected ';
if ($ledger_activity == 6) $S6 = ' selected ';

echo"<td><select name='ledger_activity' $status  style='width: 50px;'>
			<option $S1>1</option>
			<option $S2>2</option>
			<option $S3>3</option>
			<option $S4>4</option>
			<option $S5>5</option>
			<option $S6>6</option>";
			
echo"</select></td>";


			
echo " 	<td align=center><button type='button' id='submitrecord' name='submitrecord' onclick='SubmitRecord(2); return false;' title='Save Changes' $Insmode><span><span>Submit</span></span></button>";
echo"<button type='button' id='clearbutton' name='clearbutton' onclick='cleardetail(); return false;' title='Clear Detail' $Insmode><span><span>Clear</span></span></button></td>";

echo "</tr>";	

$querydt = " select AccTypeSetupInc, Type_Code, GeneratedType_Name, Ledger_Number, Ledger_activity ".
		   " from acctypesetup ".
		   " where acctypesetup.Type_Code='".$Acctype_code."'";

//echo $querydt;
$resultdt = mysql_query($querydt, $connection);
while($rowsdt=mysql_fetch_array($resultdt)){
			    
	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";	
						
				
	echo "<tr ".$Color." >";
	echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=UpdateDetail('".$rowsdt[0]."') title='Edit Record'  ></span></td>";
	echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=DeleteDetail('".$rowsdt[0]."') title='Delete Record'  ></span></td>";
	echo "	<td align='left'><span class='style15'>".$rowsdt[2]."</span></td>";
	echo "	<td align='left'><span class='style15'>".$rowsdt[3]."</span></td>";
	echo "	<td align='left'><span class='style15'>".$rowsdt[4]."</span></td>";
	echo "	<td align='left'><span class='style15'>&nbsp;</span></td>";
	echo "</tr>";
								
}					
							
echo"</table></td></tr></table></td>";
//richard
echo"</tr><tr><td  valign='top'>";

echo"<table style='width:1050px;' border='0' cellspacing=0>
	<col width=230>
	<tr><td id='' style='width:1100px;height:15px;' colspan='4'></td>
	</tr>
	<tr><td  valign='top' colspan=3 id='' style='width:1050px; position:relative; left:15px;'>
	 <table cellspacing=0>
	 <col width=50>
	<col width=350>
	<col width=350>
	<col width=350>
	 <tr height='30px' style='background-color:darkgray;' >
	 <td>&nbsp;</td>
	 <td align='center'><span class='style1'><b>Code</b></span></td>
	 <td align='center'><span class='style1'><b>Name</b></span></td>
	 <td align='center'><span class='style1'><b>Ledger</b></span></td></tr>";
	 
	echo"<tr><td colspan=4 id=''>
	<div style='overflow-y:scroll;height:250px;width:1060px;border:0px solid #000000;'>
	<table  border='0' width='1100px'>
	<col width=50>
	<col width=350>
	<col width=350>
	<col width=350>";
	
	$querysearch="select Acctype_increment,Acctype_code,Acctype_name,Acctype_ledger from acctype ";
	$querysearch=$querysearch." where (Acctype_name like"."('%".$txtKeyword."%') or Acctype_ledger like"."('%".$txtKeyword."%') or Acctype_code like"."('%".$txtKeyword."%')) ";

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
	$totalrows = mysql_num_rows($resultsearch);
	
	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
	
	$querysearch = $querysearch." limit ".$startrange.",".$perpage;
	

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());	
	while($rows=mysql_fetch_array($resultsearch)){
		$ct+=1;
		$stylefont='style15';
		if($ct%2==0)
			$Color="style='background-color:".$grid_color1."'";
		else			
			$Color="style='background-color:".$grid_color2."'";	
				
		if($mainmode=='edit' && $Acctype_increment==$rows[0]){
			
			$Color="style='background-color:#1e87a5'";
			$stylefont='style28';
	}	
		
	echo'<tr '.$Color.' height="20px" >';
	
	if($FA_AccountTypeDel==1)	
print<<<HERE

<td align=center ><img border='0' src='img/c_delete.png' width='9' height='10' title='Delete Detail' onmouseover="this.style.cursor='pointer'" OnClick="confirm_delete('$rows[0]')" $DelMode></td>

HERE;
else print<<<HERE

<td align=center >&nbsp;</td>

HERE;

	echo"<td style='cursor:pointer;' ";if($FA_AccountTypeMod==1) echo " onclick=SetAcc('$rows[0]');";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
		 <td style='cursor:pointer;' ";if($FA_AccountTypeMod==1) echo " onclick=SetAcc('$rows[0]');";echo" align='left'><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[2]&nbsp;</span></font></td>
		 <td style='cursor:pointer;' ";if($FA_AccountTypeMod==1) echo " onclick=SetAcc('$rows[0]');";echo"><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[3]&nbsp;</span></font></td>";
	echo"";
	

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

echo"<tr ><td >&nbsp;</td><td align='right'>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.jpg' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center' colspan=2>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.jpg' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr>";

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

echo"</tr><tr>
					<td id='' style='width:1100px;height:20px;' colspan='3'></td>
				</tr></table></td></tr>";				
echo"</tr></table></td></tr>";

echo" <tr height='30'><td align='center' id='' ></td></tr>";
include("footer.php");	
echo" </table>  ";//end of last table menu	
							
		

print <<< HERE
       </td>
      </tr>
	  </table>
HERE;


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

HERE;

?>