<?php
header("Content-type: text/html; charset=windows-1256");

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

if($_SESSION['cashregister']==""){
header("location:Form_Retail_CashUsers.php");
}

include("config.inc.php");
include("Functions_Sales.php");
include("Functions_Retail.php");
include("function.inc.php");
include("FunctionsLicense.inc.php");




$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

//Check For License
/*$LicenseError = CheckSoftwareLicense($connection,$EncryptKey);
if ($LicenseError != "") {
	header("location:../cashregister_index.php");
}
*/

$querylog="SELECT FC_CashRegister as loginaccess,FC_CashRegisterCustomer as FC_CashRegisterCustomer , ifNull(FC_CashRegisterHold,0) As FC_CashRegisterHold,IfNull(FC_RetailReport,0) FC_RetailReport
from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}
//echo $loginaccess;exit;
if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");


		
//$querylog="select * from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$querylog=" 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(login_belongstogrp,0) As FI_BelongsToGrp, ifNull(FC_CashRegisterMenu,0) As FC_CashRegisterMenu, ".
		  " ifNull(FI_RetailCashOut,0) As FI_RetailCashOut ".
		  " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}


	
//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, ifNull(ShowSlipNumber,0) As ShowSlipNumber, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage, Company_Name As CompanyName, ".
			 " ifNull(CashReg_DispLedMsg, 'Welcome !') As CashReg_DispLedMsg, ifNull(CashReg_Weight,0) As CashReg_Weight, ifNull(CashReg_RoundDivisor,1) As CashReg_RoundDivisor,ifnull(cashreg_colortheme,'default') as cashreg_colortheme,discount_amount ".
			 " , keyboardfocus, Retaildt_height,shortcutgrid_height, subgroupgrid_height,shortcutgrid_width,subgroupgrid_width, ifnull(RestrictZeroPrice,0) as RestrictZeroPrice ".
			 " 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_AdditionalTaxes,0) As Module_AdditionalTaxes, ifNull(Module_Pack,0) As Module_Pack, ".
             " ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_SerialNo,0) As Module_SerialNo, ifNull(Module_PriceOffer,0) As Module_PriceOffer , ifNull(Module_GroupHoldFire,0) As Module_GroupHoldFire , ifNull(Module_HoldPermission,0) As Module_HoldPermission".
			 " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

//Read From CashRegister Table
$queryCashRegister=" Select Upper(CashRegister_Name) As CashRegister_Name, Currency_Code As StpCurrCode, CostCenter_Code As StpCostCentCode, Project_Code As StpProjectCode, ".
                   " ifNull(CashRegister_BarCode,0) As CashRegisterBarCode, ifNull(CashRegister_SerialNo,0) As CashRegisterSerialNo, ifNull(CashRegister_Discount,0) As CashRegisterDiscount, ".
				   " CashRegisterTTC, Client_Account As StpClientAccount, ifNull(CashRegister_SlipPrinter,0) As CashRegister_SlipPrinter, ifNull(CashRegister_SlipRePrinter,0) As CashRegister_SlipRePrinter, ".
				   " ifNull(CashRegister_AutoPost,0) As CashRegister_AutoPost, ifNull(CashReg_Vendor,0) As CashReg_Vendor, ".
				   " ifNull(CashRegister_DisplayLed,0) As CashRegister_DisplayLed, ifNull(CashRegister_DispCOM,0) As CashRegister_DispCOM, ".
				   " ifNull(CashRegister_PrintBarcode,0) As CashRegister_PrintBarcode, ifNull(CashReg_ForcingVendor,0) As CashReg_ForcingVendor, ".
				   " ifNull(CashRegister_LedDescLength,0) As CashRegister_LedDescLength, ifNull(CashRegister_Printer,0) As CashRegister_Printer, ".
				   " ifNull(Module_CashRegisterFastItem,0) As Module_CashRegisterFastItem, ifNull(Module_RestaurantDelivery,0) As Module_RestaurantDelivery, ".
				   " ifNull(Module_CashRegisterStandardView,0) As Module_CashRegisterStandardView, ifNull(Module_CashRegisterTable,0) As Module_CashRegisterTable, ".
				   " ifNull(Module_CashRegAutoItemsList,0) As Module_CashRegAutoItemsList, ifNull(CashRegister_ShowTaxNonTax,0) as CashRegister_ShowTaxNonTax,  ".
				   " ifNull(CashRegister_Drawer,0) As CashRegister_Drawer, ifNull(CashRegister_SlipKitchen,0) As CashRegister_SlipKitchen, ".
				   " ifNull(CashRegister_SlipCopy,1) As CashRegister_SlipCopy,ifNull(cashregister_logout,1) As cashregister_logout ,ifNull(cashregister_retailtype,1) As cashregister_retailtype,".
				   " ifNull(CashRegister_showitemcode,0) As CashRegister_showitemcode, ifNull(CashRegister_showdiscount,0) As CashRegister_showdiscount, ".
				   " ifnull(cashregister_service,0) as cashregister_service, cashregister_servicePercentage, ifnull(cashregister_TaxConsumption,0) as cashregister_TaxConsumption, cashregister_TaxConsumptionpPer ".
				   " From CashRegister ".
				   " Where CashRegister_Name = '".$_SESSION['cashregister']."' ";
				 //echo$queryCashRegister;exit;
$resultCashRegister=mysql_query($queryCashRegister,$connection) or die(mysql_error());
while($rowCashRegister=mysql_fetch_array($resultCashRegister)){
	extract($rowCashRegister);
}


	
$queryUsers="SELECT User_Account As UserAccount, FullName As UserFullName From ".$_SESSION['dbLabel'].".Users where user_account='".$_SESSION['useraccount']."' 	";
$resultUsers=mysql_query($queryUsers,$connection) or die(mysql_error());
while($rowUsers=mysql_fetch_array($resultUsers)){
	extract($rowUsers);
}

$queryMenu = " SELECT Menu_Index, Menu_Title, Menu_Link, Menu_ImageName, Menu_ShortCutLabel, ifNull(Menu_WinWidth,1000) as Menu_WinWidth, ifNull(Menu_WinHeight,700) as Menu_WinHeight ".
			 " From cashregistermenu ".
			 " where ifNull(Menu_Active,0) = 1 ".
			 " and ifNull(Menu_Belongstogrp,0) >= $FI_BelongsToGrp ".
			 " Order By lpad(Menu_Order,3,'0') 	"; 
$resultMenu=mysql_query($queryMenu,$connection) or die(mysql_error());

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

$txtProjectDtId   = $_POST["txtProjectDtId"]; if ($txtProjectDtId == ""){$txtProjectDtId = $_GET["txtProjectDtId"];}   
$txtOrderId 	  = $_POST["txtOrderId"]; if ($txtOrderId == ""){$txtOrderId = $_GET["txtOrderId"];}   
$txtOrderRef 	  = $_POST["txtOrderRef"]; if ($txtOrderRef == ""){$txtOrderRef = $_GET["txtOrderRef"];}   
$txtClientCode 	  = $_POST["txtClientCode"]; if ($txtClientCode == ""){$txtClientCode = $_GET["txtClientCode"];}   
$txtProjectCode   = $_POST["txtProjectCode"]; if ($txtProjectCode == ""){$txtProjectCode = $_GET["txtProjectCode"];}   
$txtCostCentCode  = $_POST["txtCostCentCode"]; if ($txtCostCentCode == ""){$txtCostCentCode = $_GET["txtCostCentCode"];}   
$txtId 			  = $_POST["txtId"]; if ($txtId == ""){$txtId = $_GET["txtId"];}   
$txtRef 		  = $_POST["txtRef"]; if ($txtRef == ""){$txtRef = $_GET["txtRef"];}   
$txtCurr 		  = $_POST["txtCurr"]; if ($txtCurr == ""){$txtCurr = $_GET["txtCurr"];}   
$txtDate 		  = $_POST["txtDate"]; if ($txtDate == ""){$txtDate = $_GET["txtDate"];}
$txtItemBarcode   = $_POST["txtItemBarcode"]; if ($txtItemBarcode == ""){$txtItemBarcode = $_GET["txtItemBarcode"];}   
$txtItemPrice 	  = $_POST["txtItemPrice"]; if ($txtItemPrice == ""){$txtItemPrice = $_GET["txtItemPrice"];}   
$txtItemQty 	  = $_POST["txtItemQty"]; if ($txtItemQty == ""){$txtItemQty = $_GET["txtItemQty"];}   
$ItemOptionLabel  = $_POST["ItemOptionLabel"]; if ($ItemOptionLabel == ""){$ItemOptionLabel = $_GET["ItemOptionLabel"];}   
$txtBalanceAmount = $_POST["txtBalanceAmount"]; if ($txtBalanceAmount == ""){$txtBalanceAmount = $_GET["txtBalanceAmount"];}
$txtCashRegister  = $_POST["txtCashRegister"]; if ($txtCashRegister == ""){$txtCashRegister = $_GET["txtCashRegister"];}
$txtVendorCode 	  = $_POST["txtVendorCode"]; if ($txtVendorCode == ""){$txtVendorCode = $_GET["txtVendorCode"];}
$txtSlipNo    	  = $_POST["txtSlipNo"]; if ($txtSlipNo == ""){$txtSlipNo = $_GET["txtSlipNo"];}

$txtSaleStatus    	  = $_POST["txtSaleStatus"]; if ($txtSaleStatus == ""){$txtSaleStatus = $_GET["txtSaleStatus"];}
$txtRetDriverCode     = $_POST["txtRetDriverCode"]; if ($txtRetDriverCode == ""){$txtRetDriverCode = $_GET["txtRetDriverCode"];}
$txtRetDriverName     = $_POST["txtRetDriverName"]; if ($txtRetDriverName == ""){$txtRetDriverName = $_GET["txtRetDriverName"];}
$txtRetCustomerCode   = $_POST["txtRetCustomerCode"]; if ($txtRetCustomerCode == ""){$txtRetCustomerCode = $_GET["txtRetCustomerCode"];}
$txtRetCustomerName   = $_POST["txtRetCustomerName"]; if ($txtRetCustomerName == ""){$txtRetCustomerName = $_GET["txtRetCustomerName"];}

$openwin 	 = $_POST["openwin"]; if ($openwin == ""){$openwin = $_GET["openwin"];}
$index 	     = $_POST["index"]; if ($index == ""){$index = $_GET["index"];}
$isserial 	 = $_POST["isserial"]; if ($isserial == ""){$isserial = $_GET["isserial"];}
$string 	 = $_POST["string"]; if ($string == ""){$string = $_GET["string"];}
$passchecked = $_POST["passchecked"]; if ($passchecked == ""){$passchecked = $_GET["passchecked"];}
$QtySerNo 	 = $_POST["QtySerNo"]; if ($QtySerNo == ""){$QtySerNo = $_GET["QtySerNo"];}
$PrRetId 	 = $_POST["PrRetId"]; if ($PrRetId == ""){$PrRetId = $_GET["PrRetId"];}
$txtFocusField 		 = $_POST["txtFocusField"]; if ($txtFocusField == ""){$txtFocusField = $_GET["txtFocusField"];}
$txtSubGroup 		 = $_POST["txtSubGroup"]; if ($txtSubGroup == ""){$txtSubGroup = $_GET["txtSubGroup"];}
$subgroup_codeParent = $_POST["subgroup_codeParent"]; if ($subgroup_codeParent == ""){$subgroup_codeParent = $_GET["subgroup_codeParent"];}
$SelectedRec 	  = $_POST["SelectedRec"]; if ($SelectedRec == ""){$SelectedRec = $_GET["SelectedRec"];}
$SelectedRecColor = $_POST["SelectedRecColor"]; if ($SelectedRecColor == ""){$SelectedRecColor = $_GET["SelectedRecColor"];}
$SelectedDtId 	  = $_POST["SelectedDtId"]; if ($SelectedDtId == ""){$SelectedDtId = $_GET["SelectedDtId"];}

$txtTableGuests    	  = $_POST["txtTableGuests"]; if ($txtTableGuests == ""){$txtTableGuests = $_GET["txtTableGuests"];}
$txtTableGuestsEdit    	  = $_POST["txtTableGuestsEdit"]; if ($txtTableGuestsEdit == ""){$txtTableGuestsEdit = $_GET["txtTableGuestsEdit"];}
$pendingphone    	  = $_POST["pendingphone"]; if ($pendingphone == ""){$pendingphone = $_GET["pendingphone"];}

if (empty($mainaction))	$mainaction = 'insert';
$message = ereg_replace("'"," ",$message);
if($txtSubGroup=='' && $subgroup_codeParent!='') $txtSubGroup=$subgroup_codeParent;

if($copiedVers == '') $copiedVers = 0;
if ($txtGuestname != '') $txtGuestname1 = $txtGuestname;
print <<<HERE
<head>

<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


HERE;


if($cashreg_colortheme=='red'){
	echo'<link rel="stylesheet" type="text/css" media="all" href="css-v2/style-red.css">';
	echo'<link rel="stylesheet" type="text/css" href="js/menu-v2/menu-red.css" />';
}	
else if($cashreg_colortheme=='' || $cashreg_colortheme=='default')	{
	echo'<link rel="stylesheet" type="text/css" media="all" href="css-v2/style-default.css">';
	echo'<link rel="stylesheet" type="text/css" href="js/menu-v2/menu-default.css" />';
}

		 
print <<<HERE
<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">
<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>

HERE;
/*
if($Module_RestaurantDelivery==1)
 print <<<HERE
<script type="text/javascript" language="javascript"> 
setInterval(function () 
{

		x=document.retail;
 
	
	if(document.retail.pendingphone.value=='')	 
	{  

		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp5=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp5=new ActiveXObject("Microsoft.xmlhttp");
		}
		xmlhttp5.onreadystatechange=function()
		{
			if (xmlhttp5.readyState==4 && xmlhttp5.status==200)
			{
			
				 {
				var data = xmlhttp5.responseText.split("[BRKCALLERID]");
				
				
				var isfound = data[2];
				
				
				if(data[1] != '' && document.retail.pendingphone.value=='' && isfound == ''){
					document.retail.pendingphone.value=data[1];
					OpenCustomerRestaurant_CallerId(data[1],isfound);
					}
				else if(data[1] != ''){
					document.retail.pendingphone.value=data[1];
					document.retail.txtRetCustomerCode.value = data[2];
					document.retail.txtRetCustomerName.value = data[4];
					document.retail.txtSaleStatus.value = 'delivery';
					document.retail.txtRetDriverName.focus();					
				}
			
				
				}
			}			
		}
				
		xmlhttp5.open("GET","Form_Retail_Actions.php?mainmode=checkphone");
		xmlhttp5.send();	
		 
    } 
		
		
		
		}
		, 3000); 
</script>
HERE;*/
 
if($Module_RestaurantDelivery==1)
 print <<<HERE
<script type="text/javascript" language="javascript"> 
setInterval(function () 
{

		x=document.retail;
 
	
	if(document.retail.pendingphone.value=='')	 
	{  

		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp5=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp5=new ActiveXObject("Microsoft.xmlhttp");
		}
		xmlhttp5.onreadystatechange=function()
		{
			if (xmlhttp5.readyState==4 && xmlhttp5.status==200)
			{
			
				
				var data = xmlhttp5.responseText.split("[BRK]");
				
				if(data[1] != '0' )
					document.getElementById("div-shortcuts").innerHTML=data[0];
				
				
			}			
		}
				
		xmlhttp5.open("GET","Form_Retail_Actions.php?mainmode=showcallerid");
		xmlhttp5.send();	
		 
    } 
		
		
		
		}
		, 3000); 
</script>
HERE;
 
print <<<HERE
<script type="text/javascript" language="javascript"> 

 function OpenCustomerRestaurant_CallerId(CustomerTel,isfound){ 
	 
	
	Win_Employee = window.open('List_Customers.php?frm=3&PLedgerNo='+CustomerTel+'&fromcallerid=1&isfound='+isfound,'List_Customers', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=900,height=750,left=250,top=200');		
	Win_Employee.creator = self;
	Win_Employee.focus();
	
}
</script>
    
<script type="text/javascript" language="javascript">
var Win_Disc=null;
var Win_Cash=null;
var Win_Hold=null;
var Win_Search=null;
var Win_Employee=null;
var Win_Retail=null;
var Win_RetailOrder=null;
var Win_RetailSearch=null;
var Win_RetailAddSerial=null;
var Win_RetailDetail=null;
var Win_AddItems=null;
var Win_Retail_Post=null;
var Win_FastItem=null;
var Win_Booking=null;



function getphone(callerid){



	if(document.retail.pendingphone.value=='')	 
	{  

		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp5=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp5=new ActiveXObject("Microsoft.xmlhttp");
		}
		xmlhttp5.onreadystatechange=function()
		{
			if (xmlhttp5.readyState==4 && xmlhttp5.status==200)
			{
			
				 {
				var data = xmlhttp5.responseText.split("[BRKCALLERID]");
				
				
				var isfound = data[2];
				
				//alert(data[1]);
				/*if(data[1] != '' && document.retail.pendingphone.value=='' && isfound == ''){
					document.retail.pendingphone.value=data[1];
					OpenCustomerRestaurant_CallerId(data[1],isfound);
					}
				else*/
				
				
				if(data[1] != ''){
					document.retail.pendingphone.value=data[1];
					document.retail.txtRetCustomerCode.value = data[2];
					document.retail.txtRetCustomerName.value = data[4];
					document.retail.txtSaleStatus.value = 'delivery';
					document.retail.txtRetDriverName.focus();					
				}
			
				
				}
			}			
		}
				
		xmlhttp5.open("GET","Form_Retail_Actions.php?mainmode=getphone"+"&callerid="+callerid);
		xmlhttp5.send();	
		 
    } 

}


function EmptyDrivercode(txtId){

if(document.retail.txtRetDriverName.value=='') {
	document.retail.txtRetDriverCode.value='';
	
	
	x=document.retail;
 
	
		 
	{  
        
		var vtel = x.txtRetCustomerName.value;
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText;
			
					 
			}			
		}
				
		xmlhttp.open("GET","Form_Retail_Actions.php?mainmode=emptydrivercode&saleid="+txtId);
		xmlhttp.send();	
		 
    }
	
	
	}

}

function refreshpage(mode){

		x = document.retail;
		x.actionmode.value='addtype';
		x.action='Form_Retail.php';
		x.submit();
}

function changecolor(vobj,vtextname,vcolorname,val,isserial,moduleserial,ct,itemprinted,vitemprinted){

	document.retail.isserial.value=isserial;
	document.retail.index.value=ct;
	document.retail.itemprinted.value=itemprinted;

	if (document.getElementById('button_addserial')) {
		if(moduleserial==1 && isserial==1)
			document.retail.button_addserial.style.visibility = 'visible';
		else
			document.retail.button_addserial.style.visibility = 'hidden';
	}

	if(vitemprinted==1){
		document.retail.Edit.disabled = true;
		document.retail.Delete.disabled = true;
	} else {
		document.retail.Edit.disabled = false;
		document.retail.Delete.disabled = false;
	}
	
	document.getElementById('SelectedDtId').value = val;

	if (document.getElementById(vtextname).value=='')
	{
		document.getElementById(vtextname).value = vobj.id;
		document.getElementById(vcolorname).value = vobj.style.backgroundColor;
	}	
	else {

		var prevobj = document.getElementById(vtextname).value;

		document.getElementById(prevobj).style.backgroundColor = document.getElementById(vcolorname).value;

		document.getElementById(vtextname).value = vobj.id;
		document.getElementById(vcolorname).value = vobj.style.backgroundColor;
	}	

	document.getElementById(vobj.id).style.backgroundColor ='#B8EDFF';

}


