<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");
include("function.inc.php");



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

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

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

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

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

//Read From salessetup Table							
$querysetup= " select VatAccount as VatAccount_Setup from salessetup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}	

 
$query_ledgergrp="select module_ledgergrp from module";
	$resultledgergrp=mysql_query($query_ledgergrp,$connection) or die(mysql_error());
	$row_ledger=mysql_fetch_row($resultledgergrp);
	$module_ledgergrp=$row_ledger[0];
	
	
//User Access
$querylog=" select ifNull(FI_GroupingApp,0) As FI_GroupingApp, ifNull(FI_GroupingDel,0) As FI_GroupingDel, ".
          " ifNull(FI_GroupingMod,0) As FI_GroupingMod,language 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);
}
	
$querylang="select  language,group_code,vat_account,chk_GeneralAccount,rawmat_account,
currency,nonrawmat_account,rawmatttc_account,
nonrawmatttc_account,disc_account,rawmat_account2,nonrawmat_account2,tips_account,
export_account,stockcurrency,
debit_account,credit_account,debit_account2,credit_account2,nonvatacc,vatacc,direct_stock
 from ".$_SESSION['dbLabel'].".transactionsetup_label where language='$language'";

//echo $querylang;
$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
		//extract($rows);
		
		$codegroup=$rows[1];
		$vataccount=$rows[2];
		$generalcheck=$rows[3];
		
		$rowmatacc=$rows[4];
		$currency_account=$rows[5];
		$nonrawmat_acc1=$rows[6];
		$rowmattt_acc=$rows[7];
		
		$nonrowmattt_acc=$rows[8];
		$discacc=$rows[9];
		$rowmatacc2=$rows[10];
		$nonrawmat_acc2=$rows[11];
		$tipsaccount1=$rows[12];
		$accountexp=$rows[13];
		
		$currencyStock=$rows[14];
		$debitacc1=$rows[15];
		$creditacc1=$rows[16];
		$debitacc2=$rows[17];
		$creditacc2=$rows[18];
		$nonvatacc=$rows[19];
		$vatacc=$rows[20];
		$directstock=$rows[21];
		$nonrowmatacc1=$rows[22];
		$nonrowmatacc2=$rows[23];
		

		
	}




	
$querylang="select  language,Group_CreationDate,Group_Code, Group_Name, Group_Commission, Group_discountPer,grouping_groupcode2,grouping_ledgernumber2,
			inventory_ledger,Revenue_ledger,Discount_Ledger,Charge_ledger,Promotion_ledger,Vat_ledger,grouping_pricelist  
			from ".$_SESSION['dbLabel'].".grouping_label where language='$language'";

//echo $querylang;
$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
		//extract($rows);
		
		$groupcreationdate=$rows[1];
		$groupcode=$rows[2];
		$groupname=$rows[3];
		
		$groupcomm=$rows[4];
		$groupdiscper=$rows[5];
		$groupcodecode2=$rows[6];
		$groupledgernum2=$rows[7];
		$invenledger=$rows[8];
		$revenueledger=$rows[9];
		$ledgerdisc=$rows[10];
		
		$ledgercharge=$rows[11];
		$ledgerpromotion=$rows[12];
		$ledgervat=$rows[13];
		$grouppricelist=$rows[14];
		

		
	}

$querylang="select language, buttonclear, save, print, find, clear, results, page from ".$_SESSION['dbLabel'].".buttons_label 
where language='$language'";


$resultlang=mysql_query($querylang,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlang)){
		//extract($rows);
		
		$buttonclear=$rows[1];
		$save=$rows[2];
		$print=$rows[3];
		$find=$rows[4];
		$clear=$rows[5];
		$results=$rows[6];
		$page=$rows[7];
		
	}

	



$actionmode   = $_POST["actionmode"]; if ($actionmode == ""){$actionmode = $_GET["actionmode"];}   
$mode   	  = $_POST["mode"]; if ($mode == ""){$mode = $_GET["mode"];}   
$message 	  = $_POST["message"]; if ($message == ""){$message = $_GET["message"];}   
$Increment    = $_POST["Increment"]; if ($Increment == ""){$Increment = $_GET["Increment"];} 
$Increment2   = $_POST["Increment2"]; if ($Increment2 == ""){$Increment2 = $_GET["Increment2"];} 
$Group_Code2  = $_POST["Group_Code2"]; if ($Group_Code2 == ""){$Group_Code2 = $_GET["Group_Code2"];} 
$auto   	  = $_POST["auto"]; if ($auto == ""){$auto = $_GET["auto"];} 
$showtrans    = $_POST["showtrans"]; if ($showtrans == ""){$showtrans = $_GET["showtrans"];} 

$txtKeyword  = $_POST["txtKeyword"]; if ($txtKeyword == ""){$txtKeyword = $_GET["txtKeyword"];}   
$perpage 	 = $_POST["perpage"]; if ($perpage == ""){$perpage = $_GET["perpage"];} 
$startrange	 = $_POST["startrange"]; if ($startrange == ""){$startrange = $_GET["startrange"];} 
$txtKeyword2 = $_POST["txtKeyword2"]; if ($txtKeyword2 == ""){$txtKeyword2 = $_GET["txtKeyword2"];}   
$perpage2 	 = $_POST["perpage2"]; if ($perpage2 == ""){$perpage2 = $_GET["perpage2"];} 
$startrange2 = $_POST["startrange2"]; if ($startrange2 == ""){$startrange2 = $_GET["startrange2"];} 
$vTabFocus   = $_POST["vTabFocus"]; if ($vTabFocus == ""){$vTabFocus = $_GET["vTabFocus"];} 

$Group_CreationDate	= $_POST["Group_CreationDate"]; if ($Group_CreationDate == ""){$Group_CreationDate = $_GET["Group_CreationDate"];} 
$Group_Code    		= $_POST["Group_Code"]; if ($Group_Code == ""){$Group_Code = $_GET["Group_Code"];} 
$Group_Name 		= $_POST["Group_Name"]; if ($Group_Name == ""){$Group_Name = $_GET["Group_Name"];} 
$Group_Commission 	= $_POST["Group_Commission"]; if ($Group_Commission == ""){$Group_Commission = $_GET["Group_Commission"];} 
$Group_discountPer 	= $_POST["Group_discountPer"]; if ($Group_discountPer == ""){$Group_discountPer = $_GET["Group_discountPer"];} 
$inventory_ledger 	= $_POST["inventory_ledger"]; if ($inventory_ledger == ""){$inventory_ledger = $_GET["inventory_ledger"];} 
$charge_ledger 		= $_POST["charge_ledger"]; if ($charge_ledger == ""){$charge_ledger = $_GET["charge_ledger"];} 
$revenue_ledger 	= $_POST["revenue_ledger"]; if ($revenue_ledger == ""){$revenue_ledger = $_GET["revenue_ledger"];} 
$promotion_ledger 	= $_POST["promotion_ledger"]; if ($promotion_ledger == ""){$promotion_ledger = $_GET["promotion_ledger"];} 
$discount_ledger 	= $_POST["discount_ledger"]; if ($discount_ledger == ""){$discount_ledger = $_GET["discount_ledger"];} 
$vat_ledger 		= $_POST["vat_ledger"]; if ($vat_ledger == ""){$vat_ledger = $_GET["vat_ledger"];} 

