<?php

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


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

$actionmode = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];}   
$message 	= $_POST["message"]; if ($message == ""){$message = $_GET["message"];}   
$frm	   	= $_POST['frm']; if ($frm == ""){$frm = $_GET["frm"];}
$item 	   	= $_POST['item'];if ($item == ""){$item = $_GET["item"];}
$startrange = $_POST['startrange'];if ($startrange == ""){$startrange = $_GET["startrange"];}
$PTabIndex  = $_POST['PTabIndex'];if ($PTabIndex == ""){$PTabIndex = $_GET["PTabIndex"];}


$perpage   		= $_POST["perpage"]; if ($perpage == ""){$perpage = $_GET["perpage"];}
$p_name    		= $_POST["p_name"]; if ($p_name == ""){$p_name = $_GET["p_name"];}
$p_cashregister = $_POST["p_cashregister"]; if ($p_cashregister == ""){$p_cashregister = $_GET["p_cashregister"];}
$p_subgroup  	= $_POST["p_subgroup"]; if ($p_subgroup == ""){$p_subgroup = $_GET["p_subgroup"];}
$p_category  	= $_POST["p_category"]; if ($p_category == ""){$p_category = $_GET["p_category"];}

$Reason_Id  	= $_POST["Reason_Id"]; if ($Reason_Id == ""){$Reason_Id = $_GET["Reason_Id"];}
$Reason_Remark 	= $_POST["Reason_Remark"]; if ($Reason_Remark == ""){$Reason_Remark = $_GET["Reason_Remark"];}

$Payment_Id  		 = $_POST["Payment_Id"]; if ($Payment_Id == ""){$Payment_Id = $_GET["Payment_Id"];}
$Payment_Account 	 = $_POST["Payment_Account"]; if ($Payment_Account == ""){$Payment_Account = $_GET["Payment_Account"];}
$Payment_Description = $_POST["Payment_Description"]; if ($Payment_Description == ""){$Payment_Description = $_GET["Payment_Description"];}


$User_Account  = $_POST["User_Account"]; if ($User_Account == ""){$User_Account = $_GET["User_Account"];}
$User_Name 	   = $_POST["User_Name"]; if ($User_Name == ""){$User_Name = $_GET["User_Name"];}
$User_Password = $_POST["User_Password"]; if ($User_Password == ""){$User_Password = $_GET["User_Password"];}

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

//Read From Setup Table							
$querysetup= " Select DecimalBase, DecimalBase1, DecimalBase2, Base1, Base2, grid_color1, grid_color2, ifNull(ShowSlipNumber,0) As ShowSlipNumber, ".
             " Setup_VatNo, Date_Format(Setup_VatStartDate,'%d/%m/%Y') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage, Company_Name As CompanyName, ".
			 " CashReg_DispLedMsg, ifNull(CashReg_Weight,0) As CashReg_Weight, CashReg_StartBarcode, CashReg_EndBarcode, CashReg_StartQty, CashReg_EndQty, ".
			 " ifNull(CashReg_Price,0) As CashReg_Price, CashReg_StartPrice, CashReg_EndPrice, ifNull(CashReg_RoundDivisor,1) As CashReg_RoundDivisor, ".
			 " ifNull(CashReg_ColorTheme,'default') as CashReg_ColorTheme, CashReg_BgColorOffer, CashReg_BgColorQty, CashReg_BgColorOrderQty, Company_memo as CompanyMemo, ".
			 " CashReg_BgColorZeroPrice, CashReg_BgColorZeroQty, CashReg_BgColorHasDiscount, ifNull(CashReg_ApplyColorOffer,0) As CashReg_ApplyColorOffer, ".
			 " ifNull(CashReg_ApplyColorQty,0) As CashReg_ApplyColorQty, ifNull(CashReg_ApplyColorOrderQty,0) As CashReg_ApplyColorOrderQty, ifNull(CashReg_ApplyColorZeroPrice,0) As CashReg_ApplyColorZeroPrice,  ".
			 " ifNull(CashReg_ApplyColorZeroQty,0) As CashReg_ApplyColorZeroQty, ifNull(CashReg_ApplyColorHasDiscount,0) As CashReg_ApplyColorHasDiscount  ".
			 " From Setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

//Read From Module Table
$querymodule=" Select ifNull(Module_PostRetailOneToOne,0) As Module_PostRetailOneToOne, ifNull(Module_PostingByCashRegister,0) As Module_PostingByCashRegister, ".
             " ifNull(Module_CashRegItemQtyInCode,0) As Module_CashRegItemQtyInCode, ifNull(Module_CashRegItemSeperate,0) As Module_CashRegItemSeperate, ".
			 " ifNull(Module_CashRegisterBase2,0) As Module_CashRegisterBase2, ifNull(Module_PriceOffer,0) As Module_PriceOffer ".
			 " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

if (empty($CashRegister_Name) && !isset($CashRegister_Name)) {
	$queryCashRegisterDft=" Select CashRegister_Name From CashRegister Order By CashRegister_Name Limit 1 ";
	$resultCashRegisterDft = selectData($connection, $queryCashRegisterDft);
	
	$CashRegister_Name = $resultCashRegisterDft[0];
}

//Read From CashRegister Table
$queryCashRegister=" Select CashRegister_Name, Currency_Code, CostCenter_Code, Project_Code, Warehouse_Code, Client_Account, Sales_Account, Cash_Account, ".
				   " Check_Account, Tips_Account, Coupon_Account, ifNull(CashRegister_Drawer,0) As CashRegister_Drawer, CashRegister_DrawerCOM,  ".
                   " ifNull(CashRegister_DisplayLed,0) As CashRegister_DisplayLed, CashRegister_DispCOM, ifNull(CashRegister_LedDescLength,0) As CashRegister_LedDescLength, ".
				   " ifNull(CashRegister_BarCode,0) As CashRegister_BarCode, ifNull(CashRegister_PrintBarcode,0) As CashRegister_PrintBarcode, ".
				   " ifNull(CashRegister_SerialNo,0) As CashRegister_SerialNo, ifNull(CashRegister_RestSerialNo,0) As CashRegister_RestSerialNo, ".
				   " ifNull(CashRegister_Discount,0) As CashRegister_Discount, ifNull(CashRegister_SlipPrinter,0) As CashRegister_SlipPrinter, ".
				   " ifNull(CashRegister_Printer,0) As CashRegister_Printer, ifNull(CashRegisterTTC,0) As CashRegisterTTC, ".
				   " ifNull(CashRegister_Credit,0) As CashRegister_Credit, ifNull(CashRegister_Check,0) As CashRegister_Check, ".
				   " ifNull(CashReg_Vendor,0) As CashReg_Vendor, ifNull(CashReg_ForcingVendor,0) As CashReg_ForcingVendor, ".
				   " ifNull(Module_CashRegisterTable,0) As Module_CashRegisterTable, ifNull(Module_CashregisterStandardview,0) As Module_CashregisterStandardview, ".
				   " ifNull(Module_CashRegisterFastItem,0) As Module_CashRegisterFastItem, ifNull(Module_RestaurantDelivery,0) As Module_RestaurantDelivery, ".
				   " ifNull(Module_CashRegAutoItemsList,0) As Module_CashRegAutoItemsList, ifNull(CashRegister_ShowTaxNonTax,0) As CashRegister_ShowTaxNonTax, ".
				   " ifNull(CashRegister_AutoPost,0) As CashRegister_AutoPost, ifNull(CashRegister_SlipKitchen,0) As CashRegister_SlipKitchen, ".
				   " ifNull(CashRegister_SlipCopy, 1) As CashRegister_SlipCopy, CashRegister_DrawerPrinter, ifNull(CashRegister_AutoClosePrint,0) as CashRegister_AutoClosePrint ".
				   " ,ifNull(cashregister_logout,0) As cashregister_logout, ifNull(cashregister_retailtype,0) As cashregister_retailtype".
				   " From CashRegister ".
				   " Where CashRegister_Name = '".$CashRegister_Name."' ";

$resultCashRegister=mysql_query($queryCashRegister,$connection) or die(mysql_error());
while($rowCashRegister=mysql_fetch_array($resultCashRegister)){
	extract($rowCashRegister);
}

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

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

<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<link type="text/css" href="js/calendar/jquery.datetimepicker.css" rel="stylesheet">
<script type="text/javascript" src="js/calendar/jquery.datetimepicker.js"></script>
<script type="text/javascript" src="js/jscolor/jscolor.js"></script>
<script type="text/javascript" src="tabsClass/tabber.js"></script>
<link rel="stylesheet" href="tabsClass/tabber.css" type="text/css" />

<script type="text/javascript">

/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear.
*/

var tabberOptions = {

  /* Optional: instead of letting tabber run during the onload event,
     we'll start it up manually. This can be useful because the onload
     even runs after all the images have finished loading, and we can
     run tabber at the bottom of our page to start it up faster. See the
     bottom of this page for more info. Note: this variable must be set
     BEFORE you include tabber.js.
  */
  'manualStartup':true,

  /* Optional: code to run after each tabber object has initialized */


  /* Optional: code to run when the user clicks a tab. If this
     function returns boolean false then the tab will not be changed
     (the click is canceled). If you do not return a value or return
     something that is not boolean false, */

  'onClick': function(argsObj) {

    var t = argsObj.tabber; /* Tabber object */
    var id = t.id; /* ID of the main tabber DIV */
    var i = argsObj.index; /* Which tab was clicked (0 is the first tab) */
    var e = argsObj.event; /* Event object */
	
	if (id == 'tab1') document.getElementById('PTabIndex').value = i;
  },

  /* Optional: set an ID for each tab navigation link */
  'addLinkId': true

};

</script>

<script type="text/javascript" language="javascript">
	$(document).on('click', '#txtDateFrom', function() {
			$('#txtDateFrom').datetimepicker({
				timepicker:false,
				formatDate:'Y/m/d',
				scrollMonth:false
			});
		});
</script>
		
<script type="text/javascript" language="javascript">


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 LoadForm() 
{ 
	x=document.form1;
	x.CashRegister_Name.focus();
}

function CloseForm() {
	self.close();
}


function SubmitRecord() {
	x = document.form1;
	
	if (confirm ( "Are you sure you want to Save changes?" ))
	{
		if (document.getElementById('btnSubmit')) x.btnSubmit.disabled = true;
				
		vCashRegName = document.getElementById('CashRegister_Name').value;
		x.action="Form_Retail_Actions.php?mode=savecashreg&txtCashRegisterName="+vCashRegName;
		x.submit();
		
		MakeCursorHourglass();
	}   
	
}

function SubmitRecord1() {
	x = document.form1;
	
	if (confirm ( "Are you sure you want to Save changes?" ))
	{
		if (document.getElementById('btnSubmit1')) x.btnSubmit1.disabled = true;
				
		x.action="Form_Retail_Actions.php?mode=savesetup";
		x.submit();
		
		MakeCursorHourglass();
	}   
	
}