function SetupCashRegister(){
	x = document.retail;

	var Win = window.open('Form_CashRegisterSetup.php','Setup', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=760,height=520,left=250,top=200');		
	Win.creator = self;
	Win.focus();
}

function ShowSetupForm(){
	x = document.retail;

	var Win = window.open('Form_RetailSetup.php','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 CheckFields(){
	
  
    x = document.retail;
	
	var RetDate		  = x.txtDate.value;
	var RetProject 	  = x.txtProjectCode.value;
	var RetCostCenter = x.txtCostCentCode.value;
	var RetCurr		  = x.txtCurr.value;
	var RetClientCode = x.txtClientCode.value;
	var ItemQty		  = x.txtItemQty.value;
	var ItemPrice	  = x.txtItemPrice.value;
	var ItemBarcode   = x.txtItemBarcode.value;
	
	
	if (ItemQty == '')	 ItemQty = 1;
	if (ItemPrice == '') ItemPrice = 0;
	
	var vmode  = x.mainaction.value;
	var vmode1 = x.actionmode.value;
	
	vModuleProject    = x.ModuleProject.value;
	vModuleCostCenter = x.ModuleCostCenter.value;
	vModuleQtyReturn  = x.ModuleQtyReturn.value;
	
	var vPassChecked  = x.passchecked.value;


	var result = 1;
	
	var vMinusSignExists = 0;
	if (ItemBarcode.indexOf("-") !== -1) {
		var vItemPrefix = ItemBarcode.split("-",1);
		if ((vItemPrefix*1 == vItemPrefix/1) || vItemPrefix == "*") vMinusSignExists = 1;
	}
	
	if (RetDate=='' )
	{
		alert("Date is mandatory!");
		x.txtDate.focus();
		result = 0;
	}
	else if (RetProject=='' && vModuleProject==1)
	{
		alert("Project is mandatory!. Please check data in table cashregister.");
		result = 0;
	}
	else if (RetCostCenter=='' && vModuleCostCenter==1)
	{
		alert("CostCenter is mandatory!. Please check data in table cashregister.");
		result = 0;
	}
	else if (RetCurr=='' )
	{
		alert("Currency is mandatory!. Please check data in table cashregister.");
		result = 0;
	}
	else if (RetClientCode=='' )
	{
		alert("Client is mandatory!. Please check data in table cashregister.");
		result = 0;
	}
	else if ((ItemPrice*1 != ItemPrice/1 ) || ItemPrice < 0) {
		alert('Price should be a POSITIVE and NUMERIC value. ');
		x.txtItemPrice.focus();
		result = 0;
	}
	else if (ItemQty*1 != ItemQty/1 ) {
		alert('Quantity should be a NUMERIC value. ');
		x.txtItemQty.focus();
		result = 0;
	}
	
	else if ((ItemQty < 0 || vMinusSignExists == 1) && vModuleQtyReturn==0 && vPassChecked==0)
	{
		//alert('You have no access to return items. ');
		//x.txtItemQty.focus();
		
		win = window.open('Form_Retail_Password.php?actionmode=returnitem',
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
		
		x.passchecked.value = '';
		
		result = 0;
	}		
	
		
	if (result == 0) {
		
		PlayErrorSound();	
	}
	
	return result;	
}

function fillprojectdt(vprojectid){
document.retail.txtProjectDtId.value = vprojectid;
}

function CheckFieldsDt(PIndex,DiscountPerLimit,CashRegForcingVendor){
	
	x = document.retail;
	var vModuleQtyReturn  = x.ModuleQtyReturn.value;
	
	var vPassChecked      = x.passchecked.value;
	
	var vmode = x.actionmode.value;
	
	//var RetDtWarehouseCode = x.txtWarehouseCode[PIndex].value;
	var RetDtQty           =document.getElementById('qtydt['+PIndex+']').value;
	
	var RetDtPrice         =document.getElementById('pricedt['+PIndex+']').value;
	var RetDtDiscount 	   =document.getElementById('discdt['+PIndex+']').value;
	var RetDtVendorCode    =document.getElementById('vendordt['+PIndex+']').value;
	
	if (RetDtPrice == '')    RetDtPrice = 0;
	if (RetDtDiscount == '') RetDtDiscount = 0;
	
	RetDtDiscount    = parseFloat(RetDtDiscount);
	DiscountPerLimit = parseFloat(DiscountPerLimit);

	if (RetDtQty < 0 && vModuleQtyReturn==0 && vPassChecked==0)
	{
		
		win = window.open('Form_Retail_Password.php?actionmode=returnitem2&PIndex='+PIndex,
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
		
		x.passchecked.value = '';
		
		return 0;
	}
	//else if (RetDtWarehouseCode=='')
	//{
	//	alert("Warehouse is mandatory!");
	//	x.txtWarehouseCode.focus();
	//	return 0;
	//}
	else if ((RetDtPrice*1 != RetDtPrice/1 ) || RetDtPrice < 0) {
		alert('Price should be a POSITIVE and NUMERIC value. ');
		document.getElementById('pricedt['+PIndex+']').focus();
		return 0;
	}
	else if (RetDtDiscount > 0 && DiscountPerLimit >= 0 && RetDtDiscount > DiscountPerLimit) {
		alert('Discount should be less than or equal to allowed limit ('+DiscountPerLimit+')');
		document.getElementById('discdt['+PIndex+']').focus();
		return 0;
	}
	else if (CashRegForcingVendor == 1 && RetDtVendorCode == '') {
		alert("Vendor is mandatory!");
		document.getElementById('discdt['+PIndex+']').focus();
		document.getElementById('vendordt['+PIndex+']').focus();
		return 0;
	} 
		
	
	else
	return 1 ;	
}


function OpenPasswordForm(CashRegClear,btname){



win = window.open('Form_RetailHoldMenu_Password.php?CashRegClear='+CashRegClear+'&btname='+btname,
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
		
}


function ClearPage(CashRegClear,btname){
	x = document.retail;
	var vPassChecked = x.passchecked.value;
	var vRetId       = x.txtId.value;
	
	/*if (CashRegClear == 0 && vPassChecked == 0 && btname == 'Hold') {
		win = window.open('Form_Retail_Password.php?actionmode=clearrecord',
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
    } else {*/
		//if (confirm ( "Are you sure you want to "+btname+" Invoice?"))
		//{
			if (vRetId != '') {
				loadHoldWin();
			} else {
				ClearForm('All');
				x.mainaction.value='insert';
				x.actionmode.value='';
				x.action='Form_Retail.php';
				x.submit();
			}	
		//}	
		
		x.passchecked.value = '';
	//}	
}


function OpenTable(){
	x = document.retail;
	var vPassChecked = x.passchecked.value;
	var vProjectDtId = x.txtProjectDtId.value;
	var vTableGuests = x.txtTableGuests.value;
	var vtxtGuestname = x.txtGuestname.value; 
	
	{
		//if (confirm ( "Are you sure you want to Open New Table?"))
		if(vTableGuests>0)
		{
			ClearForm('All');
			//fillprojectdt(vprojectdtid);
			
			x.txtProjectDtId.value = vProjectDtId;
			x.txtTableGuests.value = vTableGuests;
			x.txtGuestname1.value = vtxtGuestname;
			
			x.mainaction.value='insert';
			x.actionmode.value='';
			x.action='Form_Retail.php?mainaction=insert';
			x.submit();
			
			//CloseGuestsWin();
		}
		
		else alert('Please enter number of guests greater than 0');
		
		x.passchecked.value = '';
	}	
}

function EditGuestTable(){
	x = document.retail;
	 
	 
	var vTableGuests = x.txtTableGuestsEdit.value;
	var vRetId       = x.txtId.value;
 
 if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}

	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			//alert(xmlhttp.responseText);
			//document.getElementById("testdiv").innerHTML=xmlhttp.responseText;
			xmlhttp.responseText;
			x.submit();
		}
	}
	
	xmlhttp.open("GET","Form_Retail_Actions.php?RetailId="+vRetId+"&TableGuests="+vTableGuests+"&mode=updateguests",true);
	xmlhttp.send();
	
}

function ClearPage1(){
	x = document.retail;
	var msg = x.message.value;
	
	ClearForm('All');
	
	x.mainaction.value='insert';
	x.actionmode.value='';
	x.message.value=msg;
	x.action='Form_Retail.php?message='+x.message.value;
	x.submit();
}

function CancelRecord(CashRegCancel){
	x = document.retail;
	var vmode  = x.mainaction.value;
	var vmode1 = x.actionmode.value;
	var RetId = x.txtId.value;
	var vPassChecked = x.passchecked.value;
	
	var vCancelMsg = "Are you sure you want to Delete current pending invoice permenantly?";
	
	if (CashRegCancel == 0 && vPassChecked == 0) {
		win = window.open('Form_Retail_Password.php?actionmode=cancelrecord',
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
    } else {	
	
		if (confirm ( vCancelMsg))
		{
			ClearForm('All');
			x.txtId.value = RetId;
			x.mainaction.value='insert';
			x.actionmode.value='cancel';
			x.copiedVers.value=0;
			x.action='Form_Retail.php';
			x.submit();
		}
		
		x.passchecked.value = '';
    }
}


function refundall(OpenPass,CashRegCancel){

	x = document.retail;
	var vMainMode = x.mainaction.value;
	var RetId = x.txtId.value;
	var vPassChecked = x.passchecked.value;
	
	var vCancelMsg = "Are you sure you want to Refund All Items?";
	
	if (OpenPass == 0 && vPassChecked == 0) {
		win = window.open('Form_Retail_Password.php?actionmode=refundall',
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
    } else {	
	
		if (confirm ( vCancelMsg))
		{
			
			x.action="Form_Retail_Actions.php?mode=refunddtall&mainmode="+vMainMode+"&SRetId="+RetId;
			x.submit();
		}
		
		x.passchecked.value = '';
    }
}



function PostChanges() {
	x = document.retail;
	var RetId  = x.txtId.value;
	var vMainMode = x.mainaction.value;
	
	
	
	
	if (x.txtCountDetail.value == 0 || x.txtCountDetail.value == '') {
		alert('Save not allowed. Please add items.');
	}
	else if (x.QtySerNo.value == 1){
		alert('Please check Item(s) Qty and Serial No.');
	}
	else if (x.txtBalanceAmount.value > 100){
		alert('Payment not done.');
	}
	else {
		if (confirm ( "Are you sure you want to Save current invoice?"))
		{
			
			if (document.getElementById('btnCancel'))
				x.btnCancel.disabled = true;
			if (document.getElementById('btnPost'))
				x.btnPost.disabled = true;
			if (document.getElementById('btnAddItem'))
				document.getElementById('btnAddItem').disabled = true;
			if (document.getElementById('btnClear'))
				x.btnClear.disabled = true;	
			if (document.getElementById('btnAddSerial'))
				document.getElementById('btnAddSerial').disabled = true;
			if (document.getElementById('btnDiscount'))
				x.btnDiscount.disabled = true;
			if (document.getElementById('btnCash'))
				x.btnCash.disabled = true;
			if (document.getElementById('btnPosting'))
				document.getElementById('btnPosting').disabled = true;	
				
			
			x.actionmode.value='post';
			x.action="Form_Retail_Actions.php?mode=post&mainmode="+vMainMode+"&SRetId="+RetId;
			x.submit();
		}
	}
}


	
function DeleteRecordDt(vRetDtId, ItemCode, CashRegDel, PIndex) {
	x = document.retail;
	var RetId  = x.txtId.value;
	var vMainMode    	= x.mainaction.value;
	var vPassChecked 	= x.passchecked.value;
	var ItemPrinted  	= x.itemprinted.value;
	var serviceChecked  = x.serviceChecked.value;
	var vDelMsg = '';


	var RetDtId = x.SelectedDtId.value;
	if(RetDtId=='')	return;
	
	PIndex = x.index.value;
	
    vDelMsg = "Are you sure you want to Delete Item "+ItemCode+" ?";
	
	if (ItemPrinted != 1) {
		if (CashRegDel == 0 && vPassChecked == 0) {
			win = window.open('Form_Retail_Password.php?actionmode=deletedt&PIndex='+PIndex,
							  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
			win.creator = self;
			win.focus();
		} else {
			
			if (confirm ( vDelMsg ))
			{
				
				x.action="Form_Retail_Actions.php?mode=deletedt&mainmode="+vMainMode+"&SRetId="+RetId+"&SRetDtId="+RetDtId+"&serviceChecked="+serviceChecked;
				x.submit();
			}
			
			x.passchecked.value = '';
				
		}
	} else {
		alert('Delete not allowed. Item is printed.');
	}
}
function UpdateRecord(RetId){
	
	document.retail.txtId.value=RetId;
	if (document.getElementById('SelectedDtId'))
		document.getElementById('SelectedDtId').value = '';
	document.retail.mainaction.value='edit';
	document.retail.actionmode.value='';
	document.retail.action='Form_Retail.php';
	document.retail.submit();

}

function UpdateRecordDt(vRetDtId, CashRegMod) {
    x = document.retail;
	var vRetId = x.txtId.value;
	var vRetDate = x.txtDate.value;
		
	var vMainMode    = x.mainaction.value;
	var vPassChecked = x.passchecked.value;
	
	var RetDtId = x.SelectedDtId.value;
	
	if(RetDtId=='')	return;


	if (CashRegMod == 0 && vPassChecked == 0) {
		win = window.open('Form_Retail_Password.php?actionmode=editdt',
						  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
		win.creator = self;
		win.focus();
    } else {
		x.passchecked.value = '';
		
		Win_RetailDetail = window.open('Form_RetailDetail.php?mainaction='+vMainMode+'&actionmode=&PRetId='+vRetId+'&PRetDate='+vRetDate+'&PRetDtId='+RetDtId, 'Form_RetailDetail', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=780,height=330,top=100');		
		Win_RetailDetail.creator = self;
		Win_RetailDetail.focus();		
	}
}




//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.retail;
	var vmode = x.actionmode.value;
	
	if (Option == 'All') {
		
		x.txtId.value='';
		x.txtOrderId.value='';
		x.txtOrderRef.value='';
		x.txtRef.value='';
		x.txtDate.value='';
		x.txtCurr.value='';
		x.txtProjectCode.value='';
		x.txtCostCentCode.value='';
		x.txtCashRegister.value='';
		x.txtClientCode.value='';
		x.txt_GroupHoldFire.value='';
		
		x.txtSaleStatus.value=x.cashregister_retailtype.value;
		x.txtSaleStatus.value='';
		
		
		x.txtItemBarcode.value='';
		x.txtItemQty.value='';
		x.txtItemPrice.value='';
		x.txtVendorCode.value='';
		x.txtSlipNo.value='';
		
		x.txtTaxable.value='';
		x.txtNoneTaxable.value='';
		x.txtGrossTotal.value='';
		x.txtDiscount.value='';
		x.txtDiscountAmt.value='';
		x.txtVat.value='';
		x.txtNetTotal.value='';
		x.txtTotalTaxes.value='';
		
		x.txtCountDetail.value='';	
		x.QtySerNo.value='';		
		x.message.value='';
		x.string.value = '';
		
		x.actionmode.value = '';
		x.mainaction.value = '';
		x.PrRetId.value='';
		x.passchecked.value='';
		x.txtSubGroup.value='';
		x.txtProjectDtId.value='';
		x.txtTableGuests.value='';
		x.txtGuestname.value='';
		
		x.SelectedRec.value='';
		x.SelectedRecColor.value='';
		x.SelectedDtId.value='';
		x.isserial.value='';
		x.index.value='';
		
		x.txtRetDriverCode.value='';
		x.txtRetDriverName.value='';
		x.txtRetCustomerCode.value='';
		x.txtRetCustomerName.value='';
		x.txtSaleStatus.value='';
		x.pendingphone.value='';
		
	} 
}

function AddItems() {

	x = document.retail;
	//x.actionmode.value = '';
	
	var result = CheckFields();

	var vRetId = x.txtId.value;
	var vRetDate = x.txtDate.value;
	var vRetCashRegister = x.txtCashRegister.value;
	var vRetCurr = x.txtCurr.value;
	var vRetClientCode = x.txtClientCode.value;
	var vRetProjectCode = x.txtProjectCode.value;
	var vRetCostCentCode = x.txtCostCentCode.value;
	
	
	
	var vMainMode = x.mainaction.value;
	
	if (result == 1) {
		Win_AddItems = window.open('Form_RetailDetail.php?mainaction='+vMainMode+'&actionmode=&PRetId='+vRetId+'&PRetDate='+vRetDate+'&PRetCashRegister='+vRetCashRegister+
								  '&PRetCurr='+vRetCurr+'&PRetProjectCode='+vRetProjectCode+'&PRetCostCentCode='+vRetCostCentCode+'&PRetClientCode='+vRetClientCode, 
								  'Form_RetailDetail', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=780,height=330,top=100,left=0');		
		Win_AddItems.creator = self;
		Win_AddItems.focus();	
		
	}	
	
    
}

function AddSerials() {
	x = document.retail;
	//x.actionmode.value = '';
	var result = CheckFields();
	
	
	var vRetId = x.txtId.value;
	var vRetDate = x.txtDate.value;
	var vRetCashRegister = x.txtCashRegister.value;
	var vRetCurr = x.txtCurr.value;
	var vRetClientCode = x.txtClientCode.value;
	var vRetProjectCode = x.txtProjectCode.value;
	var vRetCostCentCode = x.txtCostCentCode.value;
	
	
	
	var vMainMode = x.mainaction.value;
	
	if (result == 1) {
		Win_RetailAddSerial = window.open('Form_RetailAddSerial.php?mainaction='+vMainMode+'&actionmode=&PRetId='+vRetId+'&PRetDate='+vRetDate+'&PRetCashRegister='+vRetCashRegister+
						  '&PRetCurr='+vRetCurr+'&PRetProjectCode='+vRetProjectCode+'&PRetCostCentCode='+vRetCostCentCode+'&PRetClientCode='+vRetClientCode, 
						  'Form_RetailAddSerial', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=850,height=570,top=100,left=0');		
		Win_RetailAddSerial.creator = self;
		Win_RetailAddSerial.focus();	
		
	}
	
    
}

function AddDiscount() {
	x = document.retail;

	var vRetId   = x.txtId.value;
	var vRetDate = x.txtDate.value;
	
	var vMainMode = x.mainaction.value;
	
	if (vRetId != '') {
		Win_Disc = window.open('Form_RetailDiscount.php?mainaction='+vMainMode+'&actionmode=&PRetId='+vRetId,
						  'Form_RetailDiscount', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=710,height=320,left=750,top=400',Win_Disc);		
		Win_Disc.creator = self;
		Win_Disc.focus();		
	}

}

function OpenCustomer(){
	x = document.retail;

	Win_Employee = window.open('List_Customers.php','List_Customers', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=900,height=750,left=250,top=200');		
		Win_Employee.creator = self;
		Win_Employee.focus();


}

function OpenCustomerRestaurant(txtId){ 
	x = document.retail;
	var CustomerTel = x.txtRetCustomerName.value;
	Win_Employee = window.open('List_Customers.php?frm=3&txtId='+txtId+'&PLedgerNo='+CustomerTel,'List_Customers', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=900,height=750,left=250,top=200');		
	Win_Employee.creator = self;
	Win_Employee.focus();
	
}

function OpenDriverRestaurant(txtId){
	x = document.retail;
	var DriverTel = x.txtRetDriverName.value;
	var vRetId    = x.txtId.value;
	//Win_Employee = window.open('List_Drivers.php?PLedgerNo='+DriverTel,'List_Drivers', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=760,height=520,left=250,top=200');		
	Win_Employee = window.open('Form_SelectDriver.php?saleid='+vRetId+'&txtId='+txtId,'List_Drivers', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=760,height=520,left=250,top=200');		
	Win_Employee.creator = self;
	Win_Employee.focus();
}

function PayCash(VPhpPort,VarPort,CashRegisterDrawer) {
	x = document.retail;

	var vRetId    = x.txtId.value;
	var vRetDate  = x.txtDate.value;
	var vQtySerNo = x.QtySerNo.value;
	
	var vMainMode = x.mainaction.value;
	
	if (x.txtCountDetail.value == 0 || x.txtCountDetail.value == '') {
		alert('Not allowed. Please add items.');
	}
	else if (x.QtySerNo.value == 1){
		alert('Please check Item(s) Qty and Serial No.');
	}
	else if (vRetId != '') {
		if (VarPort!=0 && VPhpPort==0) {
			ClosePort(VarPort);
		}
		
		
		
		Win_Cash = window.open('Form_RetailPayment.php?mainaction='+vMainMode+'&actionmode=&QtySerNo='+vQtySerNo+'&PRetId='+vRetId+'&PRetDate='+vRetDate,
						  'Form_RetailPayment', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=750,height=720,left=200,top=0');		
		Win_Cash.creator = self;
		Win_Cash.focus();		
		
		//if (CashRegisterDrawer == 1) OpenDrawer();
	}	
}

function check(winObj){
if (winObj)
	if (!winObj.closed) {
      winObj.focus();
      return winObj;
    }
}

function PostRetails() {
	x = document.retail;
	
	XPos = (screen.availHeight - 200) / 2;
	YPos = (screen.availWidth - 400) / 2;
	
	var vMainMode = x.mainaction.value;
	var vRetId    = x.txtId.value;
	
	
	/*if (confirm ( "Are you sure you want to post transactions?" ))
	{
		x.action="Form_Retail_Actions.php?mode=postretails&mainmode="+vMainMode;
		x.submit();
	}*/
	
	Win_Retail_Post = window.open('Form_Retail_PostOptions.php', 'Form_Retail_PostOptions', 
					  'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=400,height=200,left='+YPos+',top='+XPos);
	Win_Retail_Post.creator = self;
	Win_Retail_Post.focus();

}

function setService(){
	if (document.getElementById('serviceChecked').checked)
		document.getElementById('serviceChecked').value = 1;
	else
		document.getElementById('serviceChecked').value = 0;
	
	var x = document.retail;
	var transid = x.txtId.value;
	var serviceChecked = document.getElementById('serviceChecked').value;
	
	if(transid != ''){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText;
						
			filepath='Functions_Retail.php';
			formname='CashReg';
			orderby='';
			morelines='';
			startrange='';
			perpage='';
			direction='';
			dftorderby='';
			x.txtItemBarcode.focus(); 
			x.passchecked.value='';
			x.txtSubGroup.value='';
			
			 
			ReloadGrid(filepath,formname,transid,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
				ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',transid,-1);
			
			}); 
		}
		
	  }
	  
		xmlhttp.open("GET","Form_Retail_Actions.php?mode=checkService&SRetId="+transid+"&serviceChecked="+serviceChecked);
		xmlhttp.send();
	}
}

function SubmitRecord(CashRegForcingVendor,vSubGroup) {
	x = document.retail;
	
	if(x.txtSaleStatus.value=='dinein'){
		 if(x.txtProjectDtId.value == '' && x.txtTableGuests.value == ''){
				alert('Please Select Table First.');
return;
	}
}
	var vMode;
	
	var vMainMode 				= x.mainaction.value;
	var transid    				= x.txtId.value;
	var vItemBarcode 			= x.txtItemBarcode.value;
	var vVendorCode  			= x.txtVendorCode.value;
	var vProjectDtId  			= x.txtProjectDtId.value;
	var vTableGuests  			= x.txtTableGuests.value;
	var vGuestname 				= x.txtGuestname1.value; 
	var GroupHoldFire  			= x.txt_GroupHoldFire.value;
	var vItemModifySellingPrice = x.txtItemModifySellingPrice.value;
	var vitemprice 				= x.txtItemPrice.value;
	var vModifierNote 			= encodeURI(decodeURIComponent(document.getElementById('txtModifierNote1').value));
	var vRestrictZeroPrice 		= x.RestrictZeroPrice.value;
	var serviceChecked			= x.serviceChecked.value;
	
	if($("#ItemModifiersDiv").css('display') != 'none'){
		document.getElementById('txtModifierNote1').value = '';
		CloseModifiersWin();
	}
	
	
	if (x.txtItemOption.length == undefined) {
		var vItemOption = 1;
	} else {
		for (var i=0; i < x.txtItemOption.length; i++)
		{
			if (x.txtItemOption[i].checked)
			{
				var vItemOption = x.txtItemOption[i].value;
				
			}
		}
	}	
	
	if (vItemOption == 1) vMode = 'submitrecord1';
	else vMode = 'submitrecord2';
	
	var result = CheckFields();
	
	if (CashRegForcingVendor == 1 && vVendorCode == '') {
		alert("Vendor is mandatory!");
		x.txtVendorCode.focus();
	} else { 
		if (vItemBarcode != '' ) {
			if (result == 1) { 
				if((vItemModifySellingPrice == 1 || vRestrictZeroPrice == 1) && vitemprice == 0){ 
					CheckItem(vItemBarcode); 
					/*if(vitemprice == 0){
					alert("Item Price is Empty!");
					x.txtItemPrice.focus();
					return 0;
					}*/
				}
				$('#subgrouparea :input').attr('disabled', true);
			
				if (document.getElementById('btnSubmit'))	x.btnSubmit.disabled = true;
				
				if (window.XMLHttpRequest)
				  {// code for IE7+, Firefox, Chrome, Opera, Safari
				  xmlhttp=new XMLHttpRequest();
				  }
				else{//code for IE6, IE5
					xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				xmlhttp.onreadystatechange=function()
				  {
				  if (xmlhttp.readyState==4 && xmlhttp.status==200)
					{
						var data = $.parseJSON(xmlhttp.responseText);
						
						var msg = data[0].message;
						var message1 = data[0].message1; 
						//var sub_query = data[0].sub_query;
						var enterPrice = data[0].enterPrice; 
						//document.getElementById('grid_contentDiv').innerHTML = message1;
						$('#subgrouparea :input').removeAttr('disabled');
						if (document.getElementById('btnSubmit'))	x.btnSubmit.disabled = false;
						
						
						if (transid == "" && data[0].txtId != ""){
							transid = data[0].txtId;
							vSubGroup = data[0].txtSubGroup;
							x.txtId.value = transid;
							x.txtSubGroup.value = vSubGroup;
							x.txtItemBarcode.value='';
							x.txtItemQty.value='';
							
							//x.txtSaleStatus.value='takeout';
							x.txtVendorCode.value='';
							x.txtSlipNo.value='';
							x.txtItemPrice.value='';
							x.txtItemModifySellingPrice.value='';
							x.actionmode.value='';
							x.submit();
						} 
						
						if (msg != "" || enterPrice == 1) {
							x.passchecked.value='';
							
							$("#Loader").removeClass("ajaxsaving");
							
							if (document.getElementById('SubBtnID'))	document.getElementById('SubBtnID').disabled = false;
							
							if (decodeURIComponent(msg) == 'Item Not Found.' && x.Module_CashRegAutoItemsList.value== 1) {
								x=document.retail; 
								showlistItems(1);
							}

							//if (decodeURIComponent(msg) == 'Item Not Found.') {
								PlayErrorSound();
								x.txtItemBarcode.focus();
							//}	
							if(enterPrice == 1) x.txtItemPrice.focus();
							if (msg != "") alert(decodeURIComponent(msg));
						} else {
							x.passchecked.value='';
							x.txtItemBarcode.value='';
							x.txtItemQty.value='';
							
							//x.txtSaleStatus.value='takeout';
							x.txtVendorCode.value='';
							x.txtSlipNo.value='';
							x.txtItemPrice.value='';
							x.txtItemModifySellingPrice.value='';
							
							filepath='Functions_Retail.php';
							formname='CashReg';
							orderby='';
							morelines='';
							startrange='';
							perpage='';
							direction='';
							dftorderby='';
							x.txtItemBarcode.focus(); 
							x.passchecked.value='';
							x.txtSubGroup.value='';
							
							 
							ReloadGrid(filepath,formname,transid,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
								ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',transid,-1);
							
							}); 
							
						}					
								
					}
				  }
				
				var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+transid+"&SItemOption="+vItemOption+"&txtItemBarcode="+encodeURIComponent(x.txtItemBarcode.value)+
							"&txtItemQty="+x.txtItemQty.value+"&txtVendorCode="+encodeURIComponent(x.txtVendorCode.value)+"&txtSlipNo="+encodeURIComponent(x.txtSlipNo.value)+"&txtDate="+x.txtDate.value+
							"&txtCurr="+x.txtCurr.value+"&txtClientCode="+x.txtClientCode.value+"&txtSaleStatus="+x.txtSaleStatus.value+"&txtRetDriverCode="+x.txtRetDriverCode.value+"&txtRetCustomerCode="+x.txtRetCustomerCode.value+
							"&txtProjectCode="+x.txtProjectCode.value+"&txtCostCentCode="+x.txtCostCentCode.value+"&txtItemPrice="+x.txtItemPrice.value+"&txtCashRegister="+x.txtCashRegister.value+
							"&txtGroupHoldFire="+GroupHoldFire+"&vSubGroup="+vSubGroup+"&ProjectDtId="+vProjectDtId+"&txtTableGuests="+vTableGuests+"&txtModifierNote1="+vModifierNote+"&txtGuestname="+vGuestname+
							"&serviceChecked="+serviceChecked; 
				
				xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
				xmlhttp.send();
			}
		} else	{
			PlayErrorSound();
			alert("Barcode is mandatory!");
			
			x.txtItemBarcode.focus();

		}
	}
}

function SubmitRecordGrid(PIndex,formname,PRedDtId,DiscountPerLimit,CashRegForcingVendor,PItemCode){

	x = document.retail;
	
	var PRedDtId = x.SelectedDtId.value;
if(PRedDtId=='')	
return;


	var result = CheckFieldsDt(PIndex,DiscountPerLimit,CashRegForcingVendor);
	
	var RetId    = x.txtId.value;
	var RetDtId  = PRedDtId;
	var vMainMode = x.mainaction.value;
	var vMode= x.actionmode.value;
	
	if (RetDtId == '')
		vMode = 'submitrecord';	
	else
		vMode = 'editdt';	

	if (result == 1) {
			
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = $.parseJSON(xmlhttp.responseText);
					
				var msg = data[0].message;
				var msg1 = data[0].message1;
						
				if (msg != "") {
					alert(decodeURIComponent(msg));
				}
						
				var transid = x.txtId.value;
				x.txtItemBarcode.focus(); 
						
				if(x.passchecked.value==1){
					x.passchecked.value='';
					//x.submit();
				}
							   
				ReloadGrid(filepath,formname,transid,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
						ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',transid,-1);
				});
			}			
		}			
			
			
		filepath='Functions_Retail.php';
		formname='CashReg';
		orderby='';
		morelines='';
		startrange='';
		perpage='';
		direction='';
		dftorderby='';
		
		var date=x.txtDate.value;
	
		var the_data='SRetId='+RetId+'&SRetDtId='+RetDtId+'&mainmode='+x.mainaction.value+'&mode='+vMode+
					'&txtRetDtQty='+document.getElementById('qtydt['+PIndex+']').value+
					'&txtRetDtVendor='+encodeURIComponent(document.getElementById('vendordt['+PIndex+']').value)+
					'&txtSlipNo='+encodeURIComponent(x.txtSlipNo.value)+
					'&txtRetDtPrice='+document.getElementById('pricedt['+PIndex+']').value+
					'&txtRetDtDiscount='+document.getElementById('discdt['+PIndex+']').value+
					'&txtRetDtSlip='+document.getElementById('slipdt['+PIndex+']').value+
					'&PRetDate='+x.txtDate.value+
					'&txtClientCode='+x.txtClientCode.value+
					'&txtItemBarcode='+document.getElementById('barcodedt['+PIndex+']').value+
					'&txtProjectCode='+x.txtProjectCode.value+
					'&txtCostCentCode='+x.txtCostCentCode.value+
					'&txtCashRegister='+x.txtCashRegister.value+
					'&txtCurr='+x.txtCurr.value+'&txtItemCode='+PItemCode+'&txtWarehouseCode='+document.getElementById('Whdt['+PIndex+']').value;
		
		//alert(the_data);
		
		xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
		xmlhttp.send();	
		
		
	}	
}

function PlayErrorSound() {

	if( navigator.userAgent.indexOf("Chrome") != -1 ) { 
		document.getElementById('audiotag1').play();
	} else if( navigator.userAgent.indexOf("Opera") != -1 ) {
		document.getElementById('audiotag1').play();
	} else if( navigator.userAgent.indexOf("MSIE") != -1 ) { 
		document.getElementById('soundstrack').play();
	} else if( navigator.userAgent.indexOf("Firefox") != -1 ) {
		document.getElementById('audiotag1').play();
	} else {
		document.getElementById('audiotag1').play();
	}


}

function LoadFastItem(ItemCode,ItemSellPrice,UnmodifySellingPrice,ItemModifySellingPrice) {
	x = document.retail;

	var vItemBarcode = x.txtItemBarcode.value;
	
	var vMinusSignExists = 0;
	if (vItemBarcode.indexOf("-") !== -1) {
		var vItemPrefix = vItemBarcode.split("-",1);
		if (vItemPrefix*1 == vItemPrefix/1 ) vMinusSignExists = 1;
	}
	
	if(vItemBarcode.indexOf("+") != -1 || vMinusSignExists == 1) { 
		x.txtItemBarcode.value = x.txtItemBarcode.value + ItemCode;
	} else {
		x.txtItemBarcode.value = ItemCode;
	}	
	
	
	x.txtItemPrice.value = ItemSellPrice;
	
	//if (x.txtItemQty.value == '')
	//x.txtItemQty.value = 1;
	
	x.txtItemPrice.readOnly = false;
	if (UnmodifySellingPrice == 1 || ItemModifySellingPrice ==	0) {
		x.txtItemPrice.readOnly = true;
		x.btnSubmit.click();
	} 
	else if (ItemSellPrice != 0){
		x.btnSubmit.click();
	}
	else {	
		x.txtItemPrice.focus();
		x.txtItemPrice.select();
	}	
}

function SubmitItemModifier(ItemCode,ItemDesc,ItemSellPrice) {
	x = document.retail;
	
	var vRetId 	  = x.txtId.value;
	var vRetDate  = x.txtDate.value;
	var vRetCurr  = x.txtCurr.value;
	var vMode 	  = 'submitmodifier';	
	var vMainMode = x.mainaction.value;
	var vRetDtId  = x.SelectedDtId.value;
	
	if (ItemCode != '') vItemBarcode = ItemCode;
	else vItemBarcode = ItemDesc;
	
	if (vRetDtId != '') {
			
		$('#subgrouparea :input').attr('disabled', true);
		if (document.getElementById('btnSubmit'))	x.btnSubmit.disabled = true;
				
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = $.parseJSON(xmlhttp.responseText);
					
				var msg = data[0].message;
				var message1 = data[0].message1;

				$('#subgrouparea :input').removeAttr('disabled');
				if (document.getElementById('btnSubmit'))	x.btnSubmit.disabled = false;
						
				if (msg != "") {
					alert(decodeURIComponent(msg));
				} else {
					x.SelectedDtId.value='';
							
					filepath='Functions_Retail.php';
					formname='CashReg';
					orderby='';
					morelines='';
					startrange='';
					perpage='';
					direction='';
					dftorderby='';
					
					ReloadGrid(filepath,formname,vRetId,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
						ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',vRetId,-1);
						x.txtItemBarcode.focus(); 
					});
							
				}			
								
			}
		}
			
		var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+vRetId+"&SRetDtId="+vRetDtId+"&txtItemBarcode="+encodeURIComponent(vItemBarcode)+
					 "&txtItemQty=1&txtDate="+vRetDate+"&txtCurr="+vRetCurr+"&txtItemPrice="+ItemSellPrice+"&txtClientCode="+x.txtClientCode.value+
					 "&txtProjectCode="+x.txtProjectCode.value+"&txtCostCentCode="+x.txtCostCentCode.value;
			
		xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
		xmlhttp.send();
	} else {
		alert('Please choose an item.');
	}

}

function openreservation(){

	Win_Booking = window.open('../Booking/Form_Booking.php','Form_Booking','width=1100,height=450,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	Win_Booking.creator = self;
	Win_Booking.focus();
}

function CreateFastItem() {
	x = document.retail;
	Win_FastItem = 	window.open('Form_Retail_FastItem.php','Form_Retail_FastItem','width=680,height=450,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	Win_FastItem.creator = self;
	Win_FastItem.focus();	

}


function AddSerialNo() {


	x = document.retail;
	var vRetId = x.txtId.value;
	var RetDtId = x.SelectedDtId.value;
if(RetDtId=='')	
return;
	
	XPos = (screen.availHeight - 450) / 2;
	YPos = (screen.availWidth - 350) / 2;
    win = window.open('Form_RetailSerialNo.php?SRRetDtId='+RetDtId+'&SRRetId='+vRetId, 'Form_RetailSerialNo', 'titlebar=no,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,directories=no, width=630,height=450,left='+YPos+',top='+XPos);		
	//win.creator = self;
	//win.focus();		
	
}

function SearchForRef(){
    
	//ClearForm('All');
    x = document.retail;
    Win_Search = window.open('Form_RetailSearch.php', 'Form_RetailSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1160,height=600,top=0,left=0');		
	Win_Search.creator = self;
	Win_Search.focus();		
			
}

function SearchForPending(OpenPass){
    //ClearForm('All');
	
	if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php?function=searchforpending',
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
}

    x = document.retail;
    Win_Hold = window.open('Form_RetailSearchPending.php', 'Form_RetailSearchPending', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=560,top=0,left=0');		
	Win_Hold.creator = self;
	Win_Hold.focus();		
			
}

function SearchItems() {
	x = document.retail;
    Win_RetailSearch = window.open('Form_RetailSearchItems.php', 'Form_RetailSearchItems', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1160,height=550,top=100,left=0');
	Win_RetailSearch.creator = self;
	Win_RetailSearch.focus();

}

function SearchItemsInfo() {
	x = document.retail;
    Win_RetailSearch = window.open('Form_RetailItemsInfo.php', 'Form_RetailItemsInfo', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=350,top=100,left=100');
	Win_RetailSearch.creator = self;
	Win_RetailSearch.focus();

}
function OpenCashout(vdate,vnow,OpenPass,usracc){
	
if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php?function=OpenCashout&vnow='+vnow,
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
} 

x = document.retail;
	VCashRegister = x.txtCashRegister.value;
	vfromdate = vnow ;
	vtodate = vnow;
	var str = 'Form_RetailCashTrans.php?TransType=OUT&fromcashreg='+VCashRegister+'&usrac='+usracc;
    Win_RetailSearch = window.open(str);
	Win_RetailSearch.creator = self;
	Win_RetailSearch.focus();
}
function OpenSummaryDetailed(vdate,vnow,OpenPass) {


if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php?function=OpenSummaryDetailed&vnow='+vnow,
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
}

	x = document.retail;
	VCashRegister = x.txtCashRegister.value;
	vfromdate = vnow ;
	vtodate = vnow;
	var str = 'Rep_SalesSummaryDetailed.php?fromdate='+vfromdate+'&todate='+vtodate+'&fromcashreg='+VCashRegister+'&groupby=2&showdetail=0&showsummary=0&varprintstatus=0&showgroups=0&fromvendor=&tovendor=&fromcredit=&tocredit=&showunpost=0&showcost=0&costoption=1&custperitem=0&showpending=0&fromdriver=&print=0&showdiscount=0';
    Win_RetailSearch = window.open(str);
	Win_RetailSearch.creator = self;
	Win_RetailSearch.focus();

}


function SearchOrders() {
	x = document.retail;
    Win_RetailOrder = window.open('Form_RetailOrdersList.php', 'Form_RetailOrdersList', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=900,height=450,top=100,left=0');
	Win_RetailOrder.creator = self;
	Win_RetailOrder.focus();

}

function OpenForm(PWidth,PHeight) {
	x = document.retail;
	var vRetId = x.txtId.value;
	
	XPos = (screen.availHeight - PHeight) / 2;
	YPos = (screen.availWidth - PWidth) / 2;
	
    Win_RetailOrder = window.open('Form_Split.php?RetId='+vRetId, 'Form_Split', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+PWidth+',height='+PHeight+',top='+XPos+',left='+YPos);
	Win_RetailOrder.creator = self;
	Win_RetailOrder.focus();

}
function opendispatch(){
win = window.open('Form_DispatchScreen.php','DispatchScreen', 'toolbar=no,location=no,status=no,menubar=no,addressbar=no,scrollbars=no,resizable=no,width=850,height=600,top=70,left=100');		
	win.creator = self;
	win.focus();
}

function opendriveraccount(){
win = window.open('Form_DriverAccount.php','DispatchScreen', 'toolbar=no,location=no,status=no,menubar=no,addressbar=no,scrollbars=no,resizable=no,width=850,height=600,top=70,left=100');		
	win.creator = self;
	win.focus();
}
function PrintSwap(RetId, RetRef, AskPrint, ReportName,ModuleRestaurantDelivery,CashRegister_Printer,CashRegister_SlipPrinter,tablename,guestnumber,cashregister_logout) {


	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}

	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			//alert(xmlhttp.responseText);
			//document.getElementById("testdiv").innerHTML=xmlhttp.responseText;
			xmlhttp.responseText;
			
			if(cashregister_logout == 1)
				LogOut();
				else
				ClearPage1();
			
		}
	}
	
	xmlhttp.open("GET","Form_Retail_Actions.php?RetailId="+RetId+"&ModuleRestaurantDelivery="+ModuleRestaurantDelivery+"&tablename="+tablename+"&guestnumber="+guestnumber+"&CashRegister_Printer="+CashRegister_Printer+"&CashRegister_SlipPrinter="+CashRegister_SlipPrinter+"&mode=printswap",true);
	xmlhttp.send();
	
	
}

function PrintRetail(RetId, RetRef, AskPrint, ReportName, ModuleRestaurantDelivery, SlipCopy) {
	var str = '';
	if (SlipCopy == '' || SlipCopy == 0) SlipCopy = 1;
	
	if (AskPrint == 1) {
		str = ReportName+'?RetailId='+RetId;
		//alert(str);exit;
		if (confirm ( "Do you want to Print current invoice with reference "+RetRef+" ?"))
		{
			str = ReportName+'?RetailId='+RetId;
			
			for (var i=1; i<=SlipCopy; i++) {
				//alert(str);exit;
				SlipTitle = 'Form_RetailSlip'+i;
				window.open(str, SlipTitle, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=500,top=100');	
			}	
		}	
	} else {
		str = ReportName+'?RetailId='+RetId;
		
		for (var i=1; i<=SlipCopy; i++) {
			SlipTitle = 'Form_RetailSlip'+i;
			window.open(str, SlipTitle, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=500,top=100');	
		}	
	}	
	
}
function PrintSummary() {
	var x = document.form1;
	
	var str = 'Form_RetailSummary.php?PDateFrom=';
	window.open(str, 'Form_RetailSummary', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=500,top=100');	
}

function PrintRetailCopy(RetId) {
	var str = '';
	
	str = 'Form_RetailSlipCopy.php?RetailId='+RetId;
	window.open(str, 'Form_RetailSlipCopy', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=500,top=100');	
}

function PrintRetailTemp(RetId, ReportName, SlipCopy,LastRetail) {
	var x = document.retail;
	
	var vMainMode = x.mainaction.value;
	
	var str = '';
	if (SlipCopy == '') SlipCopy = 1;
	
	var copiedVers = x.copiedVers.value;
	copiedVers = parseInt(copiedVers);
	
	if(LastRetail==1 && RetId !='')
return;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = $.parseJSON(xmlhttp.responseText);
			var msg = data[0].message;
			var AccessDenied = data[0].AccessDenied;
			
			if (msg !=''){
				alert(msg);
			} else {
				if (AccessDenied != 1) {
					if(document.getElementById("retail_reference").value == '')  RetId = '';
					copiedVers = parseInt(copiedVers + 1);
					x.copiedVers.value = copiedVers;
					x.submit();
					str = ReportName+'?TempRep=1&RetailId='+RetId+'&cvrs='+copiedVers;
					
					for (var i=1; i<=SlipCopy; i++) {
						SlipTitle = 'Form_RetailSlip'+i;
						window.open(str, SlipTitle, 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=500,top=100');	
					}	
				} else {
					alert('Access Denied!.');
				}	
			}									
		}			
	}			
			
	xmlhttp.open("GET","Form_Retail_Actions.php?mode=updateuseraccess&mainmode="+vMainMode+"&SRetId="+RetId+"&LastRetail="+LastRetail);
	xmlhttp.send();	
	
}

function SetPort(ParPort) { 
    var port = document.getElementById("comport"); //find the serial port ActiveX object
	
    port.Port=ParPort; //Please check what the port number is correct!!
    port.BaudRate=9600;
    port.DataBits=8;
    port.Parity=0; //NOPARITY
    port.StopBits=0; //one stop bit
    port.DataMode=1; //Gives us data as text strings instead of byte arrays
    port.Connected=1; //Connects to the serial port
    if(port.error>0) //Display errors if found
       alert(port.ErrorDescription);
   // CommEvent(port.event,EVT_DISCONNECT);	   
}
  
  
	   
function SendData(VarData) { 
	var port = document.getElementById("comport");
	port.Send(VarData);
	//alert(VarData); 
	//port.Connected=0;	
}

function ClosePort(ParPort) { 
    var port = document.getElementById("comport"); //find the serial port ActiveX object
	
    port.Port=ParPort; //Please check what the port number is correct!!
    port.BaudRate=9600;
    port.DataBits=8;
    port.Parity=0; //NOPARITY
    port.StopBits=0; //one stop bit
    port.DataMode=1; //Gives us data as text strings instead of byte arrays
    port.Connected=0; //Connects to the serial port
    if(port.error>0) //Display errors if found
       alert(port.ErrorDescription);
   // CommEvent(port.event,EVT_DISCONNECT);	   
}

function LogOut()
{
	x = document.retail;
	
	
	//if (confirm ( "Are you sure you want to Logout?" ))
	{
		//x.action="cashregister_logout.php";
		//x.submit();
		top.window.location='../cashregister_logout.php';
	}
}



function LoadForm(ModuleCashRegAutoItemsList) 
{
	x=document.retail;
	
	if((ModuleCashRegAutoItemsList == 0 && 1 == 1) || (ModuleCashRegAutoItemsList == 1 && (x.openwin.value==0 || x.openwin.value==''))){

		x.txtItemBarcode.disabled = false;
		//x.txtItemBarcode.focus();
		
		if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
		
}
else {
		document.getElementById('txtItemBarcode').focus();
		document.getElementById('txtItemBarcode').select();
		//var ua = navigator.userAgent.toLowerCase();
		}
		
	}	
	
	x.openwin.value=0;
}

function SelectItemOption() {
	x=document.retail;
	
	for (var i=0; i < x.txtItemOption.length; i++)
	{
		if (x.txtItemOption[i].checked)
		{
			var vItemOption = x.txtItemOption[i].value;
			
		}
	}
	
	if (vItemOption == 1) {
		x.txtItemOption[1].checked = true;
		x.ItemOptionLabel.value = 'SerialNo';
		x.txtItemQty.disabled = true;
	}	
	else if (vItemOption == 0) {
		x.txtItemOption[0].checked = true;
		x.ItemOptionLabel.value = 'Barcode';
		x.txtItemQty.disabled = false;
	}	
	

}

function SelectItemQty() {
	x=document.retail;

	var vItemQty = x.txtItemQty.value;
	if (vItemQty == '')   vItemQty = 1;
	
	vItemQty = vItemQty*(-1);
	
	x.txtItemQty.value = vItemQty;
}

function showlistVendors(str){
	var vVendorCode;
	x = document.retail;
  
	vVendorCode  = x.txtVendorCode.value;
	vVendorCode = vVendorCode.replace('&','%26');
	var vendorwin=null;
	

	vendorwin=window.open('List_Vendors.php?frm=3&PVendorCode='+vVendorCode+'&index='+str,'mywindow','width=750,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no',vendorwin);
	check(vendorwin);
	
}

function showlistItems(str){
	var vdate, vid, vItemBarCode, vItemWh;
	x = document.retail;
	x.message.value = '';
	
	vdate = x.txtDate.value;
	vid   = x.txtId.value;
	vItemBarCode  = x.txtItemBarcode.value;
	//vItemWh       = x.txtWarehouseCode.value;
	vItemWh 		= '';
  
	vItemBarCode = vItemBarCode.replace('&','%26');
	//vItemWh	   = vItemWh.replace('&','%26');
  
	win = window.open('List_ItemsBarcode.php?frm=2&PItem_Code='+vItemBarCode+'&TransDate='+vdate+'&ItemWh='+vItemWh,'mywindow','width=970,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	win.focus();
}

function OpenLinkForm(PLink,PWidth,PHeight){
	x = document.retail;
	
	XPos = (screen.availHeight - PHeight) / 2;
	YPos = (screen.availWidth - PWidth) / 2;
	
	if (PLink != '') {
		Win_Form = window.open(PLink,'Setup', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+PWidth+',height='+PHeight+',left='+YPos+',top='+XPos);
		Win_Form.creator = self;
		Win_Form.focus();
	}
}

function Barcodekd(e)
{ 
	x=document.retail;
    var intKey = (window.Event) ? e.which : e.keyCode;
	
		
    if (intKey == 13) { //enter key
        x.btnSubmit.click();
		return false;
    }
	
	
    return true;
}

function CheckTel(txtId,e)
{ 
	x=document.retail;
    var intKey = (window.Event) ? e.which : e.keyCode;
	
		 
    if (intKey == 13) { //enter key
        
		var vtel = x.txtRetCustomerName.value;
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else{//code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				if(data[0]!=''){
					x.txtRetCustomerCode.value = data[0];
					x.txtRetCustomerName.value = data[1];
					x.txtSaleStatus.value='delivery';
				} else {
					OpenCustomerRestaurant(txtId);
				}
					 
			}			
		}
				
		xmlhttp.open("GET","Form_Retail_Actions.php?mainmode=checktel&vtel="+vtel+"&saleid="+txtId);
		xmlhttp.send();	
		 
    }
	
	
    return true;
}


function OnHelp()
{
	return false;
}
function kd(e)
{ 
	x=document.retail;
	if (!e) { var e = window.event;}
    var intKey = (window.Event) ? e.which : e.keyCode;
	
	 
	 
	// Block browser short cuts     
	//F3, F4, F11, F12 key
	if (intKey == 114 || intKey == 115 || intKey == 122 || intKey == 123) {
		if(e.preventDefault) // non-IE browsers         
			e.preventDefault();     
		else  // IE Only  
		{
			e.keyCode=0;  
			e.returnValue = false; 
			
		}	
	}
	
    if (!e.ctrlKey && intKey == 112) { //F1 key
		if ('onhelp' in window) {   // Internet Explorer
	       window.onhelp = OnHelp;
		}
	
		document.getElementById('btnAddItem').click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 113) { //F2 key
		x.btnCash.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 114) { //F3 key
		x.btnDiscount.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 115) { //F4 key
		x.btnClear.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 117 && document.getElementById('btnCancel')) { //F6 key
		x.btnCancel.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 118 && document.getElementById('btnSearch')) { //F7 key
		x.btnSearch.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 119) { //F8 key
		x.btnPending.click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 120 && document.getElementById('Btn_1')) { //F9 key
		document.getElementById('Btn_1').click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 121 && document.getElementById('Btn_2')) { //F10 key
		document.getElementById('Btn_2').click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 122 && document.getElementById('Btn_3')) { //F11 key
		document.getElementById('Btn_3').click();
		return false;
	}
	else if (!e.ctrlKey && intKey == 123 && document.getElementById('Btn_4')) { //F12 key
		document.getElementById('Btn_4').click();
		return false;
	}
	else if (intKey == 9) { //TAB key
		
		if(document.activeElement.id == 'txtItemBarcode') {
			if (x.txtItemQty.disabled == false)
				x.txtItemQty.focus();
			else
				x.txtItemPrice.focus();
		}
		else if(document.activeElement.id == 'txtItemPrice') {
			if (document.getElementById('txtVendorCode').type == 'text')
				x.txtVendorCode.focus();
			else if (document.getElementById('txtSlipNo').type == 'text')
				x.txtSlipNo.focus();
			else		
				x.txtItemBarcode.focus();
		}		
		else if(document.activeElement.id == 'txtItemQty') {
			if (document.getElementById('txtItemPrice').type == 'text')
				x.txtItemPrice.focus();
			else if (document.getElementById('txtVendorCode').type == 'text')
				x.txtVendorCode.focus();
			else if (document.getElementById('txtSlipNo').type == 'text')
				x.txtSlipNo.focus();
			else		
				x.txtItemBarcode.focus();
		}
		else if(document.activeElement.id == 'txtVendorCode') {		
			if (document.getElementById('txtSlipNo').type == 'text')
				x.txtSlipNo.focus();
			else
				x.txtItemBarcode.focus();	
		}
		else if(document.activeElement.id == 'txtSlipNo') {		
			x.txtItemBarcode.focus();
		}
			
		return false;
	}
	else if (intKey == 35) { //End key
		SelectItemOption();
		return false;
	}
	else if (e.ctrlKey && intKey == 112) { //Ctrl + F1 key
		if ('onhelp' in window) {   // Internet Explorer
	       window.onhelp = OnHelp;
		}
		
		showlistItems(1);
		return false;
	}
	else if (e.ctrlKey && intKey == 114 && document.getElementById('btnSearchItems')) { //Ctrl + F3 key
		document.getElementById('btnSearchItems').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 115 && document.getElementById('btnOrderList')) { //Ctrl + F4 key
		document.getElementById('btnOrderList').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 117 && document.getElementById('btnOpen')) { //Ctrl + F6 key
		document.getElementById('btnOpen').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 118 && document.getElementById('btnClosing')) { //Ctrl + F7 key
		document.getElementById('btnClosing').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 119 && document.getElementById('txtVendorCode').type == 'text') { //Ctrl + F8 key
		showlistVendors(1);
		return false;
	}
	else if (e.ctrlKey && intKey == 120 && document.getElementById('btnPosting')) { //Ctrl+F9 key
		document.getElementById('btnPosting').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 121 && document.getElementById('btnAddSerial')) { //Ctrl+F10 key
		document.getElementById('btnAddSerial').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 122 && document.getElementById('btnDrawer')) { //FCtrl+11 key
		document.getElementById('btnDrawer').click();
		return false;
	}
	else if (e.ctrlKey && intKey == 123) { //Ctrl+F12 key
		document.getElementById('btnLogout').click();
		return false;
	}
	
	
    return true;
}

/*function OpenDrawer() {
	XPos = (screen.availHeight - 50) / 2;
	YPos = (screen.availWidth - 50) / 2;
	
	var disp_setting="toolbar=no,location=no,menubar=no,addressbar=no,status=no,";
	disp_setting+="scrollbars=no,resizable=no,width=50, height=50,left="+YPos+",top="+XPos; 
	
	var docprint=window.open("Form_Retail_Drawer.php","Drawer",disp_setting);
	docprint.focus(); 
}*/

function OpenDrawer(){
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = $.parseJSON(xmlhttp.responseText);
			var msg = data[0].message;
			
			if (msg !='') alert(msg);
									
		}			
	}			
			
	xmlhttp.open("GET","Functions_Retail.php?form=OpenDrawer&action=OpenDrawer");
	xmlhttp.send();	

}


function ClosingCashRegister() {
	x = document.retail;
	
	XPos = (screen.availHeight - 200) / 2;
	YPos = (screen.availWidth - 400) / 2;
	
	var vMainMode = x.mainaction.value;
	var vRetId    = x.txtId.value;
	
	
	Win_Retail = window.open('Form_Retail_Closing.php', 'Form_Retail_Closing', 
					  'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=430,height=300,left='+YPos+',top='+XPos);
	Win_Retail.creator = self;
	Win_Retail.focus();

}

function OpenCloseCashRegister(TransType) {
	x = document.retail;
	
	XPos = (screen.availHeight - 510) / 2;
	YPos = (screen.availWidth - 700) / 2;
	
	
	Win_Retail = window.open('Form_RetailTrans.php?TransType='+TransType, 'Form_RetailTrans', 
					  'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=700,height=510,left='+YPos+',top='+XPos);
	Win_Retail.creator = self;
	Win_Retail.focus();

}

function CashTransaction(TransType){
	x = document.retail;
	if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php?Option='+Option+'&PRetId='+PRetId+'&PAccess='+PAccess,
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
}


	XPos = (screen.availHeight - 350) / 2;
	YPos = (screen.availWidth - 700) / 2;
	
	
	Win_Retail = window.open('Form_RetailCashTrans.php?TransType='+TransType, 'Form_RetailCashTrans', 
					  'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=700,height=350,left='+YPos+',top='+XPos);
	Win_Retail.creator = self;
	Win_Retail.focus();
}

function ControlOrderItemGroup(Obj,OpenPass) {

	
	
if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php',
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
}


x = document.retail;
//	document.getElementById(vobj.id).style.backgroundColor ='#B8EDFF';


if(x.txt_GroupHoldFire.value == 1) {
	x.txt_GroupHoldFire.value = 0;
	document.getElementById(Obj.id).style.backgroundColor = '';
	}
else {
	x.txt_GroupHoldFire.value = 1;	
	document.getElementById(Obj.id).style.backgroundColor = 'green';	
}

}

function RefundOrderItem(OpenPass,ItemCode) {
x = document.retail;
	var RetId  = x.txtId.value;
	var vMainMode    = x.mainaction.value;
	var vPassChecked = x.passchecked.value;
	
	var vDelMsg = '';


	var RetDtId = x.SelectedDtId.value;
	if(RetDtId=='')	return;
	
	PIndex = x.index.value;
	
    vDelMsg = "Are you sure you want to Refund Item "+ItemCode+" ?";
	
	
		if (OpenPass==0 && vPassChecked == 0) {
			win = window.open('Form_Retail_Password.php?actionmode=refunddt&PIndex='+PIndex,
							  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');		
			win.creator = self;
			win.focus();
		} else {
			
			if (confirm ( vDelMsg ))
			{
				
				x.action="Form_Retail_Actions.php?mode=refunddt&mainmode="+vMainMode+"&SRetId="+RetId+"&SRetDtId="+RetDtId;
				x.submit();
			}
			
			x.passchecked.value = '';
				
		}
	
}

function ControlOrderItem(Option, PRetId, PAccess,OpenPass) {
	x = document.retail;
	//Option: 1-Gift,  2-Void,  3-Waste,  4-Hold,  5-Fire
	
	
	if(OpenPass==1){
	
	win = window.open('Form_RetailHold_Password.php?Option='+Option+'&PRetId='+PRetId+'&PAccess='+PAccess,
							  'Form_RetailHold_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
	win.creator = self;
	win.focus();
			
return;	
}
	
	
	var vRetDtId      = x.SelectedDtId.value;
	var vMainMode     = x.mainaction.value;
	var vPassChecked  = x.passchecked.value;
	var vStatusRemark = decodeURIComponent(x.txtStatusRemark.value);
	
	var vSelectedRec = '';
	if(document.getElementById('SelFireItems')) vSelectedRec = document.getElementById('SelFireItems').value; 
	
	filepath='Functions_Retail.php';
	formname='CashReg';
	orderby='';
	morelines='';
	startrange='';
	perpage='';
	direction='';
	dftorderby='';
	
	if (Option == 1) vMode = 'gift';
	else if (Option == 2) vMode = 'void';
	else if (Option == 3) vMode = 'waste';
	else if (Option == 4) vMode = 'hold';
	else if (Option == 5) vMode = 'fire';
		
	var Module_GroupHoldFire  = x.Module_GroupHoldFire.value;	
	var GroupHoldFire  = x.txt_GroupHoldFire.value;	
	
 
		
	if (vRetDtId != ""  || (Module_GroupHoldFire == 1 && Option == 5) ) {
		if (PAccess == 0 && vPassChecked == 0) {
			win = window.open('Form_Retail_Password.php?actionmode='+vMode,
							  'Form_Retail_Password', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250,left=200,top=100');
			
			win.creator = self;
			win.focus();
		} else {
		
			if ((Option != 2) || (Option == 2 && vStatusRemark != "")){
				x.passchecked.value = '';
				x.txtStatusRemark.value = '';
				x.SelectedDtId.value = '';
					
				if (window.XMLHttpRequest)
				{// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp=new XMLHttpRequest();
				}
				else{//code for IE6, IE5
					xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				xmlhttp.onreadystatechange=function()
				{
					if (xmlhttp.readyState==4 && xmlhttp.status==200)
					{
						var data = $.parseJSON(xmlhttp.responseText);
							
						var msg = data[0].message;
						var msg1 = data[0].message1;
						
						
						if (msg != "") {
							alert(decodeURIComponent(msg));
						} else {
							if (Option == 4 || Option == 5){
								var HoldItems = data[0].HoldItems;
								if (HoldItems > 0 && document.getElementById('btnHold')) {
									document.getElementById('btnHold').value = 'Hold(' + HoldItems + ')';
								}
								else if (HoldItems == 0 && document.getElementById('btnHold')) {
									document.getElementById('btnHold').value = 'Hold';
								}
								
								/*if(Option == 5){
									if (document.getElementById('btnSwap')) document.getElementById('btnSwap').click();
									LoadHoldItems()
								}	*/
							}	
						}
								
						ReloadGrid(filepath,formname,PRetId,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
								ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',PRetId,-1);
						});
					}			
				}
				
				xmlhttp.open("GET","Form_Retail_Actions.php?mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+PRetId+"&SRetDtId="+vRetDtId+"&txtStatusRemark="+vStatusRemark+"&SelectedRec="+vSelectedRec+"&txtGroupHoldFire="+GroupHoldFire);
				xmlhttp.send();	
			} else {
				loadVoidWin();
			}
		}
	} else {
		alert('Please choose an item.');
	}
}

function SelectVoidReason(PReasonRemark) {
	x = document.retail;
	x.txtStatusRemark.value = PReasonRemark;
	
	unloadVoidWin();
	document.getElementById("btnVoid").click();
}

function loadVoidWin() {    // To Load the Popupbox
    XPos = (screen.availHeight - 400) / 2;
	YPos = (screen.availWidth - 240) / 2;
	
    $("#VoidOptions").fadeIn("fast");
	$("#VoidOptions").css({ // this is just for style
		"top": XPos,
		"left": YPos
    });	
} 

function unloadVoidWin() {    // TO Unload the Popupbox
	$("#VoidOptions").fadeOut("fast");
}  

function loadHoldWin() {    // To Load the Popupbox
    XPos = (screen.availHeight - 150) / 2;
	YPos = (screen.availWidth - 300) / 2;
	
    $("#HoldDiv").fadeIn("fast");
	$("#HoldDiv").css({ // this is just for style
		"top": XPos,
		"left": YPos
    });

	//document.getElementById('txtHoldReference').value='';
	document.getElementById('txtHoldReference').focus();
	document.getElementById('txtHoldReference').select();
} 

function unloadHoldWin() {    // TO Unload the Popupbox
	$("#HoldDiv").fadeOut("fast");
	document.getElementById('txtHoldReference').value='';
} 

function SetHoldReference(){
	x = document.retail;
	
	var vRetId      = x.txtId.value;
	var vMode       = 'holdinvoice';
	var vMainMode   = x.mainaction.value;
	var vHoldRemark = decodeURIComponent(document.getElementById('txtHoldReference').value);
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	 }
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = $.parseJSON(xmlhttp.responseText);
			var msg = data[0].message;
						
			if (msg != "") {
				alert(decodeURIComponent(msg));
			} else {
				ClearForm('All');
				x.mainaction.value='insert';
				x.actionmode.value='';
				x.action='Form_Retail.php';
				x.submit();
			}			
		}
	}
			
	var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+vRetId+"&txtHoldRemark="+vHoldRemark; 
			
	xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
	xmlhttp.send();
}

function ClearValues() {
	x = document.retail;
	
	x.txtItemPrice.value = '';
}

function OpenModifierWin() {    // To Load the Popupbox
	x = document.retail;
	
	var vRetId      = x.txtId.value;
	var vRetDtId    = x.SelectedDtId.value;
	var vMode       = 'getmodifiernote';
	var vMainMode   = x.mainaction.value;
	
    XPos = (screen.availHeight - 200) / 2;
	YPos = (screen.availWidth - 350) / 2;
	
	if (vRetDtId != '') {
		$("#ModifiersDiv").fadeIn("fast");
		$("#ModifiersDiv").css({ // this is just for style
			"top": XPos,
			"left": YPos
		});
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		 }
		else{//code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}

		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = $.parseJSON(xmlhttp.responseText);
				var msg = data[0].message;
				var ModifierNote = data[0].ModifierNote;
				
				if (msg != "") {
					alert(decodeURIComponent(msg));
				} else {
					document.getElementById('txtModifierNote').value = ModifierNote;
					document.getElementById('txtModifierNote').focus();
					//document.getElementById('txtModifierNote').select();
				}
			}
		}	
		
		var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+vRetId+"&SRetDtId="+vRetDtId; 
		xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
		xmlhttp.send();
	} else {
		alert('Please choose an item.');
	}	
} 