$transtype 			= $_POST["transtype"]; if ($transtype == ""){$transtype = $_GET["transtype"];} 
$vat_account 		= $_POST["vat_account"]; if ($vat_account == ""){$vat_account = $_GET["vat_account"];} 
$vat_accountname 	= $_POST["vat_accountname"]; if ($vat_accountname == ""){$vat_accountname = $_GET["vat_accountname"];} 
$currency 			= $_POST["currency"]; if ($currency == ""){$currency = $_GET["currency"];} 
$rawmat_account 	= $_POST["rawmat_account"]; if ($rawmat_account == ""){$rawmat_account = $_GET["rawmat_account"];} 
$rawmat_accountname = $_POST["rawmat_accountname"]; if ($rawmat_accountname == ""){$rawmat_accountname = $_GET["rawmat_accountname"];} 
$nonrawmat_account 	= $_POST["nonrawmat_account"]; if ($nonrawmat_account == ""){$nonrawmat_account = $_GET["nonrawmat_account"];} 
$nonrawmat_accountname 		= $_POST["nonrawmat_accountname"]; if ($nonrawmat_accountname == ""){$nonrawmat_accountname = $_GET["nonrawmat_accountname"];} 
$rawmatttc_account 			= $_POST["rawmatttc_account"]; if ($rawmatttc_account == ""){$rawmatttc_account = $_GET["rawmatttc_account"];} 
$rawmatttc_accountname 		= $_POST["rawmatttc_accountname"]; if ($rawmatttc_accountname == ""){$rawmatttc_accountname = $_GET["rawmatttc_accountname"];} 
$nonrawmatttc_account 		= $_POST["nonrawmatttc_account"]; if ($nonrawmatttc_account == ""){$nonrawmatttc_account = $_GET["nonrawmatttc_account"];} 
$nonrawmatttc_accountname 	= $_POST["nonrawmatttc_accountname"]; if ($nonrawmatttc_accountname == ""){$nonrawmatttc_accountname = $_GET["nonrawmatttc_accountname"];} 
$disc_account 			= $_POST["disc_account"]; if ($disc_account == ""){$disc_account = $_GET["disc_account"];} 
$disc_accountname 		= $_POST["disc_accountname"]; if ($disc_accountname == ""){$disc_accountname = $_GET["disc_accountname"];} 
$rawmat_account2 		= $_POST["rawmat_account2"]; if ($rawmat_account2 == ""){$rawmat_account2 = $_GET["rawmat_account2"];} 
$rawmat_accountname2 	= $_POST["rawmat_accountname2"]; if ($rawmat_accountname2 == ""){$rawmat_accountname2 = $_GET["rawmat_accountname2"];} 
$nonrawmat_account2 	= $_POST["nonrawmat_account2"]; if ($nonrawmat_account2 == ""){$nonrawmat_account2 = $_GET["nonrawmat_account2"];} 
$nonrawmat_accountname2	= $_POST["nonrawmat_accountname2"]; if ($nonrawmat_accountname2 == ""){$nonrawmat_accountname2 = $_GET["nonrawmat_accountname2"];} 
$stockcurrency 			= $_POST["stockcurrency"]; if ($stockcurrency == ""){$stockcurrency = $_GET["stockcurrency"];} 
$debit_account 			= $_POST["debit_account"]; if ($debit_account == ""){$debit_account = $_GET["debit_account"];} 
$debit_accountname 		= $_POST["debit_accountname"]; if ($debit_accountname == ""){$debit_accountname = $_GET["debit_accountname"];} 
$credit_account 		= $_POST["credit_account"]; if ($credit_account == ""){$credit_account = $_GET["credit_account"];} 
$credit_accountname 	= $_POST["credit_accountname"]; if ($credit_accountname == ""){$credit_accountname = $_GET["credit_accountname"];} 
$tips_account 			= $_POST["tips_account"]; if ($tips_account == ""){$tips_account = $_GET["tips_account"];} 
$tips_accountname	 	= $_POST["tips_accountname"]; if ($tips_accountname == ""){$tips_accountname = $_GET["tips_accountname"];} 


//Access Mode On Insert/Edit/Delete
$InsMode = '';
if ($FI_GroupingApp == 0)
	$InsMode = ' disabled ';

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


class tabs {
	var $name;
	var $tabs;
	var $active;
	var $current;
function start($name){
		if (empty($this->active)){ $this->active = $name; }
		$this->current = $name;
		ob_start();
	}
	function end(){
		$this->tabs[$this->current] = ob_get_contents();
		ob_end_clean();
	}
	function run(){
	
	
	
		if (count($this->tabs) > 0){
			echo "<DIV CLASS='tabs'>\n";
			$jsClear = "";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				$jsClear .= "\tdocument.getElementById('$tabid').className = 'tab_inactive';\n";
				$jsClear .= "\tdocument.getElementById('$contentid').style.display = 'none';\n";
			}
			echo "<script type=\"text/javascript\">\n";
			echo "function tab_".$this->name."(id,fieldname){\n";
			echo "$jsClear";
			
			echo "\tdocument.getElementById('tab_".$this->name."_'+id).className = 'tab_active';\n";
			echo "\tdocument.getElementById('tabcontent_".$this->name."_'+id).style.display = '';\n";
			
			echo"	
				//alert(fieldname);
				if(fieldname!='' && fieldname!=undefined)
					
					document.clientdt[fieldname].focus();
				";
			echo "}\n";
			echo "</script>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV CLASS='";
				if ($this->active == $tabname){ echo "tab_active"; }else{ echo "tab_inactive"; }
				echo "' ID='$tabid' ";
				echo "onClick=\"tab_".$this->name."('$tabname');\">$tabname</DIV>\n";
			}
			echo "<DIV STYLE='float: center; clear:both;'></DIV>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV ID = '$contentid' CLASS='tab_content' STYLE='display: ";
				if ($this->active == $tabname){ echo "block"; }else{ echo "none"; }
				echo ";'>$tabcontent</DIV>\n";
			}
			echo "</DIV>\n";
			echo "<DIV STYLE='clear: both;'></DIV>\n";
		}}
}	


if($mode=='editmode' or $mode=='view'){

	$query_edit=" select Increment, Group_Code, Group_Name, Group_Commission, Group_discountPer, ifNull(Group_Parent,0), date_format(Group_CreationDate,'%d-%m-%Y'),inventory_ledger,".
				" charge_ledger,revenue_ledger,promotion_ledger,discount_ledger,vat_ledger,group_length, grouping_pricelist, grouping.grouping_optionledger, grouping_groupcode2, ".
				" grouping.grouping_ledgernumber2, ledger.ledger_name as LedgerName2, Group_Export, VATonSale_ledger, costAdjust_ledger
				from Grouping left join ledger on ledger.ledger_number = grouping.grouping_ledgernumber2 where Increment='".$Increment."'";

		
	$resultedit = mysql_query($query_edit, $connection);
	while($row=mysql_fetch_array($resultedit)){
        extract($row);
		$Increment			= $row[0];
		$Group_Code			= $row[1];
		$Group_Name			= $row[2];
		$Group_Commission	= $row[3];
		$Group_discountPer	= $row[4];
		$Group_Parent		= $row[5];
        $Group_CreationDate	= $row[6];
		$inventory_ledger	= $row[7];
		$charge_ledger		= $row[8];
		$revenue_ledger		= $row[9];
		$promotion_ledger	= $row[10];
		$discount_ledger	= $row[11];
		$vat_ledger			= $row[12];
		$group_length		= $row[13];
		$VATonSale_ledger	= $row[20];
		$costAdjust_ledger	= $row[21];
	}
	$mode='edit';
}