function ClearRecord() {
	x = document.form1;
	
	x.CashRegister_Name.value = '';
	x.Currency_Code.value = '';
	x.CostCenter_Code.value = '';
	x.Project_Code.value = '';
	x.Warehouse_Code.value = '';
	x.Client_Account.value = '';
	x.Sales_Account.value = '';
	x.Cash_Account.value = '';
	x.Check_Account.value = '';
	x.Tips_Account.value = '';
	x.Coupon_Account.value = '';
	
	x.action="Form_RetailSetup.php";
	x.submit();

}
	

function MakeCursorHourglass()
{
    document.body.style.cursor = "wait";
}

function SelectRecord(CashReg){
	
	document.form1.CashRegister_Name.value=CashReg;
	document.form1.message.value='';
	document.form1.actionmode.value='';
	document.form1.action="Form_RetailSetup.php";
	document.form1.submit();
}

function ClearForm()
{
	document.form1.PLedgerNo.value='';
	document.form1.actionmode.value='';
	document.form1.startrange.value = 0;
	document.form1.submit();
}

function AddRecord() {
	var x = document.form1;
	
	x.PLedgerNo.value='';
	x.actionmode.value='Add';
	x.submit();
}

function CancelRecord() {
	var x = document.form1;
	
	x.actionmode.value='';
	
	
	x.p_name.value='';
	x.p_id.value='';
	x.p_cashregister.value='';
	x.p_subgroup.value='';
	x.p_category.value='';
	
	
	x.submit();
}

function SubmitForm()
{	

	document.form1.actionmode.value='';
	document.form1.startrange.value = 0;
	document.form1.action='Form_RetailSetup.php?startrange=0';
	document.form1.submit();

}

function SubmitRecordPrinter() {
	var x = document.form1;
	var result = CheckFields();
	
	if (result == 1) {
		x.actionmode.value='Submit';
		x.submit();
	}
}

function UpdateRecordPrinter(pid) {
	var x = document.form1;
	
	x.actionmode.value='Edit';
	x.p_id.value=pid;
	x.submit();

}

function DeleteRecordPrinter(pid) {
	var x = document.form1;
	
	x.actionmode.value='DeletePrinter';
	x.p_id.value=pid;
	x.submit();
}

function CheckFields(){
  
    var x = document.form1;
	
	var vCode = x.p_name.value;
	var vName = x.p_subgroup.value;
	
	if (vCode=='' )
	{
		alert("Name is mandatory!");
		x.p_name.focus();
		return 0;
	}
	else if (vName=='')
	{
		alert("Subgroup is mandatory!");
		x.p_subgroup.focus();
		return 0;
	}
	
	
	else
	return 1 ;	
}

function SetNextPage(startrange, perpage){
	x=document.form1;
	
	x.startrange.value = startrange;
	x.action='Form_RetailSetup.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	x.submit();
}

function SetPrvPage(startrange, perpage){
	x=document.form1;
	
	x.startrange.value = startrange;
	x.action='Form_RetailSetup.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	x.submit();
}

function SubmitRecordVoid() {
	var x = document.form1;
	var result = 1;
	var ReasonRemark = x.Reason_Remark.value;
	
	if (ReasonRemark == '') {
		result = 0;
		alert('Please enter void remark.');
	}
	
	if (result == 1) {
		x.actionmode.value='SubmitVoid';
		x.submit();
	}
}

function ClearRecordVoid() {
	var x = document.form1;
	
	x.actionmode.value='';
	x.Reason_Remark.value='';
	x.Reason_Id.value='';
	
	x.submit();

}

function UpdateRecordVoid(ReasonId, ReasonRemark) {
	var x = document.form1;
	
	x.actionmode.value='EditVoid';
	x.Reason_Id.value=ReasonId;
	x.Reason_Remark.value=ReasonRemark;
}

function DeleteRecordVoid(ReasonId) {
	var x = document.form1;
	
	x.actionmode.value='DeleteVoid';
	x.Reason_Id.value=ReasonId;
	x.submit();
}


function SubmitRecordCredits() {
	var x = document.form1;
	var result = 1;
	var PaymentAccount = x.Payment_Account.value;
	var PaymentDescription = x.Payment_Description.value;
	
	if (PaymentAccount == '') {
		result = 0;
		alert('Please enter credit account #.');
	}
	else if (PaymentDescription == '') {
		result = 0;
		alert('Please enter credit description.');
	}
	
	if (result == 1) {
		x.actionmode.value='SubmitCredits';
		x.PTabIndex.value=4;
		x.submit();
	}
}

function ClearRecordCredits() {
	var x = document.form1;
	
	x.actionmode.value='';
	x.Payment_Account.value='';
	x.Payment_Description.value='';
	x.Payment_Id.value='';
	
	x.PTabIndex.value=4;
	x.submit();

}

function UpdateRecordCredits(PaymentId, PaymentAccount, PaymentDescription) {
	var x = document.form1;
	
	x.actionmode.value='EditCredits';
	x.Payment_Id.value=PaymentId;
	x.Payment_Account.value=PaymentAccount;
	x.Payment_Description.value=PaymentDescription;
	
	x.PTabIndex.value=4;
	x.submit();
}

function DeleteRecordCredits(PaymentId) {
	var x = document.form1;
	
	x.actionmode.value='DeleteCredits';
	x.Payment_Id.value=PaymentId;
	x.PTabIndex.value=4;
	x.submit();
}