function CloseModifierWin() {    // TO Unload the Popupbox
	$("#ModifiersDiv").fadeOut("fast");
	document.getElementById('txtModifierNote').value='';
} 

function SetModifierNote(){
	x = document.retail;
	
	var vRetId      = x.txtId.value;
	var vRetDtId    = x.SelectedDtId.value;
	var vMode       = 'modifiernote';
	var vMainMode   = x.mainaction.value;
	var vModifierNote = encodeURI(decodeURIComponent(document.getElementById('txtModifierNote').value));
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	 }
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = $.parseJSON(xmlhttp.responseText);
			var msg = data[0].message;
						
			if (msg != "") {
				alert(decodeURIComponent(msg));
			} else {
				filepath='Functions_Retail.php';
				formname='CashReg';
				orderby='';
				morelines='';
				startrange='';
				perpage='';
				direction='';
				dftorderby='';
					
				ReloadGrid(filepath,formname,vRetId,'datagrid','1',dftorderby,'ADD',orderby,morelines,startrange,perpage,0,direction,function() {
						ReloadGridDt(filepath,'RT-TOT','TOTALS','totals',vRetId,-1);
						CloseModifierWin();
						x.txtItemBarcode.focus(); 
						x.SelectedDtId.value=''; 
					});
			}			
		}
	}
			
	var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+vRetId+"&SRetDtId="+vRetDtId+"&txtModifierNote="+vModifierNote; 
			
	xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
	xmlhttp.send();
}