if($Increment2!=''){

	$query="select group_code from grouping where increment='".$Increment2."'";
	$result = mysql_query($query, $connection);
	$row=mysql_fetch_array($result);
	$Group_Code2=$row[0];
	
	$query="select Trans_VATAccount,Trans_RMAcc,Trans_NonRMAcc,Trans_RMTTCIncAcc,Trans_NonRMTTCIncAcc,Trans_RMVatAcc,Trans_NonRMVatAcc, Trans_DirectStkDbt,Trans_DirectStkCrd,trans_currency, Trans_DirectStkCur,Trans_DiscountAcc,".
			" ledger.ledger_name,ledger1.ledger_name,ledger2.ledger_name,ledger3.ledger_name,ledger4.ledger_name,ledger5.ledger_name,ledger6.ledger_name,ledger7.ledger_name,ledger8.ledger_name, ledger9.ledger_name,ledger10.ledger_name,".
			" auto, Trans_TipsAcc, ledger11.ledger_name, Trans_wasteDifferenceAcc, ledger12.ledger_name, Trans_wasteDebitAcc, ledger13.ledger_name, trans_wastecreditacc, ledger14.ledger_name , chk_GeneralAccount, ".
			" transactionsetup.trans_export, ledger15.ledger_name as ExportName, ledger_costAcc, ledger16.ledger_name ".
			" from transactionsetup ".
			" left join ledger on ledger.ledger_number=transactionsetup.Trans_VATAccount ".
			" left join ledger as ledger1 on ledger1.ledger_number=transactionsetup.Trans_RMAcc ".
			" left join ledger as ledger2 on ledger2.ledger_number=transactionsetup.Trans_NonRMAcc ".
			" left join ledger as ledger3 on ledger3.ledger_number=transactionsetup.Trans_RMTTCIncAcc ".
			" left join ledger as ledger4 on ledger4.ledger_number=transactionsetup.Trans_NonRMTTCIncAcc ".
			" left join ledger as ledger5 on ledger5.ledger_number=transactionsetup.Trans_RMVatAcc ".
			" left join ledger as ledger6 on ledger6.ledger_number=transactionsetup.Trans_NonRMVatAcc ".
			" left join ledger as ledger7 on ledger7.ledger_number=transactionsetup.Trans_DirectStkDbt ".
			" left join ledger as ledger8 on ledger8.ledger_number=transactionsetup.Trans_DirectStkCrd ".
			" left join ledger as ledger9 on ledger9.ledger_number=transactionsetup.Trans_DirectStkCur ".
			" left join ledger as ledger10 on ledger10.ledger_number=transactionsetup.Trans_DiscountAcc ".
			" left join ledger as ledger11 on ledger11.ledger_number=transactionsetup.Trans_TipsAcc ".
			" left join ledger as ledger12 on ledger12.ledger_number=transactionsetup.Trans_wasteDifferenceAcc ".
			" left join ledger as ledger13 on ledger13.ledger_number=transactionsetup.Trans_wasteDebitAcc ".
			" left join ledger as ledger14 on ledger14.ledger_number=transactionsetup.trans_wastecreditacc ".
			" left join ledger as ledger15 on ledger15.ledger_number=transactionsetup.trans_export ".
			" left join ledger as ledger16 on ledger16.ledger_number=transactionsetup.ledger_costAcc ".
			" where group_code='".$Group_Code2."' and Journal_type='".$transtype."'";
	//echo$query;
	$result = mysql_query($query, $connection);
	$row=mysql_fetch_array($result);
	extract($row);
	$vat_account			=	$row[0];
	$rawmat_account			=	$row[1];
	$nonrawmat_account		=	$row[2];
	$rawmatttc_account		=	$row[3];
	$nonrawmatttc_account	=	$row[4];
	$rawmat_account2		=	$row[5];
	$nonrawmat_account2		=	$row[6];
	$debit_account			=	$row[7];
	$credit_account			=	$row[8];
	$currency				=	$row[9];
	$stockcurrency			=	$row[10];
	$disc_account			=	$row[11];
	$tips_account			=	$row[24];
	
	$vat_accountname			=	$row[12];
	$rawmat_accountname			=	$row[13];
	$nonrawmat_accountname		=	$row[14];
	$rawmatttc_accountname		=	$row[15];
	$nonrawmatttc_accountname	=	$row[16];
	$rawmat_accountname2		=	$row[17];
	$nonrawmat_accountname2		=	$row[18];
	$debit_accountname			=	$row[19];
	$credit_accountname			=	$row[20];
	$disc_accountname			=	$row[22];
	$tips_accountname			=	$row[25];
	$export_account				=	$row[26];
	$export_accountname			=	$row[27];
	$debit_account2				=	$row[28];
	$debit_accountname2			=	$row[29];
	$credit_account2			=	$row[30];
	$credit_accountname2		=	$row[31];
	$auto 						= $row[23];
	$chkGeneralAcc				= $row[32];
	$trans_export				= $row[33];
	$trans_export2				= $row[34];
	$ledgerCostAcc				= $row[35];
	$ledgerCostName				= $row[36];
	//echo$auto;
}

if($mode=='') $mode='insert';
if ($VATonSale_ledger == '' && $mode == 'insert')
	$VATonSale_ledger = $VatAccount_Setup;

print <<<HERE

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">

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

<script type="text/javascript" language="javascript">

function ShowListTransaction(){

	x = document.Grouping;
	
	if (x.inventory_ledger.value=='' ) {
		alert ('Please Fill Inventory Ledger');
		document.Grouping.inventory_ledger.focus();
	}	
	else if (x.charge_ledger.value=='' ) {
		alert ('Please Fill Charge Ledger');
		document.Grouping.charge_ledger.focus();
	}
	
	else if (x.revenue_ledger.value=='' ) {
		alert ('Please Fill Revenue Ledger');
		document.Grouping.revenue_ledger.focus();
	}
	else if (x.promotion_ledger.value=='' ) {
		alert ('Please Fill Promotion Ledger');
		document.Grouping.promotion_ledger.focus();
	}
	else if (x.discount_ledger.value=='' ) {
		alert ('Please Fill Discount Ledger');
		document.Grouping.discount_ledger.focus();
	}
	
	else if (x.vat_ledger.value=='' ) {
		alert ('Please Fill Vat Ledger');
		document.Grouping.vat_ledger.focus();
	}
	else {
		
		document.Grouping.action="Form_Grouping_Actions.php?showtrans=1";
		document.Grouping.submit();
	}
}

function CheckCommission() {
	var len;
	len = document.Grouping.Group_Commission.value;
	len = parseInt(len);	
	
	if (len > 100) {
		alert ('Please enter a number less than or equal to 100');
		document.Grouping.Group_Commission.focus();
	}	

}

