
<?php

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


include("config.inc.php");
include("function.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 FI_Category 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");

	
$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2,maxperpage from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

	
//Read From module Table							
$querysetup= " select module_rawmaterial,ifNull(Module_AutoItemcode,0) as Module_AutoItemcode  from module ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}	

	
//User Access
$querylog=" select ifNull(FI_CategoryApp,0) As FI_CategoryApp, ifNull(FI_CategoryDel,0) As FI_CategoryDel, ".
          " ifNull(FI_CategoryMod,0) As FI_CategoryMod 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);
}

//Access Mode On Insert/Edit/Delete

$InsMode = '';
if ($FI_CategoryApp == 0)
	$InsMode = ' disabled ';

function displayToday(){
	return strftime("%d")."/".strftime("%m")."/".strftime("%Y");
}

//$inactive_date = '';
$TodayDate = displayToday();
//$selecteddeactivate = 1;
//$category_active = 1;

if(!isset($actionmode))
	$actionmode='';

$mode=$_GET['mode']; if (!isset($mode)) $mode='insert';
$access_id = $_GET['accId'];
//echo "Mode: ".$mode;
//echo "AccessId: ".$access_id;
$message = $_GET['message'];
$access_active = 1;
$admin = 1;
$access_free_items = 1;
$access_menu_sorder = 1;
$access_menu_sales = 1;
$access_menu_sreturn = 1;
$access_menu_receipt = 1;
$access_menu_aging = 1;
$access_menu_comments = 1;
$access_menu_deliverystatus = 1;
$access_menu_routend = 1;
$access_menu_routsummary = 1;
$access_menu_routweekly = 1;
$access_menu_synchro = 1;
$access_sync_sendsorder = 1;
$access_sync_getdata = 1;
$access_menu_clientinfo = 1;
$ACCESS_RECEIPT_BASE2 = 1;
$access_change_sorder_price = 1;
$access_show_sorder_cost = 1;
$access_change_sale_price = 1;
$access_show_sale_cost = 1;

if($mode=='edit' or $mode=='view'){
	//echo "*inside edit query*";
	$query_edit="select access_type, Access_Code, access_name as accName, access_password as accPass, access_remark, access_fromdate, ".
	            "access_todate, access_inactivereason, access_group, access_shift,access_language, access_active, ".
				"access_belongstogrp, access_DefaultComp, access_DefaultYear, cashregister, admin, access_free_items, ".
				"access_menu_sorder, access_menu_sales, access_menu_sreturn, access_menu_receipt, access_menu_aging, access_menu_comments, ".
				"access_menu_deliverystatus, access_menu_routend, ".
				"access_menu_routsummary, access_menu_routweekly, ".
				"access_menu_synchro, access_sync_sendsorder, ".
				"access_sync_getdata, access_menu_clientinfo, ACCESS_RECEIPT_BASE2, ".
				"printer_brand as PrinterBrand, printer_name as PrinterName, ".
				"access_change_sorder_price, access_change_sale_price, ".
				"access_show_sorder_cost, access_show_sale_cost ".
				"from ".$_SESSION['dbLabel'].".access where access_id='$access_id'";

	 
	//echo $query_edit;
	$resultedit = mysql_query($query_edit, $connection);
	$message = mysql_error();
	while($rowedit=mysql_fetch_array($resultedit)){
		extract($rowedit);
	}
}

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

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

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

function checkRout(){
	if(document.getElementById('access_menu_routend').checked){
		document.getElementById('access_menu_routsummary').disabled = false;
		document.getElementById('access_menu_routweekly').disabled = false;
	}else{
		document.getElementById('access_menu_routsummary').checked = false;
		document.getElementById('access_menu_routweekly').checked = false;
		document.getElementById('access_menu_routsummary').disabled = true;
		document.getElementById('access_menu_routweekly').disabled = true;
	}
}

function editForm(accId) {
	document.MobileAccess.action="Form_MobileAccess.php?mode=edit&accId="+accId;
	document.MobileAccess.submit();
}

function SaveChanges(){
	x = document.MobileAccess;
	var accId = document.getElementById('access_id').value;

	x.method="POST";
	x.action="Form_MobileAccess_Actions.php?mode=edit&accId="+accId;
	x.submit();
}