function AssignTable() {
	x = document.form1; 
	var UserName = x.User_Account.value;
	
	var Win = window.open('Form_Assign_Table.php?UserName='+UserName,'Setup', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=720,height=650,left=250,top=50');
	Win.creator = self;
	Win.focus();
}

function SubmitRecordUsers() {
	var x = document.form1;
	var result = 1;
	var UserAccount = x.User_Account.value;
	var UserPassword = x.User_Password.value;
	var UserName = x.User_Name.value;
	
	var BelongsToGrp = x.FI_BelongsToGrp.value;
	var DiscountPerLimit = x.FC_DiscountPerLimit.value;
	
	if (UserAccount == '') {
		result = 0;
		x.User_Account.focus();
		alert('Please enter user account.');
	}
	else if (UserPassword == '') {
		result = 0;
		x.User_Password.focus();
		alert('Please enter user password.');
	}
	else if (UserName == '') {
		result = 0;
		x.User_Name.focus();
		alert('Please enter user name.');
	}
	else if (BelongsToGrp*1 != BelongsToGrp/1 ) {
		result = 0;
		x.FI_BelongsToGrp.focus();
		alert('User Level should be a NUMERIC value. ');
	}
	else if ((DiscountPerLimit*1 != DiscountPerLimit/1 ) || (DiscountPerLimit != '' && DiscountPerLimit > 100)) {
		result = 0;
		x.FC_DiscountPerLimit.focus();
		alert('Discount(%) should be a NUMERIC value and not more than 100. ');
	}
	
	
	if (result == 1) {
		x.actionmode.value='SubmitUsers';
		x.PTabIndex.value=5;
		x.submit();
	}
}

function ClearRecordUsers() {
	var x = document.form1;
	
	x.actionmode.value='';
	x.User_Account.value='';
	x.User_Password.value='';
	x.User_Name.value='';
	
	x.PTabIndex.value=5;
	x.submit();

}

function UpdateRecordUsers(UserAccount, UserPassword, UserName) {
	var x = document.form1;
	
	document.getElementById('assignTable').disabled = false;
	
	x.actionmode.value='EditUsers';
	x.User_Account.value=UserAccount;
	x.User_Password.value=UserPassword;
	x.User_Name.value=UserName;
	
	x.PTabIndex.value=5;
	x.submit();
}

function DeleteRecordUsers(UserAccount) {
	var x = document.form1;
	
	x.actionmode.value='DeleteUsers';
	x.User_Account.value=UserAccount;
	x.PTabIndex.value=5;
	x.submit();
}
function kd(e)
{ 
	x=document.form1;
	if (!e) { var e = window.event;}
    var intKey = (window.Event) ? e.which : e.keyCode;
	
	 
	// Block browser short cuts     
	//F1, F3, F4  key
	if (intKey == 112 || intKey == 114 || intKey == 115 ) {
		if(e.preventDefault) // non-IE browsers         
			e.preventDefault();     
		else  // IE Only  
		{
			e.keyCode=0;  
			e.returnValue = false; 
			
		}	
	}

	
    if (intKey == 113) { //F2 key
		x.btnSubmit.click();
		return false;
	}
	else if (intKey == 114) { //F3 key
		x.btnClear.click();
		return false;
	}
	else if (intKey == 115) { //F4 key
		x.btnSubmit1.click();
		return false;
	}
	else if (intKey == 27) { //ESC key
		x.btnClose.click();
		return false;
	}
	
	
    return true;
}


</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CashRegister Setup</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;
}
.style39 {color:#FF0000; font-weight:bold; font-size:16px; padding:2px;}
.style38 {color:#0026FF; font-weight:bold; font-size:14px; padding:2px;}

div#mainDiv, div#imgDiv {
	font-size: 12px; 
    font-weight:bold; 
	color: #FF0000 ;
	text-align: center; 
	margin-top:10px;
	display:none;
}
 button {
  padding: 0 0 0 0;
  margin: 0 3px 0 3px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  white-space: nowrap;
  overflow: visible;
  height: 22px; 
  font-family: 11px Arial, sans-serif;
  font-size: 13px;
  color: #000000;
  background: none;
  font-weight: bold;

}
</style>

</head>
<body onLoad='LoadForm();' onkeydown='return kd(event);'>
<form name='form1' method='post' enctype="multipart/form-data">
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='message' value='$message'>
<input type='hidden' name='PTabIndex' id='PTabIndex' value='$PTabIndex'>

<input type='hidden' name='p_id' id='p_id'  value='$p_id' >
<input type='hidden' name='item' id='item' value='$item' />
<input type='hidden' name='frm' id='frm' value='$frm' />
<input type='hidden' name='startrange' value='$startrange'>
HERE;
	

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' style='table-layout:fixed' width='700px;'>";
echo"<tr>
		<td id='search-top1' style='height:34px; width:31px;'>&nbsp;</td>
	  	<td id='search-top2' style='height:34px; width:638px' align='center' valign='middle'>$message</td>
		<td id='search-top3' style='height:34px; width:31px;'>&nbsp;</td>
	</tr>";

	  
echo"<tr><td id='search-content1' style='width:31px;'>&nbsp;</td>
		 <td id='search-content2' >"; 
		 
echo"<div class='tabber' id='tab1'>";
echo"	<div class='tabbertab' tabberIndex='0'>
		<h2 title='General'>General</h2>";
		
echo"   <table border='0' cellpadding='0' cellspacing='0' align='center' valign='center' style='width:630px;' >
          <col width=500>
		  <col width=130>
		   <tr bgcolor='#F7F7F7' height='20'>	
			 <td colspan='2' align='left'><span class='style1'>Cashregister Name: </span><input type='text' name='CashRegister_Name' id='CashRegister_Name' value='$CashRegister_Name' maxlength='20' style='width:200px;' readonly></td>
		   </tr>";
		
		  
		  
echo"	  <tr bgcolor='#F7F7F7' height='50'>";
echo"       <td align='left' valign='top'>";
echo"   		<table border='0' cellpadding='0' cellspacing='0' align='left' style='width:490px;' >
				<col width=53>
				<col width=110>
				<col width=53>
				<col width=110>
				<col width=53>
				<col width=110>";
echo"			<tr>";
echo"				<td align='left' colspan='6'><span class='style39'>Accounts:</span></td>";
echo"			</tr>";
echo"			<tr>";
echo"				<td align='left'><span class='style1'>Client:</span></td>";
echo"				<td align='left'><input type='text' name='Client_Account' id='Client_Account' value='$Client_Account' maxlength='10' style='width:100px;'></td>";
echo"				<td align='left'><span class='style1'>Sales:</span></td>";
echo"				<td align='left'><input type='text' name='Sales_Account' id='Sales_Account' value='$Sales_Account' maxlength='10' style='width:100px;'></td>";
echo"				<td align='left'><span class='style1'>Coupon:</span></td>";
echo"				<td align='left'><input type='text' name='Coupon_Account' id='Coupon_Account' value='$Coupon_Account' maxlength='10' style='width:100px;'></td>";
echo"			</tr>";
echo"			<tr>";
echo"				<td align='left'><span class='style1'>Cash:</span></td>";
echo"				<td align='left'><input type='text' name='Cash_Account' id='Cash_Account' value='$Cash_Account' maxlength='10' style='width:100px;'></td>";
echo"				<td align='left'><span class='style1'>Check:</span></td>";
echo"				<td align='left'><input type='text' name='Check_Account' id='Check_Account' value='$Check_Account' maxlength='10' style='width:100px;'></td>";
echo"				<td align='left'><span class='style1'>Tips:</span></td>";
echo"				<td align='left'><input type='text' name='Tips_Account' id='Tips_Account' value='$Tips_Account' maxlength='10' style='width:100px;'></td>";
echo"			</tr>";
echo"			</table>";
echo"	    </td>";
echo"		<td valign='top' align='left' rowspan='2'>
			<div style='overflow-y:scroll;height:150px;width:130px;border:1px solid #D8D8D8;padding-left:5px;'><table border='0' cellpadding='0' cellspacing='0'>";
			
			$querysearch="Select CashRegister_Name From CashRegister ";
			$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
			
			while($rows=mysql_fetch_array($resultsearch)){
				$ct+=1;
				$styleFont='style15';
				
				if($ct%2==0)
					$bgColor="style='background-color:".$grid_color1."'";
				else			
					$bgColor="style='background-color:".$grid_color2."'";	
						
				if($CashRegister_Name == $rows[0]){
					$bgColor="style='background-color:#1e87a5'";
					$styleFont='style28';
				}	
						
				echo'<tr '.$bgColor.' height="20px" >';
				echo"	<td onclick=\"SelectRecord('$rows[0]')\"; style='width:130px; cursor:pointer;'><span class='$styleFont' >$rows[0]</span></td>";
				echo"</tr>";
			}	
echo"		</table></div></td>";
echo"	  </tr>";

echo"	  <tr bgcolor='#F7F7F7' height='50'>";
echo"       <td align='left' valign='top'>";
echo"   		<table border='0' cellpadding='0' cellspacing='0' align='left' style='width:490px;' >
				<col width=100>
				<col width=145>
				<col width=100>
				<col width=145>";
echo"			<tr>";
echo"				<td align='left' colspan='4'><span class='style39'>Defaults:</span></td>";
echo"			</tr>";
echo"			<tr>";
echo"				<td align='left'><span class='style1'>Currency:</span></td>";
echo"				<td align='left'><select name='Currency_Code' id='Currency_Code' style='width:100px;'>";
					echo"<option></option>";
					while($curf=mysql_fetch_row($resultcurrency)){
						echo"<option ";
						if ($Currency_Code==$curf[0]) 	echo " selected ";
						echo" value='$curf[0]'>$curf[0] </option>";
					}
echo"				</select></td>";	
echo"				<td align='left'><span class='style1'>Warehouse:</span></td>";
echo"				<td align='left'><input type='text' name='Warehouse_Code' id='Warehouse_Code' value='$Warehouse_Code' maxlength='15' style='width:100px;'></td>";
echo"			</tr>";
echo"			<tr>";
echo"				<td align='left'><span class='style1'>Project:</span></td>";
echo"				<td align='left'><input type='text' name='Project_Code' id='Project_Code' value='$Project_Code' maxlength='15' style='width:100px;'></td>";
echo"				<td align='left'><span class='style1'>CostCenter:</span></td>";
echo"				<td align='left'><input type='text' name='CostCenter_Code' id='CostCenter_Code' value='$CostCenter_Code' maxlength='15' style='width:100px;'></td>";
echo"			</tr>";

if($cashregister_retailtype=='takeout')
	$stat=' selected ';
else if($cashregister_retailtype=='dinein')
	$stat2=' selected ';
else if($cashregister_retailtype=='delivery')	
	$stat3=' selected ';
else{	$stat='  ';$stat2='  ';$stat3='  '; }
	
echo"			<tr><td align='left'><span class='style1'><label>Order Type</label></span></td>
	<td align=left><select name='cashregister_retailtype' id='cashregister_retailtype'>
							<option value=''></option>
							<option $stat value='takeout'>Take Out</option>
							<option $stat2 value='dinein'>Dine In</option>
							<option $stat3 value='delivery'>Delivery</option>
						</select></td>
</tr>";


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

echo"	  <tr bgcolor='#F7F7F7'>";
echo"		<td align='left' colspan='2'><span class='style39'>Options:</span></td>";
echo"	  </tr>";
echo"	  <tr bgcolor='#F7F7F7' height='50'>";
echo"       <td align='left' valign='top' colspan='2'>";
echo"			<div style='overflow-y:scroll;height:280px;width:625px;border:1px solid #D8D8D8;padding-left:3px; margin-top:5px;'>";
echo"   		<table border='0' cellpadding='0' cellspacing='0' align='left' style='width:600px; margin-top:3px;' >
				<col width=600>";
				
echo"	  		<tr><td align='left'><span class='style38'>Main Layout:</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkRestaurant' id='chkRestaurant' value='1' "; if($Module_RestaurantDelivery==1) echo " checked ";  echo" >Restaurant Layout</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkTables' id='chkTables' value='1' "; if($Module_CashRegisterTable==1) echo " checked ";  echo" >Tables Layout</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkFastItems' id='chkFastItems' value='1' "; if($Module_CashRegisterFastItem==1) echo " checked ";  echo" >Fast Items Layout</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkStandard' id='chkStandard' value='1' "; if($Module_CashregisterStandardview==1) echo " checked ";  echo" >Standard Layout</label></span></td></tr>";
				
echo"	  		<tr><td align='left'><span class='style38'>Hardware:</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkBarcode' id='chkBarcode' value='1' "; if($CashRegister_BarCode==1) echo " checked ";  echo" >Use Barcode Reader</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkShowBarcode' id='chkShowBarcode' value='1' "; if($CashRegister_PrintBarcode==1) echo " checked ";  echo" >Show Barcode Column</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkPrinter' id='chkPrinter' value='1' "; if($CashRegister_Printer==1) echo " checked ";  echo" >Use Printer</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'>
						<label><input type='checkbox' name='chkSlip' id='chkSlip' value='1' "; if($CashRegister_SlipPrinter==1) echo " checked ";  echo" >Slip Print</label>
						<span class='style1'>&nbsp;&nbsp;Copies:</span><input type='text' name='CashRegister_SlipCopy' id='CashRegister_SlipCopy' value='$CashRegister_SlipCopy' maxlength='2' style='width:30px;'>
						<label><input type='checkbox' name='chkSlipKitchen' id='chkSlipKitchen' value='1' "; if($CashRegister_SlipKitchen==1) echo " checked ";  echo" >Slip Print Kitchen</label>
				</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkDispLed' id='chkDispLed' value='1' "; if($CashRegister_DisplayLed==1) echo " checked ";  echo" >Use Display Led</label></span>
						<span class='style1'>&nbsp;&nbsp;COM:</span><input type='text' name='CashRegister_DispCOM' id='CashRegister_DispCOM' value='$CashRegister_DispCOM' maxlength='10' style='width:50px;'>
						<span class='style1'>Characters Per Line:</span><input type='text' name='CashRegister_LedDescLength' id='CashRegister_LedDescLength' value='$CashRegister_LedDescLength' maxlength='10' style='width:50px;'>
					</td>
				</tr>";
echo"			<tr><td align='left' style='padding-left:20px;'><span class='style1'>Display Led Message  </span><input type='text' name='CashReg_DispLedMsg' id='CashReg_DispLedMsg' value='$CashReg_DispLedMsg' maxlength='20' style='width:250px;'></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkDrawer' id='chkDrawer' value='1' "; if($CashRegister_Drawer==1) echo " checked ";  echo" >Use Drawer</label></span>
						<span class='style1'>&nbsp;&nbsp;COM:</span><input type='text' name='CashRegister_DrawerCOM' id='CashRegister_DrawerCOM' value='$CashRegister_DrawerCOM' maxlength='10' style='width:50px;'>
						<span class='style1'>&nbsp;&nbsp;PRINTER CODE:</span><input type='text' name='CashRegister_DrawerPrinter' id='CashRegister_DrawerPrinter' value='$CashRegister_DrawerPrinter' maxlength='100' style='width:300px;'>
					</td>
				</tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkScaleWeight' id='chkScaleWeight' value='1' "; if($CashReg_Weight==1) echo " checked ";  echo" >Use Weight Scale</label></span>
						<span class='style1'>Start/End Barcode </span>
						<input type='text' name='CashReg_StartBarcode' id='CashReg_StartBarcode' value='$CashReg_StartBarcode' maxlength='2' style='width:30px;'>
						<span class='style1'>/</span>
						<input type='text' name='CashReg_EndBarcode' id='CashReg_EndBarcode' value='$CashReg_EndBarcode' maxlength='2' style='width:30px;'>
						<span class='style1'>Start/End Qty </span>
						<input type='text' name='CashReg_StartQty' id='CashReg_StartQty' value='$CashReg_StartQty' maxlength='2' style='width:30px;'>
						<span class='style1'>/</span>
						<input type='text' name='CashReg_EndQty' id='CashReg_EndQty' value='$CashReg_EndQty' maxlength='2' style='width:30px;'>
					</td>
				</tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkScalePrice' id='chkScalePrice' value='1' "; if($CashReg_Price==1) echo " checked ";  echo" >Scale Pricing</label></span>
						<span class='style1'>Start/End Price </span>
						<input type='text' name='CashReg_StartPrice' id='CashReg_StartPrice' value='$CashReg_StartPrice' maxlength='2' style='width:30px;'>
						<span class='style1'>/</span>
						<input type='text' name='CashReg_EndPrice' id='CashReg_EndPrice' value='$CashReg_EndPrice' maxlength='2' style='width:30px;'>
					</td>
				</tr>";

echo"	  		<tr><td align='left'><span class='style38'>Payment Layout:</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkCredit' id='chkCredit' value='1' "; if($CashRegister_Credit==1) echo " checked ";  echo" >Show Credit Layout</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkCheck' id='chkCheck' value='1' "; if($CashRegister_Check==1) echo " checked ";  echo" >Show Check Layout</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkShowBase2' id='chkShowBase2' value='1' "; if($Module_CashRegisterBase2==1) echo " checked ";  echo" >Show Base2</label></span></td></tr>";

echo"	  		<tr><td align='left'><span class='style38'>Posting:</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkAutoPost' id='chkAutoPost' value='1' "; if($CashRegister_AutoPost==1) echo " checked ";  echo" >Auto Posting</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkPostOneToOne' id='chkPostOneToOne' value='1' "; if($Module_PostRetailOneToOne==1) echo " checked ";  echo" >One To One Posting</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkPostByCashReg' id='chkPostByCashReg' value='1' "; if($Module_PostingByCashRegister==1) echo " checked ";  echo" >Posting By CashReg</label></span></td></tr>";

echo"	  		<tr><td align='left'><span class='style38'>Others:</span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkDiscount' id='chkDiscount' value='1' "; if($CashRegister_Discount==1) echo " checked ";  echo" >Allow Invoice Discount</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkSerialNo' id='chkSerialNo' value='1' "; if($CashRegister_SerialNo==1) echo " checked ";  echo" >Use Serial No</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkRestSerial' id='chkRestSerial' value='1' "; if($CashRegister_RestSerialNo==1) echo " checked ";  echo" >Restrict Serial No Existance</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkTTC' id='chkTTC' value='1' "; if($CashRegisterTTC==1) echo " checked ";  echo" >Mode TTC</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkVendor' id='chkVendor' value='1' "; if($CashReg_Vendor==1) echo " checked ";  echo" >Show Vendor</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkForceVendor' id='chkForceVendor' value='1' "; if($CashReg_ForcingVendor==1) echo " checked ";  echo" >Force Vendor</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkTaxNonTax' id='chkTaxNonTax' value='1' "; if($CashRegister_ShowTaxNonTax==1) echo " checked ";  echo" >Show Taxable/NonTaxable Amount</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkShowSlip' id='chkShowSlip' value='1' "; if($ShowSlipNumber==1) echo " checked ";  echo" >Show Slip Number</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkAutoItemsList' id='chkAutoItemsList' value='1' "; if($Module_CashRegAutoItemsList==1) echo " checked ";  echo" >Show Items List InCase Item Not Found</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkItemSeperate' id='chkItemSeperate' value='1' "; if($Module_CashRegItemSeperate==1) echo " checked ";  echo" >Force New Record For Same Item</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkItemQtyInCode' id='chkItemQtyInCode' value='1' "; if($Module_CashRegItemQtyInCode==1) echo " checked ";  echo" >Allow Item Qty In Barcode</label></span></td></tr>";
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkAutoClosePrint' id='chkAutoClosePrint' value='1' "; if($CashRegister_AutoClosePrint==1) echo " checked ";  echo" >Auto Print Out When Closing Shift</label></span></td></tr>";

//maroun
echo"			<tr><td align='left'><span class='style1'><label><input type='checkbox' name='chkcashregister_logout' id='chkcashregister_logout' value='1' "; if($cashregister_logout==1) echo " checked ";  echo" >Logout After Print Order</label></span></td></tr>";


echo"			</table></div>";
echo"		</td>";
echo"	  </tr>	 	
			 
		  <tr bgcolor='#F7F7F7' height='30'>
		     <td colspan='2' align='center' bgcolor=#D8D8D8>
			 <button type='button' id='btnSubmit' name='btnSubmit' onclick='SubmitRecord();return false;'   title='Save'><span><span>F2:Save</span></span></button>
			 <button type='button' id='btnClear' name='btnClear' onclick='ClearRecord();return false;'   title='Clear'><span><span>F3:Clear</span></span></button>
			 <button type='button' id='btnClose' name='btnClose' onclick='CloseForm();return false;'   title='Close'><span><span>Esc:Exit</span></span></button>
			 </td>
		  </tr>
		  
        </table>";
		
echo"	</div>";

echo"	<div class='tabbertab' tabberIndex='1'>
		<h2 title='Conditions'>Conditions</h2>";
echo"  		<table border='0' cellpadding='0' cellspacing='0' align='center' valign='center' style='width:620px;' >
			<col width=120>
			<col width=350>
			<col width=150>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>Company Name</span></td>
					<td align='left'><input type='text' name='Company_Name' id='Company_Name' value='$CompanyName' maxlength='60' style='width:300px;'></td>
					<td align='center' rowspan='2'><img src='LogoFile.php' alt='Photo' style='width:120px; height:110px;'></img></td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7'><td align='left' valign='top'><span class='style1'>Company Memo</span></td>
					<td align='left'><textarea name='Company_Memo' id='Company_Memo' rows='4' style='width:300px;'>$CompanyMemo</textarea></td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>VAT (%)</span></td><td align='left'>
					<input type='text' name='Setup_VatPercentage' id='Setup_VatPercentage' value='$Setup_VatPercentage' maxlength='3' style='width:30px;'>
					<span class='style1'>Date </span><input type='text' name='Setup_VatStartDate' id='Setup_VatStartDate' value='$Setup_VatStartDate' maxlength='11' style='width:80px;'>
					<span class='style1'>VAT No </span><input type='text' name='Setup_VatNo' id='Setup_VatNo' value='$Setup_VatNo' maxlength='20' style='width:100px;'>
				</td>
				<td><input type='file' name='photo' id='photo' style='width:200px;' accept='image/jpeg,image/gif,image/png'></td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>Currency Base1</span></td>";
echo"				<td align='left' colspan='2'><select name='Base1' id='Base1' style='width:80px; height:22px;'>";
					echo"<option></option>";
					while($curf=mysql_fetch_row($resultcurrency1)){
						echo"<option ";
						if ($Base1==$curf[0]) 	echo " selected ";
						echo" value='$curf[0]'>$curf[0] </option>";
					}
echo"				</select><span class='style1'>  Base2 </span><select name='Base2' id='Base2' style='width:80px; height:22px;'>";
					echo"<option></option>";
					while($curf=mysql_fetch_row($resultcurrency2)){
						echo"<option ";
						if ($Base2==$curf[0]) 	echo " selected ";
						echo" value='$curf[0]'>$curf[0] </option>";
					}
echo"				</select></td>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>Rounding Divisor </span></td><td align='left' colspan='2'><input type='text' name='CashReg_RoundDivisor' id='CashReg_RoundDivisor' value='$CashReg_RoundDivisor' maxlength='5' style='width:50px;'></td></tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>Price Offer</span></td><td align='left' colspan='2'>
						<select name='Module_PriceOffer' id='Module_PriceOffer' style='width:100px;'>";
echo"						<option value=''></option>";
echo"						<option value='1' "; if($Module_PriceOffer==1) echo" selected ";  echo" >1</option>";
echo"						<option value='2' "; if($Module_PriceOffer==2) echo" selected ";  echo" >2</option>";
echo"						<option value='3' "; if($Module_PriceOffer==3) echo" selected ";  echo" >3</option>";
echo"						<option value='4' "; if($Module_PriceOffer==4) echo" selected ";  echo" >4</option>";
echo"						<option value='5' "; if($Module_PriceOffer==5) echo" selected ";  echo" >5</option>";
echo"						<option value='6' "; if($Module_PriceOffer==6) echo" selected ";  echo" >6</option>";
echo"				</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left'><span class='style1'>Color Theme</span></td><td align='left' colspan='2'>
						<select name='CashReg_ColorTheme' id='CashReg_ColorTheme' style='width:100px;'>";
echo"						<option value='default' "; if($CashReg_ColorTheme=='default') echo" selected ";  echo" >Default</option>";
echo"						<option value='red' "; if($CashReg_ColorTheme=='red') echo" selected ";  echo" >Red</option>";
echo"						<option value='blue' "; if($CashReg_ColorTheme=='blue') echo" selected ";  echo" >Blue</option>";
echo"				</td>
				</tr>";		
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left' colspan='3'>&nbsp;</td></tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'><td align='left' colspan='3'><span class='style1'>Grid Record Background Color</span></td></tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorZeroPrice' id='CashReg_BgColorZeroPrice' value='".htmlspecialchars($CashReg_BgColorZeroPrice, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorZeroPrice' id='chkApplyColorZeroPrice' value='1' "; if($CashReg_ApplyColorZeroPrice==1) echo " checked ";  echo" >
						<span class='style1'>Item Has Zero Price</span>
					</td>
				</tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorZeroQty' id='CashReg_BgColorZeroQty' value='".htmlspecialchars($CashReg_BgColorZeroQty, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorZeroQty' id='chkApplyColorZeroQty' value='1' "; if($CashReg_ApplyColorZeroQty==1) echo " checked ";  echo" >
						<span class='style1'>Item Has Zero Qty</span>
					</td>
				</tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorHasDiscount' id='CashReg_BgColorHasDiscount' value='".htmlspecialchars($CashReg_BgColorHasDiscount, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorHasDiscount' id='chkApplyColorHasDiscount' value='1' "; if($CashReg_ApplyColorHasDiscount==1) echo " checked ";  echo" >
						<span class='style1'>Item Has Discount</span>
					</td>
				</tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorOffer' id='CashReg_BgColorOffer' value='".htmlspecialchars($CashReg_BgColorOffer, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorOffer' id='chkApplyColorOffer' value='1' "; if($CashReg_ApplyColorOffer==1) echo " checked ";  echo" >
						<span class='style1'>Module Price Offer Is Set and Item Offer True</span>
					</td>
				</tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorQty' id='CashReg_BgColorQty' value='".htmlspecialchars($CashReg_BgColorQty, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorQty' id='chkApplyColorQty' value='1' "; if($CashReg_ApplyColorQty==1) echo " checked ";  echo" >
						<span class='style1'>Module Weight True and Item Weight > 0 and Item Qty Below 10 GRAMS</span>
					</td>
				</tr>";
echo"	  		<tr bgcolor='#F7F7F7' height='25'>
					<td align='left'><input type='text' name='CashReg_BgColorOrderQty' id='CashReg_BgColorOrderQty' value='".htmlspecialchars($CashReg_BgColorOrderQty, ENT_QUOTES)."' class='color' style='width:100px;' maxlength='50' /></td>
					<td align='left' colspan='2'>
						<input type='checkbox' name='chkApplyColorOrderQty' id='chkApplyColorOrderQty' value='1' "; if($CashReg_ApplyColorOrderQty==1) echo " checked ";  echo" >
						<span class='style1'>Module Restaurant True and Item Qty Doesn't Match Order Item Qty</span>
					</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='30'>
					<td colspan='3' align='center' bgcolor=#D8D8D8>
						<button type='button' id='btnSubmit1' name='btnSubmit1' onclick='SubmitRecord1(); return false;'  title='Save'><span><span>F4:Save</span></span></button>
					</td>
				</tr>";
echo"		</table>";		
echo"	</div>";

echo"	<div class='tabbertab' tabberIndex='2'>
		<h2 title='Printer'>Printer</h2>";
echo"	  <table width='630px' border='0' cellspacing='1' align='center'>";

if ($startrange=='') $startrange = 0;
if ($perpage=='')	 $perpage = 20;

if ($actionmode == 'Submit') { 
	$ErrorExists = 0;
	
	if ($p_id == '') {
		if ($p_name != '') {
			$sub_query = " Select Count(p_id) From ".$_SESSION['dbLabel'].".printersubgroup ".
						 " Where p_id = '".$p_id."'";
			$sub_result = selectData($connection, $sub_query);
			if ($sub_result[0] != 0) $ErrorExists = 1;
		}
		
		if ($ErrorExists == 1) {
			$actionmode = 'Add';
			$message = 'Insert not allowed. Duplicate Printer: '.$p_name;
		}	
			
		
		
		if ($p_name != "" && $ErrorExists == 0){
		
			fbegin();
			$query = " INSERT INTO ".$_SESSION['dbLabel'].".printersubgroup (p_name, p_subgroup, p_cashregister, p_category ) ".
					 " VALUES ( '".$p_name."', '".ereg_replace("'", "\'", trim($p_subgroup))."', '".$p_cashregister."', '".$p_category."'  )";
						 
				 
			$result=mysql_query($query,$connection);
			//echo $query."<br>";exit;	
			
			if ($result){
				$actionmode = '';
				$PLedgerNo   = $p_name;
				fcommit();
				
				//header ("Location: ./Form_RetailSetup.php?frm=1&p_name=".$p_name."&p_subgroup=".$p_subgroup."&p_cashregister=".$p_cashregister."&message=".$message);	
			}else{
				$actionmode = 'Add';
				$message  = mysql_error(); 
				frollback();
			}
	
		}
	} else {
		fbegin();
		$query = " UPDATE ".$_SESSION['dbLabel'].".printersubgroup SET ".
		         " p_name = '".ereg_replace("'", "\'", trim($p_name))."', p_subgroup = '".$p_subgroup."', p_cashregister = '".$p_cashregister."', p_category = '".$p_category."'  
							WHERE p_id = '".$p_id."'";
						 
				 
		$result=mysql_query($query,$connection);
		//echo $query."<br>";exit;	
			
		if ($result){
			$actionmode = '';
			
			$PLedgerNo   = $p_name;
			fcommit();
				
			//header ("Location: ./Form_RetailSetup.php?frm=1&p_name=".$p_name."&p_subgroup=".$p_subgroup."&p_cashregister=".$p_cashregister."&message=".$message);
		}else{
			$actionmode = 'Edit';
			$message  = mysql_error(); 
			frollback();
		}
	}	
	
}
else if ($actionmode == 'DeletePrinter' && $p_id != "") {
	$ErrorExists = 0;
	
	fbegin();
	$query = " DELETE FROM ".$_SESSION['dbLabel'].".printersubgroup WHERE p_id = '".$p_id."'";
	$result=mysql_query($query,$connection);
	//echo $query."<br>";exit;	
			
	if ($result){
		fcommit();
	}else{
		$message  = mysql_error($connection); 
		frollback();
	}
}


if ($actionmode == 'Add'  || $actionmode == 'Edit') {
			
	if ($p_id != '') {
		$sub_query = " Select  p_name,p_subgroup,p_cashregister, p_category   ".
					 " From  ".$_SESSION['dbLabel'].".printersubgroup ".
					 " Where p_id = '".$p_id."'";
					 
		$sub_result=selectData($connection, $sub_query);
		
		$p_name    		= $sub_result[0];
		$p_subgroup     = $sub_result[1];
		$p_cashregister = $sub_result[2];
		$p_category     = $sub_result[3];
		
		$CodeMode = ' readonly ';
	}
		
	
	
	echo"<tr><td colspan='5'>";
	echo"  <table width='620' border='0' cellspacing='1' align='left'>";
	echo"	<tr bgcolor='#F7F7F7'>
			  <td height='20' colspan='2' align='center'><font size='1' color='#FF0000' face='Verdana'><b>$message</b></font></td>
			</tr>";
	echo"	<tr bgcolor='#F7F7F7'>";
	echo"	  <td width='100'><span class='style5'>Printer</span></td>";
	echo"	  <td width='500'><input type='text' name='p_name' id='p_name' value='$p_name' style='width:350px;' maxlength='200'    /></td>";
	echo"	</tr>";
	echo"	<tr bgcolor='#F7F7F7'>";
	echo"	  <td width='100'><span class='style5'>SubGroup</span></td>";
	echo"	  <td width='500'>
	<input type='text' name='p_subgroup' id='p_subgroup' value='".htmlspecialchars($p_subgroup, ENT_QUOTES)."'  style='width:90px;' maxlength='200'  />
	<input type='text' name='subgroup_name' value='$subgroup_name' readonly size='37'>
	";
	echo"&nbsp;<label><span class='style1'><img src='img/btnopen.jpg' title=' Select SubGroup ' width='15' height='20' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistsubgroups(3); '  /></span></label>";
	echo"</td>";
	echo"	</tr>";
	echo"	<tr bgcolor='#F7F7F7'>";
	echo"	  <td width='100'><span class='style5'>CashRegister</span></td>";
	echo"	  <td width='500'>
				<input type='hidden' name='p_cashregister' id='p_cashregister' value='".htmlspecialchars($p_cashregister, ENT_QUOTES)."'  style='width:163px;' maxlength='200'  />
				<select name='p_category' id='p_category' style='width:100px;'>";
	echo"			<option value=''></option>";
	echo"			<option value='1' "; if($p_category==1) echo" selected ";  echo" >1</option>";
	echo"			<option value='2' "; if($p_category==2) echo" selected ";  echo" >2</option>";
	echo"			<option value='3' "; if($p_category==3) echo" selected ";  echo" >3</option>";
	echo"			<option value='4' "; if($p_category==4) echo" selected ";  echo" >4</option>";
	echo"			<option value='5' "; if($p_category==5) echo" selected ";  echo" >5</option>";
	echo"			<option value='6' "; if($p_category==6) echo" selected ";  echo" >6</option>";
	echo"	   </td>";
	echo"	</tr>";
	
	echo"	<tr bgcolor='#DDDDDD'>";
	echo"	<td colspan='2' align='center'>";
	
	echo "<button type='button' id='btnSubmit' name='btnSubmit' onclick='SubmitRecordPrinter(); return false;' title='Submit'><span><span>Submit</span></span></button>";
	echo "<button type='button' id='btnClear' name='btnClear' onclick='CancelRecord(); return false;' title='Cancel'><span><span>Cancel</span></span></button>";

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

}

if ($actionmode == '' or  $actionmode=='Submit') {
	echo"<tr><td colspan=5><table width=100% border=0>";
	echo"<tr>
		  <td bgcolor='#DDDDDD' colspan='2'><span class='style4'>Search</span></td>
		  <td bgcolor='#DDDDDD' colspan='2'><input type='text' name='PLedgerNo' id = 'keyword' value='$PLedgerNo'  size='23'  />
			<button type='button' id='btnSubmit' name='btnSubmit' onclick='SubmitForm();return false;' title='Find'><span><span>Find</span></span></button>
			<button type='button' id='btnCancel' name='btnCancel' onclick='ClearForm();return false;' title='Cancel'><span><span>Cancel</span></span></button>
			<button type='button' id='btnAdd' name='btnAdd' onclick='AddRecord();return false;' title='Add'><span><span>Add</span></span></button>

			<span class='style4'>Per page </span><span class='style11'><select name='perpage' id='perpage' value='$perpage' onchange='ClearForm();'>";
              
			
			if ($perpage==10)
				$s10 = 'selected';
			else if ($perpage==20)
				$s20 = 'selected';	
			else if ($perpage==30)
				$s30 = 'selected';	
			else if ($perpage==40)
				$s40 = 'selected';
			else if ($perpage==50)
				$s50 = 'selected';

			
				
        echo'<option '.$s10.' value="10">10</option>
			 <option '.$s20.' value="20">20</option>
			 <option '.$s30.' value="30">30</option>
			 <option '.$s40.' value="40">40</option>
			 <option '.$s50.' value="50">50</option>
			 </select></span>';	
			 
	echo"  </td>
		</tr>";
	echo"</table></td></tr>";
}


echo"<tr bgcolor='#E5E5E5'>
      <td width='25'>&nbsp;</td>
	  <td width='25'>&nbsp;</td>
      <td width='250'><span class='style4'>Printer </span></td>
      <td width='200'><span class='style4'>Subgroup </span></td>
	  <td width='120'><span class='style4'>Category</span></td>
    </tr>";


			
$sub_query= " Select p_id as pid, p_name as pname, p_subgroup as psubgroup, p_cashregister as pcashregister, p_category as pcategory ".
			" From ".$_SESSION['dbLabel'].".printersubgroup ".
			" Where (p_name like '%".$PLedgerNo."%' or p_subgroup like '%".$PLedgerNo."%' or p_cashregister like '%".$PLedgerNo."%' ) ".
			" Order By Lpad(p_name,10,'0') ";
//echo $sub_query;		

$sub_result=mysql_query($sub_query,$connection) or die(mysql_error());
$totalrows = mysql_num_rows($sub_result);

		
$sub_query = $sub_query." limit ".$startrange.",".$perpage;

$sub_result=mysql_query($sub_query,$connection) or die(mysql_error());
while($sub_rows=mysql_fetch_array($sub_result)){
	
	extract($sub_rows);

	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";		

    $pname=ereg_replace("'","%27",$pname);

	echo"<tr $Color>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/edit.png' style='cursor:pointer;' onclick=\"UpdateRecordPrinter('".$pid."');\" title='Edit Record' ></span></td>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/delete.png' style='cursor:pointer;' onclick=\"DeleteRecordPrinter('".$pid."');\" title='Delete Record' ></span></td>";
	echo"  <td align='left'><span class='style5'>$pname</span></a></td>";
	echo"  <td align='left'><span class='style5'>$psubgroup</span></td>";
	echo"  <td align='left'><span class='style5'>$pcategory</span></td>";
    echo"</tr>";
	
}	

echo"<tr><td colspan='5'>&nbsp;</td></tr>
	 <tr height='30'><td colspan=5><table width='100%' border=0><tr><td width='260'>&nbsp;</td><td width='150' align='center'>";
		
$diff= $startrange - $perpage;
		
if (($diff) >= 0 ){
	$prvstartrange = $startrange - $perpage;
	echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='pointer'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
}
else
	echo "&nbsp;";
		
echo"</td><td width='150' align='center'>";
		
if ($startrange <= $totalrows){
	$startrange = $startrange + $perpage;
	if  ($startrange < $totalrows)
		echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='pointer'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
} else
	echo "&nbsp;";
			
echo"	</td><td width='170'>&nbsp;</td></tr>";
echo"	</table></td></tr>";		
echo"	</table>";
echo"	</div>";


if ($actionmode == 'SubmitVoid') {
	$ErrorExists = 0;
	
	if ($Reason_Id == '') {
		if ($Reason_Remark != '') {
			$sub_query = " Select Count(*) From cashregister_voidreasons Where Reason_Remark = '".$Reason_Remark."'";
			$sub_result = selectData($connection, $sub_query);
			if ($sub_result[0] != 0) $ErrorExists = 1;
		}
		
		if ($ErrorExists == 1) {
			$message = 'Insert not allowed. Duplicate Remark: '.$Reason_Remark;
		}	
			
		
		
		if ($Reason_Remark != "" && $ErrorExists == 0){
		
			fbegin();
			$query = " INSERT INTO cashregister_voidreasons (Reason_Remark) VALUES ( '".ereg_replace("'", "\'", trim($Reason_Remark))."')";
			$result=mysql_query($query,$connection);
			//echo $query."<br>";exit;	
			
			if ($result){
				fcommit();
			}else{
				$message  = mysql_error($connection); 
				frollback();
			}
	
		}
	} else {
		fbegin();
		$query = " UPDATE cashregister_voidreasons SET Reason_Remark = '".ereg_replace("'", "\'", trim($Reason_Remark))."' WHERE Reason_Id = '".$Reason_Id."'";
		$result=mysql_query($query,$connection);
		//echo $query."<br>";exit;	
			
		if ($result){
			fcommit();
		}else{
			$message  = mysql_error($connection); 
			frollback();
		}
	}	
	
}
else if ($actionmode == 'DeleteVoid' && $Reason_Id != "") {
	$ErrorExists = 0;
	
	fbegin();
	$query = " DELETE FROM cashregister_voidreasons WHERE Reason_Id = '".$Reason_Id."'";
	$result=mysql_query($query,$connection);
	//echo $query."<br>";exit;	
			
	if ($result){
		fcommit();
	}else{
		$message  = mysql_error($connection); 
		frollback();
	}
}

echo"	<div class='tabbertab' tabberIndex='3'>
		<h2 title='Void Reasons'>Void Reasons</h2>";
echo"  		<table border='0' cellpadding='0' cellspacing='0' align='center' valign='center' style='width:620px;' >
			<col width=25>
			<col width=25>
			<col width=50>
			<col width=370>
			<col width=150>";
echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>Description</span></td>
					<td align='left' colspan='2'>
						<input type='hidden' name='Reason_Id' id='Reason_Id' value='$Reason_Id'>
						<input type='text' name='Reason_Remark' id='Reason_Remark' value='$Reason_Remark' maxlength='200' style='width:350px;'>
						<button type='button' id='btnSubmit2' name='btnSubmit2' onclick='SubmitRecordVoid(); return false;'  title='Save'><span><span>Submit</span></span></button>
						<button type='button' id='btnClear2' name='btnClear2' onclick='ClearRecordVoid(); return false;'  title='Clear'><span><span>Clear</span></span></button>
					</td>
				</tr>";
				
echo"			<tr bgcolor='#D8D8D8' height='25'>
					<td width='25'>&nbsp;</td>
					<td width='25'>&nbsp;</td>
					<td width='570' colspan='3'><span class='style4'>Description</span></td>
				</tr>";


$ct = 0;
$sub_query2= " Select Reason_Id, Reason_Remark From cashregister_voidreasons Order By Reason_Remark ";
$sub_result2=mysql_query($sub_query2,$connection) or die(mysql_error());
while($sub_rows2=mysql_fetch_array($sub_result2)){
	
	extract($sub_rows2);

	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";		

    $voidreason=ereg_replace("'","%27",$Reason_Remark);

	echo"<tr $Color>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/edit.png' style='cursor:pointer;' onclick=\"UpdateRecordVoid('".$Reason_Id."','".$voidreason."');\" title='Edit Record' ></span></td>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/delete.png' style='cursor:pointer;' onclick=\"DeleteRecordVoid('".$Reason_Id."');\" title='Delete Record' ></span></td>";
	echo"  <td align='left' colspan='3'><span class='style5'>$Reason_Remark</span></a></td>";
    echo"</tr>";
	
}

echo"		</table>";		
echo"	</div>";



if ($actionmode == 'SubmitCredits') {
	$ErrorExists = 0;
	
	if (isset($_FILES['photo_credit']) && $_FILES['photo_credit']['size'] > 0) { 

		$image_name = addslashes($_FILES['photo_credit']['name']);
		$image_size = getimagesize($_FILES['photo_credit']['tmp_name']);
		$image_type =$_FILES['photo_credit']['type'];
				
		if ($image_size == FALSE) {
			$message_credits = "That's not an image.";
		}
		else {
			if ($_FILES['photo_credit']['size'] > 204800) {
				$message_credits = "Image is too large.";
			}
			else {
				$image_credit = addslashes(file_get_contents($_FILES['photo_credit']['tmp_name']));
			}
		}	
	}
	
	$sub_query = " Select Count(*) From ledger Where Ledger_Number = '".$Payment_Account."'";
	$sub_result = selectData($connection, $sub_query);
	if ($sub_result[0] == 0){
		$ErrorExists = 1;
		$message_credits = 'Incorrect Account#: '.$Payment_Account;
	}	
	
	if ($Payment_Id == '' && $ErrorExists == 0) {
		if ($Payment_Account != '') {
			$sub_query = " Select Count(*) From paymentmethods Where Payment_Account = '".$Payment_Account."'";
			$sub_result = selectData($connection, $sub_query);
			if ($sub_result[0] != 0) $ErrorExists = 1;
		}
		
		if ($ErrorExists == 1) {
			$message_credits = 'Insert not allowed. Duplicate Account#: '.$Payment_Account;
		}	
			
		
		
		if ($Payment_Account != "" && $Payment_Description != "" && $ErrorExists == 0){
		
			fbegin();
			$query = " INSERT INTO paymentmethods (Payment_Account, Payment_Description, Payment_Image) VALUES ('".ereg_replace("'", "\'", trim($Payment_Account))."', '".ereg_replace("'", "\'", trim($Payment_Description))."', '$image_credit')";
			$result=mysql_query($query,$connection);
			//echo $query."<br>";exit;	
			
			if ($result){
				fcommit();
			}else{
				$message_credits  = mysql_error($connection); 
				frollback();
			}
	
		}
	} 
	else if ($ErrorExists == 0){
		fbegin();
		$query = " UPDATE paymentmethods SET ".
			 	 " Payment_Account = '".ereg_replace("'", "\'", trim($Payment_Account))."', ".
				 " Payment_Description = '".ereg_replace("'", "\'", trim($Payment_Description))."', ".
				 " Payment_Image = '$image_credit' ".
				 " WHERE Payment_Id = '".$Payment_Id."'";
		$result=mysql_query($query,$connection);
		//echo $query."<br>";exit;	
			
		if ($result){
			fcommit();
		}else{
			$message_credits  = mysql_error($connection); 
			frollback();
		}
	}	
	
}
else if ($actionmode == 'DeleteCredits' && $Payment_Id != "") {
	$ErrorExists = 0;
	
	fbegin();
	$query = " DELETE FROM paymentmethods WHERE Payment_Id = '".$Payment_Id."'";
	$result=mysql_query($query,$connection);
	//echo $query."<br>";exit;	
			
	if ($result){
		fcommit();
	}else{
		$message_credits  = mysql_error($connection); 
		frollback();
	}
}


echo"	<div class='tabbertab' tabberIndex='4'>
		<h2 title='Credits'>Credits</h2>";
echo"  		<table border='0' cellpadding='0' cellspacing='0' align='center' valign='center' style='width:620px;' >
			<col width=25>
			<col width=25>
			<col width=100>
			<col width=320>
			<col width=150>";
			
if ($message_credits != ""){
	echo"<tr bgcolor='#F7F7F7' height='25'>";
	echo"	<td align='left' colspan='5'><span class='style1'>".$message_credits."</span></td>";
	echo"</tr>";
}

echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>Account #</span></td>
					<td align='left'>
						<input type='hidden' name='Payment_Id' id='Payment_Id' value='$Payment_Id'>
						<input type='text' name='Payment_Account' id='Payment_Account' value='$Payment_Account' maxlength='10' style='width:150px;'>
					</td>
					<td align='left' rowspan='3'>
						<img src='PaymentLogoFile.php?PayId=$Payment_Id' alt='Photo' style='width:60px; height:50px;'></img>
						<input type='file' name='photo_credit' id='photo_credit' style='width:200px;' accept='image/jpeg,image/gif,image/png'>
					</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>Description</span></td>
					<td align='left'>
						<input type='text' name='Payment_Description' id='Payment_Description' value='$Payment_Description' maxlength='50' style='width:300px;'>
					</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='40'>
					<td align='left' colspan='3'><span class='style1'>&nbsp;</span></td>
					<td align='left'>
						<button type='button' id='btnSubmit3' name='btnSubmit3' onclick='SubmitRecordCredits(); return false;'  title='Save'><span><span>Submit</span></span></button>
						<button type='button' id='btnClear3' name='btnClear3' onclick='ClearRecordCredits(); return false;'  title='Clear'><span><span>Clear</span></span></button>
					</td>
				</tr>";	
				
echo"			<tr bgcolor='#D8D8D8' height='25'>
					<td width='25'>&nbsp;</td>
					<td width='25'>&nbsp;</td>
					<td width='80'><span class='style4'>Account #</span></td>
					<td width='490' colspan='2'><span class='style4'>Description</span></td>
				</tr>";


$ct = 0;
$sub_query2= " Select Payment_Id as PaymentId, Payment_Account as PaymentAccount, Payment_Description as PaymentDescription From paymentmethods Order By Payment_Description ";
$sub_result2=mysql_query($sub_query2,$connection) or die(mysql_error());
while($sub_rows2=mysql_fetch_array($sub_result2)){
	
	extract($sub_rows2);

	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";		

    $creditsname=ereg_replace("'","%27",$PaymentDescription);

	echo"<tr $Color>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/edit.png' style='cursor:pointer;' onclick=\"UpdateRecordCredits('".$PaymentId."','".$PaymentAccount."','".$creditsname."');\" title='Edit Record' ></span></td>";
	echo " <td align='center' valign='center'><span class='style15'><img src='img/delete.png' style='cursor:pointer;' onclick=\"DeleteRecordCredits('".$PaymentId."');\" title='Delete Record' ></span></td>";
	echo"  <td align='left'><span class='style5'>$PaymentAccount</span></a></td>";
	echo"  <td align='left' colspan='2'><span class='style5'>$PaymentDescription</span></a></td>";
    echo"</tr>";
	
}

echo"		</table>";		
echo"	</div>";



//Users Tab
if ($actionmode == 'SubmitUsers') {
	$ErrorExists = 0;
	$UsersExists = 0;

	$User_Password = ereg_replace("'", "\'", trim($User_Password));
	
	if ($config['EncryptPassMod'] == 1)	
		$querypass="Select ".$_SESSION['dbLabel'].".encryptpassword('$User_Password') as UserPass ";
	else
		$querypass="Select '$User_Password' as UserPass ";
			
	$resultpass=mysql_query($querypass, $connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultpass)){
		extract($rows);
	}
	
	$sub_query = " Select Count(*) From ".$_SESSION['dbLabel'].".users Where User_Account = '".$User_Account."'";
	$sub_result = selectData($connection, $sub_query);
	if ($sub_result[0] > 0) $UsersExists = 1;	
	
	if ($UsersExists == 0 && $ErrorExists == 0) {
		
		if ($User_Account != "" && $User_Name != "" && $ErrorExists == 0){
		
			$MainCompanyName=explode('_',$_SESSION['dbName']);  
			$DefaultComp = $MainCompanyName[0];
			$DefaultYear = $MainCompanyName[1];
		
			fbegin();
			$query = " INSERT INTO ".$_SESSION['dbLabel'].".users (User_Account, User_Password, User_Name, DefaultComp, DefaultYear) VALUES ('".ereg_replace("'", "\'", trim($User_Account))."', '".$UserPass."', '".ereg_replace("'", "\'", trim($User_Name))."', '".$DefaultComp."', '".$DefaultYear."')";
			$result=mysql_query($query,$connection);
			//echo $query."<br>";exit;	
			
			if ($result){
				fcommit();
				
				$query = " Insert Into ".$_SESSION['dbLabel'].".login (User_account, User_Name, Login_Schema, DefaultComp, DefaultYear, Print, FC_CashRegister, ".
						 " FI_RepRestrictProject, FI_RepRestrictCostcenter, FI_RepRestrictWarehouse, FI_ShowCostPrice, FC_CashRegisterApp, FC_CashRegisterDel, ".
						 " FC_CashRegisterMod, FC_CashRegisterDelItem, FC_CashRegisterQtyRet, FC_CashRegisterGift, FC_CashRegisterVoid, FC_CashRegisterWaste, ".
						 " Unmodify_SellingPrice, FC_CashRegisterCredit, FC_CashRegisterCheck, FC_CashRegisterCoupon, FC_CashRegisterSearch, FC_SearchByCashRegister, ".
						 " Login_ModifyAllPending, FC_CashRegisterAskPrint, FC_CashRegisterPosting, FC_CashRegisterDisc, FC_ShowBtnCancel, FC_ShowBtnOpenDrawer, ".
						 " FC_CashRegisterClosing, FC_ShowAllTables, FC_CashRegisterSetup, FC_CashRegisterCustomer, Login_negativeQty, FC_RetailReport, ExporttoExcel, ".
						 " FC_DiscountPerLimit, login_belongstogrp, FC_CashRegisterMenu,EDataCom,RetailInvoice, Fi_POS ) ".
						 " Values ('".$User_Account."', '".$User_Name."', '".$_SESSION['dbName']."', '".$DefaultComp."', '".$DefaultYear."', 1, 1, 1, 1, 1, 1, ".
						 "		   '".$_POST['chkCashRegisterApp']."', '".$_POST['chkCashRegisterDel']."', '".$_POST['chkCashRegisterMod']."', '".$_POST['chkCashRegisterDelItem']."', '".$_POST['chkCashRegisterQtyRet']."', ".
						 "		   '".$_POST['chkCashRegisterGift']."', '".$_POST['chkCashRegisterVoid']."', '".$_POST['chkCashRegisterWaste']."', '".$_POST['chkModifySellingPrice']."', '".$_POST['chkCashRegisterCredit']."', ".
						 "         '".$_POST['chkCashRegisterCheck']."', '".$_POST['chkCashRegisterCoupon']."', '".$_POST['chkCashRegisterSearch']."', '".$_POST['chkSearchByCashRegister']."', '".$_POST['chkModifyAllPending']."', ".
						 "		   '".$_POST['chkCashRegisterAskPrint']."', '".$_POST['chkCashRegisterPosting']."', '".$_POST['chkCashRegisterDisc']."', '".$_POST['chkShowBtnCancel']."', '".$_POST['chkShowBtnOpenDrawer']."', ".
						 "         '".$_POST['chkCashRegisterClosing']."', '".$_POST['chkShowAllTables']."', '".$_POST['chkCashRegisterSetup']."', '".$_POST['chkCashRegisterCustomer']."', '".$_POST['chkNegativeQty']."', ".
						 "         '".$_POST['chkRetailReport']."', '".$_POST['chkExporttoExcel']."', '".$_POST['FC_DiscountPerLimit']."', '".$_POST['FI_BelongsToGrp']."', '".$_POST['chkCashRegisterMenu']."',1,1,1) ";
				
				$result=mysql_query($query,$connection);
				
			$query = " INSERT INTO ".$_SESSION['dbLabel'].".listuserdir 
								(Usercode, Username, CompanyName, Diryear, AllowLockedPeriod) 
						VALUES ('".ereg_replace("'", "\'", trim($User_Account))."','".ereg_replace("'", "\'", trim($User_Name))."', '".$DefaultComp."', '".$DefaultYear."'
								,0
							)";
			$result=mysql_query($query,$connection);
				
				
			}else{
				$message_users  = mysql_error($connection); 
				frollback();
			}
	
		}
	} 
	else if ($UsersExists > 0 && $ErrorExists == 0){
		fbegin();
		$query = " UPDATE ".$_SESSION['dbLabel'].".users SET ".
			 	 " User_Password = '".$UserPass."', User_Name = '".ereg_replace("'", "\'", trim($User_Name))."' ".
				 " WHERE User_Account = '".$User_Account."'";
		$result=mysql_query($query,$connection);
		//echo $query."<br>";exit;	
			
		if ($result){
			fcommit();
			
			$query = " Update ".$_SESSION['dbLabel'].".login Set ".
					 " FC_CashRegisterApp = '".$_POST['chkCashRegisterApp']."', FC_CashRegisterDel = '".$_POST['chkCashRegisterDel']."', FC_CashRegisterMod = '".$_POST['chkCashRegisterMod']."', ".
					 " FC_CashRegisterDelItem = '".$_POST['chkCashRegisterDelItem']."', FC_CashRegisterQtyRet = '".$_POST['chkCashRegisterQtyRet']."', FC_CashRegisterGift = '".$_POST['chkCashRegisterGift']."', ".
					 " FC_CashRegisterVoid = '".$_POST['chkCashRegisterVoid']."', FC_CashRegisterWaste = '".$_POST['chkCashRegisterWaste']."', Unmodify_SellingPrice = '".$_POST['chkModifySellingPrice']."', ".
					 " FC_CashRegisterCredit = '".$_POST['chkCashRegisterCredit']."', FC_CashRegisterCheck = '".$_POST['chkCashRegisterCheck']."', FC_CashRegisterCoupon = '".$_POST['chkCashRegisterCoupon']."', ".
					 " FC_CashRegisterSearch = '".$_POST['chkCashRegisterSearch']."', FC_SearchByCashRegister = '".$_POST['chkSearchByCashRegister']."', Login_ModifyAllPending = '".$_POST['chkModifyAllPending']."', ".
					 " FC_CashRegisterAskPrint = '".$_POST['chkCashRegisterAskPrint']."', FC_CashRegisterPosting = '".$_POST['chkCashRegisterPosting']."', FC_CashRegisterDisc = '".$_POST['chkCashRegisterDisc']."', ".
					 " FC_ShowBtnCancel = '".$_POST['chkShowBtnCancel']."', FC_ShowBtnOpenDrawer = '".$_POST['chkShowBtnOpenDrawer']."', FC_CashRegisterClosing = '".$_POST['chkCashRegisterClosing']."', ".
					 " FC_ShowAllTables = '".$_POST['chkShowAllTables']."', FC_CashRegisterSetup = '".$_POST['chkCashRegisterSetup']."', FC_CashRegisterCustomer = '".$_POST['chkCashRegisterCustomer']."', ".
					 " Login_negativeQty = '".$_POST['chkNegativeQty']."', FC_RetailReport = '".$_POST['chkRetailReport']."', ExporttoExcel = '".$_POST['chkExporttoExcel']."', ".
					 " FC_DiscountPerLimit = '".$_POST['FC_DiscountPerLimit']."', login_belongstogrp = '".$_POST['FI_BelongsToGrp']."', ".
					 " FC_CashRegisterMenu = '".$_POST['chkCashRegisterMenu']."' ".
					 " Where Upper(User_Account) = Upper('".$User_Account."') And upper(Login_Schema) = upper('".$_SESSION['dbName']."')";
						 
			$result=mysql_query($query,$connection);
		}else{
			$message_users  = mysql_error($connection); 
			frollback();
		}
	}	
	
}
else if ($actionmode == 'DeleteUsers' && $User_Account != "") {
	$ErrorExists = 0;
	
	fbegin();
	$query = " DELETE FROM ".$_SESSION['dbLabel'].".users WHERE User_Account = '".$User_Account."'";
	$result=mysql_query($query,$connection);
	//echo $query."<br>";exit;	
			
	if ($result){
		fcommit();
		
		$query = " DELETE FROM ".$_SESSION['dbLabel'].".login WHERE User_Account = '".$User_Account."' And upper(Login_Schema) = upper('".$_SESSION['dbName']."')";
		$result=mysql_query($query,$connection);
	}else{
		$message_users  = mysql_error($connection); 
		frollback();
	}
}