function CheckDiscount() {
	var len;
	len = document.Grouping.Group_discountPer.value;
	len = parseInt(len);	
	
	if (len > 100) {
		alert ('Please enter a number less than or equal to 100');
		document.Grouping.Group_discountPer.focus();
	}	

}

function editmode () {

	document.Grouping.action="Form_Grouping.php?mode=edit";
	document.Grouping.submit();
}

function AddGroup() {
ClearForm('All');
	document.Grouping.mode.value='insert';
	document.Grouping.action="Form_Grouping.php";
	document.Grouping.submit();
}



function SubmitRecord(option) {
	var x = document.Grouping;
    var module_rawmaterial = document.getElementById('module_rawmaterial').value;
	
	if (document.Grouping.Group_Code.value=='' && option==1)
	{
		alert('Unable to save : check missing field Code ');
			document.Grouping.Group_Code.focus();
		
	}
		
	else 
	if (document.Grouping.Group_Name.value=='' && option==1)
	{
		alert('Unable to save : check missing field Name ');
		document.Grouping.Group_Name.focus();
		
	}
		
	else {
		if(option==2)
			document.Grouping.actionmode.value='submittrans';
		if(option == 1){
			var optionType = '';
			for (var i=0; i < x.option_ledger.length; i++)
			{
				if (x.option_ledger[i].checked)
				{
				  var optionType = x.option_ledger[i].value;
				}
			}
			
			if (optionType == '1' && x.group_code2.value==''){
				alert('Unable to save : check missing field!');
				x.group_code2.focus();
				return 0;
			}
			if (optionType == '2' ){
				if (x.inventory_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.inventory_ledger.focus();
					return 0;
				}
				else if (x.charge_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.charge_ledger.focus();
					return 0;
				}
				else if (x.revenue_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.revenue_ledger.focus();
					return 0;
				}
				else if (x.vat_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.vat_ledger.focus();
					return 0;
				}
				else if (x.VATonSale_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.VATonSale_ledger.focus();
					return 0;
				}
				else if (x.costAdjust_ledger.value == ''){
					alert('Unable to save : check missing field!');
					x.costAdjust_ledger.focus();
					return 0;
				}
			}
		} 
		document.Grouping.action="Form_Grouping_Actions.php?optionType="+optionType;
		document.Grouping.submit();
	}
}


function ClearPage(){
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		cleardetail();
		
		

		x.mode.value='';
		x.action='Form_Grouping.php';
		x.submit();
	}	
}

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.Grouping;
	x.Increment.value			= '';
	x.Group_Code.value			= '';
	x.Group_Name.value			= '';
	x.Group_Commission.value	= '';
	x.Group_discountPer.value	= '';
	x.Group_CreationDate.value	= '';
	x.message.value				= '';
	x.inventory_ledger.value	= '';
	x.revenue_ledger.value		= '';
	x.charge_ledger.value		= '';
	x.vat_ledger.value			= ''; 
	x.discount_ledger.value		= '';
	x.Increment2.value			= '';
	x.VATonSale_ledger.value	= '';
	x.costAdjust_ledger.value	= '';
	x.promotion_ledger.value 	= '';
}

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

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

}

function SetSub(SubId){
	
	document.Grouping.Increment.value=SubId;
	document.Grouping.message.value='';
	document.Grouping.mode.value='';
	
	document.Grouping.mode.value='editmode';
	document.Grouping.submit();
}

function SetSub2(SubId2){
	
	document.Grouping.Increment2.value=SubId2;
	document.Grouping.message.value='';
	
	document.Grouping.mode.value='editmode';
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction';
	document.Grouping.submit();
}

function Refreshpage(){
	
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction';
	document.Grouping.submit();
}


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

function SetNextPage2(startrange,perpage){
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction&startrange2='+startrange+'&perpage2='+perpage;
	document.Grouping.submit();
}

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

function SetPrvPage2(startrange,perpage){
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction&startrange2='+startrange+'&perpage2='+perpage;
	document.Grouping.submit();
}

function SearchForGroup(){
	x = document.Grouping;
	document.Grouping.action='Form_Grouping.php?startrange=0';
	document.Grouping.submit();
}

function SearchForSup2(){
	x = document.Grouping;
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction&startrange=0';
	document.Grouping.submit();
}

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

function ClearKeyword2(){
	x = document.Grouping;
	x.txtKeyword2.value='';
	document.Grouping.action='Form_Grouping.php?startrange=0&vTabFocus=Transaction';
	document.Grouping.submit();
}



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

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

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

if (keycode == 13)
   {
   	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction&startrange=0';
	document.Grouping.submit();
  
   return false;
   }
else
   return true;
}

function confirm_delete(Code) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		//window.event.returnValue = true;
		document.Grouping.mode.value='delete';	
		
		document.Grouping.action='Form_Grouping_Actions.php?IncrementId='+Code;
		document.Grouping.submit();
	}
					
}

function set_limit(){

	perpage=document.Grouping.perpage.value;
	document.Grouping.action='Form_Grouping.php?perpage='+perpage+'&startrange=0';
	document.Grouping.submit();
}
function set_limit2(){

	perpage2=document.Grouping.perpage2.value;
	document.Grouping.action='Form_Grouping.php?vTabFocus=Transaction&perpage2='+perpage2+'&startrange2=0';
	document.Grouping.submit();
}