function ShowGuestsWin(TableID) {    // To Load the Popupbox
    XPos = (screen.availHeight - 100) / 2;
	YPos = (screen.availWidth - 250) / 2;
	
    $("#GuestsDiv").fadeIn("fast");
	$("#GuestsDiv").css({ // this is just for style
		"top": XPos,
		"left": YPos
    });

	fillprojectdt(TableID);
	document.getElementById('txtTableGuests').value='';
	document.getElementById('txtTableGuests').focus();
	document.getElementById('txtTableGuests').select();
} 

function EditGuestsWin(TableID,GuestNo) {    // To Load the Popupbox
    XPos = (screen.availHeight - 100) / 2;
	YPos = (screen.availWidth - 250) / 2;
	
    $("#GuestsDivEdit").fadeIn("fast");
	$("#GuestsDivEdit").css({ // this is just for style
		"top": XPos,
		"left": YPos
    });

	//fillprojectdt(TableID);
	
	document.getElementById('txtTableGuests').value=GuestNo;
	document.getElementById('txtTableGuests').focus();
	document.getElementById('txtTableGuests').select();
}

function CloseGuestsWin() {    // TO Unload the Popupbox
	$("#GuestsDiv").fadeOut("fast");
	//document.getElementById('txtTableGuests').value='';
}
function CloseGuestsWinEdit() {    // TO Unload the Popupbox
	$("#GuestsDivEdit").fadeOut("fast");
	//document.getElementById('txtTableGuests').value='';
} 