function SubmitRecord() {
	x = document.MobileAccess;

	if (x.access_code.value==''){
			alert('Unable to save : check missing field Code ');
			x.access_code.focus();
			
			}
			
	else  if (x.accName.value=='' ){
			alert('Unable to save : check missing field Name ');
			x.accName.focus();
			
			}
			
	else  if (x.accPass.value=='' ){
			alert('Unable to save : check missing field Name ');
			x.accPass.focus();
			
			}
			else if (x.access_fromdate.value=='' ){
				alert('Unable to save : check missing field Name ');
				x.access_fromdate.focus();	
			}
				else {
					if (confirm ( "Are you sure you want to Save this Record " + "?")) {
						if (x.access_fromdate.value=='' ) x.access_fromdate.value;
						x.method='POST';
						x.action="Form_MobileAccess_Actions.php?mode=insert";
						x.submit();
					}
				}


}

function ClearPage(){
	x = document.MobileAccess;
	if (confirm ( "Are you sure you want to Clear Page?")){
		ClearForm();
		
		x.mode.value='insert';	
		x.actionmode.value='';
		x.action='Form_MobileAccess.php';
		x.submit();
	}	
}

//All= All form; D= Detail Part
function ClearForm(){
    x = document.MobileAccess;
	
	x.access_id.value = '';
	x.access_type.value ='';
	x.access_code.value ='';
	x.accName.value ='';
	x.accPass.value ='';
	x.access_remark.value ='';
	x.access_fromdate.value ='';
	x.access_todate.value ='';
	x.access_inactivereason.value ='';
	x.access_group.value ='';
	x.access_shift.value ='';
	x.access_language.value ='';
	x.access_active.value ='';
	x.access_belongstogrp.value ='';
	x.access_DefaultComp.value ='';
	x.access_DefaultYear.value ='';
	x.cashregister.value ='';
	x.admin.value ='';
	x.access_free_items.value ='';
	x.access_menu_sorder.value ='';
	x.access_menu_sales.value ='';
	x.access_menu_sreturn.value ='';
	x.access_menu_receipt.value ='';
	x.access_menu_aging.value ='';
	x.access_menu_comments.value =''
	x.PrinterBrand.value='';
	x.PrinterName.value='';
	x.access_menu_deliverystatus.value ='';
	x.access_menu_routend.value ='';
	x.access_menu_routsummary.value ='';
	x.access_menu_routweekly.value ='';
	x.access_menu_synchro.value ='';
	x.access_sync_sendsorder.value =''
	x.access_sync_getdata.value='';
	x.access_menu_clientinfo.value='';
		
}

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

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

function SearchForAcc(){
	x = document.MobileAccess;
	document.MobileAccess.action='Form_MobileAccess.php?startrange=0';
	document.MobileAccess.submit();
}

function ClearKeyword(){
	x = document.MobileAccess;
	x.txtKeyword.value='';
	document.MobileAccess.action='Form_MobileAccess.php?startrange=0';
	document.MobileAccess.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.MobileAccess.action='Form_MobileAccess.php?startrange=0';
	document.MobileAccess.submit();
  
	return false;
   }
else
   return true;
}

function confirm_delete(accId) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		
		document.MobileAccess.mode.value='insert';	
		document.MobileAccess.action='Form_MobileAccess_Actions.php?mode=delete&accId='+accId;
		document.MobileAccess.submit();
	}
					
}

function setRow(accId){
	document.MobileAccess.mode.value="view";
	document.MobileAccess.action="Form_MobileAccess.php?mode=view&accId="+accId;
	document.MobileAccess.submit();
}

function set_limit(){

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

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

.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>

</head>
<body >
<form name='MobileAccess' method='post'>
<input type=hidden name='mode' value='$mode'>
<input type=hidden name='actionmode' value='$actionmode'>
<input type=hidden name='message' value='$message'>
<input type=hidden id='access_id' name='access_id' value='$access_id'>
HERE;



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

}


if($mode=='view'){

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

}

if($mode=='insert'){
	$status='';
	$dis='';
}
//echo $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'>Mobile Access</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>";
if($mode=='insert') echo "<button type='button' id='btnPost' name='btnPost' onclick='SubmitRecord(); return false;' title='Save Record'><span><span>Save</span></span></button>";
if($mode=='edit') echo "<button type='button' id='btnSave' name='btnSave' onclick='SaveChanges(); return false;' title='Save Changes'><span><span>Save</span></span></button>";
if($mode=='view') echo "<button type='button' id='btnEdit' name='btnEdit' onclick='editForm($access_id); return false;' title='Edit Record'><span><span>Edit Record</span></span></button>";

				
echo"</td><td align='left' width='260px'>
	
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:110px;' onKeyPress='return submitenter(this,event)'>&nbsp;
	<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForAcc(); return false;' title='Search Access'><span><span>Find</span></span></button>
	<button type='button' id='btnClearKw' name='btnClearKw' onclick='ClearKeyword(); return false;' title='Clear Keyword'><span><span>Clear</span></span></button>
	</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'>