echo"	<div class='tabbertab' tabberIndex='5'>
		<h2 title='Users'>Users</h2>";
echo"  		<table border='0' cellpadding='0' cellspacing='0' align='center' valign='center' style='width:620px;' >
			<col width=25>
			<col width=25>
			<col width=100>
			<col width=270>
			<col width=200>";
			
if ($message_users != ""){
	echo"<tr bgcolor='#F7F7F7' height='25'>";
	echo"	<td align='left' colspan='5'><span class='style1'>".$message_users."</span></td>";
	echo"</tr>";
}

echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>User Account</span></td>
					<td align='left'>
						<input type='text' name='User_Account' id='User_Account' value='$User_Account' maxlength='10' style='width:120px;'>
					</td>
					<td>
						<button type='button' id='assignTable' name='assignTable'  onclick='AssignTable(); return false;'  title='Assign Table'><span><span>Assign Table</span></span></button>
					</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>User Name</span></td>
					<td align='left' colspan='2'>
						<input type='text' name='User_Name' id='User_Name' value='$User_Name' maxlength='50' style='width:200px;'>
					</td>
				</tr>";
echo"			<tr bgcolor='#F7F7F7' height='25'>
					<td align='left' colspan='3'><span class='style1'>User Pass</span></td>
					<td align='left'>
						<input type='password' name='User_Password' id='User_Password' value='$User_Password' maxlength='50' style='width:120px;'>
					</td>
					<td align='left'>
						<button type='button' id='btnSubmit4' name='btnSubmit4' onclick='SubmitRecordUsers(); return false;'  title='Save'><span><span>Submit</span></span></button>
						<button type='button' id='btnClear4' name='btnClear4' onclick='ClearRecordUsers(); return false;'  title='Clear'><span><span>Clear</span></span></button>
					</td>
				</tr>";