function ShowModifiersWin(PItemCode) {    // To Load the Popupbox
    XPos = (screen.availHeight - 400) / 2;
	YPos = (screen.availWidth - 600) / 2;

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			
			document.getElementById("ItemModifiersDiv-1").innerHTML=xmlhttp.responseText;
			
			$("#ItemModifiersDiv").fadeIn("fast");
			$("#ItemModifiersDiv").css({ // this is just for style
				"top": XPos,
				"left": YPos
			});
									
		}			
	}			
			
	xmlhttp.open("GET","Functions_Retail.php?form=ShowItemModifiers&action=ShowItemModifiers&ItemCode="+PItemCode);
	xmlhttp.send();	
} 
function CloseModifiersWin() {    // TO Unload the Popupbox
	$("#ItemModifiersDiv").fadeOut("fast");
} 

function CheckItemModifiers(CashRegForcingVendor,vSubGroup) {
	x=document.retail;
	
	var vRetId       = x.txtId.value;
	var vMode        = 'checkitemmodifiers';
	var vMainMode    = x.mainaction.value;
	var vItemBarcode = x.txtItemBarcode.value;
	
	var hasmodifier = 0;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = $.parseJSON(xmlhttp.responseText);
			var msg = data[0].message;
			hasmodifier = data[0].hasmodifier;
				
			if (hasmodifier == 1) {
				ShowModifiersWin(vItemBarcode);
			
			} else {
				SubmitRecord(CashRegForcingVendor,vSubGroup);
			}
		}			
	}			
		
	var the_data="mode="+vMode+"&mainmode="+vMainMode+"&SRetId="+vRetId+"&txtItemCode="+vItemBarcode; 
	xmlhttp.open("GET","Form_Retail_Actions.php?"+the_data);
	xmlhttp.send();	
	
}

function FillItemModifiers(PModifier, PObj) {

	var vItemModifiers = document.getElementById('txtModifierNote1').value;
	
	if (vItemModifiers.indexOf(PModifier) === -1) {
		if (vItemModifiers != '')
			document.getElementById('txtModifierNote1').value = vItemModifiers + "\\n" + PModifier;
		else
			document.getElementById('txtModifierNote1').value = PModifier;

		document.getElementById(PObj.id).style.border = "1px solid #0000FF";
	} else {
		var portion = vItemModifiers.split(PModifier);
		
		vItemModifiers = portion[0] + portion[1];
		vItemModifiers = vItemModifiers.trim();
			
		
		document.getElementById('txtModifierNote1').value = vItemModifiers;
		document.getElementById(PObj.id).style.border = "";
	}
}

function OpenFireWin() {    // To Load the Popupbox

    XPos = (screen.availHeight - 300) / 2;
	YPos = (screen.availWidth - 350) / 2;
	
	$("#FireItemsDiv").fadeIn("fast");
	$("#FireItemsDiv").css({ // this is just for style
		"top": XPos,
		"left": YPos
	});
	
	LoadHoldItems();
} 

function CloseFireWin() {    // TO Unload the Popupbox
	$("#FireItemsDiv").fadeOut("fast");
	document.getElementById('SelFireItems').value='';
} 

function LoadHoldItems(){
	x = document.retail;
	
	var vRetId      = x.txtId.value;
	var vMode       = 'getholditems';
	var vMainMode   = x.mainaction.value;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	 }
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("FireItemsDiv-1").innerHTML=xmlhttp.responseText;
		}
	}	
		
	xmlhttp.open("GET","Functions_Retail.php?form=GetHoldItems&action=GetHoldItems&transid="+vRetId);
	xmlhttp.send();

}

function SelectFireItems(){
	x = document.retail;
	var SelectedRec = '';
	
	var CheckName = document.getElementsByName('ChkH[]');
	for(var i=0; i<CheckName.length; i++){
		if(CheckName[i].checked){
			if (SelectedRec != '') SelectedRec = SelectedRec + ',';
			SelectedRec = SelectedRec + CheckName[i].value;
		}
	}
	
	document.getElementById('SelFireItems').value=SelectedRec;

}

function showSubgroup(vSubGroupCode,vZone,vType){

x=document.retail;

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


	/*alert(vSubGroupCode);
	
	alert(vType);*/
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}

	else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){{ 
			document.getElementById(vZone).innerHTML=xmlhttp.responseText;
			$("#LoaderBut").removeClass("ajaxsaving");
		}

		}
	}
	x.txtSubGroup.value='';
	xmlhttp.open("GET","Form_Retail_ItemDisplay.php?vZone="+vZone+"&subgroup_code="+vSubGroupCode+"&vType="+vType,true);
	xmlhttp.send();
}

function DisplayShortCuts() {
	x=document.retail;
	$("#LoaderBut").addClass("ajaxsaving");
	
	var vButLabel = document.getElementById('btnShortCut').value;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById('div-shortcuts').innerHTML=xmlhttp.responseText;
			$("#LoaderBut").removeClass("ajaxsaving");
									
			if (vButLabel == 'Modifier') document.getElementById('btnShortCut').value = 'Short\\nCut';
			else document.getElementById('btnShortCut').value = 'Modifier';
		}			
	}			
			
	xmlhttp.open("GET","Functions_Retail.php?form=DisplayShortCuts&action=DisplayShortCuts&option="+vButLabel);
	xmlhttp.send();	
	

}

function Fillitem(vItem,vSubGroup){
	x=document.retail;

	//x.txtItemBarcode.value=vItem;
	var vItemBarcode = x.txtItemBarcode.value;
	var vMinusSignExists = 0;
	if (vItemBarcode.indexOf("-") !== -1) {
		var vItemPrefix = vItemBarcode.split("-",1);
		if (vItemPrefix*1 == vItemPrefix/1 ) vMinusSignExists = 1;
	}
	
	if(vItemBarcode.indexOf("+") != -1 || vMinusSignExists == 1) { 
		x.txtItemBarcode.value = x.txtItemBarcode.value + vItem;
	} else {
		x.txtItemBarcode.value = vItem;
	}
	
	x.txtItemQty.focus();
	var CashReg_ForcingVendor=x.CashReg_ForcingVendor.value;
	var vModuleRestaurantDelivery  = x.Module_RestaurantDelivery.value;
	
	if (vModuleRestaurantDelivery == 1) {
		CheckItemModifiers(CashReg_ForcingVendor,vSubGroup);
	} else {
		SubmitRecord(CashReg_ForcingVendor,vSubGroup);
	}
}

/*function OpenKeyboard(field){
	VirtualKeyboard.attachInput(field);
	VirtualKeyboard.open(field,'td');
}*/


	
function FillInput(PValue){
	var vField=document.retail.txtFocusField.value;
	document.retail.txtItemQty.focus();
	document.retail.txtItemQty.select();
	if(vField=='txtItemPrice' && PValue != '-'){
		document.retail.txtItemPrice.value = document.retail.txtItemPrice.value + PValue;
	}
	else {
		var qty = document.retail.txtItemQty.value;
	
		if(qty >= 0 && PValue == '-'){
			document.retail.txtItemQty.value = PValue + document.retail.txtItemQty.value;
		}
		else if (qty.length < 6 && PValue != '-') {
			document.retail.txtItemQty.value = document.retail.txtItemQty.value + PValue;
		}
		
		document.retail.txtItemBarcode.focus();
	}
	/*else{	
		document.retail[vField].value=document.retail[vField].value+PValue;
	}*/
}
function FillInput1(PValue){
	var vField=document.retail.txtFocusField.value;
	if(vField=='txtItemPrice'){
		document.retail.txtItemPrice.value = document.retail.txtItemPrice.value + PValue ;
		document.retail.txtItemPrice.focus();
	}
	if(vField=='txtItemQty'){
		document.retail.txtItemQty.value = document.retail.txtItemQty.value + PValue ;
		document.retail.txtItemQty.focus();
	}
	if(vField=='txtItemBarcode'){
		document.retail.txtItemBarcode.value = document.retail.txtItemBarcode.value + PValue;
		document.retail.txtItemBarcode.focus();
	}
	
}

function EraseInput(PValue){
	var vField=document.retail.txtFocusField.value;
	document.retail[vField].value='';
	
	document.retail.txtItemBarcode.focus();
}

function EraseFromInput(){
	var vField=document.retail.txtFocusField.value;
	
}


function FillHidden(PField){
	document.retail.txtFocusField.value=PField;
}

function ShowMenu(DivID) {
	$(DivID).animate({width: 'toggle'});
}
function CloseMenu(DivID) {
	$(DivID).slideToggle();
}

function checkopenedwindows(){

	if (Win_Disc)
	if (!Win_Disc.closed) {
		  Win_Disc.focus();
		  return Win_Disc;
		}
		
	if (Win_Cash)
	if (!Win_Cash.closed) {
		  Win_Cash.focus();
		  return Win_Cash;
		}
		
	if (Win_Hold)
	if (!Win_Hold.closed) {
		  Win_Hold.focus();
		  return Win_Hold;
		}
		
	if (Win_Search)
	if (!Win_Search.closed) {
		  Win_Search.focus();
		  return Win_Search;
		}
		
	if (Win_Employee)
	if (!Win_Employee.closed) {
		  Win_Employee.focus();
		  return Win_Employee;
		}
		
	if (Win_Retail)
	if (!Win_Retail.closed) {
		  Win_Retail.focus();
		  return Win_Retail;
		}

		
	if (Win_RetailOrder)
	if (!Win_RetailOrder.closed) {
		  Win_RetailOrder.focus();
		  return Win_RetailOrder;
		}
		
	if (Win_RetailSearch)
	if (!Win_RetailSearch.closed) {
		  Win_RetailSearch.focus();
		  return Win_RetailSearch;
		}

		
	if (Win_RetailAddSerial)
	if (!Win_RetailAddSerial.closed) {
		  Win_RetailAddSerial.focus();
		  return Win_RetailAddSerial;
		}

		
	if (Win_RetailDetail)
	if (!Win_RetailDetail.closed) {
		  Win_RetailDetail.focus();
		  return Win_RetailDetail;
		}

		
	if (Win_AddItems)
	if (!Win_AddItems.closed) {
		  Win_AddItems.focus();
		  return Win_AddItems;
		}
		
	if (Win_Retail_Post)
	if (!Win_Retail_Post.closed) {
		  Win_Retail_Post.focus();
		  return Win_Retail_Post;
		}

	if (Win_FastItem)
	if (!Win_FastItem.closed) {
		  Win_FastItem.focus();
		  return Win_FastItem;
		}

	if (Win_Booking)
	if (!Win_Booking.closed) {
		  Win_Booking.focus();
		  return Win_Booking;
		}


	if (document.activeElement.type == undefined || document.activeElement.type == 'button') {
		document.getElementById('txtItemBarcode').focus();
	}
	
}

function CheckItem(vItemBarcode) {

	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
	}
	else{//code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp2.onreadystatechange=function()
	{
		if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
		{
			var data = xmlhttp2.responseText.split("[BRK]"); 
			if(data[1]==0) {
				alert("Item Price is Empty!");
				x.txtItemPrice.focus();
				return 0;
			}
		}			
	}			
	
	vItemBarcode = encodeURIComponent(vItemBarcode);	
	xmlhttp2.open("GET","Form_Retail_Actions.php?mode=checkItemSellingPrice&txtItemBarcode="+vItemBarcode);
	xmlhttp2.send();	
	
	
}
</script>
<title>Cash Register</title>
<style type="text/css">

body,td,th {
	font-family: Arial, Times, sans-serif;
	font-size: 14px;
}
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;
}