<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
	<col width=65%>";
	
echo"   <tr bgcolor='#F7F7F7'><td valign='top'>";	 
	  
echo"  <table border='0' style='table-layout:fixed' align='left' valign='top'>
		<col width=120>
		<col width=120>
		<col width=120>
		<col width=140>
		<col width=120>
		<col width=120> 
		<col width=120>";
	  
	  
/*echo"<tr bgcolor='#F7F7F7' height='25'>
             <td valign='center' align='left' ><span class='style1'>Creation Date&nbsp;<span class='style26'>*</span></span>";
	
			 echo"</td>";
			 
			 if($mode!=''){
			
					$today = date('d-m-Y');
					$Category_CreationDate = $today;
					}			
				
					
			 echo"
		     <td align='left'>
			  <input type='text' name='Category_CreationDate' id='Category_CreationDate' value='$Category_CreationDate' style='font-size:12px; width:100px; height:18px;' readonly />
			  ";
			
			  if ($mode!=''){
	         $Category_CreationDate = "disabled";
	         }

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

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Name&nbsp;<span class='style26'>*</span></span></td>";
echo"<td align='left'><input type='text' name='accName' value='".htmlspecialchars($accName, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;' maxlength='15'"; echo $status; echo "/></td>";
echo"<td valign='center' align='left' ><span class='style1'>Password&nbsp;<span class='style26'>*</span></span></td>";
echo"<td align='left'><input type='";if($mode==view or $mode==edit) echo "text"; else echo "password"; echo"'name='accPass' value='".htmlspecialchars($accPass, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;' maxlength='15'"; echo $status; echo "/></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Remark&nbsp;</span></td>";
echo"<td align='left' colspan='4'><input type='text' name='access_remark' value='$access_remark' style='font-size:12px; width:344px; height:18px;' maxlength='250'"; echo $status; echo "/></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>From Date&nbsp;<span class='style26'>*</span></span></td>";
echo"<td align='left'><input type='text' name='access_fromdate' value='$access_fromdate' id='access_fromdate' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<A HREF=\"#\" onClick=\"displayCalendar(document.MobileAccess.access_fromdate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center ></image></A></td>";
echo"<td valign='center' align='left' ><span class='style1'>To Date&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_todate' value='$access_todate' id='access_todate' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<A HREF=\"#\" onClick=\"displayCalendar(document.MobileAccess.access_todate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\"><image src='./img/cal.gif' border=0 align=center ></image></A></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Inactive Reason&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left' colspan='4'><input type='text' name='access_inactivereason' value='$access_inactivereason' style='font-size:12px; width:344px; height:18px;' maxlength='250'"; echo $status; echo "/></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Access Group&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_group' value='$access_group' id='access_group' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<td valign='left' align='left' ><span class='style1'>Access Shift&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_shift' value='$access_shift' id='access_shift' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/></tr>";

echo"<tr><td valign='left' align='left' ><span class='style1'>Access Language&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_language' value='$access_language' id='access_language' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/></td>";
echo"<td valign='left' align='left' ><span class='style1'>Active&nbsp;<input type='checkbox' name='access_active' id='access_active' onclick='' value='$access_active' "; if($access_active==1) echo "checked"; echo" $dis /></span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Belongs To Group&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_belongstogrp' value='$access_belongstogrp' id='access_belongstogrp' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<td valign='center' align='left' ><span class='style1'>Default Company&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_DefaultComp' value='$access_DefaultComp' id='access_DefaultComp' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Default Year&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='access_DefaultYear' value='$access_DefaultYear' id='access_DefaultYear' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<td valign='center' align='left' ><span class='style1'>Cash Register&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='cashregister' value='$cashregister' id='cashregister' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='center' align='left' ><span class='style1'>Printer Brand&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='PrinterBrand' value='";if($PrinterBrand == "") echo "noprinter"; else echo $PrinterBrand; echo "' id='PrinterBrand' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/>";
echo"<td valign='center' align='left' ><span class='style1'>Printer Name&nbsp;<span class='style26'></span></span></td>";
echo"<td align='left'><input type='text' name='PrinterName' value='";if($PrinterName == "") echo "noprinter"; else echo $PrinterName; echo "' id='PrinterName' style='font-size:12px; width:100px; height:18px;'"; echo $status; echo "/></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='admin' id='admin' onclick='' value='$admin' "; if($admin==1) echo "checked"; echo" $dis /><span class='style1'>Admin&nbsp;</span></td>";
echo"<td valign='left' align='left' ><input type='checkbox' name='access_free_items' id='access_free_items' onclick='' value='$access_free_items' "; if($access_free_items==1) echo "checked"; echo" $dis /><span class='style1'>Free Items&nbsp;</span></td>";

echo"</table></td>";
echo"<td  valign='top'>";

echo"<table style='width:380px;' border='0' cellspacing=0><col width=100><col width=150>
	<tr><td id='search-top' style='width:380px;height:15px;' colspan='4'></td>
	</tr>
	 <tr><td  valign='top' colspan=3 id='search-content' style='width:380px;'><table style='width:380px;' border='0' cellspacing=0><col width=30><col width=80><col width=140><col width=130>
	<tr height='30px'><td>&nbsp;</td>
	<td align='center'><span class='style1'><b>Code</b></td><td align='center'><span class='style1'><b>Type</b></td>
	<td align='center'><span class='style1'><b>Name</b></td>
	</tr>
	
	</table></td></tr>";
	 
	echo"<tr><td colspan=3 id='search-content'><div style='overflow-y:scroll;height:280px;width:370px;border:0px solid #000000;padding-left:5px;'><table  border='0' width='352px'>
	<col width=30><col width=160><col width=170>";
	
	$querysearch="select access_code, access_type, access_name, access_id from ".$_SESSION['dbLabel'].".access";
	$querysearch=$querysearch." where (access_code like"."('%".$txtKeyword."%') or access_type like"."('%".$txtKeyword."%') or access_name 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());	
	//echo $querysearch;exit;
	while($rowsearch=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($mode=='edit' && $access_id==$rowsearch[0]){
			
			$Color="style='background-color:#1e87a5'";
			$stylefont='style28';
		}	
		echo"<tr '.$Color.' height='20px' >";
		//if($FI_CategoryDel==1)	
		
		echo "<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('$rowsearch[3]')\"></td>";
		echo "<td align=center ><img border='0' src='img/btnopen.jpg' width='12' height='12' title='Select Project' onmouseover=\"this.style.cursor='pointer'\" onclick=\"setRow('$rowsearch[3]')\"></td>";

		//else 
		echo "<td align=center >&nbsp;</td>";


			echo"<td width=33%><span class='$stylefont' >$rowsearch[0]&nbsp;</span></font></td>
				<td width=33%><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rowsearch[1]&nbsp;</span></font></td>
				<td width=33%><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rowsearch[2]&nbsp;</span></font></td>";
			
			echo"";


			echo"	</tr>";
	}		
	
echo"</table></div></td></tr>";
echo"<tr height='50px'><td id='search-content' colspan='2'><table width=100% border='0'><tr><td align='center' width=50%>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center'>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr><tr>
					<td id='search-bottom' style='width:380px;height:20px;' colspan='6'></td>
				</tr></table></td></tr>";
		

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

echo"   <tr bgcolor='#F7F7F7'><td align='left' valign='top'>";	 
	  
echo"  <table border='0' style='table-layout:fixed;' align='left' valign='top'>
		<col width=160>
		<col width=160>";
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><span class='style1'>Main Menu&nbsp;</span>";
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_routend' id='access_menu_routend' onclick='checkRout()' value='$access_menu_routend' "; if($access_menu_routend==1) echo "checked"; echo" $dis /><span class='style1'>Rout End&nbsp;</span></td></tr>";
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_routsummary' id='access_menu_routsummary' onclick='' value='$access_menu_routsummary' "; if($access_menu_routsummary==1) echo "checked"; if($access_menu_routend==0) echo "disabled"; echo" $dis /><span class='style1'>Rout Summary&nbsp;</span></td>";
echo"<td valign='left' align='left' ><span class='style1'><input type='checkbox' name='access_menu_routweekly' id='access_menu_routweekly' onclick='' value='$access_menu_routweekly' "; if($access_menu_routweekly==1) echo "checked"; if($access_menu_routend==0) echo "disabled"; echo" $dis />Rout Weekly&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_synchro' id='access_menu_synchro' onclick='' value='$access_menu_synchro' "; if($access_menu_synchro==1) echo "checked"; echo" $dis /><span class='style1'>Synchro&nbsp;</span></td>";
echo"<td valign='left' align='left' ><span class='style1'><input type='checkbox' name='access_menu_deliverystatus' id='access_menu_deliverystatus' onclick='' value='$access_menu_deliverystatus' "; if($access_menu_deliverystatus==1) echo "checked"; echo" $dis />Delivery Status&nbsp;</span></td>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='access_sync_getdata' id='access_sync_getdata' onclick='' value='$access_sync_getdata' "; if($access_sync_getdata==1) echo "checked"; echo" $dis /><span class='style1'>Get Data&nbsp;</span></td>";
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='right' ><input type='checkbox' name='access_sync_sendsorder' id='access_sync_sendsorder' onclick='' value='$access_sync_sendsorder' "; if($access_sync_sendsorder==1) echo "checked"; echo" $dis /><span class='style1'>Send Sales Order&nbsp;</span></td></tr>";

echo"</table>";

	 
	  
echo"  <table border='0' style='table-layout:fixed;border-left:1px solid' align='left' valign='top'>
		<col width=160>
		<col width=160>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><span class='style1'>Sub Menu&nbsp;</span>";
echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_sorder' id='access_menu_sorder' onclick='' value='$access_menu_sorder' "; if($access_menu_sorder==1) echo "checked"; echo" $dis /><span class='style1'>Sales Order&nbsp;</span></td>";
echo"<td valign='left' align='left' ><input type='checkbox' name='access_menu_receipt' id='access_menu_receipt' onclick='' value='$access_menu_receipt' "; if($access_menu_receipt==1) echo "checked"; echo" $dis /><span class='style1'>Receipt&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='right' ><input type='checkbox' name='access_change_sorder_price' id='access_change_sorder_price' onclick='' value='$access_change_sorder_price' "; if($access_change_sorder_price==1) echo "checked"; echo" $dis /><span class='style1'>Change Price&nbsp;</span></td>";
echo"<td valign='left' align='right' ><input type='checkbox' name='ACCESS_RECEIPT_BASE2' id='ACCESS_RECEIPT_BASE2' onclick='' value='$ACCESS_RECEIPT_BASE2' "; if($ACCESS_RECEIPT_BASE2==1) echo "checked"; echo" $dis /><span class='style1'>Amount Base 2&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='right' ><input type='checkbox' name='access_show_sorder_cost' id='access_show_sorder_cost' onclick='' value='$access_show_sorder_cost' "; if($access_show_sorder_cost==1) echo "checked"; echo" $dis /><span class='style1'>Cost Price&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_sales' id='access_menu_sales' onclick='' value='$access_menu_sales' "; if($access_menu_sales==1) echo "checked"; echo" $dis /><span class='style1'>Sales&nbsp;</span></td>";
echo"<td valign='left' align='left' ><input type='checkbox' name='access_menu_clientinfo' id='access_menu_clientinfo' onclick='' value='$access_menu_clientinfo'  "; if($access_menu_clientinfo==1) echo "checked"; echo" $dis /><span class='style1'>Client Info&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='right' ><input type='checkbox' name='access_change_sale_price' id='access_change_sale_price' onclick='' value='$access_change_sale_price' "; if($access_change_sale_price==1) echo "checked"; echo" $dis /><span class='style1'>Change Price&nbsp;</span></td>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='right' ><input type='checkbox' name='access_show_sale_cost' id='access_show_sale_cost' onclick='' value='$access_show_sale_cost' "; if($access_show_sale_cost==1) echo "checked"; echo" $dis /><span class='style1'>Cost Price&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_sreturn' id='access_menu_sreturn' onclick='' value='$access_menu_sreturn' "; if($access_menu_sreturn==1) echo "checked"; echo" $dis /><span class='style1'>Return Sales&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height='25'><td valign='left' align='left' ><input type='checkbox' name='access_menu_comments' id='access_menu_comments' onclick='' value='$access_menu_comments'  "; if($access_menu_comments==1) echo "checked"; echo" $dis /><span class='style1'>Menu Comments&nbsp;</span></td>";
echo"<td valign='left' align='left' ><input type='checkbox' name='access_menu_aging' id='access_menu_aging' onclick='' value='$access_menu_aging' "; if($access_menu_aging==1) echo "checked"; echo" $dis /><span class='style1'>Menu Aging&nbsp;</span></td></tr>";


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

echo "</table>";


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

print <<< HERE
       </td>
      </tr><tr height='30'><td align='center' id='content-bottom' ></td></tr>
	  </table>
HERE;


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

HERE;

?>