$sub_query2 = " Select ifNull(FC_CashRegisterDel,0) As FC_CashRegisterDel, ifNull(FC_CashRegisterMod,0) As FC_CashRegisterMod, ".
			  " ifNull(FC_CashRegisterApp,0) As FC_CashRegisterApp, ifNull(FC_CashRegisterPosting,0) As FC_CashRegisterPosting, ".
			  " ifNull(FC_CashRegisterAskPrint,0) As FC_CashRegisterAskPrint, ifNull(FC_CashRegisterSearch,0) As FC_CashRegisterSearch, ".
			  " ifNull(FC_CashRegisterQtyRet,0) As FC_CashRegisterQtyRet, ifNull(FC_ShowBtnOpenDrawer,0) As FC_ShowBtnOpenDrawer, ".
			  " ifNull(Unmodify_sellingprice,0) As Unmodify_SellingPrice, ifNull(FC_CashRegisterClosing,0) As FC_CashRegisterClosing, ". 
			  " ifNull(FC_CashRegisterSetup,0) As FC_CashRegisterSetup, ifNull(FC_ShowBtnCancel,0) As FC_ShowBtnCancel, ".
			  " ifNull(FC_CashRegisterDelItem,0) As FC_CashRegisterDelItem,ifNull(FC_DiscountPerLimit,0) As FC_DiscountPerLimit, ".
			  " ifNull(FC_CashRegisterGift,0) As FC_CashRegisterGift, ifNull(FC_CashRegisterVoid,0) As FC_CashRegisterVoid, ".
			  " ifNull(FC_CashRegisterWaste,0) As FC_CashRegisterWaste, ifNull(FC_ShowAllTables,0) As FC_ShowAllTables, ".
			  " ifNull(FC_CashRegisterCredit,0) As FC_CashRegisterCredit, ifNull(FC_CashRegisterCheck,0) As FC_CashRegisterCheck, ".
			  " ifNull(FC_CashRegisterCoupon,0) As FC_CashRegisterCoupon, ifNull(FC_SearchByCashRegister,0) As FC_SearchByCashRegister, ".
			  " ifNull(Login_ModifyAllPending,0) As Login_ModifyAllPending, ifNull(FC_CashRegisterDisc,0) As FC_CashRegisterDisc, ".
			  " ifNull(FC_CashRegisterCustomer,0) As FC_CashRegisterCustomer, ifNull(Login_NegativeQty,0) As Login_NegativeQty, ".
			  " ifNull(FC_RetailReport,0) As FC_RetailReport, ifNull(ExporttoExcel,0) As ExporttoExcel, ".
			  " ifNull(login_belongstogrp,0) As FI_BelongsToGrp, ifNull(FC_CashRegisterMenu,0) As FC_CashRegisterMenu ".
			  " From ".$_SESSION['dbLabel'].".login where user_account='".$User_Account."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
			  