.style16 {color: #FFFFFF; font-weight: normal; font-size: 14px; font-family: Arial, Times, sans-serif; padding:2px;}
.style17 {color: #FFFFFF; font-weight: bold; font-size: 12px; font-family: Arial, Times, sans-serif;}
.style18 {color: #DE9BA5; font-weight: bold; font-size: 12px; font-family: Arial, Times, sans-serif; padding:2px;}
.style19 {color: #C2DCE4; font-weight: bold; font-size: 12px; font-family: Arial, Times, sans-serif; padding:2px;}
.style20 {color: #FF0000; font-weight: bold; font-size: 13px; font-family: Arial, Times, sans-serif;}
.style21 {color: #FF0000; font-weight: bold; font-size: 14px; font-family: Arial, Times, sans-serif; padding-left:20px; background-color:#81F7D8;}
.style26 {color: #FF0000; font-weight: bold; font-size: 14px;}
.style15 {color: #000000; font-size: 13px; font-family: Arial, Times, sans-serif; padding:2px;}
.style27 {color: #999999 ;font-size: 14px; font-family: Arial, Times, sans-serif;}
.style28 {color: #FFFFFF ;font-size: 11px; font-family: Arial, Times, sans-serif;}
.style38 {color: #C2DCE4; font-weight: bold; font-size: 17px; font-family: Arial, Times, sans-serif; padding:2px;}
.style39 {color: #C2DCE4; font-weight: bold; font-size: 23px; font-family: Arial, Times, sans-serif; padding:2px;}
.style55 {text-decoration: line-through;}

.list-containerfast {
	
    /*width: 90px;*/
    /*overflow-x: auto;
    overflow-y: hidden;*/
	/*white-space: nowrap;*/
	border: 0px #D8D8D8 solid;
	overflow-y:scroll;
	overflow-x:hidden;
	background:#ffffff;
	
}

.list-container {
	
    /*width: 90px;*/
    overflow-x: auto;
    overflow-y: hidden;
	/*white-space: nowrap;*/
	border: 1px #D8D8D8 solid;
	height:280px;


	background:#ffffff;
}

.list-item {
	
    width:62px;
	margin-right:0px;
	margin-left:0px;
	margin-top:1px;
	margin-bottom:0px;
	/*display: inline-block;*/
	display: block;
    /* for ie7 */
    /**display: inline;*/
    zoom: 1;
	border:0px solid #000000;

}

h5 { border-left-style: solid; 
	 border-left-color: black; 
	 border-left-width: 1px;
	 margin-left: 10px;
   }
   


</style>


</head>
<body  onclick='checkopenedwindows();' onload='LoadForm($Module_CashRegAutoItemsList);' onkeydown='return kd(event);' style='background-color:#000000;'>
<form name='retail' method='post' action=''>
<input type='hidden' name='actionmode' value='$actionmode'>
<input type='hidden' name='mainaction' value='$mainaction'>
<input type='hidden' name='noprint' value='$noprint'>
<input type='hidden' name='message' value='$message' size='200'>
<input type='hidden' name='QtySerNo' value='$QtySerNo'>
<input type='hidden' name='PrRetId' value='$PrRetId'>
<input type='hidden' name='openwin' value='$openwin'>
<input type='hidden' name='passchecked' value='$passchecked'>
<input type='hidden' name='ModuleProject' value='$Module_Project'>
<input type='hidden' name='ModuleCostCenter' value='$Module_CostCenter'>
<input type='hidden' name='ModuleQtyReturn' value='$FC_CashRegisterQtyRet'>
<input type='hidden' name='string' value='$string'>
<input type='hidden' name='Module_CashRegAutoItemsList' value='$Module_CashRegAutoItemsList'>
<input type='hidden' name='Module_RestaurantDelivery' value='$Module_RestaurantDelivery'>
<input type='hidden' name='CashReg_ForcingVendor' value='$CashReg_ForcingVendor'>
<input type='hidden' name='txtSubGroup' value='$txtSubGroup'>
<input type='hidden' name='txtFocusField' value='$txtFocusField'>
<input type='hidden' name='txtStatusRemark' value='$txtStatusRemark'>
<input type='hidden' name='txtGuestname1' value='$txtGuestname1'>
<input type='hidden' name='SelectedRec' id='SelectedRec' value='$SelectedRec'>
<input type='hidden' name='SelectedRecColor' id='SelectedRecColor' value='$SelectedRecColor'>
<input type='hidden' name='SelectedDtId' id='SelectedDtId' value='$SelectedDtId'>
<input type='hidden' name='isserial' id='isserial' value='$isserial'>
<input type='hidden' name='itemprinted' id='itemprinted' value='$itemprinted'>
<input type='hidden' name='index' id='index' value='$index'>
<input type='hidden' name='restaurantmode' id='restaurantmode' value='$restaurantmode'>
<input type='hidden' name='pendingphone' value='$pendingphone'>
<input type='hidden' name='txtItemModifySellingPrice' value='$txtItemModifySellingPrice'>
<input type='hidden' name='RestrictZeroPrice' value='$RestrictZeroPrice'>
<input type='hidden' name='copiedVers' value='$copiedVers'>

HERE;



if($actionmode=='addtype' && $txtId!='' && $txtRetDriverName1=='')
{
	$q = " update temp_retail set sale_type = '".$txtSaleStatus."',driver_Code = '".$txtRetDriverCode."',customer_code='".$txtRetCustomerCode."' where sale_id = ".$txtId ;
	//echo $q;
	//exit;
	$result=mysql_query($q,$connection) or die(mysql_error());
	
	
	
	$query="select 1 from DispatchDriver where deldriver_id = '".$txtRetDriverCode."'and retail_id = '".$txtId."' ";
	$result=mysql_query($query,$connection);
	$num = mysql_num_rows($result);
	
	if ($num=='')
	{
	$query="insert into DispatchDriver(deldriver_id,retail_id) values('".$txtRetDriverCode."','".$txtId."' )";
	$result=mysql_query($query,$connection);
	}
	

}

if($mainaction == 'insert' && $txtGuestname!=''){
	$query = " Select * from customer where Customer_Name = '$txtGuestname'";
	$result=mysql_query($query,$connection);
	$rows = mysql_num_rows($result);
	if($rows>0)
		echo "<div style='color:#fff;'>$rows</div>";
		
	else {
		$sub_query = " Select ifNull(Max(Lpad(Customer_Code,10,'0')),0) + 1 ".
					 " From Customer ";
		$sub_result = selectData($connection, $sub_query);
		$txtCode    = $sub_result[0];
		$query =" insert into Customer (Customer_Code,Customer_Name) Values ($txtCode , '$txtGuestname')";
		$result=mysql_query($query,$connection);
	}
}
	
	
//Display Led Section
$com = 0;
if ($CashRegister_DisplayLed == 1) {
	$com = $CashRegister_DispCOM;
	if (empty($com)) $com = 0;
	
	if ($config['PhpPort']==0 or $config['PhpPort']=='' ) {
		echo '<object classid="CLSID:7E42B8C5-73BE-4806-8904-FF4080A696EC" id="comport" style="display:none;"></object>';
		if   ($actionmode == "" || $actionmode == "cancel" ) {
			echo "<script language='javascript'>SetPort(".$com.");SendData(String.fromCharCode(12));SendData('".'      Welcome'."');</script>";	   	
		} else {
			echo "<script language='javascript'>SetPort(".$com.");SendData(String.fromCharCode(12));SendData('".$string."');</script>";	   	
		}
	} else {
		$message = ereg_replace("'"," ",$message);

		//if (!isset($actionmode) ) {
		if ($actionmode == "" || $actionmode == "cancel" ) {
	
			$com=$CashRegister_DispCOM;
			$fp = fopen ("com".$com.":9600,n,8,1,DS", "wb+");
	
			$string=chr(12); //simulating device
			fputs ($fp, $string );           
			fclose ($fp);
			$fp = fopen ("com".$com.":9600,n,8,1,DS", "wb+");
			$string=str_pad($CashReg_DispLedMsg,$CashRegister_LedDescLength," ",STR_PAD_RIGHT); 
			$string=$string.substr($CompanyName,0,$CashRegister_LedDescLength); //simulating device	
			
			fputs ($fp, $string );          
			fclose ($fp);

		}

	}
}


//printers
/*
echo"<div name='testdiv' id='testdiv'>";	
echo'</div >';*/

echo'<div style="display:none">';	
echo'<audio id="audiotag1" src="ringin.wav" ></audio>';
echo'<embed id="soundstrack" src="ringin.wav" autoplay="false" type="audio/mp3"></embed>';
echo'</div >';

//$message='';


	
//Initializations

$PriceLabel    = 'Price';	
$TaxableLabel  = 'Taxable';	
$DiscountLabel = 'Discount';	
if ($CashRegisterTTC == 1) { 	
	$PriceLabel    = 'Price TTC';	
	$TaxableLabel  = 'Taxable TTC';	
	$DiscountLabel = 'Discount TTC';	
}	
	

if ((empty($txtProjectCode)) && $Module_Project == 1)
	$txtProjectCode = $StpProjectCode;
if ((empty($txtCostCentCode)) && $Module_CostCenter == 1)	
	$txtCostCentCode = $StpCostCentCode;	
if (empty($txtCurr))
	$txtCurr = $StpCurrCode;
if (empty($txtDate))	
	$txtDate = displayToday();
if (empty($txtCashRegister))	
	$txtCashRegister = $CashRegister_Name;
if (empty($txtClientCode))	
	$txtClientCode = $StpClientAccount;	
//if (empty($txtItemQty))	 	
	//$txtItemQty=1;

	
$txtTaxable     = number_format(0,$DecimalBase);
$txtNoneTaxable = number_format(0,$DecimalBase);
$txtGrossTotal  = number_format(0,$DecimalBase);
$txtDiscount    = number_format(0,$DecimalBase);
$txtDiscountAmt = number_format(0,$DecimalBase);
$txtVat         = number_format(0,$DecimalBase);
$txtTotalTaxes  = number_format(0,$DecimalBase);
$txtNetTotal    = number_format(0,$DecimalBase);

if ($txtId != '' && $actionmode != "cancel") {

	// Read From Temp Tables For Selected Record				 
	$query = " Select Sale_ID, Sale_Reference, If(Sale_Reference='' or Sale_Reference is null,Date_Format(Now(),'%d/%m/%Y'),Date_Format(Sale_Date,'%d/%m/%Y')) As Sale_Date, ".
			 " Retail.Currency_code, Retail.Client_code As ClientCode, CashRegister_Name, Sale_Remark, Retail.Project_Code, Retail.Costcenter_code,  ".
			 " Round(ifNull(Sale_Taxable,0), ".$DecimalBase."), Round(ifNull(Sale_NoneTaxable,0), ".$DecimalBase."), ".
			 " Round(ifNull(Sale_Taxable,0) + ifNull(Sale_NoneTaxable,0), ".$DecimalBase.") As GrossTotal, ".
			 " Round(ifNull(Sale_DiscountPer,0), ".$DecimalBase."), Round(ifNull(Sale_DiscountAmount,0), ".$DecimalBase."),  ".
			 " Round(ifNull(Sale_VAT,0), ".$DecimalBase.") As Sale_VAT, ".
			 " Round((ifNull(Sale_Taxable,0) + ifNull(Sale_NoneTaxable,0) + IfNull(Sale_VAT,0) - IfNull(Sale_DiscountAmount,0) + (ifNull(Sale_Tax1,0) + ifNull(Sale_Tax2,0) + ifNull(Sale_Tax3,0) + ifNull(Sale_Tax4,0) + ifNull(Sale_Tax5,0))), ".$DecimalBase.") As Sale_NetTotal,  ".
			 " Round((ifNull(Sale_Tax1,0) + ifNull(Sale_Tax2,0) + ifNull(Sale_Tax3,0) + ifNull(Sale_Tax4,0) + ifNull(Sale_Tax5,0)), ".$DecimalBase.") As TotalTaxes,  ".
			 " Round(ifNull(Sale_NetTotal,0), ".$DecimalBase."),  ".
			 " Round(ifNull(Sale_NetTotalBase1,0) - (ifNull(Coupon_AmountBase1,0) + ifNull(Sales_CreditAmountBase1,0) + ifNull(Sale_CashBase1,0) + ifNull(Sales_CashInBase1,0) + ".
			 "       ifNull(convertcurfunc('".$base2."', '".$base1."', Sale_Date, 0, 0, '', '', ifNull(Sales_CashInBase2,0)),0)) + ifNull(Sales_CashOutBase1,0) + ".
			 "       ifNull(convertcurfunc('".$base2."', '".$base1."', Sale_Date, 0, 0, '', '', ifNull(Sales_CashOutBase2,0)),0)) As BalanceAmount,  ".
			 " Round((ifNull(Sale_Taxable,0)*(1+$Setup_VatPercentage/100)), ".$DecimalBase.") As SaleTaxableTTC, ".
			 " Round((ifNull(Sale_Taxable,0)*(1+$Setup_VatPercentage/100)) + ifNull(Sale_NoneTaxable,0), ".$DecimalBase.") As GrossTotalTTC, ".
			 " Round((((ifNull(Sale_Taxable,0)*(1+$Setup_VatPercentage/100)) + ifNull(Sale_NoneTaxable,0))*(ifNull(Sale_DiscountPer,0)/100)), ".$DecimalBase.") As SaleDiscountTTC, ".
			 " Retail.SaleOrder_Id, Retail.SaleOrder_Reference, Retail.Projectdt_id Projectdt_id, Retail.Sale_Posted, Sale_type, ". 
			 " driver_Code, Concat(clients.ledger_name, if(ifnull(Client_Telephone1,'') != '', concat('\rTel#: ', Client_Telephone1), '')) as DriverRemark, ".
			 " Retail.Customer_Code, Concat(Customer_Name, if(ifnull(Customer_Telephone1,'') != '', concat('\rTel#: ', Customer_Telephone1), ''), if(ifnull(Customer_Address,'') != '', concat('\rAddress: ', Customer_Address), '')) As CustomerRemark, ".
			 " Retail.Sale_numberofguests ".
			 " From Temp_Retail As Retail ".
			 " Left join clients on clients.ledger_number = Retail.driver_code ".
			 " Left join Customer on Customer.Customer_Code = Retail.Customer_Code ".
	         " Where Sale_ID = ".$txtId;
			 //" And Logged_Code = '".$_SESSION['useraccount']."' ";
			 
			 
			 
	//echo $query;
	$result=mysql_query($query,$connection) or die(mysql_error());
    $rows=mysql_fetch_array($result);
	
	$txtId    = $rows[0];
	$txtRef   = $rows[1];
	$txtDate  = $rows[2];
	$txtCurr  = $rows[3];
	$txtClientCode   = $rows[4];
	$txtCashRegister = $rows[5];
	$txtRemark       = $rows[6];
	$txtProjectCode  = $rows[7];
	$txtCostCentCode = $rows[8];
	
	if ($CashRegisterTTC == 1) {
		$txtTaxable     = number_format($rows[19],$DecimalBase);
		$txtGrossTotal  = number_format($rows[20],$DecimalBase);
		$txtDiscountAmt = number_format($rows[21],$DecimalBase);
	} else {
		$txtTaxable     = number_format($rows[9],$DecimalBase);
		$txtGrossTotal  = number_format($rows[11],$DecimalBase);
		$txtDiscountAmt = number_format($rows[13],$DecimalBase);
	}
	
	$txtNoneTaxable = number_format($rows[10],$DecimalBase);
	$txtDiscount    = number_format($rows[12],$DecimalBase);
	$txtVat         = number_format($rows[14],$DecimalBase);
	$txtTotalTaxes  = number_format($rows[16],$DecimalBase);
	$txtNetTotal    = number_format($rows[17],$DecimalBase);
	$NetTotalDisplay = RoundTotal($rows[17], $CashReg_RoundDivisor, $connection);
	
	$txtBalanceAmount = $rows[18];
	$txtOrderId       = $rows[22];
	$txtOrderRef      = $rows[23];
	$txtProjectDtId   = $rows[24];
	$txtSalePosted    = $rows[25];
	$txtSaleStatus    = $rows[26];
	$txtRetDriverCode   = $rows[27];
	$txtRetDriverName   = $rows[28];
	$txtRetCustomerCode	= $rows[29];
	$txtRetCustomerName	= $rows[30];
	$txtTableGuests  	= $rows[31];
	
	$query = " Select Count(*) FROM Temp_RetailDt ".
			 " WHERE Sale_id = ".$txtId;
	$result = selectData($connection, $query);
	$txtCountDetail = $result[0];
	if($txtCountDetail == '') $txtCountDetail = 0;
	
	if($txtId!=''){
	$querydt = " select count(1) from temp_retaildt where ifnull(saledt_itemstatus,0) = 4 and sale_id = ".$txtId ;
	$resultdt=mysql_query($querydt,$connection) or die(mysql_error());
    $rowsdt=mysql_fetch_array($resultdt);
	$NumofHolds = $rowsdt[0];
	}
	if ($Module_PriceOffer > 0) {
		$sub_query = " Select Sum((ifNull(SaleDt_Quantity,0)* ifNull(RetailDt.SaleDt_ActualPrice, 0))*(1 - ifNull(SaleDt_DiscountPer,0)/100)) As TotalAmountActual ".
					 " From Temp_RetailDt As RetailDt ".
					 " Where RetailDt.Sale_ID = '".$txtId."' ".
					 " And IfNull(RetailDt.SaleDt_ItemStatus,0) Not In (2,3) ";
					 //" And ifNull(Price_Offer,0) = 1 ";
		$sub_result = selectData($connection, $sub_query);
		$txtTotalAmountActual = number_format($sub_result[0],$DecimalBase);
	
	}
	
}



//Search/Cancel Mode	
if ($actionmode == "cancel" && $txtId != '') {
	
	// Delete From Temp Tables Already Filled By Search
	$query = " DELETE FROM Temp_Purchasesserialno ".
			 " WHERE RetailDt_ID In (Select SaleDt_id From Temp_RetailDt Where Sale_id = ".$txtId." ) ".
			 " AND Journal_Type In ('DI','DR') ";
			 //" AND Logged_Code = '".$_SESSION['useraccount']."' ";
	if (!updateData($connection, $query, true))		 
      $message  = mysql_error(); 

	  
	
	$query = " DELETE FROM Temp_RetailDt ".
			 " WHERE Sale_id = ".$txtId;
			 //" AND Logged_Code = '".$_SESSION['useraccount']."' ";
	if (!updateData($connection, $query, true))
      $message  = mysql_error(); 
	  
	
	  
	$query = " DELETE FROM Temp_Retail ".
			 " WHERE Sale_id = ".$txtId;
			 //" AND Logged_Code = '".$_SESSION['useraccount']."' ";
	if (!updateData($connection, $query, true))
      $message  = mysql_error();   

	$txtId = '';
}



//Main Div For Whole Page
echo"<div id='mainContainer' style='width:100%; height:100%; border:0px solid white;'>";

//Start of Left Div
echo"<div id='left' style='position:absolute; float:left; z-index:9999; border:0px solid black; width:60px; margin-top:0px;'>";
echo"<table border='0' cellspacing='0'>";

	if ($FC_CashRegisterMenu == 1) {
		echo"<tr style='height:30px;'><td align='left'><ul id='menu'><li><a href='#' class='drop' onclick=\"ShowMenu('#menu-links');\"></a>";
		echo"	<div id='menu-links' class='dropdown_5columns'>";
			
			if ($FC_CashRegisterSetup == 1) {
				echo"<div id='btnSetup' class='menu-container' onclick=\"ShowSetupForm();return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-13'></div>";
				echo"	<div class='menu-label'>General Setup</div>";
				echo"</div>";
			}
			
			/*if ($Module_CashRegisterFastItem == 1) {
				echo"<div id='btnNew' class='menu-container' onclick=\"CreateFastItem();return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-7'></div>";
				echo"	<div class='menu-label'>Shortcuts /<br>Modifiers</div>";
				echo"</div>";
			}
			
			if ($FC_CashRegisterClosing == 1){
				echo"<div id='btnOpen' class='menu-container' onclick=\"OpenCloseCashRegister('IN');return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-4'></div>";
				echo"	<div class='menu-label'>Open Pos</div>";
				echo"	<div class='menu-label-1'>Ctrl+F6</div>";
				echo"</div>";
				
				echo"<div id='btnClosing' class='menu-container' onclick=\"OpenCloseCashRegister('OUT');return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-14'></div>";
				echo"	<div class='menu-label'>Close Pos</div>";
				echo"	<div class='menu-label-1'>Ctrl+F7</div>";
				echo"</div>";
			}*/
			
			
			//Display Other Links From Menu Table
			while($rowMenu=mysql_fetch_assoc($resultMenu)){
				$DivId = 'btn'.$rowMenu['Menu_Index'];
				$DivStyle = 'background: #FFFFFF url(design/cashregister/default/'.$rowMenu['Menu_ImageName'].') no-repeat; background-size:100% 100%;';
				
				echo"<div id='$DivId' class='menu-container' onclick=\"OpenLinkForm('".$rowMenu['Menu_Link']."','".$rowMenu['Menu_WinWidth']."','".$rowMenu['Menu_WinHeight']."');return false;\"> ";
				echo"	<div class='menu-shortcut' style='$DivStyle'></div>";
				echo"	<div class='menu-label'>".nl2br($rowMenu['Menu_Title'])."</div>";
				
				if ($rowMenu['Menu_ShortCutLabel'] != '') {
					echo"	<div class='menu-label-1'>".$rowMenu['Menu_ShortCutLabel']."</div>";
				}
				echo"</div>";
			}
			
			/*echo"<div id='btnCashOut' class='menu-container' onclick=\"CashTransaction('OUT');return false;\"> ";
			echo"	<div class='menu-shortcut menu-shortcut-15'></div>";
			echo"	<div class='menu-label'>Cash Payout</div>";
			echo"</div>";
			
			
			echo"<div id='btnPosting' class='menu-container' onclick=\"PostRetails();return false;\"> ";
			echo"	<div class='menu-shortcut menu-shortcut-3'></div>";
			echo"	<div class='menu-label'>Posting</div>";
			echo"	<div class='menu-label-1'>Ctrl+F9</div>";
			echo"</div>";
			
			
			
			if ($Module_RestaurantDelivery == 1) {
			
				echo"<div id='btnsplit' class='menu-container' onclick=\"OpenForm();return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-5'></div>";
				echo"	<div class='menu-label'>Split/Combine</div>";
				echo"</div>";
				
				echo"<div id='btnReservation' class='menu-container' onclick=\"openreservation();return false;\"> ";
				echo"	<div class='menu-shortcut menu-shortcut-10'></div>";
				echo"	<div class='menu-label'>Reservation</div>";
				echo"</div>";

			}*/
			
			echo"</div></li></ul>";
		echo"</td></tr>";
	} else {
		echo"<tr style='height:30px;'><td align='left'>&nbsp;</td></tr>";
	}	
	//End Of Menu
			$openPass=0; 
			
		if($Module_HoldPermission == 1) {
					//If User has no access to hold then password form will open
					if ($FC_CashRegisterHold == 0)
						$openPass = 1;
					else
						$openPass = 0;
				}		
				
						
				
	if ($FC_CashRegisterSearch == 1) {
		echo"<tr><td><input type='button' name='btnSearch' type='button' id='btnSearch' class='searchbutton' title='F7-Search'  onclick='SearchForRef();return false;'  title='Search By Reference'  ";
				if (($actionmode!='' && $actionmode!='cancel') || $txtId!='') {
					echo " disabled ";
					echo " style='cursor:default;'";
				}	
				else echo " style='cursor:pointer;'";
				echo " /></button></td></tr>";		 
	}			
				
	echo"<tr><td><input type='button' name='btnPending' type='button' id='btnPending' title='F8-On Hold' class='pendingsearchbutton' title='Pending Invoices' ";
        if (($actionmode!='' && $actionmode!='cancel') || $txtId!=''){
		    echo " disabled ";
			echo " style='cursor:default;'";
		}	
		else echo " style='cursor:pointer;'";
	    echo " onclick='SearchForPending($openPass);return false;'/></button></td></tr>";		

	if($txtId!='')
		$butname = 'Hold';
	else	
		$butname = 'Clear';

		$openPass=0;
		if($Module_HoldPermission == 1) {
					//If User has no access to hold then password form will open
					if ($FC_CashRegisterHold == 0)
						$openPass = 1;
					else
						$openPass = 0;
				}
	
	if($openPass ==1)	
		echo"<tr><td><input type='button' id='btnClear' name='btnClear' onclick=\"OpenPasswordForm($FC_ShowBtnCancel,'$butname');return false;\" class='clearbutton'  title='F4-$butname' $InsMod title='$butname Page'></button></td></tr>";
	else
		echo"<tr><td><input type='button' id='btnClear' name='btnClear' onclick=\"ClearPage($FC_ShowBtnCancel,'$butname');return false;\" class='clearbutton'  title='F4-$butname' $InsMod title='$butname Page'></button></td></tr>";
	
	
	echo"<tr><td>  <input type='button' name='btnCancel' id='btnCancel'  ";//cancel
		if ($actionmode=='cancel' || ($actionmode=='' && $txtId=='')){
			echo " disabled ";
			echo " style='cursor:default;'";
		}	
		else echo " style='cursor:pointer;'";
			echo" onclick='CancelRecord($FC_ShowBtnCancel);return false;' class='cancelbutton' title='F6 -Cancel Changes'></button></td></tr>";

	echo"<tr><td>  <input type='button' name='btnRefundAll' id='btnRefundAll'  ";//cancel
		if ($actionmode=='cancel' || ($actionmode=='' && $txtId=='')){
			echo " disabled ";
			echo " style='cursor:default;'";
		}	
		else echo " style='cursor:pointer;'";
			echo" onclick='refundall($FC_CashRegisterVoid,$FC_ShowBtnCancel);return false;' class='refundbutton' title='Refund All Items'></button></td></tr>";

	echo"<tr><td><input type='button' id='btnCash' name='btnCash'  onclick='PayCash(".$config['PhpPort'].",".$com.",".$CashRegister_Drawer."); return false;' $PaymentMode  title='F2-Cash '  class='cashbutton'><span><span></span></span></button></td></tr>
	     <tr><td><input type='button' id='btnDiscount' name='btnDiscount' class='discountbutton' onclick='AddDiscount(); return false;' $DiscountMode title='F3-Discount' ";
	if($DiscountMode==' disabled ') echo " style='cursor:default;'"; else  echo " style='cursor:pointer;'";
	echo"><span><span></span></span></button>";
	
	if ($FC_ShowBtnOpenDrawer == 1 && $CashRegister_Drawer == 1) {
		echo"<tr><td ><input type='button' id='btnDrawer' name='btnDrawer' onclick='OpenDrawer(); return false;'  class='drawerbutton' title='Ctrl+F11-Drawer'></button></td></tr>";
	}
	
	$sub_query4 = " Select ctrans_id, date_format(ctrans_timein, '%d/%m/%Y') as ctrans_timein, ctrans_timeout, currency_code as ctrans_currency, ctrans_additionalcash, ".
				  " ifnull(ctrans_totalcashstart,0) as ctrans_totalcashstart, ifnull(ctrans_totalcashclose,0) as ctrans_totalcashclose ".
				  " From cashregistertrans ".
				  " Where upper(cashregister_name) = upper('".$_SESSION['cashregister']."') ".
				  " And cashregistertrans.ctrans_timeout is null ";
	$sub_result4=mysql_query($sub_query4,$connection) or die(mysql_error());
	while($sub_row4=mysql_fetch_array($sub_result4)){
		extract($sub_row4);
	}
	
		$sub_query4 = " Select  date_format(now(),'%d/%m/%Y')  As today from dual ";
		$sub_result4=mysql_query($sub_query4,$connection) or die(mysql_error());
		while($sub_row4=mysql_fetch_array($sub_result4)){
			extract($sub_row4);
		}
	
if ($FC_ShowBtnOpenDrawer == 0 ) {
		$opencashout = 0;
		if($Module_HoldPermission == 1) {
			if ($FI_RetailCashOut == 0) $opencashout = 1;
			else $opencashout = 0;
		}
		echo"<tr><td ><input type='button' id='btnCashout' name='btnCashout' onclick=\"OpenCashout('$ctrans_timein','".$today."',$opencashout,''); return false;\"  class='cashoutbutton' title='Ctrl+F11-Cashout'></button></td></tr>";
	}
	
$openPassSummary=0; 
			
		if($Module_HoldPermission == 1) {
					//If User has no access to hold then password form will open
					if ($FC_RetailReport == 0)
						$openPassSummary = 1;
					else
						$openPassSummary = 0;
				}
				
	echo"<tr><td><input type='button' id='btnSearchItems' name='btnSearchItems' onclick='SearchItemsInfo(); return false;'  class='iteminfobutton' title='Items Info'></button></td></tr>";
	echo"<tr><td><input type='button' id='btnSummaryDetailed' name='btnSummaryDetailed' onclick=\"OpenSummaryDetailed('$ctrans_timein','".$today."',$openPassSummary); return false;\"  class='summarydetailedbutton' title='Summary Detailed Report'></button></td></tr>";
	echo"<tr><td><input type='button' id='btnLogout' name='btnLogout' onclick='LogOut(); return false;' class='logoutbutton' title='Ctrl+F12-Logout' ></button></td></tr>";

echo"	</table>";
echo"</div>"; //End of Left Div

///////// END OF LEFT DIV CONTROLS ////////////////////////
/////////////////////////////////////////////////////////////////////////////////

//Start of Right Div
echo"<div id='right' style='position:absolute; float:left; margin-left:50px; border:0px solid black;'>";
echo"<table cellpadding='0' cellspacing='0' border='0' align='center' class='layout-width'>";

//1st row
echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'><input type='hidden' name='txtProjectDtId' value='$txtProjectDtId'>
			<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:140px; height:26px;'><span class='title'>CASH REGISTER</span></td><td width='180px'><b> $txtCashRegister / $UserAccount
				<td  valign='bottom' style='width:750px;height:26px;'>"; 
echo"			<b>Enter: </b>Submit &nbsp; / <B>Tab: </B>Barcode&Qty &nbsp;/ <B>End:</B>Barcode/SerialNo &nbsp;/ <B>Ctrl + F1: </B> Items List &nbsp; / <B>Ctrl + F8: </B> Vendors List
				</td>";
echo"		</tr></table>
		</td></tr>";
//End of First Row


//2nd row
echo"<tr><td valign='top' align='left' id='content-top2'>&nbsp;</td></tr>";

//3rd row
echo"<tr><td valign='top' align='left' id='content-body'>";
echo"<table border='0' style='margin-left:25px;'>";
///////////////////////////////////////////////////////

$roundedconrner = '	-moz-border-radius: 15px;
					-webkit-border-radius: 15px;
					-khtml-border-radius: 15px;
					border-radius: 15px;';
					
$roundedconrner1 = '-moz-border-radius: 10px;
					-webkit-border-radius: 10px;
					-khtml-border-radius: 10px;
					border-radius: 10px;';
							

if($Module_CashRegisterStandardView==1 && $Module_CashRegisterFastItem==1){
	$height='200px'; $height1='173px'; $groupswidth='800px';
}
else if($Module_CashRegisterStandardView==0 && $Module_CashRegisterFastItem==1){
	$height='230px'; $height1='210px'; 
}
else if($Module_CashRegisterStandardView==1 && $Module_CashRegisterFastItem==0){
	$height='200px'; $height1='173px'; $groupswidth='1135px'; 
}
else if($Module_CashRegisterStandardView==0 && $Module_CashRegisterFastItem==0){
	$height='410px'; $height1='390px'; 
}

if($Retaildt_height != 0) { $height=$Retaildt_height.'px'; $height1=($Retaildt_height-27).'px'; }

$Parameters = array();
$Parameters['Module_PriceOffer'] 				= $Module_PriceOffer;
$Parameters['CashRegister_PrintBarcode'] 		= $CashRegister_PrintBarcode;
$Parameters['Module_SerialNo'] 					= $Module_SerialNo;
$Parameters['DecimalBase'] 						= $DecimalBase;
$Parameters['CashRegisterTTC'] 					= $CashRegisterTTC;
$Parameters['CashReg_Weight'] 					= $CashReg_Weight;
$Parameters['Module_RestaurantDelivery'] 		= $Module_RestaurantDelivery;

$Parameters['FC_CashRegisterMod'] 				= $FC_CashRegisterMod;
$Parameters['FC_CashRegisterDelItem'] 			= $FC_CashRegisterDelItem;
$Parameters['DecimalBase1'] 					= $DecimalBase1;
$Parameters['Module_AdditionalTaxes']		 	= $Module_AdditionalTaxes;
$Parameters['PriceLabel'] 						= $PriceLabel;
$Parameters['TaxableLabel'] 					= $TaxableLabel;
$Parameters['DiscountLabel'] 					= $DiscountLabel;
$Parameters['base1'] 							= $base1;
$Parameters['base2'] 							= $base2;
$Parameters['Setup_VatPercentage'] 				= $Setup_VatPercentage;
$Parameters['ShowSlipNumber'] 					= $ShowSlipNumber;
$Parameters['txtDate'] 							= $txtDate;
$Parameters['txtCurr'] 							= $txtCurr;
$Parameters['txtClientCode'] 					= $txtClientCode;
$Parameters['txtOrderId'] 						= $txtOrderId;
$Parameters['Unmodify_SellingPrice'] 			= $Unmodify_SellingPrice;
$Parameters['passchecked'] 						= $passchecked;
$Parameters['height'] 							= $height1;
$Parameters['CashReg_Vendor'] 					= $CashReg_Vendor;
$Parameters['CashReg_RoundDivisor'] 			= $CashReg_RoundDivisor;
$Parameters['FC_DiscountPerLimit'] 				= $FC_DiscountPerLimit;
$Parameters['CashReg_ForcingVendor'] 			= $CashReg_ForcingVendor;
$Parameters['txtTotalAmountActual'] 			= $txtTotalAmountActual;
$Parameters['Module_CashRegisterTable'] 		= $Module_CashRegisterTable;
$Parameters['CashRegister_ShowTaxNonTax'] 		= $CashRegister_ShowTaxNonTax;
$Parameters['Module_CashRegisterStandardView'] 	= $Module_CashRegisterStandardView;
$Parameters['Module_CashRegisterFastItem'] 		= $Module_CashRegisterFastItem;
$Parameters['FC_ShowAllTables'] 				= $FC_ShowAllTables;

$Parameters['CashRegister_showitemcode'] 		= $CashRegister_showitemcode;
$Parameters['CashRegister_showdiscount'] 		= $CashRegister_showdiscount;

$Parameters['cashregister_service'] 			= $cashregister_service;
$Parameters['cashregister_servicePercentage'] 	= $cashregister_servicePercentage;
$Parameters['cashregister_TaxConsumption'] 		= $cashregister_TaxConsumption;
$Parameters['cashregister_TaxConsumptionpPer'] 	= $cashregister_TaxConsumptionpPer;

$_SESSION['gret_parameters']  = $Parameters;

$CashRegisterMod = $FC_CashRegisterMod;
if ($FC_CashRegisterMod == 0 && $Module_RestaurantDelivery == 1 && $txtRef == "") $CashRegisterMod = 1;

$CashRegisterDelItem = $FC_CashRegisterDelItem;
//if ($FC_CashRegisterDelItem == 0 && $Module_RestaurantDelivery == 1 && $txtRef == "") $CashRegisterDelItem = 1;


//Start 1st Table of 3rd Raw
echo"	<tr><td valign='top' >
			<table border='0' cellpadding='0' cellspacing='0'  width='1135px'  >
			<col width=350px>
			<col width=210px>
			<col width=225px>
			<col width=350px>";
				
			
			if ($CashRegisterSerialNo == 0) $ItemOptionLabel = 'Barcode';
			else $ItemOptionLabel = 'SerialNo';

			$sub_query  = " Select ifNull(Item_ModifySellingPrice,0) From Items ".
						  " Where Item_Code = '".$txtItemBarcode."' or  Item_Barcode = '".$txtItemBarcode."' or ".
						  " Item_Barcode2 = '".$txtItemBarcode."' or Item_Barcode3 = '".$txtItemBarcode."'";
			$sub_result = selectData($connection, $sub_query);

			$ItemModifySellingPrice = $sub_result[0];
				
			// User Has No Access To Modify The Price	
			$ModeModifySellPrice = '';
			if ($Unmodify_SellingPrice == 1 || ($ItemModifySellingPrice == 0 && $txtItemBarcode != ''))	
				$ModeModifySellPrice = ' readonly ';


				 
			echo"<tr>
					<td align='left' style='padding-left:3px' valign='top'>
					<div style='position:relative; float:left; width:100%; height:140px; background-color:#016A84;$roundedconrner;'>
					<table border='0' align='left' style='cellpadding:0; width:340px; margin-left:5px;' >
					<col width=70>
					<col width=125>
					<col width=50>
					<col width=95>";
					
			echo"<tr height='20px'>
					<td align='left'><span class='style17'>Date&nbsp;<span class='style26'>*</span></span></td>
					<td colspan='3'>
						<span class='style16' ><input type='text' name='txtDate' value='$txtDate' maxlength='10' style='width:80px;' readonly></span>";
echo "<A HREF='#' onClick=\"displayCalendar(document.retail.txtDate,'dd/mm/yyyy',this); return false;\" NAME='anchor1' ID='anchor1' >
	<image src='./img/cal.gif' border=0 align=center ></image></A>";			
			echo "	<span class='style17' style='padding-left:30px;'>Reference</span>
						<span class='style16'>$txtRef</span><input type='hidden' name='retail_reference' id='retail_reference' value='$txtRef' readonly>";
			echo"	</td>";
			echo"</tr>";
		
			echo"	<tr height='10px'><td>&nbsp;</td><td colspan=3>";
			if ($Module_SerialNo == 1) {	
				if ($CashRegisterBarCode == 1 || $txtItemOption == 1 || ($CashRegisterBarCode == 0 && $CashRegisterSerialNo == 0) || $Module_SerialNo == 0)
					echo "<input name='txtItemOption' id='txtItemOption' type='radio' value='1' checked /><span class='style17'> Code/Barcode</span>";
				else 
					echo "<input name='txtItemOption' id='txtItemOption' type='radio' value='1' /><span class='style17'> Code/Barcode</span>";

			
				if ($CashRegisterSerialNo == 1 || $txtItemOption == 2)	
					echo "<input name='txtItemOption' id='txtItemOption' type='radio' value='2' checked /><span class='style17'> Serial No.</span>";
				else 
					echo "<input name='txtItemOption' id='txtItemOption' type='radio' value='2' /><span class='style17'> Serial No.</span>";
			}
			else 	echo "<input name='txtItemOption' id='txtItemOption' type='radio' style='display:none' value='1' /><span class='style17'></span>";
			
			echo"	</td></tr>";
			echo"	<tr height=30px>
						<td><span class='style17'><input type='text' name='ItemOptionLabel' id='ItemOptionLabel' value='$ItemOptionLabel'  maxlength='20' style='color: #FFFFFF; font-weight: bold; font-size: 12px; font-family: Arial, Times, sans-serif; width:50px; height:22px; border:0px;background-color:#016A84' readonly ><span class='style26'>*</span></span></td>
						<td colspan='3'>
							<input type='text' name='txtItemBarcode' id='txtItemBarcode' value='".htmlentities($txtItemBarcode)."'  maxlength='40' style='font-size:13px; width:240px; height:22px;-moz-border-radius: 0px 5px 5px 5px;
							-webkit-border-radius: 0px 5px 5px 5px;	border-radius: 5px 5px 5px 5px;'  onkeydown='return Barcodekd(event);'  onfocus=FillHidden('txtItemBarcode');>
							<label><span class='style17'><img src='img/openlist.png' title=' Select Item '  width='18' height='19' border='0' style='cursor:pointer;' onClick='showlistItems(1); ' /></span></label>
						</td>
					</tr>";//onchange='ClearValues();'

			echo"	<tr >
						<td ><span class='style17'>Price</span></td><td colspan='3'>
							<input type='text' name='txtItemPrice' id='txtItemPrice' value='$txtItemPrice'  maxlength='20' style='font-size:13px; width:120px; height:22px;-moz-border-radius: 0px 5px 5px 5px;
							-webkit-border-radius: 5px 5px 5px 5px;
							border-radius: 5px 5px 5px 5px;' onkeydown='return Barcodekd(event);' $ModeModifySellPrice onfocus=FillHidden('txtItemPrice');>
							<span class='style17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Qty</span>
							<input type='text' name='txtItemQty' id='txtItemQty' value='$txtItemQty'  maxlength='6' style='font-size:13px; width:50px; height:22px;
							-moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius: 5px 5px 5px 5px;' onkeydown='return Barcodekd(event);' onfocus=FillHidden('txtItemQty');>
						</td>";
			echo"	</tr>";
			echo"	<tr >";

			if ($CashReg_Vendor == 1){
				echo "	<td align='left' valign='center' ><span class='style17'>Vendor</span></td>
						<td ><input type='text' value='$txtVendorCode'  name='txtVendorCode' id='txtVendorCode' maxlength='10' 
							style='font-size:13px; width:90px; height:22px;-moz-border-radius: 0px 5px 5px 5px;	-webkit-border-radius: 0px 5px 5px 5px;	border-radius: 5px 5px 5px 5px;' >
							<label><span class='style17'><img src='img/openlist.png' title=' Select Vendor '  width='18' height='19' border='0' style='cursor:pointer;' onClick='showlistVendors(1); ' /></span></label>
						</td>";
			} else {
				echo "<td align='left' colspan='2' ><input type='hidden' name='txtVendorCode' id='txtVendorCode' value='' >&nbsp;</td>";
			}

			if ($ShowSlipNumber == 1){
				echo "<td><span class='style17'>Slip No.</span></td><td>
					 <input type='text' value='$txtSlipNo'  name='txtSlipNo' id='txtSlipNo' maxlength='20' style='font-size:13px; width:62px; height:22px;
					 -moz-border-radius: 0px 5px 5px 5px;
						-webkit-border-radius: 0px 5px 5px 5px;
						border-radius: 5px 5px 5px 5px;'></td>";
			} else {
				echo "<td align='left' colspan='2' ><input type='hidden' name='txtSlipNo' id='txtSlipNo' value='' >&nbsp;</td>";
			}			
						
						
			echo"	</tr></table></div>
					</td>";
					
			echo"	<td valign='top' align='right' rowspan='2'>";
			echo"		<div id='totals' style='width:200px; height:180px; background-color:#016A84;$roundedconrner;'>";
						ShowRetailTotals($connection,$_SESSION['gret_parameters'],$txtId);		
			echo"		</div>";
			echo"	</td>";		
			
			echo"	<td align='right' valign='top' rowspan='2'>";
			
			if ($Module_RestaurantDelivery == 1) {
				echo"<div id='delivery' style='width:220px; height:180px; background-color:#016A84;$roundedconrner' >";			
				echo"<table width=220 border=0 cellspacing=0 cellpadding=0  style='padding-left:5px;'>";
				
				if($txtProjectDtId!='')
					$stat2 = ' selected ';
					else
					$stat2 = '';
				
				//echo $txtSaleStatus;
				if($txtSaleStatus=='')
					$txtSaleStatus = $cashregister_retailtype;
				
				if($txtSaleStatus=='takeout')
					$stat = ' selected ';
				else	
				if($txtSaleStatus=='dinein')
					$stat2 = ' selected ';
				else	
				if($txtSaleStatus=='delivery')
					$stat3 = ' selected ';
				else
				if($txtRetDriverName!='')
					$stat3 = ' selected ';
				else	
				if($txtRetCustomerName!='' or $txtRetDriverName!='')
					$stat3 = ' selected ';
					//echo $stat2." ".$stat3;
				if($txtProjectDtId!='' && $Module_CashRegisterTable==1) {
					$subquery = "select projectdt_name from projectdt where projectdt_id = $txtProjectDtId";
					$resultsub=mysql_query($subquery,$connection);
					$rowsub=mysql_fetch_row($resultsub);
					$tablename = $rowsub[0];
					echo"<tr height='25'>";
					echo"	<td colspan='2'><span class='style18'>Table: $rowsub[0]&nbsp;&nbsp;&nbsp;<u><a   onMouseOver=\"style.cursor='pointer'\"  onclick=\"EditGuestsWin('$txtProjectDtId','$txtTableGuests')\">Guests: $txtTableGuests</a></u></span></td>";
					echo"</tr>";
				} else {
					echo"<tr height='20'>";
					echo"	<td colspan='2'><span class='style18'>&nbsp;</span></td>";
					echo"</tr>";
				}
				echo"<tr>";
				echo"	<td><input type='button' name='but1' id='but1' value='  Customer '  onclick=\"OpenCustomerRestaurant('".$txtId."');\" onMouseOver=\"style.cursor='hand'\" ></td>";
				echo"	<td align=center><select name='txtSaleStatus' id='txtSaleStatus' onchange=refreshpage('addtype')>
							<option $stat value='takeout'>Take Out</option>
							<option $stat2 value='dinein'>Dine In</option>
							<option $stat3 value='delivery'>Delivery</option>
						</select></td>
					</tr>";
				
				//echo"<tr><td><input type='button' name='but1' id='but1' value='  Customer '  onclick='OpenCustomerRestaurant($txtId)' onMouseOver=\"style.cursor='hand'\" ></td></tr>";
				echo"<tr><td colspan='2'>
						<textarea name='txtRetCustomerName' id='txtRetCustomerName' rows='5' cols='20' onkeydown=\"return CheckTel('".$txtId."',event);\" style='width:210px;font-size:13px'>".htmlspecialchars($txtRetCustomerName, ENT_QUOTES)."</textarea>
						<input type='hidden' name='txtRetCustomerCode' id='txtRetCustomerCode' value='$txtRetCustomerCode' style='width:100'>
					</td></tr>";
					 
				echo"<tr><td colspan='2'>
						<input type='button' name='but2' id='but2' value='    Driver     '   onclick='OpenDriverRestaurant($txtId)'  onMouseOver=\"style.cursor='hand'\" >
						<input type='text' name='txtRetDriverName' id='txtRetDriverName' value='$txtRetDriverName' onchange=EmptyDrivercode('$txtId') style='width:125px;font-size:13px'>
						<input type='hidden' name='txtRetDriverCode' id='txtRetDriverCode' value='$txtRetDriverCode' style='width:100'>
					</td></tr>";
				
				echo"</table>";
				echo"</div>";
			} else {
			
				echo"<input type='hidden' name='txtSaleStatus' id='txtSaleStatus' value=''>";
				echo"<input type='hidden' name='txtRetCustomerName' id='txtRetCustomerName' value=''>";
				echo"<input type='hidden' name='txtRetCustomerCode' id='txtRetCustomerCode' value=''>";
				echo"<input type='hidden' name='txtRetDriverName' id='txtRetDriverName' value=''>";
				echo"<input type='hidden' name='txtRetDriverCode' id='txtRetDriverCode' value=''>";
			}		
			echo" 	</td>";
		if($keyboardfocus == 0)	$fillfunct = 'FillInput1';
		else $fillfunct = 'FillInput';
			echo"	<td valign='top'  align='right' rowspan='2'>
						<table cellspacing=0 cellpadding=1 border='0'>
						<tr>";
							
						if ($Module_RestaurantDelivery == 1)
							echo"<td><input type='button' value='Gift' id='btnGift' class='calculatorbutton'  onclick=\"ControlOrderItem(1,'".$txtId."',$FC_CashRegisterGift);\"></td>";
						else
							echo"<td><input type='button' value='' class='calculatorbutton'  onkeydown='return Barcodekd(event);'></td>";								
								
			echo"			<td><input type='button' value='' class='calculatorbutton'  onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='0' class='calculatorbutton' onclick='$fillfunct(0);' id='button0' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='1' class='calculatorbutton' onclick='$fillfunct(1);' id='button1' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='2' class='calculatorbutton' onclick='$fillfunct(2);' id='button2' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='3' class='calculatorbutton' onclick='$fillfunct(3);' id='button3' onkeydown='return Barcodekd(event);'></td>
						</tr>


						<tr>";
							
						if ($Module_RestaurantDelivery == 1) {
							echo"<td><input type='button' value='Void' id='btnVoid' class='calculatorbutton'  onclick=\"ControlOrderItem(2,'".$txtId."',$FC_CashRegisterVoid);\"></td>";
							echo"<td><input type='button' value='Modifier' id='btnShortCut' class='calculatorbutton'  onclick=\"DisplayShortCuts();\"></td>";
						}	
						else {
							echo"<td><input type='button' value='' class='calculatorbutton'  onkeydown='return Barcodekd(event);'></td>";
							echo"<td><input type='button' value='' class='calculatorbutton'  onkeydown='return Barcodekd(event);'></td>";
						}	

			if ($Module_RestaurantDelivery == 1)
				echo"<td><input type='button' id='btnSubmit' class='calculatorbutton'  name='btnSubmit' value='Enter' onclick=\"CheckItemModifiers('$CashReg_ForcingVendor','$txtSubGroup'); return false;\" title='Submit Record' ></td>";
			else 	
				echo"<td><input type='button' id='btnSubmit' class='calculatorbutton'  name='btnSubmit' value='Enter' onclick=\"SubmitRecord('$CashReg_ForcingVendor','$txtSubGroup'); return false;\" title='Submit Record' ></td>";
				
			echo"			<td><input type='button' value='4' class='calculatorbutton' onclick='$fillfunct(4);' id='button4' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='5' class='calculatorbutton' onclick='$fillfunct(5);' id='button5' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='6' class='calculatorbutton' onclick='$fillfunct(6);' id='button6' onkeydown='return Barcodekd(event);'></td>
						</tr>

						<tr>";
						
							if ($Module_RestaurantDelivery == 1)
								echo"<td><input type='button' value='Waste' id='btnWaste' class='calculatorbutton' onclick=\"ControlOrderItem(3,'".$txtId."',$FC_CashRegisterWaste);\" ></td>";
							else
								echo"<td><input type='button' value='' class='calculatorbutton'  onkeydown='return Barcodekd(event);'></td>";
								
			echo"			<td><input type='button' value='Sub' class='calculatorbutton' onclick=$fillfunct('-'); id='buttonminus' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='Clr' class='calculatorbutton' onclick='EraseInput();' id='buttonerase' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='7' class='calculatorbutton' onclick='$fillfunct(7);' id='button7' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='8' class='calculatorbutton' onclick='$fillfunct(8);' id='button8' onkeydown='return Barcodekd(event);'></td>
							<td><input type='button' value='9' class='calculatorbutton' onclick='$fillfunct(9);' id='button9' onkeydown='return Barcodekd(event);'></td>
						</tr>";
			echo"	</table></td>";
								
			echo"</tr>";
			
			echo"<tr height='37px;'><td style='padding-left:3px'>
					<div style='position:relative; float:left; width:100%; background-color:#016A84;$roundedconrner1;'>
					<table border=0 cellpading=0 cellspacing=0><tr height='35px;'>";
			echo"		<td align='center' valign='center'><span class='style15'>";
			
			if ($Module_RestaurantDelivery == 0 && $Module_SerialNo == 1) {
				echo"<input type='button' value='Serial' id='button_addserial'  onMouseOver=\"style.cursor='pointer'\" name='button_addserial' value='Add Serial'  style='width:55px;height:30px;'   onclick=AddSerialNo('".$rowsdt[0]."')  title='Add Serial Nos' >";
			}	
			
			
			echo"<input type='button' value='Edit' name='Edit'  id='Edit' style='width:45px;height:30px' onMouseOver=\"style.cursor='pointer'\" onclick=UpdateRecordDt('".$rowsdt[0]."',$CashRegisterMod) title='Edit Record'  >";
			echo"<input type='button' value='Delete'  value='Delete' id='Delete'  style='width:50px;height:30px'  onMouseOver=\"style.cursor='pointer'\" id='imgDelete[$i]' onclick=DeleteRecordDt('".$rowsdt[0]."','".$rowsdt[2]."',$CashRegisterDelItem,'$i') title='Delete Record'  width='20' height='20' disabled>";
						
				$qq = "select 1 from temp_RetailDt,temp_retail ".
					" where temp_Retail.Sale_id = '".$txtId."' and temp_retail.sale_id=temp_retaildt.sale_id ".
					" and ifnull(saleDt_ItemStatus,0) = 0 ";
			   //echo $qq;
				$resultdt=mysql_query($qq,$connection) or die(mysql_error());
				$rows=mysql_fetch_array($resultdt);
				$isexists = $rows[0];
				if($isexists=='')
					$st = ' disabled ';
				else	
					$st = ' ';
			
			if($NumofHolds==0) $NumofHolds = '';
			
			if($NumofHolds!='')
				$NumofHolds = 'Hold'.'('.$NumofHolds.')';
			else
				$NumofHolds = 'Hold';
				
			if ($CashRegister_Printer != 1 or $CashRegister_SlipRePrinter != 1) {
				$width='45px';
				$width2='45px';
				}
				
			if ($Module_RestaurantDelivery == 1) { 
				
				if($Module_HoldPermission == 1) {
					//If User has no access to hold then password form will open
			
					if ($FC_CashRegisterHold == 0)
						$openPass = 1;
					else
						$openPass = 0;
						
					if($Module_GroupHoldFire==1)
						echo"<input type='button'  value='$NumofHolds' id='btnHold' name='btnHold' style='width:45px;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItemGroup(this,$openPass);\" title='Hold Item'>";
					else
						echo"<input type='button'  value='$NumofHolds' id='btnHold' name='btnHold' style='width:45px;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItem(4,'".$txtId."',1,$openPass);\" title='Hold Item'>";
						
						
				
					
				
				} else {
				
				if($Module_GroupHoldFire==1)
					echo"<input type='button'  value='$NumofHolds' id='btnHold' name='btnHold' style='width:55px;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItemGroup(this,$openPass);\" title='Hold Item'>";
				else
					echo"<input type='button'  value='$NumofHolds' id='btnHold' name='btnHold' style='width:55px;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItem(4,'".$txtId."',1,".$Module_GroupHoldFire.");\" title='Hold Item'>";
				
				}
				
				if($Module_GroupHoldFire==1)
				echo"<input type='button'  value='Fire' id='btnFire' name='btnFire' style='width:$width;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItem(5,'".$txtId."',1); return false\" title='Fire Item'>";
				else
				echo"<input type='button'  value='Fire' id='btnFire' name='btnFire' style='width:$width;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"ControlOrderItem(5,'".$txtId."',1); return false\" title='Fire Item'>";
				
				
				
			
				
				
			}
	
				
						
		echo"<input type='button'  value='Order' id='btnSwap' name='btnSwap' style='width:$width;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"PrintSwap('".$txtId."','".$rowsdt[1]."',0,'Form_RetailSlip.php',1,$CashRegister_Printer,$CashRegister_SlipPrinter,'$tablename','$txtTableGuests','$cashregister_logout');\" title='Print Items'>";
				
			if ($CashRegister_Printer == 1 && $CashRegister_SlipPrinter == 1) {
				echo"<input type='button' id='btnPrint' value='Print'  style='width:$width2;height:30px; cursor:pointer;'  onclick=\"PrintRetailTemp('".$txtId."','Form_RetailSlip.php','$CashRegister_SlipCopy');\" title='Print Order'>";
			}
			if ($CashRegister_Printer == 1 && $CashRegister_SlipRePrinter == 1) {
				echo"<input type='button' id='btnPrint1' value='Last'  style='width:40px;height:30px; cursor:pointer;'  onclick=\"PrintRetailTemp('".$txtId."','Form_RetailSlip.php','$CashRegister_SlipCopy','1');\" title='Print Order'>";
			}
			
			
			
			echo"<input type='button'  value='Refund' id='btnRefund' name='btnRefund' style='width:55px;height:30px'  onMouseOver=\"style.cursor='pointer'\" onclick=\"RefundOrderItem($FC_CashRegisterVoid,'".$rowsdt[2]."');\" title='Refund Item'>";
			echo"	</td>";
			echo"</tr></table></div>";
			echo"</td></tr>";//buttons
			

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

//End 1st Table of 3rd Raw
////////////////////////////////////////////////////////////

if($txt_GroupHoldFire=='')
$txt_GroupHoldFire=0;



		   echo"   <input type='hidden' name='txtOrderId' value='$txtOrderId' size='10'>
			  <input type='hidden' name='txtOrderRef' value='$txtOrderRef' size='10'>
			  <input type='hidden' name='txtId' value='$txtId' size='10'>
			  <input type='hidden' name='txtRef' value='$txtRef' size='10' >
			  <input type='hidden' name='txtCashRegister' value='$txtCashRegister' >
			  <input type='hidden' name='txtCurr' value='$txtCurr' >
			  <input type='hidden' name='txtClientCode' value='$txtClientCode' >
			  <input type='hidden' name='txtProjectCode' id='txtProjectCode' value='$txtProjectCode' />
			  <input type='hidden' name='txtCostCentCode' id='txtCostCentCode' value='$txtCostCentCode' />
			  <input type='hidden' name='txtBalanceAmount' value='$txtBalanceAmount' >
			  <input type='hidden' name='txt_GroupHoldFire'  id='txt_GroupHoldFire' value='$txt_GroupHoldFire' >
			  <input type='hidden' name='Module_GroupHoldFire'  id='Module_GroupHoldFire' value='$Module_GroupHoldFire' >
			  <input type='hidden' name='cashregister_retailtype'  id='cashregister_retailtype' value='$cashregister_retailtype' >
			  ";
		  //</td>	  
   
$PaymentMode  = ' ';
$DiscountMode = '';
$PostingMode  = ' ';

if ($FC_CashRegisterPosting == 0 || $CashRegister_AutoPost == 1 || ($FC_CashRegisterPosting == 1 && $txtId != '')) 
	$PostingMode = ' disabled ';
	
if ($txtId == '') 
	$PaymentMode = ' disabled ';	

if ($CashRegisterDiscount == 0 || ($CashRegisterDiscount == 1 && $txtId == ''))
	$DiscountMode = ' disabled ';

///////////////////////////////////////////	
//Start 2nd Table of 3rd Raw
echo"   <tr><td valign='top' align='left' colspan='1'>";
		
		if($Module_CashRegisterTable==1)
			echo"<div style='height:$height; margin-top:3px; float:left; width:800px; border:0px solid black; float:left;' id='datagrid' >";
		else
			echo"<div style='height:$height; margin-top:3px; float:left; width:1135px; border:0px solid black; float:left;' id='datagrid' >";
			
		ShowRetailDtGrid($connection,$_SESSION['gret_parameters'],$txtId);		
		echo "</div>";
		
		
		if($Module_CashRegisterTable==1)
		{ 
			//echo"<td valign=top align=right>";
			echo"<div style='height:200; margin-top:3px; width:330px; overflow-y:scroll; border:0px solid black; float:right;' id='datagridtable' >";
			ShowTableGrid($connection,$_SESSION['gret_parameters'],$txtId);
			echo"</div>";
		}
echo" </td></tr>";

//End 2nd Table of 3rd Raw
/////////////////////////////////////////////////


/////////////////////////////////////////
//Start 3rd Table of 3rd Raw

echo"<tr><td  align='left'>";	

if($Module_CashRegisterStandardView==1){
	if($subgroupgrid_height != 0) $heightgroup = $subgroupgrid_height;
	else $heightgroup = '220px';
	if($subgroupgrid_width != 0) $groupswidth = $subgroupgrid_width;
	
	echo"	<div id='subgrouparea' style='overflow-y:scroll; overflow-x:scroll; width:$groupswidth; height:$heightgroup; border:0px solid #000000; float:left;'>
				
				<table border='0' style='table-layout:fixed;' cellspacing=0 cellpadding=0>";
	echo"			<input type='hidden' name='subgroup_codeParent' value='$subgroup_codeParent'>";
	
	//Get subgroup codes
	if($txtSubGroup!=''){
		$subquery="Select parent_code, subgroup_color, subgroup_picture from subgroup where subgroup_code='".$txtSubGroup."' order by subgroup_order";
		$resultsub=mysql_query($subquery,$connection);
		$row=mysql_fetch_row($resultsub);
		$parent_code=$row[0];
		
				
		/*if($parent_code!='')	
			$querysubgroup=$querysubgroup. " select subgroup_code from subgroup where parent_code='".$parent_code."'" ;
		else{ $querysubgroup="select subgroup_code from subgroup where upper(subgroup_type)=upper('cashreg') and (parent_code is null or parent_code='') ";	
			$vSkipActionButtons=1;
		}	*/
		
		$query="select item_code,substr(item_description,1,20), Item_Color, Item_Picture from items where subgroup_code='".$txtSubGroup."' and ifnull(item_active,0) = 1 ";
		$result=mysql_query($query,$connection);
		
		$querypar="select button_dimwidth,button_dimheight from subgroup where subgroup_code='".$txtSubGroup."'  order by subgroup_order";
		$respar = mysql_query($querypar,$connection);
		$rwpar = mysql_fetch_row($respar);
		
		if($rwpar[0] != '' && $rwpar[0] != 0) $dimw = $rwpar[0]."px";
		else $dimw = "70px";
		if($rwpar[1] != '' && $rwpar[1] != 0) $dimh = $rwpar[1]."px";
		else $dimh = "55px";
		
		echo"<tr>";
		if($vSkipActionButtons!='1'){
			echo"<td><input type='button' id='BackButton' style='width:$dimw; height:$dimh;' onclick=\"showSubgroup('$subgroup_codeParent','subgrouparea','back');return false;\" class='subgroupbuttons1' value='Back'><span><span></span></span></button></td>
				 <td><input type='button' id='RootButton' style='width:$dimw; height:$dimh;' onclick=\"showSubgroup('$subgroup_codeParent','subgrouparea','root');return false;\" class='subgroupbuttons1' value='Root'><span><span></span></span></button></td>";
		}
		
		
		$j=2;
		while($row=mysql_fetch_row($result)){
			
			if ($Module_CashRegisterFastItem == 1) {
				if($j%8==0) echo"</tr><tr>";
			} else {	
				if($j%8==0) echo"</tr><tr>";
			}	
			
			$ButtonColor = '';
			$ItemButton_Color   = $row[2];
			$ItemButton_Picture = $row[3];
			
			if ($ItemButton_Picture != '') {
				$ButtonLabel = '';
			}
			if ($ItemButton_Color != '') {
				$ButtonColor = "background-color:#".$ItemButton_Color;
			}	
			
			
			
			if ($ItemButton_Picture != '') {
				echo "<td width='60px'><button type='button' id='btnSub' name='btnSub' onclick=\"Fillitem('$row[0]','$txtSubGroup');return false;\" class='itembuttons' style='$ButtonColor' value='$row[1]'><img src='GetButtonImage.php?option=item&id=$row[0]' style='width:40px; height:40px;'></img></button></td>";
			} else {
				echo "<td width='60px'><input type='button' id='btnSub' name='btnSub' onclick=\"Fillitem('$row[0]','$txtSubGroup');return false;\" class='subgroupbuttons1' style='$ButtonColor;width:$dimw; height:$dimh;' value='$row[1]'><span><span></span></span></button></td>";
			}
			
			$j=$j+1;
		}
		
		echo"</tr>";
	}	
		
	else {
		$querysubgroup="select subgroup_code, subgroup_color, subgroup_picture,button_dimwidth,button_dimheight from subgroup where upper(subgroup_type)=upper('PLU') and (parent_code is null or parent_code='')  order by subgroup_order";
		$vSkipActionButtons=1;
	}
	
	$result=mysql_query($querysubgroup,$connection);
	$i=0;
	echo"<tr>";
	while($row=mysql_fetch_row($result)){

		$subquery="select subgroup_code from subgroup where parent_code='".$row[0]."'  order by subgroup_order";
		$resultsub=mysql_query($subquery,$connection);
		$numrow=mysql_num_rows($resultsub);
		
		
		if($numrow>0) $vZone='subgrouparea';
		else $vZone='subgrouparea';
		
		if ($Module_CashRegisterFastItem == 1) {
			if($i%8==0) echo"</tr><tr>";
		} else {	
			if($i%8==0) echo"</tr><tr>";
		}
		
		$ButtonColor = '';
		$ItemButton_Color   = $row[1];
		$ItemButton_Picture = $row[2];
		
		if ($ItemButton_Picture != '') {
			$ButtonLabel = '';
		}
		if ($ItemButton_Color != '') {
			$ButtonColor = "background-color:#".$ItemButton_Color;
		}
		
		if($row[3] != '') $dimw = $row[3]."px";
		else $dimw = "70px";
		if($row[4] != '') $dimh = $row[4]."px";
		else $dimh = "55px";
		if ($ItemButton_Picture != '') {
			echo "<td width='60px'><button type='button' id='btnSub' name='btnSub' onclick=\"showSubgroup('$row[0]','$vZone','main');return false;\" class='subgroupbuttons_1' style='$ButtonColor' value='$row[0]'><img src='GetButtonImage.php?option=subgroup&id=$row[0]' style='width:50px; height:40px;'></img></button></td>";
		} else {
			echo "<td width='60px'><input type='button' id='btnSub' name='btnSub' onclick=\"showSubgroup('$row[0]','$vZone','main');return false;\" class='subgroupbuttons' style='$ButtonColor;width:$dimw;height:$dimh;' value='$row[0]'></button></td>";
		}
		
		$i=$i+1;
		
		if($vSkipActionButtons!='1'){
			echo"<td><input type='button' id='BackButton' onclick=\"showSubgroup('$subgroup_codeParent','subgrouparea','back');return false;\" class='subgroupbuttons1' value='Back' style='width:$dimw;height:$dimh;'><span><span></span></span></button></td>
				 <td><input type='button' id='RootButton' onclick=\"showSubgroup('$subgroup_codeParent','subgrouparea','root');return false;\" class='subgroupbuttons1' value='Root' style='width:$dimw;height:$dimh;'><span><span></span></span></button></td>"; 
		}
	}
		echo"</tr></table></div>";	
}

if ($Module_CashRegisterFastItem == 1) {

	$widthfast = 330;

	if($Module_CashRegisterStandardView==0 ) {$heightfast='170px';$widthfast='1135px';}
	if($Module_CashRegisterStandardView==1 ) $heightfast='220px';
	
	if($shortcutgrid_height != 0) $heightfast = $shortcutgrid_height;
	if($shortcutgrid_width != 0) $widthfast = $shortcutgrid_width;
	
	echo"	<div id='div-shortcuts' class='list-containerfast' style='height:$heightfast;width:$widthfast;border:0px solid #000000; float:right;'>";
	ShowShortCutGrid($connection,$_SESSION['gret_parameters']);
	echo"	</div>";
	
}	
	
	
echo"</td></tr>";
//End 3rd Table of 3rd Raw
//////////////////////////////////////////////////

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

// Start 4th Row	
echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";  

echo"</table>";////main table
echo"</div>"; //End of Right Div

echo"</div>"; //End of Main Div


// Show List of Void Reasons
echo"<div id='VoidOptions' style='position:absolute; display:none; z-index:9999999; width:240px; height:400px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<div style='position:relative; float:left; clear:both; height:350px; margin:10px 0 0 10px; overflow:auto;'>";
		
		$queryVoid = " Select Reason_Remark From CashRegister_VoidReasons";
		$resultVoid=mysql_query($queryVoid,$connection) or die(mysql_error());
		while($rowsVoid=mysql_fetch_array($resultVoid)){
			echo "<input type='button' onclick=\"SelectVoidReason('".$rowsVoid[0]."')\" class='VoidButtons' value='".$rowsVoid[0]."' />";
		
		}
			
echo"	</div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:80px;'>
			<button type='button' id='btnExit' name='btnExit' onclick='unloadVoidWin();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";
	
// Show Hold Window
echo"<div id='HoldDiv' style='position:absolute; display:none; z-index:9999999; width:300px; height:150px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<div style='position:relative; float:left; clear:both; height:100px; margin:10px 0 0 10px; overflow:auto;'>
			<span class='style15' style='display:block; font-weight:bold; padding-bottom:10px;'>Hold Reference</span>
			<input type='text' name='txtHoldReference' id='txtHoldReference' value='".htmlentities($txtRemark)."' maxlength='40' style='font-size:13px; width:240px; height:27px; -moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius:5px 5px 5px 5px;' />
		</div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:100px;'>
			<button type='button' id='btnHoldOk' name='btnHoldOk' onclick='SetHoldReference();return false;' title='Ok'><span><span>Ok</span></span></button>
			<button type='button' id='btnHoldExit' name='btnHoldExit' onclick='unloadHoldWin();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";
	
// Show Modifier Note Window
echo"<div id='ModifiersDiv' style='position:absolute; display:none; z-index:9999999; width:350px; height:200px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<div style='position:relative; float:left; clear:both; height:150px; margin:10px 0 0 10px; overflow:none;'>
			<span class='style15' style='display:block; font-weight:bold; padding-bottom:10px;'>Add Note</span>
			<textarea name='txtModifierNote' id='txtModifierNote' rows='4' cols='35' style='font-size:13px; -moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius:5px 5px 5px 5px;' ></textarea>
		</div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:130px;'>
			<button type='button' id='btnModifierOk' name='btnModifierOk' onclick='SetModifierNote();return false;' title='Ok'><span><span>Ok</span></span></button>
			<button type='button' id='btnModifierExit' name='btnModifierExit' onclick='CloseModifierWin();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";
	
// Show Table Guests Window
echo"<div id='GuestsDiv' style='position:absolute; display:none; z-index:9999999; width:250px; height:125px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<div style='position:relative; float:left; clear:both; height:30px; margin:10px 0 0 10px; overflow:auto;'>
			<span class='style15' style='display:inline-block; font-weight:bold; padding-bottom:10px;'>Total Guests</span>
			<input type='text' name='txtTableGuests' id='txtTableGuests' value='".htmlentities($txtTableGuests)."' maxlength='10' style='font-size:13px; width:100px; height:27px; -moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius:5px 5px 5px 5px;' />
		</div>
		<div style='position:relative; float:left; clear:both; height:30px; margin:10px 0 0 10px; overflow:auto;'>
			<span class='style15' style='display:inline-block; font-weight:bold; padding-bottom:10px;'>Guest Name</span>
			<input type='text' name='txtGuestname' id='txtGuestname' value='".htmlentities($txtGuestname)."' style='font-size:13px; width:100px; height:27px; -moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius:5px 5px 5px 5px;' />
		</div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:70px;'>";
			
			echo"<button type='button' id='btnGuestsOk' name='btnGuestsOk' onclick='OpenTable();return false;' title='Ok'><span><span>Ok</span></span></button>";
			
			echo"<button type='button' id='btnGuestsExit' name='btnGuestsExit' onclick='CloseGuestsWin();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";


echo"<div id='GuestsDivEdit' style='position:absolute; display:none; z-index:9999999; width:250px; height:100px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<div style='position:relative; float:left; clear:both; height:50px; margin:10px 0 0 10px; overflow:auto;'>
			<span class='style15' style='display:inline-block; font-weight:bold; padding-bottom:10px;'>Total Guests</span>
			<input type='text' name='txtTableGuestsEdit' id='txtTableGuestsEdit' value='".htmlentities($txtTableGuests)."' maxlength='10' style='font-size:13px; width:100px; height:27px; -moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius:5px 5px 5px 5px;' />
		</div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:70px;'>";
			
			
			echo"<button type='button' id='btnGuestsOkEdit' name='btnGuestsOkEdit' onclick='EditGuestTable();return false;' title='Ok'><span><span>Ok</span></span></button>";
			echo"<button type='button' id='btnGuestsExitEdit' name='btnGuestsExitEdit' onclick='CloseGuestsWinEdit();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";
	
// Show List of Item Modifiers
echo"<div id='ItemModifiersDiv' style='position:absolute; display:none; z-index:9999999; width:600px; height:400px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<textarea name='txtModifierNote1' id='txtModifierNote1' rows='4' cols='35' style='display:none;' ></textarea>
		<div id='ItemModifiersDiv-1' style='position:relative; float:left; clear:both; height:350px; margin:10px 0 0 10px; overflow:auto;'></div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:80px;'>
			<button type='button' id='btnModDone' name='btnModDone' onclick=\"SubmitRecord('$CashReg_ForcingVendor','$txtSubGroup'); return false;\" title='Done'><span><span>Done</span></span></button>
		</div>
	</div>";
	
// Show List of Hold Items
echo"<div id='FireItemsDiv' style='position:absolute; display:none; z-index:9999999; width:350px; height:300px; border:2px solid #E6E6E6; background-color:#F7F7F7;'>
		<span class='style15' style='display:block; font-weight:bold; padding:5px 0 0 5px;'>Hold Items</span>
		<input type='hidden' name='SelFireItems' id='SelFireItems' value=''>
		<div id='FireItemsDiv-1' style='position:relative; float:left; clear:both; width:330px; height:225px; margin:10px 0 0 10px; overflow-y:auto; border:1px solid #E6E6E9;'></div>	
		<div style='position:relative; float:center; clear:both; padding-top:10px; margin-left:130px;'>
			<button type='button' id='btnFireOk' name='btnFireOk' onclick=\"ControlOrderItem(5,'".$txtId."',1); return false;\" title='Fire'><span><span>Fire</span></span></button>
			<button type='button' id='btnFireExit' name='btnFireExit' onclick='CloseFireWin();return false;' title='Close'><span><span>Close</span></span></button>
		</div>
	</div>";

if ($message != '') {

	echo '<script type="text/javascript" language="javascript">
			x=document.retail; 
			
			var vMainMode = x.mainaction.value;
			var vMode     = x.actionmode.value;
			var vRetId    = x.txtId.value;
			var vMsg      = x.message.value;
			
			alert(vMsg); 
			
			x.message.value="";
			x.action="Form_Retail.php?actionmode="+vMode+"&mainaction="+vMainMode+"&txtId="+vRetId;
			x.submit(); 
	</script>';
	
	//$message = '';
}

if ($PrRetId != '') {
	$query    = " SELECT Sale_Reference FROM Retail  ".
                " WHERE Sale_id = $PrRetId ";
	$result   = selectData($connection, $query);
	$PrRetRef = $result[0];
	
	if ($CashRegister_SlipPrinter == 1) 
		$ReportName = 'Form_RetailSlip.php';
	else 
		$ReportName = 'Form_RetailPreview.php';
	
	echo '<script type="text/javascript" language="javascript">';
	
	if ($CashRegister_Printer == 1 && $noprint != 1) {
		echo ' PrintRetail(\''.$PrRetId.'\', \''.$PrRetRef.'\', \''.$FC_CashRegisterAskPrint.'\', \''.$ReportName.'\', \''.$Module_RestaurantDelivery.'\', \''.$CashRegister_SlipCopy.'\'); ';
	}
	if ($CashRegister_SlipKitchen == 1 && $noprint != 1) {
		echo ' PrintRetailCopy(\''.$PrRetId.'\'); ';
	}
	echo ' ClearPage1(); ';
	echo '</script>';

}	
if($keyboardfocus == 1){
echo" <script>
$(document).keydown(function (e) {
	
	if($('#HoldDiv:visible').length == 0){ 
	
	$('#txtItemQty').focus();

    var key = e.keyCode;

    if (((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode== 46)) && ($('#txtItemQty').is(':focus'))) {
		var dd = String.fromCharCode(key);
	} else if(e.keyCode == 27) {
		document.getElementById('txtItemQty').value='';
		$('#txtItemBarcode').focus();
   }else if(e.keyCode== 189) {
	   document.getElementById('txtItemQty').value='';
	  
   }
   else $('#txtItemBarcode').focus();
	}
});

$(document).keyup(function (e) { 
if($('#HoldDiv:visible').length == 0){ 
	$('#txtItemBarcode').focus(); 
}
	});
	
  </script>";
}
/*
print <<<HERE
<script type="text/javascript" language="javascript">

Win_Employee = window.open('Form_CallerId.php?fromcallerid=1','CallerId', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=760,height=520,left=250,top=200');		
	Win_Employee.creator = self;
	

</script>
HERE;
*/



function ConvertCurrency($FromCurr, $ToCurr, $FromDate, $Amount, $connection)
{
	$query = "SELECT ifNull(convertcurfunc('".$FromCurr."', '".$ToCurr."', '".$FromDate."', 0, 0, '', '', ifNull($Amount,0)),0) From Dual ";
	$result = selectData($connection, $query);
	//echo $query;
	Return	$result[0];

}




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

HERE;

?>