function showlistledger(str){

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

function showlistledger2(str){

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

function cleardetail(){
	 x = document.Grouping;
	x.Group_Code2.value='';
	x.vat_account.value='';
	x.rawmat_account.value='';
	x.nonrawmat_account.value='';
	x.rawmatttc_account.value='';
	x.nonrawmatttc_account.value='';
	x.rawmat_account2.value='';
	x.nonrawmat_account2.value='';
	x.debit_account.value='';
	x.credit_account.value='';
	x.tips_account.value='';
	x.currency.value='';
	x.stockcurrency.value='';
	x.disc_account.value='';
	x.vat_accountname.value='';
	x.rawmat_accountname.value='';
	x.nonrawmat_accountname.value='';
	x.rawmatttc_accountname.value='';
	x.nonrawmatttc_accountname.value='';
	x.rawmat_accountname2.value='';
	x.nonrawmat_accountname2.value='';
	x.debit_accountname.value='';
	x.credit_accountname.value='';
	x.disc_accountname.value='';
	x.tips_accountname.value='';
	x.export_account.value='';
	x.export_accountname.value='';
	x.debit_account2.value='';
	x.debit_accountname2.value='';
	x.credit_accountname2.value='';
	x.credit_account2.value='';
	x.trans_export.value = '';
	x.trans_export2.value='';
	x.auto.value='';
	x.chkGeneralAcc.value='';
	x.submit();
	
}	
function CheckPriceList(){
	var x = document.Grouping;
	if(x.chk_pricelist.checked){
		x.grouping_pricelist.value = 1;
	}
	else{
		x.grouping_pricelist.value = 0;
	}
}
function openLedgers(){
	var str = "List_Agents_orderbycode1.php?str=27&index=0&PRef=&ShowDetails=0";
	window.open(str, 'mywindow','width=850,height=400,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}	
function setGenAcc(){
	if(document.getElementById('chkGeneralAcc').checked)
		document.getElementById('chkGeneralAcc').value=1;
	else document.getElementById('chkGeneralAcc').value=0;
}
function CheckGroupExport(){
	var x = document.Grouping;
	if(x.chk_Group_Export.checked){
		x.Group_Export.value = 1;
	}
	else{
		x.Group_Export.value = 0;
	}
}
function chkTransExport(){
	if(document.getElementById('chk_trans_export').checked){
		document.getElementById('trans_export').value = 1;
	}
	else{
		document.getElementById('trans_export').value = 0;
	}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Group</title>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}

.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

</head>
<body >
<form name='Grouping' method='post'>
<input type=hidden name='mode' value='$mode'>
<input type=hidden name='actionmode' value='$actionmode'>
<input type=hidden name='message' value='$message'>
<input type='hidden' name='Increment'  value='$Increment' />
<input type='hidden' name='Increment2'  value='$Increment2' />
<input type='hidden' name='module_rawmaterial'  value='$module_rawmaterial' />
<input type='hidden' name='Group_Code2'  value='$Group_Code2' />
<input type='hidden' name='auto'  value='$auto' />

HERE;


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

}

if($mode=='view'){

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

}

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

//$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>GROUPING</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";


echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='38'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px'>";
echo"		<button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>$buttonclear</span></span></button>";


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


				
echo"   </td><td align='left' width='260px'>
	
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:110px;' onKeyPress='return submitenter(this,event)'>&nbsp;
	<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForGroup(); return false;' title='Search Group'><span><span>find</span></span></button>
	<button type='button' id='btnClear' name='btnClear' onclick='ClearKeyword(); return false;' title='Clear Keyword'><span><span>$clear</span></span></button>
	
	</td><td align='left'><span class='style1'><b>$results/$page</b></span>
	 <span class='style1'><select name='perpage' id='perpage' value='$perpage' onchange=set_limit();>";
	 
	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
		
	for($i=10;$i<=$maxperpage;$i=$i+10){
		if($i==$perpage)
			echo "<option value='$i'  selected>$i</option>";
		else echo "<option value='$i'>$i</option>";
		
	} 
	 echo"</td></tr>";
echo"	</table>";
echo"</td></tr>";

echo"<tr><td id='content-body'>";
$tabs = new tabs("Groups");	
	
$tabs->start("Main Page");

echo"<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
	<col width=65%>";

echo"   <tr bgcolor='#F7F7F7'><td valign='top' >";	   
echo"<table border='0' style='table-layout:fixed' align='left' valign='top'>
     <col width=125>
	<col width=120>
	<col width=120>";
	
echo"<tr bgcolor='#F7F7F7' height='25'>
      <td valign='center' align='left' ><span class='style1'>$groupcreationdate <span class='style26'>*</span></span>";
 echo"</td>";
			 
 if($mode!=''){
	$today = date('d-m-Y');
	$Group_CreationDate = $today;
}			
 echo"<td colspan='3'><input type='text' name='Group_CreationDate' id='Group_CreationDate' value='$Group_CreationDate' style='font-size:12px; width:100px; height:18px;' readonly /> ";
if ($mode!=''){
	$Group_CreationDate = "disabled";
 }
echo" </td></tr>";
echo"<td></td></tr>";

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

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

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>$groupcomm (%)</span>";
echo"<td><input type='text' name='Group_Commission' value='".htmlspecialchars($Group_Commission, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;'  $status maxlength='3' onBlur='CheckCommission();' /></td>";
echo"<td valign='center' align='left' ><span class='style1'>$groupdiscper(%)</span>";
echo"<td><input type='text' name='Group_discountPer' value='".htmlspecialchars($Group_discountPer, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;'  $status maxlength='3'  onBlur='CheckDiscount();' /></td></tr>";


if($Module_AutoItemcode==1){
	echo"<tr bgcolor='#F7F7F7' height=25><td valign='center' align='left' colspan='1'><span class='style1'>Item Length</span></td>";
	echo"<td><input type='text' name='group_length' value='".htmlspecialchars($group_length, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;'  $status maxlength='10' /></td>";
	echo"</tr>";
}

echo"<tr bgcolor='#F7F7F7' height=25><td valign='center' align='left' colspan='4'><span class='style1'>&nbsp;</span></td></tr>";
echo "<input type='hidden' name='module_rawmaterial' id='module_rawmaterial' value='$module_rawmaterial' />";

echo "<tr>
	<td colspan=5><span class='style1'><input type='radio' name='option_ledger' id='option_ledger' value='1'/> $groupcodecode2 
	<select name='group_code2' id='group_code2' style='width: 173px'>
	<option value=''></option>";
$querygroup = "select group_code, group_name from grouping where if (''='', 1=1,group_code <> '') order by group_code";
$resgroup = mysql_query($querygroup, $connection);
while ($rwgroup = mysql_fetch_array($resgroup)){
	echo "<option value='$rwgroup[0]'>$rwgroup[1]</option>";
}	
echo "</select></span></td></tr>";
echo "<tr>
	<td colspan=5><span class='style1'><input type='radio' name='option_ledger' id='option_ledger' value='2' checked /> Enter New Setup
	</td></tr>";
	
//by nadine
/* if($module_rawmaterial == 1){
	echo "<tr>
	<td colspan=5 style='font-size: 12px; font-weight: bold'><input type='radio' name='chk_option_ledger' $checked1 id='check_option_ledger1' onclick=\"chkOptionLedger('1')\" /> $groupcodecode2 <select name='group_code2' id='group_code2' style='width: 173px'>
	<option value=''></option>";
	$query_grouping = "select group_code as GroupCode, group_name as GroupName from grouping where group_code in (SELECT group_code
FROM transactionsetup
WHERE Trans_RMAcc IS NOT NULL
  OR Trans_RMVatAcc IS NOT NULL
  OR Trans_NonRMAcc IS NOT NULL
  OR Trans_NonRMVatAcc IS NOT NULL
  OR Trans_RMTTCIncAcc IS NOT NULL
  OR Trans_NonRMTTCIncAcc IS NOT NULL
  OR Trans_wasteDebitAcc IS NOT NULL
  OR Trans_wasteCreditAcc IS NOT NULL
  OR Trans_wasteDifferenceAcc IS NOT NULL
  OR Trans_DiscountAcc IS NOT NULL
  OR Trans_PromotionAcc IS NOT NULL
  OR Trans_VATAccount IS NOT NULL
  OR trans_Purchasepromotionacc IS NOT NULL
  OR trans_Purchasediscountacc IS NOT NULL
  OR Trans_TipsAcc IS NOT NULL
  OR trans_export IS NOT NULL)";
  $result_grouping = mysql_query($query_grouping, $connection);
  while($row_grouping = mysql_fetch_array($result_grouping)){
	  extract($row_grouping);
	  if($grouping_groupcode2 == $GroupCode)
		  $selected = "selected = 'selected'";
	  else
		  $selected = "";
	  echo "<option value='$GroupCode' $selected>$GroupCode | $GroupName</option>";
  }
	echo"</select></td>
	</tr>";
	echo "<tr>
	<td colspan=5 style='font-size: 12px; font-weight: bold'><input type='radio' name='chk_option_ledger' id='check_option_ledger2' $checked2 onclick=\"chkOptionLedger('2')\" />$groupledgernum2 &nbsp;&nbsp;<input type='text' id='ledger_number2' name='ledger_number2' style='width: 75px' value='$grouping_ledgernumber2' /> <input type='text' name='ledger_name2' id='ledger_name2' style='width: 125px' value='$LedgerName2' /> <img src='img/btnopen.jpg' width=20 style='cursor: pointer; vertical-align: middle' onclick=\"openLedgers()\" /></td>
	</tr>";
	echo "<tr style='height: 13px'>
	<td colspan=5></td>
	</tr>";
}
else{
	echo "<input type='hidden' id='Group_Code2' name='Group_Code2' /><input type='hidden' name='Group_Name2' id='Group_Name2' />";
	echo "<input type='hidden' id='ledger_number2' name='ledger_number2' style='width: 75px' /> <input type='hidden' name='ledger_name2' id='ledger_name2' style='width: 125px' />";
} */
echo"<tr bgcolor='#F7F7F7' height=25><td valign='center' align='left' colspan='4'><span class='style1'>&nbsp;</span></td></tr>";

echo"<tr bgcolor='#F7F7F7' height=25><td valign='center' align='left' colspan='4'><span class='style16'>Ledgers</span></td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>$invenledger</span>";
echo"<td><input type='text' name='inventory_ledger' value='".htmlspecialchars($inventory_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
		<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('1'); return false\" style='cursor: pointer;'>
		</td>";
echo"<td valign='center' align='left' ><span class='style1'>$ledgercharge</span>";
echo"<td><input type='text' name='charge_ledger' value='".htmlspecialchars($charge_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('2'); return false\" style='cursor: pointer;'>
	</td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>$revenueledger</span>";
echo"<td><input type='text' name='revenue_ledger' value='".htmlspecialchars($revenue_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('3'); return false\" style='cursor: pointer;'>
	</td>";
echo"<td valign='center' align='left' ><span class='style1'>$ledgerpromotion</span>";
echo"<td><input type='text' name='promotion_ledger' value='".htmlspecialchars($promotion_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('4'); return false\" style='cursor: pointer;'>
	</td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>$ledgerdisc</span>";
echo"<td><input type='text' name='discount_ledger' value='".htmlspecialchars($discount_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('5'); return false\" style='cursor: pointer;'>
	</td>";
echo"<td valign='center' align='left' ><span class='style1'>$ledgervat</span>";
echo"<td><input type='text' name='vat_ledger' value='".htmlspecialchars($vat_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('6'); return false\" style='cursor: pointer;'>
	</td></tr>";

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>VAT on Sale Acc</span>";
echo"<td><input type='text' name='VATonSale_ledger' value='".htmlspecialchars($VATonSale_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('7'); return false\" style='cursor: pointer;'>
	</td>";
echo"<td valign='center' align='left' ><span class='style1'>Cost Adjustment Acc</span>";
echo"<td><input type='text' name='costAdjust_ledger' value='".htmlspecialchars($costAdjust_ledger, ENT_QUOTES)."' style='font-size:12px; width:99px; height:18px;'  $status maxlength='10' />
	<img src='img/btnopen.jpg' title='Select Raw Material' width='15' height='17' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistledger2('8'); return false\" style='cursor: pointer;'>
	</td></tr>";

echo "<tr style='height: 20px'>
<td></td>
</tr>";

if($Group_Export == "") $Group_Export = 0;
if ($grouping_pricelist == '') $grouping_pricelist = 0;

if (0 == 1){
echo "<tr>
<td><span class='style1'>$grouppricelist</span></td>
<td><input type='checkbox' name='chk_pricelist' onclick=\"CheckPriceList()\" ".($grouping_pricelist == 1?'checked':'')."><input type='hidden' name='grouping_pricelist' value='$grouping_pricelist' ></td>
</tr>";

echo "<tr>
<td><span class='style1'>Export</span></td>
<td><input type='checkbox' name='chk_Group_Export' onclick=\"CheckGroupExport()\" ".($Group_Export == 1?'checked':'')."><input type='hidden' name='Group_Export' value='$Group_Export'></td>
</tr>";
}
else echo "<input type='hidden' name='grouping_pricelist' value='$grouping_pricelist' >
		<input type='hidden' name='Group_Export' value='$Group_Export'>";
echo"</table></td>";

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

echo"<table style='width:380px;' border='0' cellspacing=0><col width=100><col width=150>
	<tr><td id='search-top' style='width:380px;height:15px;' colspan='4'></td>
	</tr>
	 <tr><td  valign='top' colspan=3 id='search-content' style='width:380px;'><table style='width:380px;' border='0' cellspacing=0><col width=30><col width=80><col width=140><col width=130>
	<tr height='30px'><td>&nbsp;</td>
	<td align='center'><span class='style1'><b>$groupcode</b></td><td align='center'><span class='style1'><b>$groupname</b></td></tr>";
	 
	echo"<tr><td colspan=3><div style='overflow-y:scroll;height:320px;width:370px;border:0px solid #000000;padding-left:5px;'><table  border='0' width='352px'>
	<col width=30><col width=160><col width=170>";
	
	$querysearch="select Increment,Group_Code,Group_Name from grouping ";
	$querysearch=$querysearch." where (Group_Code like"."('%".$txtKeyword."%') or Group_Name like"."('%".$txtKeyword."%') ) ";

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
	$totalrows = mysql_num_rows($resultsearch);

	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
	
	$querysearch = $querysearch." limit ".$startrange.",".$perpage;
	

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

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

HERE;
else
	print<<<HERE

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

HERE;

	echo"<td style='cursor:pointer;' ";if($FI_GroupingMod==1) echo " onclick=SetSub('$rows[0]');";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
		<td style='cursor:pointer;' ";if($FI_GroupingMod==1) echo " onclick=SetSub('$rows[0]');";echo"><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[2]&nbsp;</span></font></td>";
	
	echo"	</tr>";
}		
	
echo"</table></div></td></tr>";	
echo"<tr ><td id='search-content' colspan='4'><table width=100% border='0'><tr><td align='center'>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center'>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr></table></td></tr>";

echo"<tr>
					<td id='search-bottom' style='width:380px;height:20px;' colspan='6'></td>
				</tr></table></td></tr>";			
echo"</table></td></tr></table>";

$tabs->end();	


if($module_rawmaterial==1){
	$tabs->start("Transaction");

	echo"<table border='0'  align='left' valign='top'>";
	echo"   <tr  height='25' ><td valign='top' align='center'>";	 	  
	echo"<table border='0'  align='left' valign='top' width=100% cellspacing=0><col width='480'>
	<tr><td valign='top' >";

	echo"<table style='width:390px;' border='0'><col width=230>
	<tr ><td align='left'>
	<input type='text' name='txtKeyword2' value='$txtKeyword2' style='width:100px;' onKeyPress='return submitenter2(this,event)'>
	<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForSup2(); return false;' title='Search Grouping'><span><span>$find</span></span></button>
	<button type='button' id='btnClear' name='btnClear' onclick='ClearKeyword2(); return false;' title='Clear Keyword'><span><span>$clear</span></span></button>
	</td><td align='right'><span class='style1'><b>$results/$page</b></span>
	 <span class='style1'><select name='perpage2' id='perpage2' value='$perpage2' onchange=set_limit2();>";
	 
	if ($startrange2=='')
		$startrange2 = 0;
	if ($perpage2=='')
		$perpage2 = 20;
		
	for($i=10;$i<=$maxperpage;$i=$i+10){
		if($i==$perpage2)
			echo "<option value='$i'  selected>$i</option>";
		else echo "<option value='$i'>$i</option>";
		
	} 
	 echo"</td></tr>
	 <tr><td id='search-top' style='width:380px;height:15px;' colspan='4'></td>
	</tr>
	  <tr><td colspan=2 id='search-content'><table border=0>
	 <tr height='25px'><td align='center'><span class='style1'><b>$groupcode</b></td><td align='center' colspan=2><span class='style1'><b>$groupname</b></td></tr>";
	 
	echo"<tr><td colspan=2 ><div style='overflow-y:scroll;height:340px;width:360px;border:0px solid #000000;padding-left:5px;'><table  border='0' width='340px'>
	<col width=150>";
	
	$querysearch="select Increment,Group_Code,Group_Name from grouping ";
	$querysearch=$querysearch." where (Group_Code like"."('%".$txtKeyword2."%') or Group_Name like"."('%".$txtKeyword2."%') ) ";

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

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());	
	while($rows=mysql_fetch_array($resultsearch)){
		$ct+=1;
		$stylefont='style15';
		if($ct%2==0)
			$Color="style='background-color:".$grid_color1."'";
		else			
			$Color="style='background-color:".$grid_color2."'";	
				
		if($mode=='edit' && $Increment2==$rows[0]){
			
			$Color="style='background-color:#1e87a5'";
			$stylefont='style28';
	}	
		
	echo'<tr '.$Color.' height="20px" >';
	echo"<td style='cursor:pointer;' ";if($FI_GroupingMod==1) echo " onclick=SetSub2('$rows[0]');";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
		<td style='cursor:pointer;' ";if($FI_GroupingMod==1) echo " onclick=SetSub2('$rows[0]');";echo"><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[2]&nbsp;</span></font></td>";
	

	echo"	</tr>";
}		
	echo"</table></div></td></tr>";	
echo"<tr ><td  colspan='4'><table width=100% border='0'><tr><td align='center'>";
		
		$diff= $startrange2 - $perpage2;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange2 - $perpage2;
			echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage2('".$prvstartrange."','".$perpage2."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td >&nbsp;</td><td  align='left' width='150px'>";
		
		
		if ($startrange2 <= $totalrows2){
			$startrange2 = $startrange2 + $perpage2;
			if  ($startrange2 <= $totalrows2)
				echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage2('".$startrange2."','".$perpage2."')>";
		} else
			echo "&nbsp;";
			
			echo"</td></tr></table></td></tr>";
		
echo"</table></td></tr><tr>
					<td id='search-bottom' style='width:380px;height:20px;' colspan='6'></td>
				</tr>";

	echo"</table>";

	$queryjourtype = "select type_name, type_desc from jourtype where ifnull(type_visible,0) = 1 order by type_name";
	$resjourtype = mysql_query($queryjourtype, $connection);
	
	
	echo"</td><td valign='top'><table border=0 width=700px><col width=150><col width=150><tr><td><span class='style1'>Type</span></td>
			<td><select name='transtype' onchange='Refreshpage();'> ";
	while ($rwjour  = mysql_fetch_array($resjourtype)){
		echo "<option value='$rwjour[0]'";if($transtype==$rwjour[0]) echo " selected ";echo">$rwjour[0]|$rwjour[1]</option> ";
		
			/* <option value='PR'";if($transtype=='PR') echo " selected ";echo">PR</option>
			<option value='PD'";if($transtype=='PD') echo " selected ";echo">PD</option>
			<option value='DI'";if($transtype=='DI') echo " selected ";echo">DI</option>
			<option value='DR'";if($transtype=='DR') echo " selected ";echo">DR</option>
			<option value='SI'";if($transtype=='SI') echo " selected ";echo">SI</option>
			<option value='SR'";if($transtype=='SR') echo " selected ";echo">SR</option>
			<option value='AD'";if($transtype=='AD') echo " selected ";echo">AD</option>
			<option value='TR'";if($transtype=='TR') echo " selected ";echo">TR</option>
			<option value='SO'";if($transtype=='SO') echo " selected ";echo">SO</option>
			<option value='FV'";if($transtype=='FV') echo " selected ";echo">FV</option> */
	}		
	echo "</select></td><td align='left'>
			
			<button type='button' id='btnPost' name='btnPost' onclick='SubmitRecord(2); return false;' title='Save Changes' $Insmode><span><span>$save</span></span></button>";
			
			
 
echo"</td></tr>";
if($chkGeneralAcc == '') $chkGeneralAcc=0;
echo "<tr height=25px ><td><span class='style1'>$codegroup</span></td><td colspan=1><span class='style1'><b>$Group_Code2</b></td>
		<td><span class='style1'><input type='checkbox' name='chkGeneralAcc' id='chkGeneralAcc' value='$chkGeneralAcc' onclick=\"setGenAcc();\" ".($chkGeneralAcc == 1?'checked':'').">$generalcheck</span></td></tr>
		<tr height=25px><td><span class='style1'>$vataccount</span></td><td align=left><input type=text name='vat_account' value='$vat_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Vat Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(8); return false' /></span></label>";
	
function get_currency($connection){		
	$query_cr = "select currency_code,currency_name from currency";
	//echo$query_cr;
	$result_cr=mysql_query($query_cr, $connection);
	return $result_cr;
}	
$curr = get_currency($connection);
		
echo"</td><td><input type=text name='vat_accountname' value='$vat_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		
		<tr height=25px><td colspan=2 align='left'><span class='style1'><b><font size=2><u>$nonvatacc :</u></font></b></td><td align='left'><span class='style1'>$currency_account</span>&nbsp;&nbsp;<select  name='currency'  $dis style='width:70px;'>
				<option value=''></option>";
				while ($cr=mysql_fetch_row($curr))
				{
				if ($cr[0]==$currency)
				echo"<option selected value='$cr[0]'>$cr[0]</option>";
				else
				echo"<option value='$cr[0]'>$cr[0]</option>";
				}	
				echo"</td></tr>
		<tr height=25px><td><span class='style1'>$rowmatacc</span></td><td align=left><input type=text name='rawmat_account' value='$rawmat_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Raw Material '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(9); return false' /></span></label>";

echo"</td><td><input type=text name='rawmat_accountname' value='$rawmat_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'>$nonrawmat_acc1</span></td><td align=left><input type=text name='nonrawmat_account' value='$nonrawmat_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Non Raw Material '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(10); return false' /></span></label>";

echo"</td><td><input type=text name='nonrawmat_accountname' value='$nonrawmat_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>

		
<tr height=25px><td><span class='style1'>$rowmattt_acc.</span></td>
		<td align=left><input type=text name='rawmatttc_account' value='$rawmatttc_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select  Raw Material  TTC'  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(11); return false' /></span></label>";

echo"</td><td><input type=text name='rawmatttc_accountname' value='$rawmatttc_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'>$nonrowmattt_acc.</span></td>
		<td align=left><input type=text name='nonrawmatttc_account' value='$nonrawmatttc_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Non Raw Material  TTC'  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(12); return false' /></span></label>";

echo"</td><td><input type=text name='nonrawmatttc_accountname' value='$nonrawmatttc_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'><b><u><font size=2>$discacc :</font></u></b></td>
		<td align=left><input type=text name='disc_account' value='$disc_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Discount Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(17); return false' /></span></label>";

echo"</td><td><input type=text name='disc_accountname' value='$disc_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		
		<tr height=25px><td><span class='style1'><b><font size=2><u>$vatacc :</u></font></b></td></tr>
		<tr height=25px><td><span class='style1'>$rowmatacc</span></td><td align=left><input type=text name='rawmat_account2' value='$rawmat_account2' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Raw Material '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(13); return false' /></span></label>";

echo"</td><td><input type=text name='rawmat_accountname2' value='$rawmat_accountname2'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'>$nonrawmat_acc2</span></td>
		<td align=left><input type=text name='nonrawmat_account2' value='$nonrawmat_account2' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Non Raw Material '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(14); return false' /></span></label>";

$curr = get_currency($connection);

echo"</td><td><input type=text name='nonrawmat_accountname2' value='$nonrawmat_accountname2'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>";
echo "<tr height=25px><td><span class='style1'><b><u><font size=2>$tipsaccount1 :</font></u></b></td>
		<td align=left><input type=text name='tips_account' value='$tips_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Tips Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(25); return false' /></span></label>
		</td><td><input type=text name='tips_accountname' value='$tips_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td>
	</tr>";

echo "<tr height=25px><td><span class='style1'><b><u><font size=2>$accountexp :</font></u></b></td>
		<td align=left><input type=text name='trans_export' value='$trans_export' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;
		<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Tips Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(32); return false' /></span></label>
		</td><td><input type=text name='trans_export2' value='$trans_export2'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td>
	</tr>";	
echo "<tr height=25px><td><span class='style1'><b><u><font size=2>$directstock</font></u></b></td><td align='right'></td><td><span class='style1'>$currencyStock</span>&nbsp;&nbsp;<select  name='stockcurrency'  $dis style='width:70px;'>
				<option value=''></option>";
				while ($cr=mysql_fetch_row($curr))
				{
				if ($cr[0]==$stockcurrency)
				echo"<option selected value='$cr[0]'>$cr[0]</option>";
				else
				echo"<option value='$cr[0]'>$cr[0]</option>";
				}	
				echo"</td></tr>
		<tr height=25px><td><span class='style1'>$debitacc2</span></td><td align=left><input type=text name='debit_account' value='$debit_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Debit Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(15); return false' /></span></label>";

echo"</td><td><input type=text name='debit_accountname' value='$debit_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'>$creditacc1</span></td>
		<td align=left><input type=text name='credit_account' value='$credit_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Credit Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick='showlistledger(16); return false' /></span></label>";

echo"</td><td><input type=text name='credit_accountname' value='$credit_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>";

echo "<tr height=25px><td><span class='style1'>$debitacc2</span></td><td align=left><input type=text name='debit_account2' value='$debit_account2' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Debit Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistledger('29'); return false;\" /></span></label>";

echo"</td><td><input type=text name='debit_accountname2' value='$debit_accountname2'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>
		<tr height=25px><td><span class='style1'>$creditacc2</span></td>
		<td align=left><input type=text name='credit_account2' value='$credit_account2' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Credit Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistledger('30'); return false;\" /></span></label>";

echo"</td><td><input type=text name='credit_accountname2' value='$credit_accountname2'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>";

echo "<tr height=25px><td><span class='style1'>Export</span></td>
		<td align=left><input type=text name='export_account' value='$export_account' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
		
echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Credit Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistledger('28'); return false;\" /></span></label>";

echo"</td><td><input type=text name='export_accountname' value='$export_accountname'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>";

if (($transtype == 'SR' || $transtype == 'SI') && $module_delivery == 1){
	echo "<tr height=25px><td><span class='style1'>Cost Account</span></td>
		<td align=left><input type=text name='ledgerCostAcc' value='$ledgerCostAcc' maxlength='10'  readonly size='10' style='font-size:12px; width:100px; height:18px;'>&nbsp;";
	echo"<label><span class='style1'><img src='img/btnopen.jpg' title=' Select Cost Account '  width='15' height='17' border='0' onMouseOver=\"style.cursor='hand'\" onClick=\"showlistledger('35'); return false;\" /></span></label>";
	echo"</td><td><input type=text name='ledgerCostName' value='$ledgerCostName'   readonly size='10' style='font-size:12px; width:250px; height:18px;'></td></tr>";
} else 
	echo "<input type='hidden' name='ledgerCostAcc' value='$ledgerCostAcc' maxlength='10' ><input type='hidden' name='ledgerCostName' value='$ledgerCostName' maxlength='10' >";
echo "</table></td></tr></table>";
	echo"</div></td></tr></table>";	
	$tabs->end();	

}
	
$tabs->run();	

echo"</td></tr>";				
/*	
echo"<table border=0 align=center width=100%> <tr bgcolor=#D8D8D8 height='35'>";
echo"	<td align=center><input type='button'  value='Add Group'";  	
if($mode=='insert' or $mode=='edit')
	echo "disabled ";
echo"onclick='AddGroup()' $style title='Add Group' $InsMode>&nbsp;";
echo"<input type='button' id='btnClear' name='BtnClear' value='Clear Page'   onclick='ClearPage();' $style title='Clear Page'>&nbsp;";

			
if($mode=='view'){
	echo"<input type='button' name='btnEdit' id='btnEdit' value='Edit' ";//Edit
	echo" onclick='editmode();' $style	title='Edit Group' />";
}
else{
	echo"<input type='button' name='btnPost' id='btnPost' value='Save' ";//post
	if ($mode=='')
		echo " disabled ";
	echo" onclick='SubmitRecord(1);' $style	title='Save Changes' />";
}

echo" <input name='btnPrint' type='button' id='btnPrint' value='Print' onclick='PrintPreview();' $style title='Print' ";
	if ($mode=='edit' or $mode=='insert') echo " disabled ";
		echo" onclick='PrintPreview();' $style	title='Print' />&nbsp;";
	
/*	
echo"<input type='button' name='btntrans' id='btntrans' value='List of Transaction' ";// transaction list
	if ($mode=='' || $mode=='insert' || $mode=='view')
		echo " disabled ";
	echo" onclick='ShowListTransaction();' $style	title='List Of Transactions' />";
	
	echo"</td>";
echo"  </tr></table>";*/
print <<< HERE
       </td>
      </tr>
	  <tr height='30'><td align='center' id='content-bottom' ></td></tr>
	  </table>
HERE;

if($showtrans=='1'){
	echo"<script type='text/javascript'>";
	echo'if (confirm ( "Would you like to create Transaction?")){
	
		var increment=document.Grouping.Increment.value;
		win = window.open("Form_Grouping_TransactionTypes.php?Increment="+increment, "List_transactiontypes", "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=775,height=450,top=100,left=100");		
	}';
	
	echo"</script>";
}


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

HERE;

if($vTabFocus!=''){
	echo'<script type="text/javascript" language="javascript">';
	echo"tab_('$vTabFocus','');";
	echo'</script>';	
}	

?>