$sub_result2=mysql_query($sub_query2,$connection) or die(mysql_error());
while($sub_rows2=mysql_fetch_array($sub_result2)){
	extract($sub_rows2);
}

echo"<tr bgcolor='#F7F7F7' height='25'>
		<td align='left' colspan='3'><span class='style1'>User Level</span></td>
		<td align='left' colspan='2'>
			<input type='text' name='FI_BelongsToGrp' id='FI_BelongsToGrp' value='$FI_BelongsToGrp' maxlength='3' style='width:50px;'>
			<span class='style1'>Allowed Disc(%)</span>
			<input type='text' name='FC_DiscountPerLimit' id='FC_DiscountPerLimit' value='$FC_DiscountPerLimit' maxlength='3' style='width:50px;'>
		</td>
	</tr>";
				
echo"<tr><td colspan='5'>
		<div style='overflow-y:scroll;height:150px;width:620px;border:1px solid #D8D8D8;padding-left:5px;'>
		<table border='0' cellpadding='0' cellspacing='0'>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterApp' id='chkCashRegisterApp' value='1' "; if($FC_CashRegisterApp==1) echo " checked ";  echo" >Creating an Invoice</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterMod' id='chkCashRegisterMod' value='1' "; if($FC_CashRegisterMod==1) echo " checked ";  echo" >Modifying an Invoice</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterDel' id='chkCashRegisterDel' value='1' "; if($FC_CashRegisterDel==1) echo " checked ";  echo" >Deleting on Invoice</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterDelItem' id='chkCashRegisterDelItem' value='1' "; if($FC_CashRegisterDelItem==1) echo " checked ";  echo" >Delete Item</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterQtyRet' id='chkCashRegisterQtyRet' value='1' "; if($FC_CashRegisterQtyRet==1) echo " checked ";  echo" >Return Item</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterGift' id='chkCashRegisterGift' value='1' "; if($FC_CashRegisterGift==1) echo " checked ";  echo" >Gift Access</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterVoid' id='chkCashRegisterVoid' value='1' "; if($FC_CashRegisterVoid==1) echo " checked ";  echo" >Void Access</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterWaste' id='chkCashRegisterWaste' value='1' "; if($FC_CashRegisterWaste==1) echo " checked ";  echo" >Waste Access</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkModifySellingPrice' id='chkModifySellingPrice' value='0' "; if($Unmodify_SellingPrice==0) echo " checked ";  echo" >Modify Selling Price</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterCredit' id='chkCashRegisterCredit' value='1' "; if($FC_CashRegisterCredit==1) echo " checked ";  echo" >Show Credit Payment</label></span></td>";
