<?php
session_start();

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

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

if (!ini_get('register_globals')) {
    $superglobals = array($_SERVER, $_ENV,
        $_FILES, $_COOKIE, $_POST, $_GET);
    if (isset($_SESSION)) {
        array_unshift($superglobals, $_SESSION);
    }
    foreach ($superglobals as $superglobal) {
        extract($superglobal, EXTR_SKIP);
    }
}
//Set Time Execution For the Report
ini_set('max_execution_time', $config['ReportTimeExecution']);

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



$querymodule=" Select ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter, ifnull(Module_class4,0) as Module_class4 ".
			 " From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}


//get Action Mode
$actionmode		= $_GET['actionmode'];

$from_ledger	= $_POST['fromledger'];
$to_ledger		= $_POST['toledger'];

$journal		= $_POST['journal'];
$trans			= $_POST['trans'];
$salesjv		= $_POST['salesjv'];
$purchasejv		= $_POST['purchasejv'];

$item			= $_POST['item'];
$prepayment		= $_POST['prepayment'];
$purchases		= $_POST['purchases'];
$order			= $_POST['order'];

$delivery		= $_POST['delivery'];
$adjustment		= $_POST['adjustment'];
$production 	= $_POST['production'];
$transactionsetup = $_POST['transactionsetup'];

$sales			= $_POST['sales'];


//get items checked tables

$fromitem		= $_POST['fromitem'];
$toitem			= $_POST['toitem'];

$Request		= $_POST['Request'];
$Purchasesorder	= $_POST['Purchasesorder'];
$Order			= $_POST['Order'];
$Delivery		= $_POST['Delivery'];

$Sales			= $_POST['Sales'];
$Transfer		= $_POST['Transfer'];
$Adjustment		= $_POST['Adjustment'];
$Production_item = $_POST['Production_item'];

//echo $Production_item;
//exit;
$Pack			 =$_POST['Pack'];
$Prodrecipe		= $_POST['Prodrecipe'];
$Transaction	= $_POST['Transaction'];
$StockTake		= $_POST['StockTake'];

$filter_id 		= $_POST['filter_id']; 				if($filter_id == '') 		$filter_id 			= $_GET['filter_id'];
$filter_type 	= $_POST['filter_type']; 			if($filter_type == '') 		$filter_type 		= $_GET['filter_type'];
$CrDbType 		= $_POST['CrDbType']; 				if($CrDbType == '') 		$CrDbType 			= $_GET['CrDbType'];
$fromledgercode = $_POST['fromledgercode']; 		if($fromledgercode == '') 	$fromledgercode 	= $_GET['fromledgercode'];
$toledgercode 	= $_POST['toledgercode']; 			if($toledgercode == '') 	$toledgercode 		= $_GET['toledgercode'];

if($CrDbType == '') $CrDbType = "NULL";
else $CrDbType = "'".$CrDbType."'";

$Form_ConstraintId 	= $_POST['Form_ConstraintId'];	if($Form_ConstraintId == '') $Form_ConstraintId = $_GET['Form_ConstraintId'];
$constraint_code 	= $_POST['constraint_code']; 	if($constraint_code == '') 	 $constraint_code 	= $_GET['constraint_code'];
$form_type 			= $_POST['form_type']; 			if($form_type == '') 		 $form_type 		= $_GET['form_type'];
$constaintactive 	= $_POST['constaintactive']; 	if($constaintactive == '')   $constaintactive 	= $_GET['constaintactive'];


if ($actionmode == 'closingVat'){
	$journal_id = 0;
	$ndate = explode("/", $fromvatdate);
	$fromdate = $ndate[2]."-".$ndate[1]."-".$ndate[0];
	
	$ndate = explode("/", $tovatdate);
	$todate = $ndate[2]."-".$ndate[1]."-".$ndate[0];
	
	if($Module_class4 == 1 || $module_ReferenceByCostcenter == 1)
		$moduleCostProj = 1;
	else $moduleCostProj = 0;
	$errorExists = 0;
	//	fbegin();
	$temptrans = "";
	$query = "select Transaction,Debit_LedgerNumber as ledgercode, Credit_LedgerNumber as groupcode from closingtemplate where upper(TRANSACTION_TYPE) = 'VAT' order by Transaction ";
	//echo $query;
	$result = mysql_query($query, $connection);
	while($rw = mysql_fetch_array($result)){
		if($temptrans != $rw[0]) $journal_id = 0;
		
		
		$proc = "call closeVat('$journal_id', '$fromdate', '$todate', '$costcentvat_code', '$rw[1]', '$rw[2]', $moduleCostProj, 0, '".$_SESSION['dbName']."', '".$_SESSION['dbLabel']."','".$_SESSION['useraccount']."', '".$_SESSION['username']."', 0, @id)";		
		//echo $proc;echo "<br>";exit;
		$res = mysql_query($proc, $connection);
		$message = mysql_error();
		 
		$query1 = " select @id from dual ";
		$result1 = mysql_query($query1,$conn);
		$cur1 = mysql_fetch_row($result1);	
		$journal_id = $cur1[0];
		if ($cur1[0] == -2 || $cur1[0] == -1){
			$errorExists = 1;
			$message  = mysql_error($connection); 
			break;
		}	  
	$temptrans = $rw[0];		
	}
	//echo $message;
	/* if($errorExists == 0) fcommit();
	else frollback(); */
	//exit;
	if($message == '')
		header("Location:./Form_utilities.php");
	else header("Location:./Form_utilities.php?message=$message");
	exit;
}
if ($actionmode == 'deleteTemp'){
	$transaction 	= $_GET['transaction'];	
	$ledgercode 	= $_GET['ledgercode'];	
	$groupcode 		= $_GET['groupcode'];	
	
	$delete = "delete from closingtemplate where Debit_LedgerNumber = '$ledgercode' and Credit_LedgerNumber = '$groupcode' and TRANSACTION_TYPE = 'VAT' and Transaction = upper('$transaction') ";
	$result = mysql_query($delete, $connection);
	
	echo "[BRK]";
	draw_closingvat($connection);
exit;	
}