echo" 		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterCheck' id='chkCashRegisterCheck' value='1' "; if($FC_CashRegisterCheck==1) echo " checked ";  echo" >Show Check Payment</label></span></td>";
echo" 		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterCoupon' id='chkCashRegisterCoupon' value='1' "; if($FC_CashRegisterCoupon==1) echo " checked ";  echo" >Show Coupon</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterSearch' id='chkCashRegisterSearch' value='1' "; if($FC_CashRegisterSearch==1) echo " checked ";  echo" >Allow Searching</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkSearchByCashRegister' id='chkSearchByCashRegister' value='1' "; if($FC_SearchByCashRegister==1) echo " checked ";  echo" >Search by Cashregister</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkModifyAllPending' id='chkModifyAllPending' value='1' "; if($Login_ModifyAllPending==1) echo " checked ";  echo" >Show all Pending Invoices</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo" 		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterAskPrint' id='chkCashRegisterAskPrint' value='1' "; if($FC_CashRegisterAskPrint==1) echo " checked ";  echo" >Ask Before Printing</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterPosting' id='chkCashRegisterPosting' value='1' "; if($FC_CashRegisterPosting==1) echo " checked ";  echo" >Allow Posting</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterDisc' id='chkCashRegisterDisc' value='1' "; if($FC_CashRegisterDisc==1) echo " checked ";  echo" >Allow Adding Discount</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo" 		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkShowBtnCancel' id='chkShowBtnCancel' value='1' "; if($FC_ShowBtnCancel==1) echo " checked ";  echo" >Allow Holding Invoice</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkShowBtnOpenDrawer' id='chkShowBtnOpenDrawer' value='1' "; if($FC_ShowBtnOpenDrawer==1) echo " checked ";  echo" >Allow Open Drawer</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterClosing' id='chkCashRegisterClosing' value='1' "; if($FC_CashRegisterClosing==1) echo " checked ";  echo" >Allow Closing Cashregister</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkShowAllTables' id='chkShowAllTables' value='1' "; if($FC_ShowAllTables==1) echo " checked ";  echo" >Show All Tables</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterSetup' id='chkCashRegisterSetup' value='1' "; if($FC_CashRegisterSetup==1) echo " checked ";  echo" >Show Setup Form</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterCustomer' id='chkCashRegisterCustomer' value='1' "; if($FC_CashRegisterCustomer==1) echo " checked ";  echo" >Allow Adding Customers</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkNegativeQty' id='chkNegativeQty' value='1' "; if($Login_NegativeQty==1) echo " checked ";  echo" >Allow Negative Qty</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkRetailReport' id='chkRetailReport' value='1' "; if($FC_RetailReport==1) echo " checked ";  echo" >Retail Report</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkExporttoExcel' id='chkExporttoExcel' value='1' "; if($ExporttoExcel==1) echo " checked ";  echo" >Export To Excel</label></span></td>";
echo"	</tr>";
echo"	<tr>";
echo"  		<td align='left' width='200'><span class='style1'><label><input type='checkbox' name='chkCashRegisterMenu' id='chkCashRegisterMenu' value='1' "; if($FC_CashRegisterMenu==1) echo " checked ";  echo" >Show CashRegister Menu</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label>&nbsp;</label></span></td>";
echo"  		<td align='left' width='200'><span class='style1'><label>&nbsp;</label></span></td>";
echo"	</tr>";