if ($actionmode == 'insertTemp'){
	$transaction 	= $_GET['transaction'];	
	$ledgercode 	= $_GET['ledgercode'];	
	$groupcode 		= $_GET['groupcode'];	
	
	$errorExists = 0; 
	
	$querychkledger = "select 1 from ledger where ifnull(ledger_grpdet,0) = 0 and ledger_number = '$ledgercode'";
	$reschkledger = mysql_query($querychkledger, $connection);
	$rwledger = mysql_fetch_row($reschkledger);
	
	if ($rwledger[0] != 1){
		$errorExists = 1;
		$message = "Please Check Ledger Code Submitted!";
	}
	
	$querychkgrp = "select 1 from ledger where ifnull(ledger_grpdet,0) = 1 and ledger_number = '$groupcode'";
	$reschkgrp = mysql_query($querychkgrp, $connection);
	$rwgrp = mysql_fetch_row($reschkgrp);
	
	if ($rwgrp[0] != 1){
		$errorExists = 1;
		$message = "Please Check Group Code Submitted!";
	}
	
	if ($errorExists == 0)	{
		$queryChk = "select 1 from closingtemplate where  upper(TRANSACTION_TYPE) = 'VAT' and Debit_LedgerNumber = '$ledgercode' and Credit_LedgerNumber = '$groupcode';";
		$resChk = mysql_query($queryChk, $connection);
		$rwChk = mysql_fetch_row($resChk);
		
		if ($rwChk[0] == 1) {
			$update = "update closingtemplate set Transaction = upper('$transaction') where Debit_LedgerNumber = '$ledgercode' and Credit_LedgerNumber = '$groupcode' and TRANSACTION_TYPE = 'VAT' ";
			$result = mysql_query($update, $connection);
		} else {
			$insert = "insert into closingtemplate(Transaction, Debit_LedgerNumber, Credit_LedgerNumber, Synchronized, TRANSACTION_TYPE) 
						values (upper('$transaction'), '$ledgercode', '$groupcode', 0, 'VAT') ";
			$result = mysql_query($insert, $connection);
		}
	}
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	draw_closingvat($connection);
exit;	
}
if($actionmode == 'insertConstraint' && $Form_ConstraintId ==''){
	$search = "select 1 from Form_Constraint where constraint_typeId = $constraint_code and form_type = '$form_type' ";
	$res = mysql_query($search,$connection);
	$numr = mysql_num_rows($res);
	if($numr == 0){
		$insert = " insert into Form_Constraint (constraint_typeId, form_type, constraint_active) values ".
				  " ($constraint_code, '$form_type', $constaintactive )";
		$result = mysql_query($insert,$connection);		  
	} else {
		$message = "Error! Constraint Already Exists for Form $form_type!";
	}
	if($message == '')
		header('Location:form_utilities.php');
	else header("Location:form_utilities.php?message=$message");
	exit;
} else if($actionmode == 'updateConstraint' && $Form_ConstraintId !=''){
	$search = "select 1 from Form_Constraint where constraint_typeId = $constraint_code and form_type = '$form_type' and  Form_ConstraintId != $Form_ConstraintId";
	$res = mysql_query($search,$connection);
	$numr = mysql_num_rows($res);
	if($numr == 0){
		$update = " update Form_Constraint set constraint_typeId = $constraint_code , form_type = '$form_type', constraint_active = $constaintactive ".
				  " where Form_ConstraintId = $Form_ConstraintId ";
		$result = mysql_query($update,$connection);		  
	} else {
		$message = "Error! Constraint Already Exists for Form $form_type!";
	}
	if($message == '')
		header('Location:form_utilities.php');
	else header("Location:form_utilities.php?message=$message");
	exit;
} else if($actionmode == 'deleteConstraint' && $Form_ConstraintId !=''){
	
		$delete = " delete from Form_Constraint where Form_ConstraintId = $Form_ConstraintId ";
		$result = mysql_query($delete,$connection);		  
	
		$message =  mysql_query($update,$connection);	
	
	if($message == '')
		header('Location:form_utilities.php');
	else header("Location:form_utilities.php?message=$message");
	exit;
}
if ($actionmode == 'filtertab' && $filter_id =='' ){
	$query = "select 1 from ledgerFilter where filter_type = '$filter_type' and filter_CrDb = $CrDbType and  fromledgercode = '$fromledgercode' and toledgercode = '$toledgercode' ";
	$result = mysql_query($query, $connection);
	$numrow = mysql_num_rows($result);
	if($numrow == 0){
		$query = " insert into ledgerFilter (filter_type, filter_CrDb, fromledgercode, toledgercode) values ".
				 " ( '$filter_type', $CrDbType, '$fromledgercode', '$toledgercode' ) ";
		$res = mysql_query($query,$connection);
	} else {
		$message = "From/To ledgers already exists for this type!";		
	}	
	if($message == '')
		header('Location:form_utilities.php');
	else header("Location:form_utilities.php?message=$message");
	exit;
} 

else if($actionmode == 'filtertab' && $filter_id != ''){
	$querychk = "select 1 from ledgerFilter where filter_type = '$filter_type' and filter_CrDb = $CrDbType and  fromledgercode = '$fromledgercode' and toledgercode = '$toledgercode'  and filter_id = $filter_id ";
	$reschk = mysql_query($querychk,$connection);
	$numrow = mysql_num_rows($reschk);
	if($numrow == 0){
		$querychk2 = "select 1 from ledgerFilter where filter_type = '$filter_type' and filter_CrDb = $CrDbType and  fromledgercode = '$fromledgercode' and toledgercode = '$toledgercode'  ";
		$reschk2 = mysql_query($querychk2,$connection);
		$numrow2 = mysql_num_rows($reschk2);
		if($numrow2 == 0){
			$query = "update ledgerFilter set  filter_type = '$filter_type', filter_CrDb = $CrDbType, fromledgercode = '$fromledgercode', toledgercode = '$toledgercode'  where filter_id = $filter_id ";
			$res = mysql_query($query,$connection);
		} else $message = "Cannot Update! From/To ledgers already exists for this type!";		
	}
	if($message == '')
		header('Location:form_utilities.php');
	else header("Location:form_utilities.php?message=$message");
	exit;
} 
else if($actionmode == 'deletefilter' && $filter_id != ''){
	$query = "delete from ledgerFilter where filter_id = $filter_id ";
	$res = mysql_query($query,$connection);
	header('Location:form_utilities.php');
	exit;
}
	if($actionmode == 'changeledger'){
		
		if($journal=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(ledger_number) AS row_number1  from journaldt where ledger_number='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables journaldt
		$query_ledger_form="update journaldt set ledger_number='$to_ledger' where ledger_number='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		}
		
		
		if($trans=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(ledger_number) AS row_number2  from transdt where ledger_number='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
		//update ledger from tables transdt
		$query_ledger_form="update transdt set Ledger_number='$to_ledger' where Ledger_number='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		//exit;
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		}
		
		
		if($salesjv=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Client_Code) AS row_number3  from salesjv where Client_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables salesjv / salesjvdt
		$query_ledger_form="update salesjv set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Client_Code) AS row_number31  from salesjvdt where Client_Code='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
		$query_ledger_form2="update salesjvdt set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form2."<br>";
		$result_ledger_form2=mysql_query($query_ledger_form2,$connection) or die ("Could not find DB");
		
		}
		
		
		if($purchasejv=='on'){
			
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Supplier_Code) AS row_number4  from purchasesjv where Supplier_Code='$from_ledger' "; 
			//echo $query_count."<br>";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			//echo $result_count;
			while($count_ledger_number2=mysql_fetch_array($result_count)){
					extract($count_ledger_number2);
			}
			//echo $row_number4;
			//update ledger from tables purchasesjv /  purchasesjvdt
			$query_ledger_form="update purchasesjv set Supplier_Code='$to_ledger' where Supplier_Code='$from_ledger' "; 
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(ledger_number) AS row_number41  from purchasesjvdt where ledger_number='$from_ledger'";
		//	echo $query_count1;
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			//echo $query_count1;
			$query_ledger_form3="update purchasesjvdt set ledger_number='$to_ledger' where ledger_number='$from_ledger' ";
			//echo $query_ledger_form3."<br>";
			$result_ledger_form3 =mysql_query($query_ledger_form3,$connection) or die ("Could not find DB");
		}
		
		
		
		if($item=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(ledger_number) AS row_number5  from itemjour where ledger_number='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables itemjour
		$query_ledger_form="update itemjour set ledger_number='$to_ledger' where ledger_number='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		}
			
			
		
		if($prepayment=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(ledger_number) AS row_number6  from prepaymentm where ledger_number='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables prepaymentm / prepaymentd
		$query_ledger_form="update prepaymentm set ledger_number='$to_ledger' where ledger_number='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count1="select  COUNT(ledger_number) AS row_number61  from prepaymentd where ledger_number='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
		$query_ledger_form2="update prepaymentd set ledger_number='$to_ledger' where ledger_number='$from_ledger' ";
		//echo $query_ledger_form2."<br>";
		$result_ledger_form2 =mysql_query($query_ledger_form2,$connection) or die ("Could not find DB");
		}
		
	
		if($purchases=='on'){ 
		//count how many recorde updated in each table 
			$query_count="select  COUNT(Supplier_Code) AS row_number7  from grnpurchases where Supplier_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables grnpurchases /  grnpurchasesdt /  purchases / purchasesdt / porder / porderdt
		$query_ledger_form="update grnpurchases set Supplier_Code='$to_ledger' where Supplier_Code='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count1="select  COUNT(Supplier_Code) AS row_number71  from grnpurchasesdt where Supplier_Code='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
		$query_ledger_form0="update grnpurchasesdt set Supplier_Code='$to_ledger' where Supplier_Code='$from_ledger' ";
		//echo $query_ledger_form0."<br>";
		$result_ledger_form0 =mysql_query($query_ledger_form0,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count2="select  COUNT(Supplier_Code) AS row_number72  from purchases where Supplier_Code='$from_ledger'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB");
			while($count_ledger_number2=mysql_fetch_array($result_count2)){
					extract($count_ledger_number2);
			}
			
		$query_ledger_form1="update purchases set Supplier_Code='$to_ledger' where Supplier_Code='$from_ledger' ";
		//echo $query_ledger_form1."<br>";
		$result_ledger_form1 =mysql_query($query_ledger_form1,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count3="select  COUNT(Supplier_Code) AS row_number73  from purchasesdt where Supplier_Code='$from_ledger'";
			$result_count3=mysql_query($query_count3,$connection) or die ("Could not find DB");
			while($count_ledger_number3=mysql_fetch_array($result_count3)){
					extract($count_ledger_number3);
			}
			
		$query_ledger_form2="update purchasesdt set Supplier_Code='$to_ledger' where Supplier_Code='$from_ledger' ";
		//echo $query_ledger_form2."<br>";
		$result_ledger_form2 =mysql_query($query_ledger_form2,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count4="select  COUNT(Supplier_code) AS row_number74  from porder where Supplier_code='$from_ledger'";
			$result_count4=mysql_query($query_count4,$connection) or die ("Could not find DB");
			while($count_ledger_number4=mysql_fetch_array($result_count4)){
					extract($count_ledger_number4);
			}
			
		$query_ledger_form3="update porder set Supplier_code='$to_ledger' where Supplier_code='$from_ledger' ";
		//echo $query_ledger_form3."<br>";
		$result_ledger_form3 =mysql_query($query_ledger_form3,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count5="select  COUNT(Supplier_code) AS row_number75  from porderdt where Supplier_code='$from_ledger'";
			$result_count5=mysql_query($query_count5,$connection) or die ("Could not find DB");
			while($count_ledger_number5=mysql_fetch_array($result_count5)){
					extract($count_ledger_number5);
			}
			
		$query_ledger_form4="update porderdt set Supplier_code='$to_ledger' where Supplier_code='$from_ledger' ";
		//echo $query_ledger_form4."<br>";
		$result_ledger_form4 =mysql_query($query_ledger_form4,$connection) or die ("Could not find DB");
		}
			
		
		
		if($order=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Client_Code) AS row_number8  from sorder where Client_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables sorder / sorderdt
		$query_ledger_form="update sorder set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count1="select  COUNT(Client_Code) AS row_number81  from sorderdt where Client_Code='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
		$query_ledger_form2="update sorderdt set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form2."<br>";
		$result_ledger_form2 =mysql_query($query_ledger_form2,$connection) or die ("Could not find DB");
		}
		
		
		if($delivery=='on'){
			
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Client_Code) AS row_number9  from deliveries where Client_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables deliveries / deliverydt
			$query_ledger_form="update deliveries set Client_code='$to_ledger' where Client_code='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Client_Code) AS row_number91  from deliverydt where Client_Code='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
			$query_ledger_form="update deliverydt set Client_code='$to_ledger' where Client_code='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		}
		
		
		if($adjustment=='on'){
			
			//count how many recorde updated in each table 
		/*	$query_count="select  COUNT(Invdebitaccount) AS row_number10  from adjustment where Invdebitaccount='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB1");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			//echo $query_count;
			//update ledger from tables adjustment / adjustmentdt
			$query_ledger_form="update adjustment set Invdebitaccount='$to_ledger' where Invdebitaccount='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB2");
		
			//count how many recorde updated in each table 
		    $query_count1="select  COUNT(AdjustmentDt_DirectStkDbt) AS row_number101  from adjustmentdt where AdjustmentDt_DirectStkDbt='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB3");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
			$query_ledger_form1="update adjustmentdt set AdjustmentDt_DirectStkDbt='$to_ledger' where AdjustmentDt_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form1 =mysql_query($query_ledger_form1 , $connection) or die ("Could not find DB4");
			*/
			//count how many recorde updated in each table 
			$query_count2="select  COUNT(AdjustmentDt_DirectStkDbt) AS row_number102  from adjustmentdt where AdjustmentDt_DirectStkDbt='$from_ledger'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB5");
			while($count_ledger_number2=mysql_fetch_array($result_count2)){
					extract($count_ledger_number2);
			}
			
			$query_ledger_form2="update adjustmentdt set AdjustmentDt_DirectStkDbt='$to_ledger' where AdjustmentDt_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form2 =mysql_query($query_ledger_form2) or die ("Could not find DB6");
			
			//count how many recorde updated in each table 
			$query_count3="select  COUNT(AdjustmentDt_DirectStkCrd) AS row_number103  from adjustmentdt where AdjustmentDt_DirectStkCrd='$from_ledger'";
			$result_count3=mysql_query($query_count3,$connection) or die ("Could not find DB8");
			while($count_ledger_number3=mysql_fetch_array($result_count3)){
					extract($count_ledger_number3);
			}
			
			$query_ledger_form3="update adjustmentdt set AdjustmentDt_DirectStkCrd='$to_ledger' where AdjustmentDt_DirectStkCrd='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form3 =mysql_query($query_ledger_form3) or die ("Could not find DB9");
		}
		
		
		if($production=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Client_Code) AS row_number11  from production where Client_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB1");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables production / productiondt / productionrm / productionfg
			$query_ledger_form="update production set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB2");
		
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(ProductionDt_DirectStkDbt) AS row_number111  from productiondt where ProductionDt_DirectStkDbt='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB3");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
			$query_ledger_form2="update productiondt set ProductionDt_DirectStkDbt='$to_ledger' where ProductionDt_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form2."<br>";
			$result_ledger_form2 =mysql_query($query_ledger_form2,$connection) or die ("Could not find DB4");
		
			//count how many recorde updated in each table 
			$query_count2="select  COUNT(ProductionDt_DirectStkCrd) AS row_number112  from productionrm where ProductionDt_DirectStkCrd='$from_ledger'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB5");
			while($count_ledger_number2=mysql_fetch_array($result_count2)){
					extract($count_ledger_number2);
			}
			
			$query_ledger_form3="update productionrm set ProductionDt_DirectStkCrd='$to_ledger' where ProductionDt_DirectStkCrd='$from_ledger' ";
			//echo $query_ledger_form3."<br>";
			$result_ledger_form3 =mysql_query($query_ledger_form3,$connection) or die ("Could not find DB6");
		
			//count how many recorde updated in each table 
			$query_count3="select  COUNT(ProductionRM_ItemAccount) AS row_number113  from productionrm where ProductionRM_ItemAccount='$from_ledger'";
			$result_count3=mysql_query($query_count3,$connection) or die ("Could not find DB7");
			while($count_ledger_number3=mysql_fetch_array($result_count3)){
					extract($count_ledger_number3);
			}
			
			$query_ledger_form4="update productionrm set ProductionRM_ItemAccount='$to_ledger' where ProductionRM_ItemAccount='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form4 =mysql_query($query_ledger_form4,$connection) or die ("Could not find DB8");
			
			//count how many recorde updated in each table 
			$query_count4="select  COUNT(ProductionRM_DirectStkDbt) AS row_number114  from productionrm where ProductionRM_DirectStkDbt='$from_ledger'";
			$result_count4=mysql_query($query_count4,$connection) or die ("Could not find DB9");
			while($count_ledger_number4=mysql_fetch_array($result_count4)){
					extract($count_ledger_number4);
			}
			
			$query_ledger_form5="update productionrm set ProductionRM_DirectStkDbt='$to_ledger' where ProductionRM_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form5 =mysql_query($query_ledger_form5,$connection) or die ("Could not find DB10");
			
			//count how many recorde updated in each table 
			$query_count6="select  COUNT(ProductionRM_DirectStkCrd) AS row_number115  from productionrm where ProductionRM_DirectStkCrd='$from_ledger'";
			$result_count6=mysql_query($query_count6,$connection) or die ("Could not find DB");
			while($count_ledger_number6=mysql_fetch_array($result_count6)){
					extract($count_ledger_number6);
			}
			
			$query_ledger_form6="update productionrm set ProductionRM_DirectStkCrd='$to_ledger' where ProductionRM_DirectStkCrd='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form6 =mysql_query($query_ledger_form6,$connection) or die ("Could not find DB12");
			
			//count how many recorde updated in each table 
			$query_count7="select  COUNT(ProductionRM_WasteDebit) AS row_number116  from productionrm where ProductionRM_WasteDebit='$from_ledger'";
			$result_count7=mysql_query($query_count7,$connection) or die ("Could not find DB12");
			while($count_ledger_number7=mysql_fetch_array($result_count7)){
					extract($count_ledger_number7);
			}
			//echo $row_number116." --)ss";
			$query_ledger_form70="update productionrm set ProductionRM_WasteDebit='$to_ledger' where ProductionRM_WasteDebit='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form70 =mysql_query($query_ledger_form70,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count70="select  COUNT(ProductionRM_WasteCredit) AS row_number117  from productionrm where ProductionRM_WasteCredit='$from_ledger'";
			$result_count70=mysql_query($query_count70,$connection) or die ("Could not find DB");
			while($count_ledger_number70=mysql_fetch_array($result_count70)){
					extract($count_ledger_number70);
			}
			
			$query_ledger_form7="update productionrm set ProductionRM_WasteCredit='$to_ledger' where ProductionRM_WasteCredit='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form7 =mysql_query($query_ledger_form7,$connection) or die ("Could not find DB");
			
			//Productionfg
			
			//count how many recorde updated in each table 
			$query_count8="select  COUNT(ProductionFG_ItemAccount) AS row_number118  from productionfg where ProductionFG_ItemAccount='$from_ledger'";
			$result_count8=mysql_query($query_count8,$connection) or die ("Could not find DB");
			while($count_ledger_number8=mysql_fetch_array($result_count8)){
					extract($count_ledger_number8);
			}
			
			$query_ledger_form8="update productionfg set ProductionFG_ItemAccount='$to_ledger' where ProductionFG_ItemAccount='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form8 =mysql_query($query_ledger_form8,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count9="select  COUNT(ProductionFG_DirectStkDbt) AS row_number119  from productionfg where ProductionFG_DirectStkDbt='$from_ledger'";
			$result_count9=mysql_query($query_count9,$connection) or die ("Could not find DB");
			while($count_ledger_number9=mysql_fetch_array($result_count9)){
					extract($count_ledger_number9);
			}
			
			$query_ledger_form9="update productionfg set ProductionFG_DirectStkDbt='$to_ledger' where ProductionFG_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form9."<br>";
			$result_ledger_form9 =mysql_query($query_ledger_form9,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count10="select  COUNT(ProductionFG_DirectStkCrd) AS row_number120  from productionfg where ProductionFG_DirectStkCrd='$from_ledger'";
			$result_count10=mysql_query($query_count10,$connection) or die ("Could not find DB");
			while($count_ledger_number10=mysql_fetch_array($result_count10)){
					extract($count_ledger_number10);
			}
			
			$query_ledger_form10="update productionfg set ProductionFG_DirectStkCrd='$to_ledger' where ProductionFG_DirectStkCrd='$from_ledger' ";
			//echo $query_ledger_form10."<br>";
			$result_ledger_form10=mysql_query($query_ledger_form10,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count11="select  COUNT(ProductionFG_WasteDebit) AS row_number121  from productionfg where ProductionFG_WasteDebit='$from_ledger'";
			$result_count11=mysql_query($query_count11,$connection) or die ("Could not find DB");
			while($count_ledger_number11=mysql_fetch_array($result_count11)){
					extract($count_ledger_number11);
			}
			
			$query_ledger_form11="update productionfg set ProductionFG_WasteDebit='$to_ledger' where ProductionFG_WasteDebit='$from_ledger' ";
			//echo $query_ledger_form11."<br>";
			$result_ledger_form11=mysql_query($query_ledger_form11,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count12="select  COUNT(ProductionFG_WasteCredit) AS row_number122  from productionfg where ProductionFG_WasteCredit='$from_ledger'";
			$result_count12=mysql_query($query_count12,$connection) or die ("Could not find DB");
			while($count_ledger_number12=mysql_fetch_array($result_count12)){
					extract($count_ledger_number12);
			}
			
			$query_ledger_form12="update productionfg set ProductionFG_WasteCredit='$to_ledger' where ProductionFG_WasteCredit='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form12=mysql_query($query_ledger_form12,$connection) or die ("Could not find DB");
			
		}
		

				
		if($transactionsetup=='on'){
			
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Trans_RMAcc) AS row_number12 from transactionsetup where Trans_RMAcc='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form="update transactionsetup set Trans_RMAcc='$to_ledger' where Trans_RMAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
			
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Trans_RMVatAcc) AS row_number121 from transactionsetup where Trans_RMVatAcc='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form1="update transactionsetup set Trans_RMVatAcc='$to_ledger' where Trans_RMVatAcc='$from_ledger' ";
			//echo $query_ledger_form1."<br>";
			$result_ledger_form1 =mysql_query($query_ledger_form1,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count2="select  COUNT(Trans_NonRMAcc) AS row_number122 from transactionsetup where Trans_NonRMAcc='$from_ledger'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB");
			while($count_ledger_number2=mysql_fetch_array($result_count2)){
					extract($count_ledger_number2);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form2="update transactionsetup set Trans_NonRMAcc='$to_ledger' where Trans_NonRMAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form2=mysql_query($query_ledger_form2,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count3="select  COUNT(Trans_NonRMVatAcc) AS row_number123 from transactionsetup where Trans_NonRMVatAcc='$from_ledger'";
			$result_count3=mysql_query($query_count3,$connection) or die ("Could not find DB");
			while($count_ledger_number3=mysql_fetch_array($result_count3)){
					extract($count_ledger_number3);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form3="update transactionsetup set Trans_NonRMVatAcc='$to_ledger' where Trans_NonRMVatAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form3=mysql_query($query_ledger_form3,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count4="select COUNT(Trans_RMTTCIncAcc) AS row_number124 from transactionsetup where Trans_RMTTCIncAcc='$from_ledger'";
			$result_count4=mysql_query($query_count4,$connection) or die ("Could not find DB");
			while($count_ledger_number4=mysql_fetch_array($result_count4)){
					extract($count_ledger_number4);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form4="update transactionsetup set Trans_RMTTCIncAcc='$to_ledger' where Trans_RMTTCIncAcc='$from_ledger' ";
			//echo $query_ledger_form4."<br>";
			$result_ledger_form4=mysql_query($query_ledger_form4) or die ("Could not find DB");
			
						
			//count how many recorde updated in each table 
			$query_count5="select  COUNT(Trans_NonRMTTCIncAcc) AS row_number125 from transactionsetup where Trans_NonRMTTCIncAcc='$from_ledger'";
			$result_count5=mysql_query($query_count5,$connection) or die ("Could not find DB");
			while($count_ledger_number5=mysql_fetch_array($result_count5)){
					extract($count_ledger_number5);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form5="update transactionsetup set Trans_NonRMTTCIncAcc='$to_ledger' where Trans_NonRMTTCIncAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form5=mysql_query($query_ledger_form5,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count6="select  COUNT(Trans_DirectStkDbt) AS row_number126 from transactionsetup where Trans_DirectStkDbt='$from_ledger'";
			$result_count6=mysql_query($query_count6,$connection) or die ("Could not find DB");
			while($count_ledger_number6=mysql_fetch_array($result_count6)){
					extract($count_ledger_number6);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form6="update transactionsetup set Trans_DirectStkDbt='$to_ledger' where Trans_DirectStkDbt='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form6=mysql_query($query_ledger_form6,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count7="select  COUNT(Trans_DirectStkCrd) AS row_number127 from transactionsetup where Trans_DirectStkCrd='$from_ledger'";
			$result_count7=mysql_query($query_count7,$connection) or die ("Could not find DB");
			while($count_ledger_number7=mysql_fetch_array($result_count7)){
					extract($count_ledger_number7);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form7="update transactionsetup set Trans_DirectStkCrd='$to_ledger' where Trans_DirectStkCrd='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form7=mysql_query($query_ledger_form7,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count8="select  COUNT(CEP_CreditAcc) AS row_number128 from transactionsetup where CEP_CreditAcc='$from_ledger'";
			$result_count8=mysql_query($query_count8,$connection) or die ("Could not find DB");
			while($count_ledger_number8=mysql_fetch_array($result_count8)){
					extract($count_ledger_number8);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form8="update transactionsetup set CEP_CreditAcc='$to_ledger' where CEP_CreditAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form8=mysql_query($query_ledger_form8,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count9="select  COUNT(Trans_wasteDebitAcc) AS row_number129 from transactionsetup where Trans_wasteDebitAcc='$from_ledger'";
			$result_count9=mysql_query($query_count9,$connection) or die ("Could not find DB");
			while($count_ledger_number9=mysql_fetch_array($result_count9)){
					extract($count_ledger_number9);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form9="update transactionsetup set Trans_wasteDebitAcc='$to_ledger' where Trans_wasteDebitAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form9=mysql_query($query_ledger_form9,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count10="select  COUNT(Trans_wasteCreditAcc) AS row_number1290 from transactionsetup where Trans_wasteCreditAcc='$from_ledger'";
			$result_count10=mysql_query($query_count10,$connection) or die ("Could not find DB");
			while($count_ledger_number10=mysql_fetch_array($result_count10)){
					extract($count_ledger_number10);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form10="update transactionsetup set Trans_wasteCreditAcc='$to_ledger' where Trans_wasteCreditAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form10=mysql_query($query_ledger_form10,$connection) or die ("Could not find DB");
			
			
			//count how many recorde updated in each table 
			$query_count11="select  COUNT(Trans_wasteDifferenceAcc) AS row_number1291 from transactionsetup where Trans_wasteDifferenceAcc='$from_ledger'";
			$result_count11=mysql_query($query_count11,$connection) or die ("Could not find DB");
			while($count_ledger_number11=mysql_fetch_array($result_count11)){
					extract($count_ledger_number11);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form11="update transactionsetup set Trans_wasteDifferenceAcc='$to_ledger' where Trans_wasteDifferenceAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form11=mysql_query($query_ledger_form11,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count12="select  COUNT(Trans_DiscountAcc) AS row_number1292 from transactionsetup where Trans_DiscountAcc='$from_ledger'";
			$result_count12=mysql_query($query_count12,$connection) or die ("Could not find DB");
			while($count_ledger_number12=mysql_fetch_array($result_count12)){
					extract($count_ledger_number12);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form12="update transactionsetup set Trans_DiscountAcc='$to_ledger' where Trans_DiscountAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form12=mysql_query($query_ledger_form12,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count13="select  COUNT(Trans_PromotionAcc) AS row_number1293 from transactionsetup where Trans_PromotionAcc='$from_ledger'";
			$result_count13=mysql_query($query_count13,$connection) or die ("Could not find DB");
			while($count_ledger_number13=mysql_fetch_array($result_count13)){
					extract($count_ledger_number13);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form13="update transactionsetup set Trans_PromotionAcc='$to_ledger' where Trans_PromotionAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form13=mysql_query($query_ledger_form13,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count14="select  COUNT(Trans_VATAccount) AS row_number1294 from transactionsetup where Trans_VATAccount='$from_ledger'";
			$result_count14=mysql_query($query_count14,$connection) or die ("Could not find DB");
			while($count_ledger_number14=mysql_fetch_array($result_count14)){
					extract($count_ledger_number14);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form14="update transactionsetup set Trans_VATAccount='$to_ledger' where Trans_VATAccount='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form14=mysql_query($query_ledger_form14,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count15="select  COUNT(trans_Purchasepromotionacc) AS row_number1295 from transactionsetup where trans_Purchasepromotionacc='$from_ledger'";
			$result_count15=mysql_query($query_count15,$connection) or die ("Could not find DB");
			while($count_ledger_number15=mysql_fetch_array($result_count15)){
					extract($count_ledger_number15);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form15="update transactionsetup set trans_Purchasepromotionacc='$to_ledger' where trans_Purchasepromotionacc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form15=mysql_query($query_ledger_form15,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count16="select  COUNT(trans_Purchasediscountacc) AS row_number1296 from transactionsetup where trans_Purchasediscountacc='$from_ledger'";
			$result_count16=mysql_query($query_count16,$connection) or die ("Could not find DB");
			while($count_ledger_number16=mysql_fetch_array($result_count16)){
					extract($count_ledger_number16);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form16="update transactionsetup set trans_Purchasediscountacc='$to_ledger' where trans_Purchasediscountacc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form16=mysql_query($query_ledger_form16,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count17="select  COUNT(Trans_TipsAcc) AS row_number1297 from transactionsetup where Trans_TipsAcc='$from_ledger'";
			$result_count17=mysql_query($query_count17,$connection) or die ("Could not find DB");
			while($count_ledger_number17=mysql_fetch_array($result_count17)){
					extract($count_ledger_number17);
			}
			//update ledger from tables transactionsetup
			$query_ledger_form17="update transactionsetup set Trans_TipsAcc='$to_ledger' where Trans_TipsAcc='$from_ledger' ";
			//echo $query_ledger_form."<br>";
			$result_ledger_form17=mysql_query($query_ledger_form17,$connection) or die ("Could not find DB");
		}
		
		if($sales=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Client_Code) AS row_number13 from sales where Client_Code='$from_ledger'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
			while($count_ledger_number=mysql_fetch_array($result_count)){
					extract($count_ledger_number);
			}
			
			//update ledger from tables sales / salesdt
		$query_ledger_form="update sales set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form."<br>";
		$result_ledger_form =mysql_query($query_ledger_form,$connection) or die ("Could not find DB");
		
		//count how many recorde updated in each table 
			$query_count1="select  COUNT(Client_Code) AS row_number131 from salesdt where Client_Code='$from_ledger'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
			while($count_ledger_number1=mysql_fetch_array($result_count1)){
					extract($count_ledger_number1);
			}
			
		$query_ledger_form1="update salesdt set Client_Code='$to_ledger' where Client_Code='$from_ledger' ";
		//echo $query_ledger_form1."<br>";
		$result_ledger_form1 =mysql_query($query_ledger_form1,$connection) or die ("Could not find DB");
			
		}
	
		/* echo 		$row_number1."<br>".$row_number2."<br>".$row_number3."<br>".
					$row_number31."<br>".$row_number4."<br>".$row_number41."<br>".
					$row_number5."<br>".$row_number6."<br>".$row_number61."<br>".
					$row_number7."<br>".$row_number71."<br>".$row_number72."<br>".
					$row_number73."<br>".$row_number74."<br>".$row_number75."<br>".
					$row_number8."<br>".$row_number81."<br>".$row_number9."<br>".
					$row_number91."<br>".$row_number10."<br>".$row_number101."<br>".
					$row_number102."<br>".$row_number103."<br>".$row_number11."<br>".
					$row_number111."<br>".$row_number112."<br>".$row_number113."<br>".
					$row_number114."<br>".$row_number115."<br>".$row_number116."<br>".
					$row_number117."<br>".$row_number118."<br>".$row_number119."<br>".
					$row_number120."<br>".$row_number121."<br>".$row_number122."<br>".
					$row_number12."<br>".$row_number121."<br>".$row_number122."<br>".
					$row_number123."<br>".$row_number124."<br>".$row_number125."<br>".
					$row_number126."<br>".$row_number127."<br>".$row_number128."<br>".
					$row_number129."<br>".$row_number1290."<br>".$row_number1291."<br>".
					$row_number1292."<br>".$row_number1293."<br>".$row_number1294."<br>".
					$row_number1295."<br>".$row_number1296."<br>".$row_number1297."<br>".
					$row_number13."<br>".$row_number131."<br>";
				exit; */

		header('Location:form_utilities.php?&journal='.$journal.'&trans='.$trans.'&salesjv='.$salesjv.'&purchasejv='.$purchasejv.'&item='.$item.'&prepayment='.$prepayment.'&purchases='.$purchases.'&order='.$order.
		'&delivery='.$delivery.'&adjustment='.$adjustment.'&production='.$production.'&transactionsetup='.$transactionsetup.'&sales='.$sales.
		'&row_number1='.$row_number1.'&row_number2='.$row_number2.'&row_number3='.$row_number3.'&row_number31='.$row_number31.'&row_number4='.$row_number4.
		'&row_number41='.$row_number41.'&row_number5='.$row_number5.'&row_number6='.$row_number6.'&row_number61='.$row_number61.'&row_number7='.$row_number7.
		'&row_number71='.$row_number71.'&row_number72='.$row_number72.'&row_number73='.$row_number73.'&row_number74='.$row_number74.'&row_number75='.$row_number75.
		'&row_number8='.$row_number8.'&row_number81='.$row_number81.'&row_number9='.$row_number9.'&row_number91='.$row_number91.'&row_number10='.$row_number10.
		'&row_number101='.$row_number101.'&row_number102='.$row_number102.'&row_number103='.$row_number103.'&row_number11='.$row_number11.'&row_number111='.$row_number111.'&row_number112='.$row_number112.'&row_number113='.$row_number113.
		'&row_number114='.$row_number114.'&row_number115='.$row_number115.'&row_number116='.$row_number116.
		'&row_number117='.$row_number117.'&row_number113='.$row_number118.'&row_number113='.$row_number118.
		'&row_number119='.$row_number119.'&row_number120='.$row_number120.'&row_number121='.$row_number121.
		'&row_number122='.$row_number122.
		'&row_number12='.$row_number12.'&row_number121='.$row_number121.'&row_number122='.$row_number122.
		'&row_number123='.$row_number123.'&row_number124='.$row_number124.'&row_number125='.$row_number125.
		'&row_number126='.$row_number126.'&row_number127='.$row_number127.'&row_number128='.$row_number128.
		'&row_number129='.$row_number129.'&row_number1290='.$row_number1290.'&row_number1291='.$row_number1291.
		'&row_number1292='.$row_number1292.'&row_number1293='.$row_number1293.'&row_number1294='.$row_number1294.
		'&row_number1295='.$row_number1295.'&row_number1296='.$row_number1296.'&row_number1277='.$row_number1297.
		'&row_number13='.$row_number13.'&row_number131='.$row_number131);
	}

	
	if($actionmode == 'changeitem'){

		if($Request=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item1  from prequestdt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update prequestdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			$query_delete_item = "delete from items where item_code='$fromitem'";
			
		}
		
		if($Purchasesorder=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item2  from porderdt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update porderdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item21  from grnpurchasesdt where Item_code='$fromitem'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update grnpurchasesdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form1."<br>";
			$result_item_form1 =mysql_query($query_item_form1,$connection) or die ("Could not find DB");
			
			
			//count how many recorde updated in each table 
			$query_count2="select  COUNT(Item_code) AS row_number_item22  from purchasesdt where Item_code='$fromitem'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB");
				while($count_Item_number2=mysql_fetch_array($result_count2)){
						extract($count_Item_number2);
				}
				
			//update ledger from tables journaldt
			$query_item_form2="update purchasesdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form2 =mysql_query($query_item_form2,$connection) or die ("Could not find DB");
				
		}
		
		
		if($Order=='on'){
				//count how many recorde updated in each table 
				$query_count="select  COUNT(Item_code) AS row_number_item3  from sorderdt where Item_code='$fromitem'";
				$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
					while($count_Item_number=mysql_fetch_array($result_count)){
							extract($count_Item_number);
					}
					
				//update ledger from tables journaldt
				$query_item_form="update sorderdt set Item_code='$toitem' where Item_code='$fromitem' ";
				//echo $query_item_form."<br>";
				$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
		}
		
		
		if($Delivery=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item4 from deliverydt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update deliverydt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//retail
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item4 from retaildt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update retaildt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item41  from deliveriedqty where Item_code='$fromitem'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update deliveriedqty set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form1."<br>";
			$result_item_form1 =mysql_query($query_item_form1,$connection) or die ("Could not find DB");
		}
		
		if($Sales=='on'){
				//count how many recorde updated in each table 
				$query_count="select  COUNT(Item_code) AS row_number_item5  from salesdt where Item_code='$fromitem'";
				$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
					while($count_Item_number=mysql_fetch_array($result_count)){
							extract($count_Item_number);
					}
					
				//update ledger from tables journaldt
				$query_item_form="update salesdt set Item_code='$toitem' where Item_code='$fromitem' ";
				//echo $query_item_form."<br>";
				$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
		}
		
		
		if($Transfer=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item6 from transferdt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update transferdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item61  from transferrequestdt where Item_code='$fromitem'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update transferrequestdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form1."<br>";
			$result_item_form1 =mysql_query($query_item_form1,$connection) or die ("Could not find DB");
		}
		
		if($Adjustment=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item7 from adjustmentdt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update adjustmentdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item71  from adjustmentrequestdt where Item_code='$fromitem'";
			//echo $query_count1;
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update adjustmentrequestdt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form1."<br>";
			$result_item_form1 =mysql_query($query_item_form1,$connection) or die ("Could not find DB");
		}
		
		
		if($Production_item=='on'){ 
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item8  from production where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
				
			//update ledger from tables journaldt
			$query_item_form="update production set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item81  from productiondt where Item_code='$fromitem'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update productiondt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form1."<br>";
			$result_item_form1 =mysql_query($query_item_form1,$connection) or die ("Could not find DB");
			
			
			//count how many recorde updated in each table 
			$query_count2="select  COUNT(Item_code) AS row_number_item82  from productionfg where Item_code='$fromitem'";
			$result_count2=mysql_query($query_count2,$connection) or die ("Could not find DB");
				while($count_Item_number2=mysql_fetch_array($result_count2)){
						extract($count_Item_number2);
				}
				
			//update ledger from tables journaldt
			$query_item_form2="update productionfg set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form2 =mysql_query($query_item_form2,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count3="select  COUNT(Item_code) AS row_number_item83  from productionrm where Item_code='$fromitem'";
			$result_count3=mysql_query($query_count3,$connection) or die ("Could not find DB");
				while($count_Item_number3=mysql_fetch_array($result_count3)){
						extract($count_Item_number3);
				}
				
			//update ledger from tables journaldt
			$query_item_form3="update productionrm set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form3 =mysql_query($query_item_form3,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count4="select  COUNT(Item_code) AS row_number_item84  from preproduction where Item_code='$fromitem'";
			$result_count4=mysql_query($query_count4,$connection) or die ("Could not find DB");
				while($count_Item_number4=mysql_fetch_array($result_count4)){
						extract($count_Item_number4);
				}
				
			//update ledger from tables journaldt
			$query_item_form4="update preproduction set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form4 =mysql_query($query_item_form4,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count5="select  COUNT(Item_code) AS row_number_item85  from preproductiondt where Item_code='$fromitem'";
			$result_count5=mysql_query($query_count5,$connection) or die ("Could not find DB");
				while($count_Item_number5=mysql_fetch_array($result_count5)){
						extract($count_Item_number5);
				}
				
			//update ledger from tables journaldt
			$query_item_form5="update preproductiondt set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form5 =mysql_query($query_item_form5,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count6="select  COUNT(Item_code) AS row_number_item86  from productionreqfg where Item_code='$fromitem'";
			$result_count6=mysql_query($query_count6,$connection) or die ("Could not find DB");
				while($count_Item_number6=mysql_fetch_array($result_count6)){
						extract($count_Item_number6);
				}
				
			//update ledger from tables journaldt
			$query_item_form6="update productionreqfg set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form6 =mysql_query($query_item_form6,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count7="select  COUNT(Item_code) AS row_number_item87  from productionreqrm where Item_code='$fromitem'";
			$result_count7=mysql_query($query_count7,$connection) or die ("Could not find DB");
				while($count_Item_number7=mysql_fetch_array($result_count7)){
						extract($count_Item_number7);
				}
				
			//update ledger from tables journaldt
			$query_item_form7="update productionreqrm set Item_code='$toitem' where Item_code='$fromitem' ";
			//echo $query_item_form2."<br>";
			$result_item_form7=mysql_query($query_item_form7,$connection) or die ("Could not find DB");
		}
		
		if($Pack=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item9  from packdt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update packdt set Item_code='$toitem', Item_CodePackDt='$toitem' where Item_code='$fromitem'";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
		}
	
		
		if($Prodrecipe=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item10  from prodrecipefg where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update prodrecipefg set Item_code='$toitem' where Item_code='$fromitem'";
			//echo $query_item_form."<br>";
			//exit;
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			
			//count how many recorde updated in each table 
			$query_count1="select  COUNT(Item_code) AS row_number_item101  from prodreciperm where Item_code='$fromitem'";
			$result_count1=mysql_query($query_count1,$connection) or die ("Could not find DB");
				while($count_Item_number1=mysql_fetch_array($result_count1)){
						extract($count_Item_number1);
				}
				
			//update ledger from tables journaldt
			$query_item_form1="update prodreciperm set Item_code='$toitem' where Item_code='$fromitem'";
			//echo $query_item_form."<br>";
			$result_item_form1=mysql_query($query_item_form1,$connection) or die ("Could not find DB");
		}
		
		
		if($Transaction=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item11  from stktransaction where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update stktransaction set Item_code='$toitem'  where Item_code='$fromitem'";
			//echo $query_item_form."<br>";
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
		}
		if($StockTake=='on'){
			//count how many recorde updated in each table 
			$query_count="select  COUNT(Item_code) AS row_number_item12  from stocktakedt where Item_code='$fromitem'";
			$result_count=mysql_query($query_count,$connection) or die ("Could not find DB");
				while($count_Item_number=mysql_fetch_array($result_count)){
						extract($count_Item_number);
				}
				
			//update ledger from tables journaldt
			$query_item_form="update stocktakedt set Item_code='$toitem' where Item_code='$fromitem'";
			//echo $query_item_form."<br>";
			//exit;
			$result_item_form =mysql_query($query_item_form,$connection) or die ("Could not find DB");
			

		}
		//echo $_GET['updateall'];exit;
		if($_GET['updateall']=='true'){
		$query_delete_item = "delete from items where item_code='$fromitem'";
		$result_delete_item =mysql_query($query_delete_item,$connection) or die ("Could not find DB111");
		}
			//Request  Purchasesorder Order Delivery Sales Transfer Adjustment Production Pack  Prodrecipe Transaction	

			 /* 	echo	$row_number_item1."<br>".$row_number_item2."<br>".$row_number_item21."<br>".
						$row_number_item3."<br>".$row_number_item4."<br>".$row_number_item41."<br>".
						$row_number_item5."<br>".$row_number_item6."<br>".$row_number_item61."<br>".
						$row_number_item7."<br>".$row_number_item71."<br>".$row_number_item8."<br>".
						$row_number_item81."<br>".$row_number_item82."<br>".$row_number_item83."<br>".
						$row_number_item84."<br>".$row_number_item85."<br>".$row_number_item86."<br>".
						$row_number_item87."<br>".$row_number_item9."<br>".$row_number_item10."<br>".
						$row_number_item101."<br>".$row_number_item11."<br>";
				exit;  */
				
	header('Location:form_utilities.php?&Request='.$Request.'&Purchasesorder='.$Purchasesorder.'&Order='.$Order.'&Delivery='.$Delivery.'&Sales='.$Sales.'&Transfer='.$Transfer.'&Adjustment='.$Adjustment.'&Production_item='.$Production_item.
		'&Pack='.$Pack.'&Prodrecipe='.$Prodrecipe.'&Transaction='.$Transaction.
		'&row_number_item1='.$row_number_item1.'&row_number_item2='.$row_number_item2.'&row_number_item21='.$row_number_item21.'&row_number_item22='.$row_number_item22.'&row_number_item3='.$row_number_item3.'&row_number_item4='.$row_number_item4.
		'&row_number_item41='.$row_number_item41.'&row_number_item5='.$row_number_item5.'&row_number_item6='.$row_number_item6.'&row_number_item61='.$row_number_item61.'&row_number_item7='.$row_number_item7.
		'&row_number_item71='.$row_number_item71.'&row_number_item8='.$row_number_item8.'&row_number_item81='.$row_number_item81.'&row_number_item82='.$row_number_item82.'&row_number_item83='.$row_number_item83.'&row_number_item84='.$row_number_item84.'&row_number_item85='.$row_number_item85.
		'&row_number_item86='.$row_number_item86.'&row_number_item87='.$row_number_item87.'&row_number_item9='.$row_number_item9.'&row_number_item10='.$row_number_item10.'&row_number_item101='.$row_number_item101.
		'&row_number_item11='.$row_number_item11.'&row_number_item12='.$row_number_item12);		
			
			//exit;	

}
?>