echo"	</table></div>
		</td></tr>";
echo"			<tr bgcolor='#D8D8D8' height='20'>
					<td width='25'>&nbsp;</td>
					<td width='25'>&nbsp;</td>
					<td width='100'><span class='style4'>User Account</span></td>
					<td width='470' colspan='2'><span class='style4'>User Name</span></td>
				</tr>";

				
echo"			<tr><td colspan='5'><div style='overflow-y:scroll;height:230px;width:620px;border:1px solid #D8D8D8;padding-left:5px;'><table border='0' cellpadding='0' cellspacing='0'>";


$ct = 0;
$sub_query2= " Select User_Account as UserAccount, User_Name as UserName, User_Password as UserPassword From ".$_SESSION['dbLabel'].".users Order By User_Account ";
$sub_result2=mysql_query($sub_query2,$connection) or die(mysql_error());
while($sub_rows2=mysql_fetch_array($sub_result2)){
	
	extract($sub_rows2);

	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";		

    $usersname=ereg_replace("'","%27",$UserName);

	echo"<tr $Color>";
	echo " <td width='25' align='center' valign='center'><span class='style15'><img src='img/edit.png' style='cursor:pointer;' onclick=\"UpdateRecordUsers('".$UserAccount."','".$UserPassword."','".$usersname."');\" title='Edit Record' ></span></td>";
	echo " <td width='25' align='center' valign='center'><span class='style15'><img src='img/delete.png' style='cursor:pointer;' onclick=\"DeleteRecordUsers('".$UserAccount."');\" title='Delete Record' ></span></td>";
	echo"  <td width='100' align='left'><span class='style5'>$UserAccount</span></a></td>";
	echo"  <td width='470' align='left'><span class='style5'>$UserName</span></a></td>";
    echo"</tr>";
	
}
echo"		</table></div></td></tr>";
echo"		</table>";		
echo"	</div>";

echo"</div>";
				
echo "</td><td id='search-content3' style='width:31px;'>&nbsp;</td></tr>";			 
echo"<tr >
		<td id='search-bottom1' style='height:34px; width:31px;'>&nbsp;</td>
		<td id='search-bottom2' style='height:34px; width:638px;' valign='top'></td>
		<td id='search-bottom3' style='height:34px; width:31px;' valign='top'></td>";
echo"</tr>";	


echo"<script type=\"text/javascript\" language=\"javascript\">";
echo"	tabberAutomatic(tabberOptions);";
echo"   vTabIndex = document.getElementById('PTabIndex').value; ";
echo"	if (document.getElementById('tab1')) document.getElementById('tab1').tabber.tabShow(vTabIndex); ";
echo"</script>";

function fbegin()
{
	mysql_query("START TRANSACTION");
}
function fcommit(){
	mysql_query("COMMIT");
}
function frollback()
{
	mysql_query("ROLLBACK");
}
print <<<HERE
</form>
</body>

HERE;

?>