<?php
   session_start();
   if($_SESSION['dbName']==""){
   header("location:../index.php");
   }
   
   define("_DEBUG",       "DEBUG MODE ON");
define("_PRODUCTION",  "DEBUG MODE OFF");
///////////////////////////////////////////   
$_mode = _DEBUG;   // Set mode to production after debug is finished
$_showhiddeninputs = 0; //show hidden inputs 1/0 only will work in debug mode 
   
 

 
 
if ($_mode == _DEBUG) 
{

///////////////////////////////////////////////////////////
error_reporting (E_ALL ^ E_NOTICE ^ E_WARNING);
///////////////////////////////////////////////////////////
ini_set('display_errors', TRUE); // Error display
ini_set('log_errors', TRUE); // Error logging
ini_set('error_log', '../notice-logs.log'); // Logging file   // ../  to create file in main root cz ususaly root is contract
ini_set('log_errors_max_len', 10240); // Logging file size
///////////////////////////////////////////////////////////
}

global $_mode;




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

   //User Access
	$querylog=" select ifNull(login_belongstogrp,0) As FI_BelongsToGrp from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
	$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlog)){
		extract($rows);
	}
	
	//Read From Module Table
	$querymodule=" Select ifNull(module_ReferenceByCostcenter,0) As module_ReferenceByCostcenter From Module ";
	$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
	while($rowmodule=mysql_fetch_array($resultmodule)){
		extract($rowmodule);
	}	
   $actionmode=$_GET['actionmode'];
   $Tabnumber = $_POST['Tabnumber']; if($Tabnumber == "") $Tabnumber = $_GET['Tabnumber'];
   
 
   //tab generalsetup    from table setup
   $COMPANY_NAME=$_POST['COMPANY_NAME41']; $Company_memo=$_POST['Company_memo41']; $COMPANY_TELEPHONE=$_POST['COMPANY_TELEPHONE41']; 
   $COMPANY_FAX=$_POST['COMPANY_FAX41']; $COMPANY_CITY=$_POST['COMPANY_CITY41']; $COMPANY_STAT=$_POST['COMPANY_STAT41']; $COMPANY_COUNTRY=$_POST['COMPANY_COUNTRY41']; 
   $BASE1=$_POST['BASE141']; $BASE2=$_POST['BASE241']; $Base1LessBase2=$_POST['Base1LessBase241']; $DecimalBase=$_POST['DecimalBase41']; $Decimalbase1=$_POST['Decimalbase141']; 
   $Decimalbase2=$_POST['Decimalbase241']; $COMPANY_LOGO=$_POST['COMPANY_LOGO41']; $GVprinteddate_time=$_POST['GVprinteddate_time41']; $JVprinteddate_time=$_POST['JVprinteddate_time41']; 
   $MainCompany=$_POST['MainCompany41']; $Background_color=$_POST['Background_color41']; $Header_color=$_POST['Header_color41']; $Logo_exist=$_POST['Logo_exist41']; $CUSTOML=$_POST['CUSTOML41']; 
   $CUSTOMW=$_POST['CUSTOMW41']; $FolioByMonth=$_POST['FolioByMonth41']; $Clientaccount=$_POST['Clientaccount41']; $Checkaccount=$_POST['Checkaccount41']; $CreditLimitValue=$_POST['CreditLimitValue41']; 
   $BillAccount=$_POST['BillAccount41']; $CashAccount=$_POST['CashAccount41']; $ClientRetailAccount=$_POST['ClientRetailAccount41']; $CheckRetailAccount=$_POST['CheckRetailAccount41']; 
   $BillRetailAccount=$_POST['BillRetailAccount41']; $POSTTOVIEWER=$_POST['POSTTOVIEWER41']; $Setup_vatno=$_POST['Setup_vatno41']; $Setup_vatstartdate=$_POST['Setup_vatstartdate41']; 
   $Setup_vatpercentage=$_POST['Setup_vatpercentage41']; $COMPANY_LOGO1=$_POST['COMPANY_LOGO141']; $SupplierFirstDigit=$_POST['SupplierFirstDigit41']; $ClientFirstDigit=$_POST['ClientFirstDigit41']; 
   $SalesmenFirstDigit=$_POST['SalesmenFirstDigit41']; $NbrOfDigitInLedger=$_POST['NbrOfDigitInLedger41']; $SupplierLedgerDefault=$_POST['SupplierLedgerDefault41']; 
   $ClientLedgerDefault=$_POST['ClientLedgerDefault41']; $SalesmenLedgerDefault=$_POST['SalesmenLedgerDefault41']; $ItemCodeDefault=$_POST['ItemCodeDefault41']; $ItemCodeFirstDigit=$_POST['ItemCodeFirstDigit41']; 
   $NbrOfDigitInItem=$_POST['NbrOfDigitInItem41']; $DirectStock=$_POST['DirectStock41']; $DirectStock_Debit=$_POST['DirectStock_Debit41']; $DirectStock_Credit=$_POST['DirectStock_Credit41']; 
   $DirectStock_Base=$_POST['DirectStock_Base41']; $PrintedDate_Time=$_POST['PrintedDate_Time41']; $CurrencyVatBase=$_POST['CurrencyVatBase41']; $NbrOfDigitInItemCode=$_POST['NbrOfDigitInItemCode41']; 
   $SerialNo_RecordCount=$_POST['SerialNo_RecordCount41']; $Item_NonActive=$_POST['Item_NonActive41']; $PrintOption=$_POST['PrintOption41']; $Itemcurrency=$_POST['Itemcurrency41']; 
   $PathArchive=$_POST['PathArchive41']; $Setup_MinBalancesBase1=$_POST['Setup_MinBalancesBase141']; $Setup_MinBalancesBase2=$_POST['Setup_MinBalancesBase241']; $DEFAULTL=$_POST['DEFAULTL41']; 
   $DEFAULTW=$_POST['DEFAULTW41']; $ITEMSEPERATOR=$_POST['ITEMSEPERATOR41']; $SHOWSLIPNUMBER=$_POST['SHOWSLIPNUMBER41']; $REMARKINV=$_POST['REMARKINV41']; $PATHDATACOLLECTOR=$_POST['PATHDATACOLLECTOR41']; 
   $ITEMTARGETDATE=$_POST['ITEMTARGETDATE41']; $DIFFOFEXCHPOS=$_POST['DIFFOFEXCHPOS41']; $DIFFOFEXCHNEG=$_POST['DIFFOFEXCHNEG41']; 
   $DiscountAccount=$_POST['DiscountAccount41']; $AfterDecimalRetailBase=$_POST['AfterDecimalRetailBase41']; $AfterDecimalRetailbase1=$_POST['AfterDecimalRetailbase141']; 
   $AfterDecimalRetailbase2=$_POST['AfterDecimalRetailbase241']; $ReportMsg=$_POST['ReportMsg41']; $BeforeDecimalRetailBase=$_POST['BeforeDecimalRetailBase41']; 
   $BeforeDecimalRetailBase1=$_POST['BeforeDecimalRetailBase141']; $BeforeDecimalRetailBase2=$_POST['BeforeDecimalRetailBase241']; $Warehouse_Code=$_POST['Warehouse_Code41']; 
   $DigitRetailBase=$_POST['DigitRetailBase41']; $DigitRetailBase1=$_POST['DigitRetailBase141']; $DigitRetailBase2=$_POST['DigitRetailBase241']; $BeforeDigitRetailBase=$_POST['BeforeDigitRetailBase41']; 
   $BeforeDigitRetailBase1=$_POST['BeforeDigitRetailBase141']; $BeforeDigitRetailBase2=$_POST['BeforeDigitRetailBase241']; $AfterDigitRetailBase=$_POST['AfterDigitRetailBase41']; 
   $AfterDigitRetailBase1=$_POST['AfterDigitRetailBase141']; $AfterDigitRetailBase2=$_POST['AfterDigitRetailBase241']; $Setup_OfferMemo=$_POST['Setup_OfferMemo41']; 
   $ChkCommissionAcc=$_POST['ChkCommissionAcc41']; $Salesttc=$_POST['Salesttc41']; $GROUP_DISPLAYCOLOR=$_POST['GROUP_DISPLAYCOLOR41']; $StmtMessage=$_POST['StmtMessage41']; $Ndigitacctypeledger=$_POST['Ndigitacctypeledger41']; 
   $DelinventoryJvTransaction=$_POST['DelinventoryJvTransaction41']; $Journal_DefaultCur=$_POST['Journal_DefaultCur41']; $Supplier_DefaultCur=$_POST['Supplier_DefaultCur41']; $Supplier_PaymentTerms=$_POST['Supplier_PaymentTerms41']; 
   $Supplier_CreditLimit=$_POST['Supplier_CreditLimit41']; $Client_DefaultCur=$_POST['Client_DefaultCur41']; $Client_PaymentTerms=$_POST['Client_PaymentTerms41']; 
   $Client_CreditLimit=$_POST['Client_CreditLimit41']; $Salesman_DefaultCur=$_POST['Salesman_DefaultCur41']; $Salesman_CreditLimit=$_POST['Salesman_CreditLimit41']; $Customer_DefaultCur=$_POST['Customer_DefaultCur41']; 
   $Customer_PaymentTerms=$_POST['Customer_PaymentTerms41']; $Customer_CreditLimit=$_POST['Customer_CreditLimit41']; $Setup_Minbalances=$_POST['Setup_Minbalances41']; $Setup_MinBalancesCur=$_POST['Setup_MinBalancesCur41']; 
   $LoadingElectricityPath=$_POST['LoadingElectricityPath41']; $StmtSignature=$_POST['StmtSignature41']; $Setup_PrintJVRef=$_POST['Setup_PrintJVRef41']; $Setup_PrintJVType=$_POST['Setup_PrintJVType41']; 
   $Setup_PrintJVFolio=$_POST['Setup_PrintJVFolio41']; $CalcSellPriceForItems=$_POST['CalcSellPriceForItems41']; $SndRec_SenderName=$_POST['SndRec_SenderName41']; $Supplier_ValidateCur=$_POST['Supplier_ValidateCur41']; 
   $Client_ValidateCur=$_POST['Client_ValidateCur41']; $Report_BelgToGrpByTrans=$_POST['Report_BelgToGrpByTrans41']; $DisplayDecimalName=$_POST['DisplayDecimalName41']; $PosttoItemviewer=$_POST['PosttoItemviewer41']; 
   $Setup_Tax1Percentage=$_POST['Setup_Tax1Percentage41']; $Setup_Tax2Percentage=$_POST['Setup_Tax2Percentage41']; $Setup_Tax3Percentage=$_POST['Setup_Tax3Percentage41']; $Setup_Tax4Percentage=$_POST['Setup_Tax4Percentage41']; 
   $Setup_Tax5Percentage=$_POST['Setup_Tax5Percentage41']; $Setup_Tax1Active=$_POST['Setup_Tax1Active41']; $Setup_Tax2Active=$_POST['Setup_Tax2Active41']; $Setup_Tax3Active=$_POST['Setup_Tax3Active41']; $Setup_Tax4Active=$_POST['Setup_Tax4Active41']; $Setup_Tax5Active=$_POST['Setup_Tax5Active41']; $Setup_Tax1Name=$_POST['Setup_Tax1Name41']; 
   $Setup_Tax2Name=$_POST['Setup_Tax2Name41']; $Setup_Tax3Name=$_POST['Setup_Tax3Name41']; $Setup_Tax4Name=$_POST['Setup_Tax4Name41']; $Setup_Tax5Name=$_POST['Setup_Tax5Name41']; $DefaultProfitPer=$_POST['DefaultProfitPer41']; $ProductionApp_AddQty=$_POST['ProductionApp_AddQty41']; $Supplier_ValidateProject=$_POST['Supplier_ValidateProject41']; 
   $Client_ValidateProject=$_POST['Client_ValidateProject41']; $AddTaxesCurDefault=$_POST['AddTaxesCurDefault41']; $LastDateLocked=$_POST['LastDateLocked41']; $Item_MinQtyState=$_POST['Item_MinQtyState41']; 
   $StmtOfItemRMaskQty=$_POST['StmtOfItemRMaskQty41']; $InventoryRMaskqty=$_POST['InventoryRMaskqty41']; $ProfitPerItemsRMaskQty=$_POST['ProfitPerItemsRMaskQty41']; $ClientSalesRMaskQty=$_POST['ClientSalesRMaskQty41']; $PurchaseRMaskQty=$_POST['PurchaseRMaskQty41']; 
   $ListTransactionRMaskQty=$_POST['ListTransactionRMaskQty41']; $PackingRMaskQty=$_POST['PackingRMaskQty41']; $SoldBySalesmanRMaskQty=$_POST['SoldBySalesmanRMaskQty41']; $ListofPreProdRMaskQty=$_POST['ListofPreProdRMaskQty41']; 
   $ListOfProductionMaskQty=$_POST['ListOfProductionMaskQty41']; $UpdatedMeanCostRMaskQty=$_POST['UpdatedMeanCostRMaskQty41']; $SaleRMaskQty=$_POST['SaleRMaskQty41']; $YearlyRMaskQty=$_POST['YearlyRMaskQty41']; 
   $PorderReportMaskQty=$_POST['PorderReportMaskQty41']; $InventryByEntryNoMaskQty=$_POST['InventryByEntryNoMaskQty41']; $ListOfDlvQtyMaskQty=$_POST['ListOfDlvQtyMaskQty41']; $SalesOrderRMaskQty=$_POST['SalesOrderRMaskQty41']; 
   $MaskQty=$_POST['MaskQty41']; $Setup_StmtOfAccCostcenter=$_POST['Setup_StmtOfAccCostcenter41']; $Setup_StmtOfAccProject=$_POST['Setup_StmtOfAccProject41']; $Synchronized=$_POST['Synchronized41']; 
   $CashReg_SlipBtmMsg=$_POST['CashReg_SlipBtmMsg41']; $Setup_TranslateLanguage=$_POST['Setup_TranslateLanguage41']; $Barcode=$_POST['Barcode41']; $DefaultChildCostcenter=$_POST['DefaultChildCostcenter41']; 
   $DefaultChildProject=$_POST['DefaultChildProject41']; $ApplyJournal_JVRef=$_POST['ApplyJournal_JVRef41']; $ApplyLedger_Deactivate=$_POST['ApplyLedger_Deactivate41']; $Item_EnableDiscPer=$_POST['Item_EnableDiscPer41']; $SQLStockCalculation=$_POST['SQLStockCalculation41']; $JV_DefaultCostcenter=$_POST['JV_DefaultCostcenter41']; 
   $JV_DefaultProject=$_POST['JV_DefaultProject41']; $UseLanguage=$_POST['UseLanguage41']; $AllowDateBiggerSysDate=$_POST['AllowDateBiggerSysDate41']; $Setup_printJvDate=$_POST['Setup_printJvDate41']; 
   $JVModeAsLedger=$_POST['JVModeAsLedger41']; $CashReg_LastClosingDate=$_POST['CashReg_LastClosingDate41']; $RMA_In=$_POST['RMA_In41']; $RMA_Out=$_POST['RMA_Out41']; $Salesman_IsLedger=$_POST['Salesman_IsLedger41']; $Ledger_ValidateProject=$_POST['Ledger_ValidateProject41']; 
   $UseApproximateQty=$_POST['UseApproximateQty41']; $ApproximatePercentage=$_POST['ApproximatePercentage41']; $ApproximateQty=$_POST['ApproximateQty41']; $LedgerDeactivateInAcc=$_POST['LedgerDeactivateInAcc41']; 
   $PagePath=$_POST['PagePath41']; $UsePagePath=$_POST['UsePagePath41']; $NbrOfDigitInLedgerSalesmen=$_POST['NbrOfDigitInLedgerSalesmen41']; $NbrOfDigitInLedgerSupplier=$_POST['NbrOfDigitInLedgerSupplier41']; $Setup_ItemLoad=$_POST['Setup_ItemLoad41']; $Path_LoadSales=$_POST['Path_LoadSales41']; 
   $setup_GCIExp=$_POST['setup_GCIExp41']; $Path_ExportPrjGrpSub=$_POST['Path_ExportPrjGrpSub41']; $Variant_Mode=$_POST['Variant_Mode41']; $Path_LoadSOF=$_POST['Path_LoadSOF41']; $DefaultBase=$_POST['DefaultBase41']; 
   $AccessLabels=$_POST['AccessLabels41']; $Iso_Logo=$_POST['Iso_Logo41']; $IsoDescription=$_POST['IsoDescription41']; $grid_color1=$_POST['grid_color141']; $grid_color2=$_POST['grid_color241']; $setup_branch=$_POST['setup_branch41']; $setup_salesjvtax=$_POST['setup_salesjvtax41']; 
   $setup_purchasesjvtax=$_POST['setup_purchasesjvtax41']; $PrevShowThumbsStatment=$_POST['PrevShowThumbsStatment41']; $PrevShowThumbsTrialBalance=$_POST['PrevShowThumbsTrialBalance41']; $PrevShowThumbsStatmentofItems=$_POST['PrevShowThumbsStatmentofItems41']; 
   $PrevShowThumbsSalesReport=$_POST['PrevShowThumbsSalesReport41']; $PrevShowThumbsInventoryReport=$_POST['PrevShowThumbsInventoryReport41']; $Setup_TipsMaxAmount=$_POST['Setup_TipsMaxAmount41']; 
   $Setup_SorderMailMsg=$_POST['Setup_SorderMailMsg41']; $CashReg_Weight=$_POST['CashReg_Weight41']; $CashReg_StartBarcode=$_POST['CashReg_StartBarcode41']; $CashReg_EndBarcode=$_POST['CashReg_EndBarcode41']; 
   $CashReg_StartQty=$_POST['CashReg_StartQty41']; $CashReg_EndQty=$_POST['CashReg_EndQty41']; $setup_plu41=$_POST['Setup_plu41']; $setup_ItemDtGrid=$_POST['setup_ItemDtGrid41']; $CashReg_Price=$_POST['CashReg_Price41']; $CashReg_StartPrice=$_POST['CashReg_StartPrice41']; 
   $CashReg_EndPrice=$_POST['CashReg_EndPrice41']; $CashReg_DispLedMsg=$_POST['CashReg_DispLedMsg41']; $companyseq_id=$_POST['companyseq_id41']; $maxperpage=$_POST['maxperpage41']; $Setup_LogoWidth=$_POST['Setup_LogoWidth41']; 
   $Setup_LogoHeight=$_POST['Setup_LogoHeight41']; $show_companylogo=$_POST['show_companylogo41']; $show_companyname=$_POST['show_companyname41']; $show_printdatetime=$_POST['show_printdatetime41']; $show_user=$_POST['show_user41']; $show_companymemo=$_POST['show_companymemo41']; $cashreg_colortheme=$_POST['cashreg_colortheme41']; 
   $Company_NameF=$_POST['Company_NameF41']; $Company_MemoF=$_POST['Company_MemoF41']; $Company_Capital=$_POST['Company_Capital41']; $Company_CapitalF=$_POST['Company_CapitalF41']; $Setup_MultiLangPrint=$_POST['Setup_MultiLangPrint41']; 
   $report_color1=$_POST['report_color141']; $report_color2=$_POST['report_color241']; $VATSufixLength=$_POST['VATSufixLength41']; $CashReg_BgColorOffer=$_POST['CashReg_BgColorOffer41']; $CashReg_BgColorQty=$_POST['CashReg_BgColorQty41']; 
   $CashReg_BgColorOrderQty=$_POST['CashReg_BgColorOrderQty41']; $CashReg_BgColorZeroPrice=$_POST['CashReg_BgColorZeroPrice41']; $CashReg_BgColorZeroQty=$_POST['CashReg_BgColorZeroQty41']; 
   $CashReg_BgColorHasDiscount=$_POST['CashReg_BgColorHasDiscount41']; $CashReg_RoundDivisor=$_POST['CashReg_RoundDivisor41']; $Setup_SlipFooter=$_POST['Setup_SlipFooter41']; $Setup_GenerateJvNoAmount=$_POST['Setup_GenerateJvNoAmount41']; $CashReg_ApplyColorOffer=$_POST['CashReg_ApplyColorOffer41']; 
   $CashReg_ApplyColorQty=$_POST['CashReg_ApplyColorQty41']; $CashReg_ApplyColorOrderQty=$_POST['CashReg_ApplyColorOrderQty41']; $CashReg_ApplyColorZeroPrice=$_POST['CashReg_ApplyColorZeroPrice41']; 
   $CashReg_ApplyColorZeroQty=$_POST['CashReg_ApplyColorZeroQty41']; $CashReg_ApplyColorHasDiscount=$_POST['CashReg_ApplyColorHasDiscount41']; $Setup_LicenseNo=$_POST['Setup_LicenseNo41']; 
   $Setup_ClientSerialNo=$_POST['Setup_ClientSerialNo41']; $discount_amount=$_POST['discount_amount41']; $keyboardfocus=$_POST['keyboardfocus41'];
   $Setup_TransShowLedger=$_POST['Setup_TransShowLedger41']; $category_order=$_POST['category_order41']; $category_length=$_POST['category_length41']; $group_order=$_POST['group_order41']; $group_length=$_POST['group_length41']; $subgroup_order=$_POST['subgroup_order41']; 
   $subgroup_length=$_POST['subgroup_length41']; $remaining_length=$_POST['remaining_length41']; $delivery_maxrecords=$_POST['delivery_maxrecords41']; $journal_setup=$_POST['journal_setup41']; 
   $serialNb_quantity_setup=$_POST['serialNb_quantity_setup41'];
   //echo $Tabnumber;exit;
     if($Tabnumber == 3){
		$target_dir = "upload/";
		
		$target_file = $target_dir . basename($COMPANY_LOGO);
		 //echo "test";exit;
   $result4 = mysql_query("SELECT * FROM setup" ,  $connection);
   $num_rows4 = mysql_num_rows($result4);
 //echo $num_rows4;exit;
   if($num_rows4==0){
   $query_setup="Insert into setup (COMPANY_NAME, Company_memo, COMPANY_TELEPHONE, COMPANY_FAX, COMPANY_CITY, COMPANY_STAT, COMPANY_COUNTRY, BASE1, BASE2, Base1LessBase2, DecimalBase,
   								Decimalbase1, Decimalbase2, ";
   								
   								if($COMPANY_LOGO41 != '')
   								$query_setup=$query_setup."COMPANY_LOGO41,";
   								
   								$query_setup=$query_setup." 
   								
   								GVprinteddate_time, JVprinteddate_time, MainCompany, Background_color, Header_color, Logo_exist, CUSTOML,
   								CUSTOMW, FolioByMonth, Clientaccount, Checkaccount, CreditLimitValue, BillAccount, CashAccount, ClientRetailAccount, CheckRetailAccount, BillRetailAccount,
   								POSTTOVIEWER, Setup_vatno, Setup_vatstartdate, Setup_vatpercentage, ";
   								
   								if($COMPANY_LOGO141 != '')
									$query_setup=$query_setup."COMPANY_LOGO1,";
   								
   								$query_setup=$query_setup." 
   								
   								SupplierFirstDigit, ClientFirstDigit, SalesmenFirstDigit, NbrOfDigitInLedger,
   								SupplierLedgerDefault, ClientLedgerDefault, SalesmenLedgerDefault, ItemCodeDefault, ItemCodeFirstDigit, NbrOfDigitInItem, DirectStock, DirectStock_Debit, DirectStock_Credit,
   								DirectStock_Base, PrintedDate_Time, CurrencyVatBase, NbrOfDigitInItemCode, SerialNo_RecordCount, Item_NonActive, PrintOption, Itemcurrency, PathArchive, Setup_MinBalancesBase1,
   								Setup_MinBalancesBase2, DEFAULTL, DEFAULTW, ITEMSEPERATOR, SHOWSLIPNUMBER, REMARKINV, PATHDATACOLLECTOR, ITEMTARGETDATE, DIFFOFEXCHPOS, DIFFOFEXCHNEG, DiscountAccount,
   								AfterDecimalRetailBase, AfterDecimalRetailbase1, AfterDecimalRetailbase2, ReportMsg, BeforeDecimalRetailBase, BeforeDecimalRetailBase1, BeforeDecimalRetailBase2, Warehouse_Code,
   								DigitRetailBase, DigitRetailBase1, DigitRetailBase2, BeforeDigitRetailBase, BeforeDigitRetailBase1, BeforeDigitRetailBase2, AfterDigitRetailBase, AfterDigitRetailBase1, 
   								AfterDigitRetailBase2, Setup_OfferMemo, ChkCommissionAcc, Salesttc, GROUP_DISPLAYCOLOR, StmtMessage, Ndigitacctypeledger, DelinventoryJvTransaction, Journal_DefaultCur, Supplier_DefaultCur,
   								Supplier_PaymentTerms, Supplier_CreditLimit, Client_DefaultCur, Client_PaymentTerms, Client_CreditLimit, Salesman_DefaultCur, Salesman_CreditLimit, Customer_DefaultCur, 
   								Customer_PaymentTerms, Customer_CreditLimit, Setup_Minbalances, Setup_MinBalancesCur, LoadingElectricityPath, StmtSignature, Setup_PrintJVRef, Setup_PrintJVType, Setup_PrintJVFolio,
   								CalcSellPriceForItems, SndRec_SenderName, Supplier_ValidateCur, Client_ValidateCur, Report_BelgToGrpByTrans, DisplayDecimalName, PosttoItemviewer, Setup_Tax1Percentage, Setup_Tax2Percentage,
   								Setup_Tax3Percentage, Setup_Tax4Percentage, Setup_Tax5Percentage, Setup_Tax1Active, Setup_Tax2Active, Setup_Tax3Active, Setup_Tax4Active, Setup_Tax5Active, Setup_Tax1Name, Setup_Tax2Name, 
   								Setup_Tax3Name, Setup_Tax4Name, Setup_Tax5Name, DefaultProfitPer, ProductionApp_AddQty, Supplier_ValidateProject, Client_ValidateProject, AddTaxesCurDefault, LastDateLocked, Item_MinQtyState, 
   								StmtOfItemRMaskQty, InventoryRMaskqty, ProfitPerItemsRMaskQty, ClientSalesRMaskQty, PurchaseRMaskQty, ListTransactionRMaskQty, PackingRMaskQty, SoldBySalesmanRMaskQty, ListofPreProdRMaskQty,
   								ListOfProductionMaskQty, UpdatedMeanCostRMaskQty, SaleRMaskQty, YearlyRMaskQty, PorderReportMaskQty, InventryByEntryNoMaskQty, ListOfDlvQtyMaskQty, SalesOrderRMaskQty, MaskQty,
   								Setup_StmtOfAccCostcenter, Setup_StmtOfAccProject, Synchronized, CashReg_SlipBtmMsg, Setup_TranslateLanguage, Barcode, DefaultChildCostcenter, DefaultChildProject, ApplyJournal_JVRef,
   								ApplyLedger_Deactivate, Item_EnableDiscPer, SQLStockCalculation, JV_DefaultCostcenter, JV_DefaultProject, UseLanguage, AllowDateBiggerSysDate, Setup_printJvDate, JVModeAsLedger, 
   								CashReg_LastClosingDate, RMA_In, RMA_Out, Salesman_IsLedger, Ledger_ValidateProject, UseApproximateQty, ApproximatePercentage, ApproximateQty, LedgerDeactivateInAcc, PagePath, UsePagePath,
   								NbrOfDigitInLedgerSalesmen, NbrOfDigitInLedgerSupplier, Setup_ItemLoad, Path_LoadSales, setup_GCIExp, 
   								Path_ExportPrjGrpSub, Variant_Mode, Path_LoadSOF, DefaultBase, AccessLabels,";
   								
   								if($Iso_Logo41 != '')
									$query_setup=$query_setup."Iso_Logo,";
   								
   								$query_setup=$query_setup."
   							
   								IsoDescription, grid_color1, grid_color2, setup_branch, setup_salesjvtax, setup_purchasesjvtax, PrevShowThumbsStatment, PrevShowThumbsTrialBalance, PrevShowThumbsStatmentofItems, 
   								PrevShowThumbsSalesReport, PrevShowThumbsInventoryReport, Setup_TipsMaxAmount, Setup_SorderMailMsg, CashReg_Weight, CashReg_StartBarcode, CashReg_EndBarcode, CashReg_StartQty, CashReg_EndQty,
   								setup_plu, setup_ItemDtGrid, CashReg_Price, CashReg_StartPrice, CashReg_EndPrice, CashReg_DispLedMsg, companyseq_id, maxperpage, Setup_LogoWidth, Setup_LogoHeight, show_companylogo, 
   								show_companyname, show_printdatetime, show_user, show_companymemo, cashreg_colortheme, Company_NameF, Company_MemoF, Company_Capital, Company_CapitalF, Setup_MultiLangPrint, report_color1, 
   								report_color2, VATSufixLength, CashReg_BgColorOffer, CashReg_BgColorQty, CashReg_BgColorOrderQty, CashReg_BgColorZeroPrice, CashReg_BgColorZeroQty, CashReg_BgColorHasDiscount, 
   								CashReg_RoundDivisor, Setup_SlipFooter, Setup_GenerateJvNoAmount, CashReg_ApplyColorOffer, CashReg_ApplyColorQty, CashReg_ApplyColorOrderQty, CashReg_ApplyColorZeroPrice, 
   								CashReg_ApplyColorZeroQty, CashReg_ApplyColorHasDiscount, Setup_LicenseNo, Setup_ClientSerialNo, discount_amount, keyboardfocus, Setup_TransShowLedger, 
   								category_order, category_length, group_order, group_length, subgroup_order, subgroup_length, remaining_length, delivery_maxrecords, journal_setup, serialNb_quantity_setup
   								)
   				values( '".GetSQLValueString($COMPANY_NAME41,'text')."',
   						'".GetSQLValueString($Company_memo41,'text')."',
   						'".GetSQLValueString($COMPANY_TELEPHONE41,'text')."', 
   						'".GetSQLValueString($COMPANY_FAX41,'text')."',
   						'".GetSQLValueString($COMPANY_CITY41,'text')."',
   						'".GetSQLValueString($COMPANY_STAT41,'text')."',
   						'".GetSQLValueString($COMPANY_COUNTRY41,'text')."',
   						'".GetSQLValueString($BASE141,'text')."',
   						'".GetSQLValueString($BASE241,'text')."',
   						'".GetSQLValueString($Base1LessBase241,'int')."',
   
   						'".GetSQLValueString($DecimalBase41,'int')."',
   						'".GetSQLValueString($Decimalbase141,'int')."', 
   						'".GetSQLValueString($Decimalbase241,'int')."',";
   	if($COMPANY_LOGO41 != '')
		$query_setup=$query_setup."'".$COMPANY_LOGO41."',";
	
   	$query_setup=$query_setup."
   						'".GetSQLValueString($GVprinteddate_time41,'int')."',
   						'".GetSQLValueString($JVprinteddate_time41,'int')."',
   						'".GetSQLValueString($MainCompany41,'text')."',
   						'".GetSQLValueString($Background_color41,'text')."',
   						'".GetSQLValueString($Header_color41,'text')."',
   
   						'".GetSQLValueString($Logo_exist41,'int')."',
   						'".GetSQLValueString($CUSTOML41,'double')."',
   						'".GetSQLValueString($CUSTOMW41,'double')."',
   						'".GetSQLValueString($FolioByMonth41,'int')."', 
   						'".GetSQLValueString($Clientaccount41,'text')."', 
   						'".GetSQLValueString($Checkaccount41,'text')."', 
   						'".GetSQLValueString($CreditLimitValue41,'double')."',
   						'".GetSQLValueString($BillAccount41,'text')."',
   						'".GetSQLValueString($CashAccount41,'text')."', 
   						'".GetSQLValueString($ClientRetailAccount41,'text')."', 
   						'".GetSQLValueString($CheckRetailAccount41,'text')."',
   						'".GetSQLValueString($BillRetailAccount41,'text')."',
   						'".GetSQLValueString($POSTTOVIEWER41,'int')."',
   
   						'".GetSQLValueString($Setup_vatno41,'text')."',
   						'".GetSQLValueString($Setup_vatstartdate41,'date')."',
   						'".GetSQLValueString($Setup_vatpercentage41,'double')."',";
   	if($COMPANY_LOGO141 != '')
		$query_setup=$query_setup."'".$COMPANY_LOGO141."',";
   	
   	$query_setup=$query_setup."
   						'".GetSQLValueString($SupplierFirstDigit41,'text')."',
   						'".GetSQLValueString($ClientFirstDigit41,'text')."', 
   						'".GetSQLValueString($SalesmenFirstDigit41,'text')."',
   						'".GetSQLValueString($NbrOfDigitInLedger41,'int')."',
   						'".GetSQLValueString($SupplierLedgerDefault41,'int')."', 
   						'".GetSQLValueString($ClientLedgerDefault41,'int')."',
   						'".GetSQLValueString($SalesmenLedgerDefault41,'int')."', 
   
   						'".GetSQLValueString($ItemCodeDefault41,'int')."',
   						'".GetSQLValueString($ItemCodeFirstDigit41,'text')."', 
   						'".GetSQLValueString($NbrOfDigitInItem41,'int')."', 
   						'".GetSQLValueString($DirectStock41,'int')."', 
   						'".GetSQLValueString($DirectStock_Debit41,'text')."', 
   						'".GetSQLValueString($DirectStock_Credit41,'text')."',
   						'".GetSQLValueString($DirectStock_Base41,'double')."',
   
   						'".GetSQLValueString($PrintedDate_Time41,'int')."',
   						'".GetSQLValueString($CurrencyVatBase41,'double')."',
   						'".GetSQLValueString($NbrOfDigitInItemCode41,'int')."',
   						'".GetSQLValueString($SerialNo_RecordCount41,'int')."',
   						'".GetSQLValueString($Item_NonActive41,'int')."',
   						'".GetSQLValueString($PrintOption41,'int')."',
   						'".GetSQLValueString($Itemcurrency41,'text')."',
   						'".GetSQLValueString($PathArchive41,'text')."',
   						'".GetSQLValueString($Setup_MinBalancesBase141,'double')."',
   						'".GetSQLValueString($Setup_MinBalancesBase241,'double')."',
   						'".GetSQLValueString($DEFAULTL41,'double')."',
   						'".GetSQLValueString($DEFAULTW41,'double')."',
   
   						'".GetSQLValueString($ITEMSEPERATOR41,'text')."',
   						'".GetSQLValueString($SHOWSLIPNUMBER41,'int')."',
   						'".GetSQLValueString($REMARKINV41,'text')."',
   						'".GetSQLValueString($PATHDATACOLLECTOR41,'text')."',
   						'".GetSQLValueString($ITEMTARGETDATE41,'int')."',
   						'".GetSQLValueString($DIFFOFEXCHPOS41,'text')."',
   						'".GetSQLValueString($DIFFOFEXCHNEG41,'text')."',
   						'".GetSQLValueString($DiscountAccount41,'text')."',
   						'".GetSQLValueString($AfterDecimalRetailBase41,'double')."', 
   						'".GetSQLValueString($AfterDecimalRetailbase141,'double')."', 
   						'".GetSQLValueString($AfterDecimalRetailbase241,'double')."', 
   						'".GetSQLValueString($ReportMsg41,'text')."', 
   
   						'".GetSQLValueString($BeforeDecimalRetailBase41,'double')."',
   						'".GetSQLValueString($BeforeDecimalRetailBase141,'double')."',
   						'".GetSQLValueString($BeforeDecimalRetailBase241,'double')."',
   						'".GetSQLValueString($Warehouse_Code41,'text')."',
   						'".GetSQLValueString($DigitRetailBase41,'double')."',
   						'".GetSQLValueString($DigitRetailBase241,'double')."',
   						'".GetSQLValueString($BeforeDigitRetailBase41,'double')."',
   						'".GetSQLValueString($BeforeDigitRetailBase41,'double')."', 
   						'".GetSQLValueString($BeforeDigitRetailBase141,'double')."',
   						'".GetSQLValueString($BeforeDigitRetailBase241,'double')."',
   						'".GetSQLValueString($AfterDigitRetailBase41,'double')."',
   						'".GetSQLValueString($AfterDigitRetailBase141,'double')."',
   						'".GetSQLValueString($AfterDigitRetailBase241,'double')."',
   
   						'".GetSQLValueString($Setup_OfferMemo41,'text')."',
   						'".GetSQLValueString($ChkCommissionAcc41,'text')."',
   						'".GetSQLValueString($Salesttc41,'int')."',
   						'".GetSQLValueString($GROUP_DISPLAYCOLOR41,'int')."', 
   						'".GetSQLValueString($StmtMessage41,'text')."',
   						'".GetSQLValueString($Ndigitacctypeledger41,'int')."', 
   						'".GetSQLValueString($DelinventoryJvTransaction41,'int')."',
   						'".GetSQLValueString($Journal_DefaultCur41,'text')."',
   						'".GetSQLValueString($Supplier_DefaultCur41,'text')."',
   						'".GetSQLValueString($Supplier_PaymentTerms41,'double')."',
   						'".GetSQLValueString($Supplier_CreditLimit41,'double')."', 
   
   						'".GetSQLValueString($Client_DefaultCur41,'text')."',
   						'".GetSQLValueString($Client_PaymentTerms41,'double')."',
   						'".GetSQLValueString($Client_CreditLimit41,'double')."',
   						'".GetSQLValueString($Salesman_DefaultCur41,'text')."', 
   						'".GetSQLValueString($Salesman_CreditLimit41,'double')."',
   						'".GetSQLValueString($Customer_DefaultCur41,'text')."',
   						'".GetSQLValueString($Customer_PaymentTerms41,'double')."',
   						'".GetSQLValueString($Customer_CreditLimit41,'double')."',
   						'".GetSQLValueString($Setup_Minbalances41,'double')."',
   						'".GetSQLValueString($Setup_MinBalancesCur41,'text')."',
   
   						'".GetSQLValueString($LoadingElectricityPath41,'text')."',
   						'".GetSQLValueString($StmtSignature41,'text')."',
   						'".GetSQLValueString($Setup_PrintJVRef41,'int')."',
   						'".GetSQLValueString($Setup_PrintJVType41,'int')."', 
   						'".GetSQLValueString($Setup_PrintJVFolio41,'int')."',
   						'".GetSQLValueString($CalcSellPriceForItems41,'int')."',
   						'".GetSQLValueString($SndRec_SenderName41,'text')."', 
   						'".GetSQLValueString($Supplier_ValidateCur41,'int')."',
   						'".GetSQLValueString($Client_ValidateCur41,'int')."',
   						'".GetSQLValueString($Report_BelgToGrpByTrans41,'int')."', 
   						'".GetSQLValueString($DisplayDecimalName41,'int')."',
   						'".GetSQLValueString($PosttoItemviewer41,'int')."',
   
   						'".GetSQLValueString($Setup_Tax1Percentage41,'double')."',
   						'".GetSQLValueString($Setup_Tax2Percentage41,'double')."',
   						'".GetSQLValueString($Setup_Tax3Percentage41,'double')."',
   						'".GetSQLValueString($Setup_Tax4Percentage41,'double')."',
   						'".GetSQLValueString($Setup_Tax5Percentage41,'double')."',
   						'".GetSQLValueString($Setup_Tax1Active41,'int')."',
   						'".GetSQLValueString($Setup_Tax2Active41,'int')."',
   						'".GetSQLValueString($Setup_Tax3Active41,'int')."',
   						'".GetSQLValueString($Setup_Tax4Active41,'int')."',
   						'".GetSQLValueString($Setup_Tax5Active41,'int')."',
   						'".GetSQLValueString($Setup_Tax1Name41,'text')."',
   
   						'".GetSQLValueString($Setup_Tax2Name41,'text')."',
   						'".GetSQLValueString($Setup_Tax3Name41,'text')."',
   						'".GetSQLValueString($Setup_Tax4Name41,'text')."',
   						'".GetSQLValueString($Setup_Tax5Name41,'text')."',
   						'".GetSQLValueString($DefaultProfitPer41,'double')."',
   						'".GetSQLValueString($ProductionApp_AddQty41,'double')."',
   						'".GetSQLValueString($Supplier_ValidateProject41,'int')."',
   						'".GetSQLValueString($Client_ValidateProject41,'int')."',
   						'".GetSQLValueString($AddTaxesCurDefault41,'double')."',
   						'".GetSQLValueString($LastDateLocked41,'date')."',
   						'".GetSQLValueString($Item_MinQtyState41,'int')."',
   						'".GetSQLValueString($StmtOfItemRMaskQty41,'int')."',
   						'".GetSQLValueString($InventoryRMaskqty41,'int')."',
   						'".GetSQLValueString($ProfitPerItemsRMaskQty41,'int')."',
   						'".GetSQLValueString($ClientSalesRMaskQty41,'int')."',
   						'".GetSQLValueString($PurchaseRMaskQty41,'int')."',
   						'".GetSQLValueString($ListTransactionRMaskQty41,'int')."',
   						'".GetSQLValueString($PackingRMaskQty41,'int')."',
   						'".GetSQLValueString($SoldBySalesmanRMaskQty41,'int')."',
   						'".GetSQLValueString($ListofPreProdRMaskQty41,'int')."',
   						'".GetSQLValueString($ListOfProductionMaskQty41,'int')."',
   						'".GetSQLValueString($UpdatedMeanCostRMaskQty41,'int')."',
   						'".GetSQLValueString($SaleRMaskQty41,'int')."',
   						'".GetSQLValueString($YearlyRMaskQty41,'int')."',
   						
   						'".GetSQLValueString($PorderReportMaskQty41,'int')."',
   						'".GetSQLValueString($InventryByEntryNoMaskQty41,'int')."',
   						'".GetSQLValueString($ListOfDlvQtyMaskQty41,'int')."',
   						'".GetSQLValueString($SalesOrderRMaskQty41,'int')."',
   						'".GetSQLValueString($MaskQty41,'int')."',
   						'".GetSQLValueString($Setup_StmtOfAccCostcenter41,'int')."',
   						'".GetSQLValueString($Setup_StmtOfAccProject41,'int')."',
   						'".GetSQLValueString($Synchronized41,'int')."',
   						'".GetSQLValueString($CashReg_SlipBtmMsg41,'text')."',
   						'".GetSQLValueString($Setup_TranslateLanguage41,'int')."',
   						'".GetSQLValueString($Barcode41,'int')."',
   						'".GetSQLValueString($DefaultChildCostcenter41,'int')."',
   						'".GetSQLValueString($DefaultChildProject41,'int')."',
   						'".GetSQLValueString($ApplyJournal_JVRef41,'int')."',
   						'".GetSQLValueString($ApplyLedger_Deactivate41,'int')."',
   						'".GetSQLValueString($Item_EnableDiscPer41,'int')."',
   						'".GetSQLValueString($SQLStockCalculation41,'int')."',
   						'".GetSQLValueString($JV_DefaultCostcenter41,'int')."',
   						'".GetSQLValueString($JV_DefaultProject41,'text')."',
   						'".GetSQLValueString($UseLanguage41,'int')."',
   
   						'".GetSQLValueString($AllowDateBiggerSysDate41,'int')."',
   						'".GetSQLValueString($Setup_printJvDate41,'int')."',
   						'".GetSQLValueString($JVModeAsLedger41,'int')."',
   						'".GetSQLValueString($CashReg_LastClosingDate41,'date')."',
   						'".GetSQLValueString($RMA_In41,'text')."',
   						'".GetSQLValueString($RMA_Out41,'text')."',
   						'".GetSQLValueString($Salesman_IsLedger41,'int')."',
   						'".GetSQLValueString(Ledger_ValidateProject41,'int')."',
   						'".GetSQLValueString($UseApproximateQty41,'int')."',
   						'".GetSQLValueString($ApproximatePercentage41,'double')."',
   						'".GetSQLValueString($ApproximateQty41,'double')."',
   						'".GetSQLValueString($LedgerDeactivateInAcc41,'int')."',
   						'".GetSQLValueString($PagePath41,'text')."',
   						'".GetSQLValueString($UsePagePath41,'int')."',
   
   						'".GetSQLValueString($NbrOfDigitInLedgerSalesmen41,'int')."',
   						'".GetSQLValueString($NbrOfDigitInLedgerSupplier41,'int')."',
   						'".GetSQLValueString($Setup_ItemLoad41,'text')."',
   						'".GetSQLValueString($Path_LoadSales41,'text')."',
   						'".GetSQLValueString($setup_GCIExp41,'text')."',
   						'".GetSQLValueString($Path_ExportPrjGrpSub41,'text')."',
   
   						'".GetSQLValueString($Variant_Mode41,'int')."',
   						'".GetSQLValueString($Path_LoadSOF41,'text')."',
   						'".GetSQLValueString($DefaultBase41,'int')."',
   						'".GetSQLValueString($AccessLabels41,'text')."',";
   	if($Iso_Logo41 != '')
   	$query_setup=$query_setup."'".$Iso_Logo41."',";
   	
   	$query_setup=$query_setup."
   						'".GetSQLValueString($IsoDescription41,'text')."',
   						'".GetSQLValueString($grid_color141,'text')."',
   						'".GetSQLValueString($grid_color241,'text')."',
   						'".GetSQLValueString($setup_branch41,'text')."',
   						'".GetSQLValueString($setup_salesjvtax41,'text')."',
   						'".GetSQLValueString($setup_purchasesjvtax41,'text')."',
   
   						'".GetSQLValueString($PrevShowThumbsStatment41,'int')."',
   						'".GetSQLValueString($PrevShowThumbsTrialBalance41,'int')."',
   						'".GetSQLValueString($PrevShowThumbsStatmentofItems41,'int')."',
   						'".GetSQLValueString($PrevShowThumbsSalesReport41,'int')."',
   						'".GetSQLValueString($PrevShowThumbsInventoryReport41,'int')."',
   						'".GetSQLValueString($Setup_TipsMaxAmount41,'double')."',
   						'".GetSQLValueString($Setup_SorderMailMsg41,'text')."',
   						'".GetSQLValueString($CashReg_Weight41,'int')."',
   						'".GetSQLValueString($CashReg_StartBarcode41,'int')."',
   						'".GetSQLValueString($CashReg_EndBarcode41,'int')."',
   						'".GetSQLValueString($CashReg_StartQty41,'int')."',
   						'".GetSQLValueString($CashReg_EndQty41,'int')."',
   						'".GetSQLValueString($setup_plu41,'text')."',
   
   						'".GetSQLValueString($setup_ItemDtGrid41,'double')."',
   						'".GetSQLValueString($CashReg_Price41,'int')."',
   						'".GetSQLValueString($CashReg_StartPrice41,'int')."',
   						'".GetSQLValueString($CashReg_EndPrice41,'int')."',
   						'".GetSQLValueString($CashReg_DispLedMsg41,'text')."',
   						'".GetSQLValueString($companyseq_id41,'long')."',
   						'".GetSQLValueString($maxperpage41,'double')."',
   						'".GetSQLValueString($Setup_LogoWidth41,'double')."',
   						'".GetSQLValueString($Setup_LogoHeight41,'double')."',
   
   						'".GetSQLValueString($show_companylogo41,'int')."',
   						'".GetSQLValueString($show_companyname41,'int')."',
   						'".GetSQLValueString($show_printdatetime41,'int')."',
   						'".GetSQLValueString($show_user41,'int')."',
   						'".GetSQLValueString($show_companymemo41,'int')."',
   						'".GetSQLValueString($cashreg_colortheme41,'text')."',
   						'".GetSQLValueString($Company_NameF41,'text')."',
   						'".GetSQLValueString($Company_MemoF41,'text')."',
   						'".GetSQLValueString($Company_Capital41,'text')."',
   						'".GetSQLValueString($Company_CapitalF41,'text')."',
   						'".GetSQLValueString($Setup_MultiLangPrint41,'int')."',
   
   						'".GetSQLValueString($report_color141,'text')."',
   						'".GetSQLValueString($report_color241,'text')."',
   						'".GetSQLValueString($VATSufixLength41,'int')."',
   						'".GetSQLValueString($CashReg_BgColorOffer41,'text')."',
   						'".GetSQLValueString($CashReg_BgColorQty41,'text')."',
   						'".GetSQLValueString($CashReg_BgColorOrderQty41,'text')."',
   						'".GetSQLValueString($CashReg_BgColorZeroPrice41,'text')."',
   						'".GetSQLValueString($CashReg_BgColorZeroQty41,'text')."',
   						'".GetSQLValueString($CashReg_BgColorHasDiscount41,'text')."',
   
   						'".GetSQLValueString($CashReg_RoundDivisor41,'double')."',
   						'".GetSQLValueString($Setup_SlipFooter41,'text')."',
   						'".GetSQLValueString($Setup_GenerateJvNoAmount41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorOffer41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorQty41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorOrderQty41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorZeroPrice41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorZeroQty41,'int')."',
   						'".GetSQLValueString($CashReg_ApplyColorHasDiscount41,'int')."',
   
   						'".GetSQLValueString($Setup_LicenseNo41,'text')."',
   						'".GetSQLValueString($Setup_ClientSerialNo41,'text')."',
   						'".GetSQLValueString($discount_amount41,'double')."',
   						'".GetSQLValueString($keyboardfocus41,'int')."',
   						'".GetSQLValueString($Setup_TransShowLedger41,'int')."', 
   						'".GetSQLValueString($category_order41,'double')."',
   						'".GetSQLValueString($category_length41,'double')."',
   						'".GetSQLValueString($group_order41,'double')."',
   						'".GetSQLValueString($group_length41,'double')."',
   						'".GetSQLValueString($subgroup_order41,'double')."',
   						'".GetSQLValueString($subgroup_length41,'double')."',
   						'".GetSQLValueString($remaining_length41,'double')."',
   						'".GetSQLValueString($delivery_maxrecords41,'double')."',
   						'".GetSQLValueString($journal_setup41,'text')."',
   						'".GetSQLValueString($serialNb_quantity_setup,'int')."' ) ";
   						
	$result_setup4=mysql_query($query_setup4 , $connection) or die(mysql_error());				
   						}
   						
	else{
	   /*2018-03-06 sami $fileToUpload = "uploads/".$_FILES["COMPANY_LOGO41"]["name"];
	   $tmp_name = $_FILES["COMPANY_LOGO41"]["tmp_name"];
	   move_uploaded_file($tmp_name, $fileToUpload);*/
		$name = $_FILES['COMPANY_LOGO41']['name'];
		$name2 = $_FILES['COMPANY_LOGO141']['name'];
		$target_dir = "uploads/";
		$target_file = $target_dir . basename($_FILES['COMPANY_LOGO41']['name']);
		$target_file2 = $target_dir . basename($_FILES['COMPANY_LOGO141']['name']);
		//echo $target_file;exit;
		$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
		$imageFileType2 = strtolower(pathinfo($target_file2,PATHINFO_EXTENSION));
		
		$extensions_arr = array("jpg","jpeg","png","gif");

		if( in_array($imageFileType,$extensions_arr) ){
			$image=addslashes(file_get_contents($_FILES["COMPANY_LOGO41"]["tmp_name"]));//addslashes(file_get_contents($name));
			
			move_uploaded_file($_FILES["COMPANY_LOGO41"]["tmp_name"],$target_dir.$name);
			
		}
		
		if( in_array($imageFileType2,$extensions_arr) ){
			$image2=addslashes(file_get_contents($_FILES["COMPANY_LOGO141"]["tmp_name"]));//addslashes(file_get_contents($name));
			
			move_uploaded_file($_FILES["COMPANY_LOGO141"]["tmp_name"],$target_dir.$name2);
			
		}
		
	  // $handle = fopen($_FILES["COMPANY_LOGO41"]["tmp_name"], 'r');
	   //echo $fileToUpload;exit;
	   
   //updating the data inside the setup table 
   $queryupdatesetup="UPDATE setup
   				   SET
   					COMPANY_NAME	=".GetSQLValueString($COMPANY_NAME41,'text').",
   					Company_memo	=".GetSQLValueString($Company_memo41,'text').",
   					COMPANY_TELEPHONE 	=".GetSQLValueString($COMPANY_TELEPHONE41,'text').", 
   					COMPANY_FAX	=".GetSQLValueString($COMPANY_FAX41,'text').",
   					COMPANY_CITY	=".GetSQLValueString($COMPANY_CITY41,'text').",
   					COMPANY_STAT	=".GetSQLValueString($COMPANY_STAT41,'text').",
   					COMPANY_COUNTRY 	=".GetSQLValueString($COMPANY_COUNTRY41,'text').",
   					BASE1	=".GetSQLValueString($BASE141,'text').",
   					BASE2	=".GetSQLValueString($BASE241,'text').",
   					Base1LessBase2	=".GetSQLValueString($Base1LessBase241,'int').",
   					DecimalBase	=".GetSQLValueString($DecimalBase41,'int').",
   					Decimalbase1	=".GetSQLValueString($Decimalbase141,'int').", 
   					Decimalbase2	=".GetSQLValueString($Decimalbase241,'int').",";
   	if($_FILES['COMPANY_LOGO41']["tmp_name"] != ''){
		//echo $_FILES['COMPANY_LOGO41'];exit;
		//echo $target_dir.$name;exit;
		//$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO = load_file('".$fileToUpload."'),";
		$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO = '".$image."',";
	}
	
	if($_FILES['COMPANY_LOGO141']["tmp_name"] != ''){
		//echo $_FILES['COMPANY_LOGO41'];exit;
		//$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO	=load_file('".$fileToUpload."'),";
		$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO1 = '".$image2."',";
	}
   	
   	$queryupdatesetup=$queryupdatesetup."
   					GVprinteddate_time	=".GetSQLValueString($GVprinteddate_time41,'int').",
   					JVprinteddate_time 	=".GetSQLValueString($JVprinteddate_time41,'int').",
   					MainCompany	=".GetSQLValueString($MainCompany41,'text').",
   					Background_color	=".GetSQLValueString($Background_color41,'text').",
   					Header_color	=".GetSQLValueString($Header_color41,'text').",
   					Logo_exist	=".GetSQLValueString($Logo_exist41,'int').",
   					CUSTOML 	=".GetSQLValueString($CUSTOML41,'double').",
   					CUSTOMW	=".GetSQLValueString($CUSTOMW41,'double').",
   					FolioByMonth	=".GetSQLValueString($FolioByMonth41,'int').", 
   					Clientaccount	=".GetSQLValueString($Clientaccount41,'text').", 
   					Checkaccount	=".GetSQLValueString($Checkaccount41,'text').", 
   					CreditLimitValue 	=".GetSQLValueString($CreditLimitValue41,'double').",
   					BillAccount	=".GetSQLValueString($BillAccount41,'text').",
   					CashAccount	=".GetSQLValueString($CashAccount41,'text').", 
   					ClientRetailAccount	=".GetSQLValueString($ClientRetailAccount41,'text').", 
   					CheckRetailAccount 	=".GetSQLValueString($CheckRetailAccount41,'text').",
   					BillRetailAccount	=".GetSQLValueString($BillRetailAccount41,'text').",
   					POSTTOVIEWER	=".GetSQLValueString($POSTTOVIEWER41,'int').",
   					Setup_vatno	=".GetSQLValueString($Setup_vatno41,'text').",
   					Setup_vatstartdate	=".GetSQLValueString($Setup_vatstartdate41,'date').",
   					Setup_vatpercentage	=".GetSQLValueString($Setup_vatpercentage41,'double').",";
   	if($_FILES['COMPANY_LOGO41']["tmp_name"] != ''){
		//echo $_FILES['COMPANY_LOGO41'];exit;
		//$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO	=load_file('".$fileToUpload."'),";
		$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO = '".$image."',";
	}
	
	if($_FILES['COMPANY_LOGO141']["tmp_name"] != ''){
		
		$queryupdatesetup=$queryupdatesetup."COMPANY_LOGO1 = '".$image2."',";
	}
   	
   	$queryupdatesetup=$queryupdatesetup."SupplierFirstDigit	=".GetSQLValueString($SupplierFirstDigit41,'text').",
   					ClientFirstDigit	=".GetSQLValueString($ClientFirstDigit41,'text').", 
   					SalesmenFirstDigit	=".GetSQLValueString($SalesmenFirstDigit41,'text').",
   					NbrOfDigitInLedger	=".GetSQLValueString($NbrOfDigitInLedger41,'int').",
   					SupplierLedgerDefault 	=".GetSQLValueString($SupplierLedgerDefault41,'int').", 
   					ClientLedgerDefault	=".GetSQLValueString($ClientLedgerDefault41,'int').",
   					SalesmenLedgerDefault	=".GetSQLValueString($SalesmenLedgerDefault41,'int').", 
   					ItemCodeDefault	=".GetSQLValueString($ItemCodeDefault41,'int').",
   					ItemCodeFirstDigit	=".GetSQLValueString($ItemCodeFirstDigit41,'text').", 
   					NbrOfDigitInItem	=".GetSQLValueString($NbrOfDigitInItem41,'int').", 
   					DirectStock	=".GetSQLValueString($DirectStock41,'int').", 
   					DirectStock_Debit	=".GetSQLValueString($DirectStock_Debit41,'text').", 
   					DirectStock_Credit 	=".GetSQLValueString($DirectStock_Credit41,'text').",
   					DirectStock_Base	=".GetSQLValueString($DirectStock_Base41,'double').",
   					PrintedDate_Time	=".GetSQLValueString($PrintedDate_Time41,'int').",
   					CurrencyVatBase	=".GetSQLValueString($CurrencyVatBase41,'double').",
   					NbrOfDigitInItemCode	=".GetSQLValueString($NbrOfDigitInItemCode41,'int').",
   					SerialNo_RecordCount	=".GetSQLValueString($SerialNo_RecordCount41,'int').",
   					Item_NonActive	=".GetSQLValueString($Item_NonActive41,'int').",
   					PrintOption	=".GetSQLValueString($PrintOption41,'int').",
   					Itemcurrency	=".GetSQLValueString($Itemcurrency41,'text').",
   					PathArchive	=".GetSQLValueString($PathArchive41,'text').",
   					Setup_MinBalancesBase1	=".GetSQLValueString($Setup_MinBalancesBase141,'double').",
   					Setup_MinBalancesBase2	=".GetSQLValueString($Setup_MinBalancesBase241,'double').",
   					DEFAULTL	=".GetSQLValueString($DEFAULTL41,'double').",
   					DEFAULTW	=".GetSQLValueString($DEFAULTW41,'double').",
   					ITEMSEPERATOR	=".GetSQLValueString($ITEMSEPERATOR41,'text').",
   					SHOWSLIPNUMBER	=".GetSQLValueString($SHOWSLIPNUMBER41,'int').",
   					REMARKINV	=".GetSQLValueString($REMARKINV41,'text').",
   					PATHDATACOLLECTOR	=".GetSQLValueString($PATHDATACOLLECTOR41,'text').",
   					ITEMTARGETDATE	=".GetSQLValueString($ITEMTARGETDATE41,'int').",
   					DIFFOFEXCHPOS	=".GetSQLValueString($DIFFOFEXCHPOS41,'text').",
   					DIFFOFEXCHNEG	=".GetSQLValueString($DIFFOFEXCHNEG41,'text').",
   					DiscountAccount	=".GetSQLValueString($DiscountAccount41,'text').",
   					AfterDecimalRetailBase	=".GetSQLValueString($AfterDecimalRetailBase41,'double').", 
   					AfterDecimalRetailbase1	=".GetSQLValueString($AfterDecimalRetailbase141,'double').", 
   					AfterDecimalRetailbase2	=".GetSQLValueString($AfterDecimalRetailbase241,'double').", 
   					ReportMsg	=".GetSQLValueString($ReportMsg41,'text').", 
   					BeforeDecimalRetailBase	=".GetSQLValueString($BeforeDecimalRetailBase41,'double').",
   					BeforeDecimalRetailBase1	=".GetSQLValueString($BeforeDecimalRetailBase141,'double').",
   					BeforeDecimalRetailBase2	=".GetSQLValueString($BeforeDecimalRetailBase241,'double').",
   					Warehouse_Code	=".GetSQLValueString($Warehouse_Code41,'text').",
   					DigitRetailBase	=".GetSQLValueString($DigitRetailBase41,'double').",
   					DigitRetailBase1	=".GetSQLValueString($DigitRetailBase241,'double').",
   					DigitRetailBase2	=".GetSQLValueString($BeforeDigitRetailBase41,'double').",
   					BeforeDigitRetailBase	=".GetSQLValueString($BeforeDigitRetailBase41,'double').", 
   					BeforeDigitRetailBase1	=".GetSQLValueString($BeforeDigitRetailBase141,'double').",
   					BeforeDigitRetailBase2	=".GetSQLValueString($BeforeDigitRetailBase241,'double').",
   					AfterDigitRetailBase	=".GetSQLValueString($AfterDigitRetailBase41,'double').",
   					AfterDigitRetailBase1	=".GetSQLValueString($AfterDigitRetailBase141,'double').",
   					AfterDigitRetailBase2	=".GetSQLValueString($AfterDigitRetailBase241,'double').",
   					Setup_OfferMemo	=".GetSQLValueString($Setup_OfferMemo41,'text').",
   					ChkCommissionAcc	=".GetSQLValueString($ChkCommissionAcc41,'text').",
   					Salesttc	=".GetSQLValueString($Salesttc41,'int').",
   					GROUP_DISPLAYCOLOR	=".GetSQLValueString($GROUP_DISPLAYCOLOR41,'int').", 
   					StmtMessage	=".GetSQLValueString($StmtMessage41,'text').",
   					Ndigitacctypeledger	=".GetSQLValueString($Ndigitacctypeledger41,'int').", 
   					DelinventoryJvTransaction	=".GetSQLValueString($DelinventoryJvTransaction41,'int').",
   					Journal_DefaultCur	=".GetSQLValueString($Journal_DefaultCur41,'text').",
   					Supplier_DefaultCur	=".GetSQLValueString($Supplier_DefaultCur41,'text').",
   					Supplier_PaymentTerms	=".GetSQLValueString($Supplier_PaymentTerms41,'double').",
   					Supplier_CreditLimit	=".GetSQLValueString($Supplier_CreditLimit41,'double').", 
   					Client_DefaultCur	=".GetSQLValueString($Client_DefaultCur41,'text').",
   					Client_PaymentTerms	=".GetSQLValueString($Client_PaymentTerms41,'double').",
   					Client_CreditLimit	=".GetSQLValueString($Client_CreditLimit41,'double').",
   					Salesman_DefaultCur	=".GetSQLValueString($Salesman_DefaultCur41,'text').", 
   					Salesman_CreditLimit	=".GetSQLValueString($Salesman_CreditLimit41,'double').",
   					Customer_DefaultCur	=".GetSQLValueString($Customer_DefaultCur41,'text').",
   					Customer_PaymentTerms	=".GetSQLValueString($Customer_PaymentTerms41,'double').",
   					Customer_CreditLimit	=".GetSQLValueString($Customer_CreditLimit41,'double').",
   					Setup_Minbalances	=".GetSQLValueString($Setup_Minbalances41,'double').",
   					Setup_MinBalancesCur	=".GetSQLValueString($Setup_MinBalancesCur41,'text').",
   					LoadingElectricityPath	=".GetSQLValueString($LoadingElectricityPath41,'text').",
   					StmtSignature	=".GetSQLValueString($StmtSignature41,'text').",
   					Setup_PrintJVRef	=".GetSQLValueString($Setup_PrintJVRef41,'int').",
   					Setup_PrintJVType	=".GetSQLValueString($Setup_PrintJVType41,'int').", 
   					Setup_PrintJVFolio	=".GetSQLValueString($Setup_PrintJVFolio41,'int').",
   					CalcSellPriceForItems	=".GetSQLValueString($CalcSellPriceForItems41,'int').",
   					SndRec_SenderName	=".GetSQLValueString($SndRec_SenderName41,'text').", 
   					Supplier_ValidateCur 	=".GetSQLValueString($Supplier_ValidateCur41,'int').",
   					Client_ValidateCur	=".GetSQLValueString($Client_ValidateCur41,'int').",
   					Report_BelgToGrpByTrans	=".GetSQLValueString($Report_BelgToGrpByTrans41,'int').", 
   					DisplayDecimalName	=".GetSQLValueString($DisplayDecimalName41,'int').",
   					PosttoItemviewer	=".GetSQLValueString($PosttoItemviewer41,'int').",
   					Setup_Tax1Percentage	=".GetSQLValueString($Setup_Tax1Percentage41,'double').",
   					Setup_Tax2Percentage	=".GetSQLValueString($Setup_Tax2Percentage41,'double').",
   					Setup_Tax3Percentage	=".GetSQLValueString($Setup_Tax3Percentage41,'double').",
   					Setup_Tax4Percentage	=".GetSQLValueString($Setup_Tax4Percentage41,'double').",
   					Setup_Tax5Percentage	=".GetSQLValueString($Setup_Tax5Percentage41,'double').",
   					Setup_Tax1Active	=".GetSQLValueString($Setup_Tax1Active41,'int').",
   					Setup_Tax2Active	=".GetSQLValueString($Setup_Tax2Active41,'int').",
   					Setup_Tax3Active	=".GetSQLValueString($Setup_Tax3Active41,'int').",
   					Setup_Tax4Active	=".GetSQLValueString($Setup_Tax4Active41,'int').",
   					Setup_Tax5Active	=".GetSQLValueString($Setup_Tax5Active41,'int').",
   					Setup_Tax1Name	=".GetSQLValueString($Setup_Tax1Name41,'text').",
   					Setup_Tax2Name	=".GetSQLValueString($Setup_Tax2Name41,'text').",
   					Setup_Tax3Name	=".GetSQLValueString($Setup_Tax3Name41,'text').",
   					Setup_Tax4Name	=".GetSQLValueString($Setup_Tax4Name41,'text').",
   					Setup_Tax5Name	=".GetSQLValueString($Setup_Tax5Name41,'text').",
   					DefaultProfitPer	=".GetSQLValueString($DefaultProfitPer41,'double').",
   					ProductionApp_AddQty	=".GetSQLValueString($ProductionApp_AddQty41,'double').",
   					Supplier_ValidateProject	=".GetSQLValueString($Supplier_ValidateProject41,'int').",
   					Client_ValidateProject	=".GetSQLValueString($Client_ValidateProject41,'int').",
   					AddTaxesCurDefault	=".GetSQLValueString($AddTaxesCurDefault41,'double').",
   					LastDateLocked	=".GetSQLValueString($LastDateLocked41,'date').",
   					Item_MinQtyState	=".GetSQLValueString($Item_MinQtyState41,'int').",
   					StmtOfItemRMaskQty	=".GetSQLValueString($StmtOfItemRMaskQty41,'int').",
   					InventoryRMaskqty	=".GetSQLValueString($InventoryRMaskqty41,'int').",
   					ProfitPerItemsRMaskQty	=".GetSQLValueString($ProfitPerItemsRMaskQty41,'int').",
   					ClientSalesRMaskQty	=".GetSQLValueString($ClientSalesRMaskQty41,'int').",
   					PurchaseRMaskQty	=".GetSQLValueString($PurchaseRMaskQty41,'int').",
   					ListTransactionRMaskQty	=".GetSQLValueString($ListTransactionRMaskQty41,'int').",
   					PackingRMaskQty	=".GetSQLValueString($PackingRMaskQty41,'int').",
   					SoldBySalesmanRMaskQty	=".GetSQLValueString($SoldBySalesmanRMaskQty41,'int').",
   					ListofPreProdRMaskQty	=".GetSQLValueString($ListofPreProdRMaskQty41,'int').",
   					ListOfProductionMaskQty	=".GetSQLValueString($ListOfProductionMaskQty41,'int').",
   					UpdatedMeanCostRMaskQty	=".GetSQLValueString($UpdatedMeanCostRMaskQty41,'int').",
   					SaleRMaskQty	=".GetSQLValueString($SaleRMaskQty41,'int').",
   					YearlyRMaskQty	=".GetSQLValueString($YearlyRMaskQty41,'int').",
   					PorderReportMaskQty	=".GetSQLValueString($PorderReportMaskQty41,'int').",
   					InventryByEntryNoMaskQty	=".GetSQLValueString($InventryByEntryNoMaskQty41,'int').",
   					ListOfDlvQtyMaskQty	=".GetSQLValueString($ListOfDlvQtyMaskQty41,'int').",
   					SalesOrderRMaskQty	=".GetSQLValueString($SalesOrderRMaskQty41,'int').",
   					MaskQty	=".GetSQLValueString($MaskQty41,'int').",
   					Setup_StmtOfAccCostcenter	=".GetSQLValueString($Setup_StmtOfAccCostcenter41,'int').",
   					Setup_StmtOfAccProject	=".GetSQLValueString($Setup_StmtOfAccProject41,'int').",
   					Synchronized	=".GetSQLValueString($Synchronized41,'int').",
   					CashReg_SlipBtmMsg	=".GetSQLValueString($CashReg_SlipBtmMsg41,'text').",
   					Setup_TranslateLanguage	=".GetSQLValueString($Setup_TranslateLanguage41,'int').",
   					Barcode	=".GetSQLValueString($Barcode41,'int').",
   					DefaultChildCostcenter 	=".GetSQLValueString($DefaultChildCostcenter41,'int').",
   					DefaultChildProject	=".GetSQLValueString($DefaultChildProject41,'int').",
   					ApplyJournal_JVRef	=".GetSQLValueString($ApplyJournal_JVRef41,'int').",
   					ApplyLedger_Deactivate	=".GetSQLValueString($ApplyLedger_Deactivate41,'int').",
   					Item_EnableDiscPer	=".GetSQLValueString($Item_EnableDiscPer41,'int').",
   					SQLStockCalculation	=".GetSQLValueString($SQLStockCalculation41,'int').",
   					JV_DefaultCostcenter 	=".GetSQLValueString($JV_DefaultCostcenter41,'int').",
   					JV_DefaultProject	=".GetSQLValueString($JV_DefaultProject41,'text').",
   					UseLanguage	=".GetSQLValueString($UseLanguage41,'int').",
   					AllowDateBiggerSysDate	=".GetSQLValueString($AllowDateBiggerSysDate41,'int').",
   					Setup_printJvDate	=".GetSQLValueString($Setup_printJvDate41,'int').",
   					JVModeAsLedger	=".GetSQLValueString($JVModeAsLedger41,'int').",
   					CashReg_LastClosingDate	=".GetSQLValueString($CashReg_LastClosingDate41,'date').",
   					RMA_In	=".GetSQLValueString($RMA_In41,'text').",
   					RMA_Out	=".GetSQLValueString($RMA_Out41,'text').",
   					Salesman_IsLedger	=".GetSQLValueString($Salesman_IsLedger41,'int').",
   					Ledger_ValidateProject 	=".GetSQLValueString(Ledger_ValidateProject41,'int').",
   					UseApproximateQty	=".GetSQLValueString($UseApproximateQty41,'int').",
   					ApproximatePercentage	=".GetSQLValueString($ApproximatePercentage41,'double').",
   					ApproximateQty	=".GetSQLValueString($ApproximateQty41,'double').",
   					LedgerDeactivateInAcc	=".GetSQLValueString($LedgerDeactivateInAcc41,'int').",
   					PagePath	=".GetSQLValueString($PagePath41,'text').",
   					UsePagePath	=".GetSQLValueString($UsePagePath41,'int').",
   					NbrOfDigitInLedgerSalesmen	=".GetSQLValueString($NbrOfDigitInLedgerSalesmen41,'int').",
   					NbrOfDigitInLedgerSupplier	=".GetSQLValueString($NbrOfDigitInLedgerSupplier41,'int').",
   					Setup_ItemLoad	=".GetSQLValueString($Setup_ItemLoad41,'text').",
   					Path_LoadSales	=".GetSQLValueString($Path_LoadSales41,'text').",
   					setup_GCIExp	=".GetSQLValueString($setup_GCIExp41,'text').",
   					Path_ExportPrjGrpSub	=".GetSQLValueString($Path_ExportPrjGrpSub41,'text').",
   					Variant_Mode	=".GetSQLValueString($Variant_Mode41,'int').",
   					Path_LoadSOF	=".GetSQLValueString($Path_LoadSOF41,'text').",
   					DefaultBase	=".GetSQLValueString($DefaultBase41,'int').",
   					AccessLabels	=".GetSQLValueString($AccessLabels41,'text').",";
   	if($Iso_Logo41 != '')
   	$queryupdatesetup=$queryupdatesetup."Iso_Logo	='".$Iso_Logo41."',";
   	
   	$queryupdatesetup=$queryupdatesetup."
   					IsoDescription	=".GetSQLValueString($IsoDescription41,'text').",
   					grid_color1	=".GetSQLValueString($grid_color141,'text').",
   					grid_color2	=".GetSQLValueString($grid_color241,'text').",
   					setup_branch	=".GetSQLValueString($setup_branch41,'text').",
   					setup_salesjvtax 	=".GetSQLValueString($setup_salesjvtax41,'text').",
   					setup_purchasesjvtax	=".GetSQLValueString($setup_purchasesjvtax41,'text').",
   					PrevShowThumbsStatment	=".GetSQLValueString($PrevShowThumbsStatment41,'int').",
   					PrevShowThumbsTrialBalance	=".GetSQLValueString($PrevShowThumbsTrialBalance41,'int').",
   					PrevShowThumbsStatmentofItems	=".GetSQLValueString($PrevShowThumbsStatmentofItems41,'int').",
   					PrevShowThumbsSalesReport	=".GetSQLValueString($PrevShowThumbsSalesReport41,'int').",
   					PrevShowThumbsInventoryReport	=".GetSQLValueString($PrevShowThumbsInventoryReport41,'int').",
   					Setup_TipsMaxAmount	=".GetSQLValueString($Setup_TipsMaxAmount41,'double').",
   					Setup_SorderMailMsg	=".GetSQLValueString($Setup_SorderMailMsg41,'text').",
   					CashReg_Weight	=".GetSQLValueString($CashReg_Weight41,'int').",
   					CashReg_StartBarcode	=".GetSQLValueString($CashReg_StartBarcode41,'int').",
   					CashReg_EndBarcode	=".GetSQLValueString($CashReg_EndBarcode41,'int').",
   					CashReg_StartQty	=".GetSQLValueString($CashReg_StartQty41,'int').",
   					CashReg_EndQty	=".GetSQLValueString($CashReg_EndQty41,'int').",
   					setup_plu	=".GetSQLValueString($setup_plu41,'text').",
   					setup_ItemDtGrid	=".GetSQLValueString($setup_ItemDtGrid41,'double').",
   					CashReg_Price	=".GetSQLValueString($CashReg_Price41,'int').",
   					CashReg_StartPrice	=".GetSQLValueString($CashReg_StartPrice41,'int').",
   					CashReg_EndPrice	=".GetSQLValueString($CashReg_EndPrice41,'int').",
   					CashReg_DispLedMsg	=".GetSQLValueString($CashReg_DispLedMsg41,'text').",
   					companyseq_id	=".GetSQLValueString($companyseq_id41,'long').",
   					maxperpage	=".GetSQLValueString($maxperpage41,'double').",
   					Setup_LogoWidth 	=".GetSQLValueString($Setup_LogoWidth41,'double').",
   					Setup_LogoHeight	=".GetSQLValueString($Setup_LogoHeight41,'double').",
   					show_companylogo	=".GetSQLValueString($show_companylogo41,'int').",
   					show_companyname	=".GetSQLValueString($show_companyname41,'int').",
   					show_printdatetime	=".GetSQLValueString($show_printdatetime41,'int').",
   					show_user	=".GetSQLValueString($show_user41,'int').",
   					show_companymemo	=".GetSQLValueString($show_companymemo41,'int').",
   					cashreg_colortheme	=".GetSQLValueString($cashreg_colortheme41,'text').",
   					Company_NameF	=".GetSQLValueString($Company_NameF41,'text').",
   					Company_MemoF	=".GetSQLValueString($Company_MemoF41,'text').",
   					Company_Capital	=".GetSQLValueString($Company_Capital41,'text').",
   					Company_CapitalF	=".GetSQLValueString($Company_CapitalF41,'text').",
   					Setup_MultiLangPrint 	=".GetSQLValueString($Setup_MultiLangPrint41,'int').",
   					report_color1	=".GetSQLValueString($report_color141,'text').",
   					report_color2	=".GetSQLValueString($report_color241,'text').",
   					VATSufixLength	=".GetSQLValueString($VATSufixLength41,'int').",
   					CashReg_BgColorOffer	=".GetSQLValueString($CashReg_BgColorOffer41,'text').",
   					CashReg_BgColorQty	=".GetSQLValueString($CashReg_BgColorQty41,'text').",
   					CashReg_BgColorOrderQty	=".GetSQLValueString($CashReg_BgColorOrderQty41,'text').",
   					CashReg_BgColorZeroPrice	=".GetSQLValueString($CashReg_BgColorZeroPrice41,'text').",
   					CashReg_BgColorZeroQty	=".GetSQLValueString($CashReg_BgColorZeroQty41,'text').",
   					CashReg_BgColorHasDiscount	=".GetSQLValueString($CashReg_BgColorHasDiscount41,'text').",
   					CashReg_RoundDivisor	=".GetSQLValueString($CashReg_RoundDivisor41,'double').",
   					Setup_SlipFooter	=".GetSQLValueString($Setup_SlipFooter41,'text').",
   					Setup_GenerateJvNoAmount	=".GetSQLValueString($Setup_GenerateJvNoAmount41,'int').",
   					CashReg_ApplyColorOffer	=".GetSQLValueString($CashReg_ApplyColorOffer41,'int').",
   					CashReg_ApplyColorQty	=".GetSQLValueString($CashReg_ApplyColorQty41,'int').",
   					CashReg_ApplyColorOrderQty	=".GetSQLValueString($CashReg_ApplyColorOrderQty41,'int').",
   					CashReg_ApplyColorZeroPrice	=".GetSQLValueString($CashReg_ApplyColorZeroPrice41,'int').",
   					CashReg_ApplyColorZeroQty	=".GetSQLValueString($CashReg_ApplyColorZeroQty41,'int').",
   					CashReg_ApplyColorHasDiscount	=".GetSQLValueString($CashReg_ApplyColorHasDiscount41,'int').",
   					Setup_LicenseNo	=".GetSQLValueString($Setup_LicenseNo41,'text').",
   					Setup_ClientSerialNo	=".GetSQLValueString($Setup_ClientSerialNo41,'text').",
   					discount_amount	=".GetSQLValueString($discount_amount41,'double').",
   					keyboardfocus	=".GetSQLValueString($keyboardfocus41,'int').",
   					Setup_TransShowLedger	=".GetSQLValueString($Setup_TransShowLedger41,'int').", 
   					category_order	=".GetSQLValueString($category_order41,'double').",
   					category_length	=".GetSQLValueString($category_length41,'double').",
   					group_order	=".GetSQLValueString($group_order41,'double').",
   					group_length	=".GetSQLValueString($group_length41,'double').",
   					subgroup_order 	=".GetSQLValueString($subgroup_order41,'double').",
   					subgroup_length	=".GetSQLValueString($subgroup_length41,'double').",
   					remaining_length	=".GetSQLValueString($remaining_length41,'double').",
   					delivery_maxrecords	=".GetSQLValueString($delivery_maxrecords41,'double').",
   					journal_setup	=".GetSQLValueString($journal_setup41,'text').",
   					serialNb_quantity_setup	=".GetSQLValueString($serialNb_quantity_setup,'int')."
   					";
   		   
   		  // echo $_POST['Setup_plu41']; exit;
   			//echo $queryupdatesetup;  exit;
   $result_setup5=mysql_query($queryupdatesetup , $connection) or die(mysql_error());	
   } 
   //echo "test";
   header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	 }
   
   
   //getting the values from the purshase setup
   
   $Warehouse  =$_POST["Warehouse31"];  
   $Project  =$_POST["Project31"];  
   $Costcenter  =$_POST["Costcenter31"];  
   $PaymentMode  =$_POST["PaymentMode31"];  
   $Charges  =$_POST["Charges31"]; 
   $SupplierCur  =$_POST["SupplierCur31"];  
   $SupplierAccount  =$_POST["SupplierAccount31"]; 
   $FreightCur  =$_POST["FreightCur31"];  
   $FreightCurDefault  =$_POST["FreightCurDefault31"];  
   $FreightDebitAccount  =$_POST["FreightDebitAccount31"];  
   $FreightCreditAccount  =$_POST["FreightCreditAccount31"]; 
   $Chargeaccount  =$_POST["Chargeaccount31"];  
   $ChargeaccountCur  =$_POST["ChargeaccountCur31"]; 
   $ChargeaccountCurDefault  =$_POST["ChargeaccountCurDefault31"];  
   $CommissionsCur  =$_POST["CommissionsCur31"];  
   $CommissionsCurDefault  =$_POST["CommissionsCurDefault31"]; 
   $CommissionsDebitAccount  =$_POST["CommissionsDebitAccount31"];  
   $CommissionsCreditAccount  =$_POST["CommissionsCreditAccount31"]; 
   $InsuranceCur  =$_POST["InsuranceCur31"];  
   $InsuranceCurDefault  =$_POST["InsuranceCurDefault31"]; 
   $InsuranceDebitAccount  =$_POST["InsuranceDebitAccount31"];  
   $InsuranceCreditAccount  =$_POST["InsuranceCreditAccount31"];  
   $ClearingCur  =$_POST["ClearingCur31"];   
   $ClearingCurDefault  =$_POST["ClearingCurDefault31"];  
   $ClearingDebitAccount  =$_POST["ClearingDebitAccount31"];  
   $ClearingCreditAccount  =$_POST["ClearingCreditAccount31"];  
   $TransportCur  =$_POST["TransportCur31"];  
   $TransportCurDefault  =$_POST["TransportCurDefault31"];  
   $TransportDebitAccount  =$_POST["TransportDebitAccount31"];  
   $TransportCreditAccount  =$_POST["TransportCreditAccount31"];  
   $OtherCur  =$_POST["OtherCur31"];  
   $OtherCurDefault  =$_POST["OtherCurDefault31"]; 
   $OtherDebitAccount  =$_POST["OtherDebitAccount31"];   
   $OtherCreditAccount  =$_POST["OtherCreditAccount31"]; 
   $DebitCur  =$_POST["DebitCur31"];  
   $DebitCurdefault  =$_POST["DebitCurdefault31"];
   $DebitAccount  =$_POST["DebitAccount31"];  
   $DebitCurReturn  =$_POST["DebitCurReturn31"];  
   $DebitCurReturnDefault  =$_POST["DebitCurReturnDefault31"];  
   $DebitAccountReturn  =$_POST["DebitAccountReturn31"];  
   $CashCur  =$_POST["CashCur31"];
   $CashCurDefault  =$_POST["CashCurDefault31"];  
   $CashAccount  =$_POST["CashAccount31"];  
   $CheckCur  =$_POST["CheckCur31"];  
   $CheckCurDefault  =$_POST["CheckCurDefault31"];  
   $CheckAccount  =$_POST["CheckAccount31"];  
   $CustomsDebitAccount  =$_POST["CustomsDebitAccount31"];  
   $CustomsCreditAccount  =$_POST["CustomsCreditAccount31"];  
   $CustomsCur  =$_POST["CustomsCur31"];  $ 
   $CustomsCurDefault  =$_POST["CustomsCurDefault31"];  
   $VatAccount  =$_POST["VatAccount31"];  
   $CreditAccountReturn  =$_POST["CreditAccountReturn31"];  
   $CreditCurReturnDefault  =$_POST["CreditCurReturnDefault31"];  
   $DiscountAccount  =$_POST["DiscountAccount31"];  
   $Barcode  =$_POST["Barcode31"];  
   $PURCHASETTC  =$_POST["PURCHASETTC31"];  
   $DebitAccountVAT  =$_POST["DebitAccountVAT31"]; 
   $DirectStockCurrency_Code  =$_POST["DirectStockCurrency_Code31"];  
   $TipsAccount  =$_POST["TipsAccount31"];  
   $TipsMaxBase1  =$_POST["TipsMaxBase131"]; 
   $Purchasejv_chargedebit  =$_POST["Purchasejv_chargedebit31"]; 
   $Purchasejv_chargecredit  =$_POST["Purchasejv_chargecredit31"];  
   $Module_Color  =$_POST["Module_Color31"]; 
   $PurchaseJV_DefaultCur  =$_POST["PurchaseJV_DefaultCur31"];  
   $PurchaseJV_VatAccount  =$_POST["PurchaseJV_VatAccount31"];  
   $WITHPRICEDEFAULT  =$_POST["WITHPRICEDEFAULT31"];  
   $GenerateCharges  =$_POST["GenerateCharges31"];  
   $PurchaseDefaultType  =$_POST["PurchaseDefaultType31"];  
   $Purchase_Acctax1  =$_POST["Purchase_Acctax131"];   
   $Purchase_Acctax2  =$_POST["Purchase_Acctax231"]; 
   $Purchase_Acctax3  =$_POST["Purchase_Acctax331"]; 
   $Purchase_Acctax4  =$_POST["Purchase_Acctax431"];  
   $Purchase_Acctax5  =$_POST["Purchase_Acctax531"];  
   $Synchronized  =$_POST["Synchronized31"];  
   $DisplayPurchaseType  =$_POST["DisplayPurchaseType31"];  
   $DefaultPrice_FobORLast  =$_POST["DefaultPrice_FobORLast31"];  
   $IsoDescription  =$_POST["IsoDescription31"];  
   $VATAccountNonStock  =$_POST["VATAccountNonStock31"];  
   $ShowCostCentLayout  =$_POST["ShowCostCentLayout31"];  
   $id  =$_POST["id31"];  
   $VatAccount2  =$_POST["VatAccount231"];   
   $VatAccount3  =$_POST["VatAccount331"];  
   $VATAccountNonStock2  =$_POST["VATAccountNonStock231"];  
   $VATAccountNonStock3  =$_POST["VATAccountNonStock331"];  
   $DebitAccount2  =$_POST["DebitAccount231"];  
   $DebitAccount3  =$_POST["DebitAccount331"];  
   $DebitAccountVat2  =$_POST["DebitAccountVat231"];  
   $DebitAccountVat3  =$_POST["DebitAccountVat331"]; 
   $DebitAccountNonStock  =$_POST["DebitAccountNonStock31"];   
   $DebitAccountNonStock2  =$_POST["DebitAccountNonStock231"];  
   $DebitAccountNonStock3  =$_POST["DebitAccountNonStock331"];  
   $DebitAccountVATNonStock  =$_POST["DebitAccountVATNonStock31"];  
   $DebitAccountVATNonStock2  =$_POST["DebitAccountVATNonStock231"];  
   $DebitAccountVATNonStock3  =$_POST["DebitAccountVATNonStock331"];  
   $VATAccountRefundable  =$_POST["VATAccountRefundable31"]; 
   $DebitAccountVatRefundable  =$_POST["DebitAccountVatRefundable31"];  
   $ShowItemSellingPrice  =$_POST["ShowItemSellingPrice31"];  
   $porder_termsconditions  =$_POST["porder_termsconditions31"]; 
   if($Tabnumber == 11){
   $result3 = mysql_query("SELECT * FROM purchasesetup" ,  $connection);
   $num_rows3 = mysql_num_rows($result3);
    
   if($num_rows3==0){
   $query_insert_purchasesetup3="insert into purchasesetup ( Warehouse ,  Project ,  Costcenter ,  PaymentMode ,  Charges ,  SupplierCur ,  SupplierAccount ,  FreightCur ,  FreightCurDefault ,  FreightDebitAccount ,  FreightCreditAccount , 
   														Chargeaccount ,  ChargeaccountCur ,  ChargeaccountCurDefault ,  CommissionsCur ,  CommissionsCurDefault ,  CommissionsDebitAccount ,  CommissionsCreditAccount ,  InsuranceCur , 
   														InsuranceCurDefault ,  InsuranceDebitAccount ,  InsuranceCreditAccount ,  ClearingCur ,  ClearingCurDefault ,  ClearingDebitAccount ,  ClearingCreditAccount ,  TransportCur , 
   														TransportCurDefault ,  TransportDebitAccount ,  TransportCreditAccount ,  OtherCur ,  OtherCurDefault ,  OtherDebitAccount ,  OtherCreditAccount ,  DebitCur ,  DebitCurdefault , 
   														DebitAccount ,  DebitCurReturn ,  DebitCurReturnDefault ,  DebitAccountReturn ,  CashCur ,  CashCurDefault ,  CashAccount ,  CheckCur ,  CheckCurDefault ,  CheckAccount ,  
   														CustomsDebitAccount ,  CustomsCreditAccount ,  CustomsCur ,  CustomsCurDefault ,  VatAccount ,  CreditAccountReturn ,  CreditCurReturnDefault ,  DiscountAccount ,  Barcode ,  
   														PURCHASETTC ,  DebitAccountVAT ,  DirectStockDebit ,  DirectStockCredit ,  DirectStockCurrency_Code ,  TipsAccount ,  TipsMaxBase1 ,  Purchasejv_chargedebit ,  
   														Purchasejv_chargecredit ,  Module_Color ,  PurchaseJV_DefaultCur ,  PurchaseJV_VatAccount ,  WITHPRICEDEFAULT ,  GenerateCharges ,  PurchaseDefaultType ,  Purchase_Acctax1 ,  
   														Purchase_Acctax2 ,  Purchase_Acctax3 ,  Purchase_Acctax4 ,  Purchase_Acctax5 ,  Synchronized ,  DisplayPurchaseType ,  DefaultPrice_FobORLast ,  IsoDescription ,  
   														VATAccountNonStock ,  ShowCostCentLayout ,  VatAccount2 ,  VatAccount3 ,  VATAccountNonStock2 ,  VATAccountNonStock3 ,  DebitAccount2 ,  DebitAccount3 ,  DebitAccountVat2 , 
   														DebitAccountVat3 ,  DebitAccountNonStock ,  DebitAccountNonStock2 ,  DebitAccountNonStock3 , DebitAccountVATNonStock ,  DebitAccountVATNonStock2 ,  
   														DebitAccountVATNonStock3 ,  VATAccountRefundable ,  DebitAccountVatRefundable ,  ShowItemSellingPrice ,  porder_termsconditions)
   												values(
   												'".GetSQLValueString($Warehouse31,'text')."' ,
   												'".GetSQLValueString($Project31,'text')."' , 
   												'".GetSQLValueString($Costcenter31,'text')."' , 
   												'".GetSQLValueString($PaymentMode31,'double')."' , 
   												'".GetSQLValueString($Charges31,'int')."' , 
   
   												'".GetSQLValueString($SupplierCur31,'text')."' , 
   												'".GetSQLValueString($SupplierAccount31,'text')."' , 
   												'".GetSQLValueString($FreightCur31,'text')."' , 
   												'".GetSQLValueString($FreightCurDefault31,'int')."' , 
   
   												'".GetSQLValueString($FreightDebitAccount31,'text')."' , 
   												'".GetSQLValueString($FreightCreditAccount31,'text')."' , 
   												'".GetSQLValueString($Chargeaccount31,'text')."' , 
   												'".GetSQLValueString($ChargeaccountCur31,'text')."' ,  
   												'".GetSQLValueString($ChargeaccountCurDefault31,'int')."' , 
   
   												'".GetSQLValueString($CommissionsCur31,'text')."' ,
   												'".GetSQLValueString($CommissionsCurDefault31,'int')."' ,
   												'".GetSQLValueString($CommissionsDebitAccount31,'text')."' , 
   												'".GetSQLValueString($CommissionsCreditAccount31,'text')."' , 
   												'".GetSQLValueString($InsuranceCur31,'text')."' ,
   
   												'".GetSQLValueString($InsuranceCurDefault31,'int')."' , 
   												'".GetSQLValueString($InsuranceDebitAccount31,'text')."' ,
   												'".GetSQLValueString($InsuranceCreditAccount31,'text')."' ,
   												'".GetSQLValueString($ClearingCur31,'text')."' , 
   												'".GetSQLValueString($ClearingCurDefault31,'int')."' , 
   
   												'".GetSQLValueString($ClearingDebitAccount31,'text')."' , 
   												'".GetSQLValueString($ClearingCreditAccount31,'text')."' , 
   												'".GetSQLValueString($TransportCur31,'text')."' ,
   												'".GetSQLValueString($TransportCurDefault31,'int')."' ,
   												'".GetSQLValueString($TransportDebitAccount31,'text')."' , 
   												'".GetSQLValueString($TransportCreditAccount31,'text')."' ,
   												'".GetSQLValueString($OtherCur31,'text')."' , 
   												'".GetSQLValueString($OtherCurDefault31,'int')."' , 
   
   												'".GetSQLValueString($OtherDebitAccount31,'text')."' ,
   												'".GetSQLValueString($OtherCreditAccount31,'text')."' , 
   												'".GetSQLValueString($DebitCur31,'text')."' ,  
   												'".GetSQLValueString($DebitCurdefault31,'int')."' , 
   												'".GetSQLValueString($DebitAccount31,'text')."' , 
   												'".GetSQLValueString($DebitCurReturn31,'text')."' ,
   
   												'".GetSQLValueString($DebitCurReturnDefault31,'int')."' , 
   												'".GetSQLValueString($DebitAccountReturn31,'text')."' ,
   												'".GetSQLValueString($CashCur31,'text')."' ,  
   												'".GetSQLValueString($CashCurDefault31,'int')."' , 
   												'".GetSQLValueString($CashAccount31,'text')."' , 
   
   												'".GetSQLValueString($CheckCur31,'text')."' , 
   												'".GetSQLValueString($CheckCurDefault31,'int')."' , 
   												'".GetSQLValueString($CheckAccount31,'text')."' ,  
   												'".GetSQLValueString($CustomsDebitAccount31,'text')."' , 
   												'".GetSQLValueString($CustomsCreditAccount31,'text')."' , 
   												'".GetSQLValueString($CustomsCur31,'text')."' , 
   
   												'".GetSQLValueString($CustomsCurDefault31,'int')."' ,
   												'".GetSQLValueString($VatAccount31,'text')."' , 
   												'".GetSQLValueString($CreditAccountReturn31,'text')."' , 
   												'".GetSQLValueString($CreditCurReturnDefault31,'int')."' , 
   												'".GetSQLValueString($DiscountAccount31,'text')."' ,
   
   												'".GetSQLValueString($Barcode31,'int')."' ,
   												'".GetSQLValueString($PURCHASETTC31,'int')."' ,  
   												'".GetSQLValueString($DebitAccountVAT31,'text')."' , 
   												'".GetSQLValueString($DirectStockDebit31,'text')."' ,
   												'".GetSQLValueString($DirectStockCredit31,'text')."' ,
   												'".GetSQLValueString($DirectStockCurrency_Code31,'text')."' ,
   												'".GetSQLValueString($TipsAccount31,'text')."' , 
   
   												'".GetSQLValueString($TipsMaxBase131,'double')."' , 
   												'".GetSQLValueString($Purchasejv_chargedebit31,'text')."' , 
   												'".GetSQLValueString($Purchasejv_chargecredit31,'text')."' , 
   												'".GetSQLValueString($Module_Color31,'int')."' , 
   												'".GetSQLValueString($PurchaseJV_DefaultCur31,'text')."' , 
   												'".GetSQLValueString($PurchaseJV_VatAccount31,'text')."' ,  
   
   												'".GetSQLValueString($WITHPRICEDEFAULT31,'int')."' ,
   												'".GetSQLValueString($GenerateCharges31,'int')."' ,
   												'".GetSQLValueString($PurchaseDefaultType31,'text')."' , 
   												'".GetSQLValueString($Purchase_Acctax131,'text')."' , 
   												'".GetSQLValueString($Purchase_Acctax231,'text')."' , 
   												'".GetSQLValueString($Purchase_Acctax331,'text')."' , 
   												'".GetSQLValueString($Purchase_Acctax431,'text')."' , 
   												'".GetSQLValueString($Purchase_Acctax531,'text')."' , 
   
   												'".GetSQLValueString($Synchronized31,'int')."' , 
   												'".GetSQLValueString($DisplayPurchaseType31,'int')."' ,
   												'".GetSQLValueString($DefaultPrice_FobORLast31,'int')."' , 
   												'".GetSQLValueString($IsoDescription31,'text')."' ,
   												'".GetSQLValueString($VATAccountNonStock31,'text')."' , 
   												'".GetSQLValueString($ShowCostCentLayout31,'int')."' ,
   
   												'".GetSQLValueString($VatAccount231,'text')."' ,  
   												'".GetSQLValueString($VatAccount331,'text')."' ,
   												'".GetSQLValueString($VATAccountNonStock231,'text')."' , 
   												'".GetSQLValueString($VATAccountNonStock331,'text')."' , 
   												'".GetSQLValueString($DebitAccount231,'text')."' , 
   
   												'".GetSQLValueString($DebitAccount331,'text')."' ,
   												'".GetSQLValueString($DebitAccountVat231,'text')."' , 
   												'".GetSQLValueString($DebitAccountVat331,'text')."' , 
   												'".GetSQLValueString($DebitAccountNonStock31,'text')."' ,
   												'".GetSQLValueString($DebitAccountNonStock231,'text')."' , 
   												'".GetSQLValueString($DebitAccountNonStock331,'text')."' ,
   												'".GetSQLValueString($DebitAccountVATNonStock31,'text')."' , 
   												'".GetSQLValueString($DebitAccountVATNonStock231,'text')."' , 
   												'".GetSQLValueString($DebitAccountVATNonStock331,'text')."' , 
   												'".GetSQLValueString($VATAccountRefundable31,'text')."' , 
   												'".GetSQLValueString($DebitAccountVatRefundable31,'text')."' ,
   												'".GetSQLValueString($ShowItemSellingPrice31,'int')."' , 
   												'".GetSQLValueString($porder_termsconditions31,'text')."' 
   												)";
   												
   											//echo $query_insert_purchasesetup3 ;
   										//	exit;
   $result_purchasesetup3=mysql_query($query_insert_purchasesetup3 , $connection) or die(mysql_error());
   }
   
   else{
   //update purshasesetup
   $queryupdatepurchasesetup3="UPDATE purchasesetup   
   							SET  	
   							
   							Warehouse	=".GetSQLValueString($Warehouse31,'text').",
   							Project	=".GetSQLValueString($Project31,'text').", 
   							Costcenter	=".GetSQLValueString($Costcenter31,'text').", 
   							PaymentMode	=".GetSQLValueString($PaymentMode31,'double').", 
   							Charges	=".GetSQLValueString($Charges31,'int').", 
   							SupplierCur	=".GetSQLValueString($SupplierCur31,'text').", 
   							
   							SupplierAccount	=".GetSQLValueString($SupplierAccount31,'text').", 
   							FreightCur	=".GetSQLValueString($FreightCur31,'text').", 
   							FreightCurDefault	=".GetSQLValueString($FreightCurDefault31,'int').", 
   							FreightDebitAccount	=".GetSQLValueString($FreightDebitAccount31,'text').", 
   							FreightCreditAccount	=".GetSQLValueString($FreightCreditAccount31,'text').", 
   							Chargeaccount	=".GetSQLValueString($Chargeaccount31,'text').", 
   							
   							ChargeaccountCur	=".GetSQLValueString($ChargeaccountCur31,'text').",  
   							ChargeaccountCurDefault	=".GetSQLValueString($ChargeaccountCurDefault31,'int').", 
   							CommissionsCur	=".GetSQLValueString($CommissionsCur31,'text').",
   							CommissionsCurDefault	=".GetSQLValueString($CommissionsCurDefault31,'int').",
   							CommissionsDebitAccount	=".GetSQLValueString($CommissionsDebitAccount31,'text').", 
   							CommissionsCreditAccount	=".GetSQLValueString($CommissionsCreditAccount31,'text').", 
   							InsuranceCur	=".GetSQLValueString($InsuranceCur31,'text').",
   							
   							InsuranceCurDefault	=".GetSQLValueString($InsuranceCurDefault31,'int').", 
   							InsuranceDebitAccount	=".GetSQLValueString($InsuranceDebitAccount31,'text').",
   							InsuranceCreditAccount	=".GetSQLValueString($InsuranceCreditAccount31,'text').",
   							ClearingCur	=".GetSQLValueString($ClearingCur31,'text').", 
   							ClearingCurDefault	=".GetSQLValueString($ClearingCurDefault31,'int').", 
   							ClearingDebitAccount	=".GetSQLValueString($ClearingDebitAccount31,'text').", 
   							ClearingCreditAccount	=".GetSQLValueString($ClearingCreditAccount31,'text').", 
   							TransportCur	=".GetSQLValueString($TransportCur31,'text').",
   							
   							TransportCurDefault	=".GetSQLValueString($TransportCurDefault31,'int').",
   							TransportDebitAccount	=".GetSQLValueString($TransportDebitAccount31,'text').", 
   							TransportCreditAccount	=".GetSQLValueString($TransportCreditAccount31,'text').",
   							OtherCur	=".GetSQLValueString($OtherCur31,'text').", 
   							OtherCurDefault	=".GetSQLValueString($OtherCurDefault31,'int').", 
   							OtherDebitAccount	=".GetSQLValueString($OtherDebitAccount31,'text').",
   							OtherCreditAccount	=".GetSQLValueString($OtherCreditAccount31,'text').", 
   							DebitCur	=".GetSQLValueString($DebitCur31,'text').",  
   							
   							DebitCurdefault	=".GetSQLValueString($DebitCurdefault31,'int').", 
   							DebitAccount	=".GetSQLValueString($DebitAccount31,'text').", 
   							DebitCurReturn	=".GetSQLValueString($DebitCurReturn31,'text').",
   							DebitCurReturnDefault	=".GetSQLValueString($DebitCurReturnDefault31,'int').", 
   							DebitAccountReturn	=".GetSQLValueString($DebitAccountReturn31,'text').",
   							CashCur	=".GetSQLValueString($CashCur31,'text').",  
   							
   							CashCurDefault	=".GetSQLValueString($CashCurDefault31,'int').", 
   							CashAccount	=".GetSQLValueString($CashAccount31,'text').", 
   							CheckCur	=".GetSQLValueString($CheckCur31,'text').", 
   							CheckCurDefault	=".GetSQLValueString($CheckCurDefault31,'int').", 
   							CheckAccount	=".GetSQLValueString($CheckAccount31,'text').",  
   							
   							CustomsDebitAccount	=".GetSQLValueString($CustomsDebitAccount31,'text').", 
   							CustomsCreditAccount	=".GetSQLValueString($CustomsCreditAccount31,'text').", 
   							CustomsCur	=".GetSQLValueString($CustomsCur31,'text').", 
   							CustomsCurDefault	=".GetSQLValueString($CustomsCurDefault31,'int').",
   							VatAccount	=".GetSQLValueString($VatAccount31,'text').", 
   							CreditAccountReturn	=".GetSQLValueString($CreditAccountReturn31,'text').", 
   							CreditCurReturnDefault	=".GetSQLValueString($CreditCurReturnDefault31,'int').", 
   							DiscountAccount	=".GetSQLValueString($DiscountAccount31,'text').",
   							Barcode	=".GetSQLValueString($Barcode31,'int').",
   							
   							PURCHASETTC	=".GetSQLValueString($PURCHASETTC31,'int').",  
   							DebitAccountVAT	=".GetSQLValueString($DebitAccountVAT31,'text').", 
   							DirectStockDebit 	=".GetSQLValueString($DirectStockDebit31,'text').",
   							DirectStockCredit	=".GetSQLValueString($DirectStockCredit31,'text').",
   							DirectStockCurrency_Code	=".GetSQLValueString($DirectStockCurrency_Code31,'text').",
   							TipsAccount	=".GetSQLValueString($TipsAccount31,'text').", 
   							TipsMaxBase1	=".GetSQLValueString($TipsMaxBase131,'double').", 
   							
   							Purchasejv_chargedebit	=".GetSQLValueString($Purchasejv_chargedebit31,'text').", 
   							Purchasejv_chargecredit	=".GetSQLValueString($Purchasejv_chargecredit31,'text').", 
   							Module_Color	=".GetSQLValueString($Module_Color31,'int').", 
   							PurchaseJV_DefaultCur	=".GetSQLValueString($PurchaseJV_DefaultCur31,'text').", 
   							PurchaseJV_VatAccount	=".GetSQLValueString($PurchaseJV_VatAccount31,'text').",  
   							WITHPRICEDEFAULT	=".GetSQLValueString($WITHPRICEDEFAULT31,'int').",
   							GenerateCharges	=".GetSQLValueString($GenerateCharges31,'int').",
   							
   							PurchaseDefaultType	=".GetSQLValueString($PurchaseDefaultType31,'text').", 
   							Purchase_Acctax1	=".GetSQLValueString($Purchase_Acctax131,'text').", 
   							Purchase_Acctax2	=".GetSQLValueString($Purchase_Acctax231,'text').", 
   							Purchase_Acctax3	=".GetSQLValueString($Purchase_Acctax331,'text').", 
   							Purchase_Acctax4	=".GetSQLValueString($Purchase_Acctax431,'text').", 
   							Purchase_Acctax5	=".GetSQLValueString($Purchase_Acctax531,'text').", 
   							Synchronized	=".GetSQLValueString($Synchronized31,'int').", 
   							
   							DisplayPurchaseType	=".GetSQLValueString($DisplayPurchaseType31,'int').",
   							DefaultPrice_FobORLast	=".GetSQLValueString($DefaultPrice_FobORLast31,'int').", 
   							IsoDescription	=".GetSQLValueString($IsoDescription31,'text').",
   							VATAccountNonStock	=".GetSQLValueString($VATAccountNonStock31,'text').", 
   							ShowCostCentLayout	=".GetSQLValueString($ShowCostCentLayout31,'int').",
   							VatAccount2	=".GetSQLValueString($VatAccount231,'text').",  
   							
   							VatAccount3	=".GetSQLValueString($VatAccount331,'text').",
   							VATAccountNonStock2	=".GetSQLValueString($VATAccountNonStock231,'text').", 
   							VATAccountNonStock3	=".GetSQLValueString($VATAccountNonStock331,'text').", 
   							DebitAccount2	=".GetSQLValueString($DebitAccount231,'text').", 
   							DebitAccount3	=".GetSQLValueString($DebitAccount331,'text').",
   							DebitAccountVat2	=".GetSQLValueString($DebitAccountVat231,'text').", 
   							DebitAccountVat3	=".GetSQLValueString($DebitAccountVat331,'text').", 
   							
   							DebitAccountNonStock	=".GetSQLValueString($DebitAccountNonStock31,'text').",
   							DebitAccountNonStock2	=".GetSQLValueString($DebitAccountNonStock231,'text').", 
   							DebitAccountNonStock3	=".GetSQLValueString($DebitAccountNonStock331,'text').",
   							DebitAccountVATNonStock	=".GetSQLValueString($DebitAccountVATNonStock31,'text').", 
   							DebitAccountVATNonStock2	=".GetSQLValueString($DebitAccountVATNonStock231,'text').", 
   							
   							DebitAccountVATNonStock3	=".GetSQLValueString($DebitAccountVATNonStock331,'text').", 
   							VATAccountRefundable	=".GetSQLValueString($VATAccountRefundable31,'text').", 
   							DebitAccountVatRefundable	=".GetSQLValueString($DebitAccountVatRefundable31,'text').",
   							ShowItemSellingPrice	=".GetSQLValueString($ShowItemSellingPrice31,'int').", 
   							porder_termsconditions	=".GetSQLValueString($porder_termsconditions31,'text')." ";
   					//echo $queryupdatepurchasesetup3;
   					//exit;
   $resultupdatepurchasesetup3=mysql_query($queryupdatepurchasesetup3 , $connection) or die(mysql_error());
   }
    header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   //getting the values from the salessetup
   
   $Warehouse=$_POST["Warehouse2"];  
   $Project=$_POST["Project2"];   
   $Costcenter =$_POST["Costcenter2"];  
   $PaymentMode =$_POST["PaymentMode2"];  
   $ClientCur =$_POST["ClientCur2"];  
   $ClientAccount =$_POST["ClientAccount2"];  
   $CreditCur =$_POST["CreditCur2"];  
   $CreditCurdefault =$_POST["CreditCurdefault2"];  
   $CreditAccount =$_POST["CreditAccount2"];  
   $CashCur =$_POST["CashCur2"];  
   $CashCurDefault =$_POST["CashCurDefault2"];  
   $CashAccount =$_POST["CashAccount2"];  
   $CheckCur =$_POST["CheckCur2"];  
   $CheckCurDefault =$_POST["CheckCurDefault2"];   
   $CheckAccount =$_POST["CheckAccount2"];  
   $TipsAccount =$_POST["TipsAccount2"];  
   $VatAccount =$_POST["VatAccount2"];  
   $CreditAccountReturn =$_POST["CreditAccountReturn2"];  
   $CreditCurReturnDefault =$_POST["CreditCurReturnDefault2"];  
   $CreditCurReturn =$_POST["CreditCurReturn2"];  
   $CHARGES =$_POST["CHARGES2"];  
   $DiscountAccount =$_POST["DiscountAccount2"];  
   $Creditaccountvat =$_POST["Creditaccountvat2"];  
   $DirectStockDebit =$_POST["DirectStockDebit2"];   
   $DirectStockCredit =$_POST["DirectStockCredit2"];  
   $DEBITACC =$_POST["DEBITACC2"];  
   $CustomsCurDefault =$_POST["CustomsCurDefault2"];  
   $CustomsAccount =$_POST["CustomsAccount2"];  
   $CustomsCur =$_POST["CustomsCur2"];   
   $BillsAccount =$_POST["BillsAccount2"];  
   $BillsCur =$_POST["BillsCur2"];  
   $BillsCurDefault =$_POST["BillsCurDefault2"];  
   $DEBITcUR =$_POST["DEBITcUR2"];  
   $DebitCurDefault =$_POST["DebitCurDefault2"];   
   $TipsMaxBase1 =$_POST["TipsMaxBase12"];  
   $WithPriceDefault =$_POST["WithPriceDefault2"];  
   $PrintPreview =$_POST["PrintPreview2"];  
   $CREDITVATRETURN =$_POST["CREDITVATRETURN2"];  
   $SALESTTC =$_POST["SALESTTC2"];   
   $DirectStockCurrency_Code =$_POST["DirectStockCurrency_Code2"];  
   $SalesSetup =$_POST["SalesSetup2"];  
   $Setup_LedgerNumber =$_POST["Setup_LedgerNumber2"];  
   $SalesJV_PrintedDateTime =$_POST["SalesJV_PrintedDateTime2"];  
   $SalesJV_PrintFolio =$_POST["SalesJV_PrintFolio2"];  
   $Sale_Remark =$_POST["Sale_Remark2"];  
   $SalesJV_DefaultCur =$_POST["SalesJV_DefaultCur2"];   
   $Sale_PrinterLPTPort =$_POST["Sale_PrinterLPTPort2"];  
   $SALE_PrintBottomLabel =$_POST["SALE_PrintBottomLabel2"];   
   $Sale_DisplayLedDefault =$_POST["Sale_DisplayLedDefault2"];  
   $Sale_COMPortDefault =$_POST["Sale_COMPortDefault2"];  
   $SalesJV_VatAccount =$_POST["SalesJV_VatAccount2"];  
   $Sale_CalculateWeight =$_POST["Sale_CalculateWeight2"];  
   $SalesJV_MaxDiscountPer =$_POST["SalesJV_MaxDiscountPer2"];  
   $Sales_MaxDiscountPer =$_POST["Sales_MaxDiscountPer2"];  
   $Sale_Acctax1 =$_POST["Sale_Acctax12"];  
   $Sale_Acctax2 =$_POST["Sale_Acctax22"];  
   $Sale_Acctax3 =$_POST["Sale_Acctax32"];   
   $Sale_Acctax4 =$_POST["Sale_Acctax42"];  
   $Sale_Acctax5 =$_POST["Sale_Acctax52"]; 
   $PromotionAccount =$_POST["PromotionAccount2"];  
   $DiscountFromItemGroup =$_POST["DiscountFromItemGroup2"];  
   $Sale_ExchangeSellPrice =$_POST["Sale_ExchangeSellPrice2"];  
   $Synchronized =$_POST["Synchronized2"];  
   $Barcode =$_POST["Barcode2"];  
   $DisplayTransferInDR =$_POST["DisplayTransferInDR2"];   
   $NoneStandardBarcode =$_POST["NoneStandardBarcode2"];   
   $AutoGenerateSizeMeasure =$_POST["AutoGenerateSizeMeasure2"];  
   $EnableDeliveryConfirmed =$_POST["EnableDeliveryConfirmed2"]; 
   $EnablePricePerUnit =$_POST["EnablePricePerUnit2"];  
   $Sale_SequentialRefViaCST =$_POST["Sale_SequentialRefViaCST2"];  
   $Sale_SeperateLines =$_POST["Sale_SeperateLines2"];  
   $Sale_changeClient =$_POST["Sale_changeClient2"];   
   $Sale_CLAAccount21 =$_POST["Sale_CLAAccount21"];  
   $Sale_DCTAccount21 =$_POST["Sale_DCTAccount21"];  
   $Sale_AWAccount21 =$_POST["Sale_AWAccount21"];  
   $Sale_TRPAccount21 =$_POST["Sale_TRPAccount21"];  
   $ExportDiscPerJV =$_POST["ExportDiscPerJV2"];  
   $Sales_DiscountAcc21 =$_POST["Sales_DiscountAcc21"];  
   $LoadItems =$_POST["LoadItems2"];  
   $CheckQuantity =$_POST["CheckQuantity2"];  
   $TransportAccount =$_POST["TransportAccount2"];  
   $ExportTransportToJV =$_POST["ExportTransportToJV2"];  
   $Sale_CLAAccount22 =$_POST["Sale_CLAACcount22"];  
   $Sale_DCTAccount22 =$_POST["Sale_DCTAccount22"];  
   $Sale_AWAccount22 =$_POST["Sale_AWAccount22"];  
   $Sale_TRPAccount22 =$_POST["Sale_TRPAccount22"];  
   $Sales_DiscountAcc22 =$_POST["Sales_DiscountAcc22"];  
   $IsoDescription =$_POST["IsoDescription2"];  
   $IsoDlvDescription =$_POST["IsoDlvDescription2"];  
   $Delivery_packPrice =$_POST["Delivery_packPrice2"];  
   $show_QtySorder =$_POST["show_QtySorder2"];  
   $BonusAccount =$_POST["BonusAccount2"];  
   $ExportBonusToJV =$_POST["ExportBonusToJV2"];  
   $InvoiceComment =$_POST["InvoiceComment2"];  
   $WaybillComment =$_POST["WaybillComment2"];  
   $Sale_MinPendingQty =$_POST["Sale_MinPendingQty2"];  
   $Sale_MaxExceedQty =$_POST["Sale_MaxExceedQty2"];   
   $Sale_MarginPer =$_POST["Sale_MarginPer2"];   
   $VATAccountNonStock =$_POST["VATAccountNonStock2"];   
   $SorderComment =$_POST["SorderComment2"];  
   $PrintDeliveryByWarehouse =$_POST["PrintDeliveryByWarehouse2"];  
   $PriceDecimalBase =$_POST["PriceDecimalBase2"];  
   $ShowCostCentLayout =$_POST["ShowCostCentLayout2"];  
   $id =$_POST["id2"];  
   $VatAccountPOS =$_POST["VatAccountPOS2"];  
   $VATAccountNonStockPOS =$_POST["VATAccountNonStockPOS2"];   
   $CreditAccountNonStock =$_POST["CreditAccountNonStock2"];   
   $CreditAccountVATNonStock =$_POST["CreditAccountVATNonStock2"];   
   $CreditReturnNonStock =$_POST["CreditReturnNonStock2"];  
   $CreditVATReturnNonStock =$_POST["CreditVATReturnNonStock2"];  
   $VatAccountRefundable =$_POST["VatAccountRefundable2"];  
   $CreditAccountVATRefundable =$_POST["CreditAccountVATRefundable2"];  
   $packingXNbrOfUnit =$_POST["packingXNbrOfUnit2"];  
   if($Tabnumber == 10){
   $result2 = mysql_query("SELECT * FROM salessetup" ,  $connection);
   $num_rows2 = mysql_num_rows($result2);
   
   if($num_rows2==0){
   
   $query_insert_salessetup2="insert into salessetup (Warehouse ,  Project ,  Costcenter ,  PaymentMode ,  ClientCur ,  ClientAccount ,  CreditCur ,  CreditCurdefault ,  CreditAccount ,  CashCur ,  
   				 CashCurDefault ,  CashAccount ,  CheckCur ,  CheckCurDefault ,  CheckAccount ,  TipsAccount ,  VatAccount ,  CreditAccountReturn ,  CreditCurReturnDefault ,  CreditCurReturn ,  CHARGES , 
   				 DiscountAccount ,  Creditaccountvat ,  DirectStockDebit ,  DirectStockCredit ,  DEBITACC ,  CustomsCurDefault ,  CustomsAccount ,  CustomsCur ,  BillsAccount ,  BillsCur ,  BillsCurDefault , 
   				 DEBITcUR ,  DebitCurDefault ,  TipsMaxBase1 ,  WithPriceDefault ,  PrintPreview ,  CREDITVATRETURN ,  SALESTTC ,  DirectStockCurrency_Code ,  SalesSetup ,  Setup_LedgerNumber ,  
   				 SalesJV_PrintedDateTime ,  SalesJV_PrintFolio ,  Sale_Remark ,  SalesJV_DefaultCur ,  Sale_PrinterLPTPort ,  SALE_PrintBottomLabel ,  Sale_DisplayLedDefault ,  Sale_COMPortDefault , 
   				 SalesJV_VatAccount ,  Sale_CalculateWeight ,  SalesJV_MaxDiscountPer ,  Sales_MaxDiscountPer ,  Sale_Acctax1 ,  Sale_Acctax2 ,  Sale_Acctax3 ,  Sale_Acctax4 ,  Sale_Acctax5 ,  
   				 PromotionAccount ,  
   				 DiscountFromItemGroup ,  Sale_ExchangeSellPrice ,  Synchronized ,  Barcode ,  DisplayTransferInDR ,  NoneStandardBarcode ,  AutoGenerateSizeMeasure ,  EnableDeliveryConfirmed , 
   				 EnablePricePerUnit , 
   				 Sale_SequentialRefViaCST ,  Sale_SeperateLines ,  Sale_changeClient ,  Sale_CLAAccount ,  Sale_DCTAccount ,  Sale_AWAccount ,  Sale_TRPAccount ,  ExportDiscPerJV ,  Sales_DiscountAcc ,  
   				 LoadItems ,  
   				 CheckQuantity ,  TransportAccount ,  ExportTransportToJV ,  Sale_CLAAccount2 ,  Sale_DCTAccount2 ,  Sale_AWAccount2 ,  Sale_TRPAccount2 ,  Sales_DiscountAcc2 ,  IsoDescription ,  
   				 IsoDlvDescription , 
   				 Delivery_packPrice ,  show_QtySorder ,  BonusAccount ,  ExportBonusToJV ,  InvoiceComment ,  WaybillComment ,  Sale_MinPendingQty ,  Sale_MaxExceedQty ,  Sale_MarginPer , 
   				 VATAccountNonStock ,  
   				 SorderComment ,  PrintDeliveryByWarehouse ,  PriceDecimalBase ,  ShowCostCentLayout ,  VatAccountPOS ,  VATAccountNonStockPOS ,  CreditAccountNonStock , 
   				 CreditAccountVATNonStock ,  CreditReturnNonStock ,  CreditVATReturnNonStock ,  VatAccountRefundable ,  CreditAccountVATRefundable ,  packingXNbrOfUnit)
   
   							VALUES(
   							'".GetSQLValueString($Warehouse,'text')."' ,
   							'".GetSQLValueString($Project,'text')."' ,
   							'".GetSQLValueString($Costcenter,'text')."' ,
   							'".GetSQLValueString($PaymentMode,'double')."' ,
   							'".GetSQLValueString($ClientCur,'text')."' , 
   							'".GetSQLValueString($ClientAccount,'text')."' ,
   							'".GetSQLValueString($CreditCur,'text')."' , 
   							
   							'".GetSQLValueString($CreditCurdefault,'int')."' , 
   							'".GetSQLValueString($CreditAccount,'text')."' ,
   							'".GetSQLValueString($CashCur,'text')."' , 
   							'".GetSQLValueString($CashCurDefault,'int')."' ,
   							'".GetSQLValueString($CashAccount,'text')."' ,
   							'".GetSQLValueString($CheckCur,'text')."' ,
   							
   							'".GetSQLValueString($CheckCurDefault,'int')."' ,
   							'".GetSQLValueString($CheckAccount,'text')."' ,
   							'".GetSQLValueString($TipsAccount,'text')."' , 
   							'".GetSQLValueString($VatAccount,'text')."' ,
   							'".GetSQLValueString($CreditAccountReturn,'text')."' , 
   							'".GetSQLValueString($CreditCurReturnDefault,'int')."' , 
   							'".GetSQLValueString($CreditCurReturn,'text')."' , 
   							'".GetSQLValueString($CHARGES,'int')."' ,
   							
   							'".GetSQLValueString($DiscountAccount,'text')."' , 
   							'".GetSQLValueString($Creditaccountvat,'text')."' , 
   							'".GetSQLValueString($DirectStockDebit,'text')."' ,
   							'".GetSQLValueString($DirectStockCredit,'text')."' , 
   							'".GetSQLValueString($DEBITACC,'text')."' ,
   							'".GetSQLValueString($CustomsCurDefault,'int')."' ,
   							
   							'".GetSQLValueString($CustomsAccount,'text')."' ,
   							'".GetSQLValueString($CustomsCur,'text')."' ,
   							'".GetSQLValueString($BillsAccount,'text')."' ,
   							'".GetSQLValueString($BillsCur,'text')."' , 
   							'".GetSQLValueString(BillsCurDefault)."' , 
   							'".GetSQLValueString($DEBITcUR,'text')."' ,
   							
   							'".GetSQLValueString($DebitCurDefault,'int')."' , 
   							'".GetSQLValueString($TipsMaxBase1,'double')."' , 
   							'".GetSQLValueString($WithPriceDefault,'int')."' ,
   							'".GetSQLValueString($PrintPreview,'int')."' , 
   							'".GetSQLValueString($CREDITVATRETURN,'text')."' ,
   							
   							'".GetSQLValueString($SALESTTC,'int')."' ,
   							'".GetSQLValueString($DirectStockCurrency_Code,'text')."' , 
   							'".GetSQLValueString($SalesSetup,'int')."' , 
   							'".GetSQLValueString($Setup_LedgerNumber,'text')."' ,
   							'".GetSQLValueString($SalesJV_PrintedDateTime,'int')."' , 
   							
   							'".GetSQLValueString($SalesJV_PrintFolio,'int')."' ,
   							'".GetSQLValueString($Sale_Remark,'text')."' , 
   							'".GetSQLValueString($SalesJV_DefaultCur,'text')."' , 
   							'".GetSQLValueString($Sale_PrinterLPTPort,'int')."' , 
   							'".GetSQLValueString($SALE_PrintBottomLabel,'text')."' ,
   							
   							'".GetSQLValueString($Sale_DisplayLedDefault,'int')."' ,
   							'".GetSQLValueString($Sale_COMPortDefault,'int')."' , 
   							'".GetSQLValueString($SalesJV_VatAccount,'text')."' ,
   							'".GetSQLValueString($Sale_CalculateWeight,'int')."' , 
   							'".GetSQLValueString($SalesJV_MaxDiscountPer,'double')."' ,
   							'".GetSQLValueString($Sales_MaxDiscountPer,'double')."' ,
   							
   							'".GetSQLValueString($Sale_Acctax1,'text')."' , 
   							'".GetSQLValueString($Sale_Acctax2,'text')."' ,
   							'".GetSQLValueString($Sale_Acctax3,'text')."' ,
   							'".GetSQLValueString($Sale_Acctax4,'text')."' , 
   							'".GetSQLValueString($Sale_Acctax5,'text')."' , 
   							'".GetSQLValueString($PromotionAccount,'text')."' ,
   							
   							'".GetSQLValueString($DiscountFromItemGroup,'int')."' , 
   							'".GetSQLValueString($Sale_ExchangeSellPrice,'int')."' , 
   							'".GetSQLValueString($Synchronized,'int')."' , 
   							'".GetSQLValueString($Barcode,'int')."' , 
   							'".GetSQLValueString($DisplayTransferInDR,'int')."' ,
   							'".GetSQLValueString($NoneStandardBarcode,'int')."' , 
   							'".GetSQLValueString($AutoGenerateSizeMeasure,'int')."' , 
   							'".GetSQLValueString($EnableDeliveryConfirmed,'int')."' ,
   							'".GetSQLValueString($EnablePricePerUnit,'int')."' ,
   							'".GetSQLValueString($Sale_SequentialRefViaCST,'int')."' , 
   							'".GetSQLValueString(Sale_SeperateLines)."' ,
   							'".GetSQLValueString($Sale_changeClient,'int')."' ,
   							'".GetSQLValueString($Sale_CLAAccount21,'text')."' ,
   							
   							'".GetSQLValueString($Sale_DCTAccount21,'text')."' , 
   							'".GetSQLValueString($Sale_AWAccount21,'text')."' ,
   							'".GetSQLValueString($Sale_TRPAccount21,'text')."' ,
   							'".GetSQLValueString($ExportDiscPerJV,'int')."' , 
   							'".GetSQLValueString($Sales_DiscountAcc21,'text')."' , 
   							
   							'".GetSQLValueString($LoadItems,'int')."' ,
   							'".GetSQLValueString($CheckQuantity,'int')."' ,
   							'".GetSQLValueString($TransportAccount,'text')."' ,
   							'".GetSQLValueString($ExportTransportToJV,'int')."' , 
   							'".GetSQLValueString($Sale_CLAAccount22,'text')."' ,
   							'".GetSQLValueString($Sale_DCTAccount22,'text')."' ,
   							'".GetSQLValueString($Sale_AWAccount22,'text')."' , 
   							'".GetSQLValueString($Sale_TRPAccount22,'text')."' , 
   							'".GetSQLValueString($Sales_DiscountAcc22,'text')."' ,
   							
   							'".GetSQLValueString($IsoDescription,'text')."' ,
   							'".GetSQLValueString($IsoDlvDescription,'text')."' ,
   							'".GetSQLValueString($Delivery_packPrice,'int')."' ,
   							'".GetSQLValueString($show_QtySorder,'int')."' ,
   							'".GetSQLValueString($BonusAccount,'text')."' ,
   							'".GetSQLValueString($ExportBonusToJV,'int')."' , 
   							'".GetSQLValueString($InvoiceComment,'text')."' , 
   							'".GetSQLValueString($WaybillComment,'text')."' ,
   							
   							'".GetSQLValueString($Sale_MinPendingQty,'double')."' ,
   							'".GetSQLValueString($Sale_MaxExceedQty,'double')."' ,
   							'".GetSQLValueString($Sale_MarginPer,'double')."' ,
   							'".GetSQLValueString($VATAccountNonStock,'text')."' ,
   							'".GetSQLValueString($SorderComment,'text')."' , 
   							'".GetSQLValueString($PrintDeliveryByWarehouse,'int')."' , 
   							
   							'".GetSQLValueString($PriceDecimalBase,'int')."' ,
   							'".GetSQLValueString($ShowCostCentLayout,'int')."' , 
   							'".GetSQLValueString($VatAccountPOS,'text')."' ,
   							'".GetSQLValueString($VATAccountNonStockPOS,'text')."' ,
   							'".GetSQLValueString($CreditAccountNonStock,'text')."' , 
   							'".GetSQLValueString($CreditAccountVATNonStock,'text')."' ,
   							'".GetSQLValueString($CreditReturnNonStock,'text')."' ,
   							'".GetSQLValueString($CreditVATReturnNonStock,'text')."' , 
   							'".GetSQLValueString($VatAccountRefundable,'text')."' , 
   							'".GetSQLValueString($CreditAccountVATRefundable,'text')."' ,  
   							'".GetSQLValueString($packingXNbrOfUnit,'int')."')";
   				
   $resultsalessetup2=mysql_query($query_insert_salessetup2 , $connection) or die(mysql_error());
   }
   
   else{
   //echo $packingXNbrOfUnit;
   $query_salessetup2="UPDATE salessetup   
   					SET
   					Warehouse=".GetSQLValueString($Warehouse ,'text').", 
   					Project=".GetSQLValueString($Project ,'text').", 
   					Costcenter=".GetSQLValueString($Costcenter ,'text').", 
   					PaymentMode=".GetSQLValueString($PaymentMode ,'double').",  
   					ClientCur=".GetSQLValueString($ClientCur ,'text').", 
   					ClientAccount=".GetSQLValueString($ClientAccount ,'text').", 
   					CreditCur=".GetSQLValueString($CreditCur ,'text').",
   					
   					CreditCurdefault=".GetSQLValueString($CreditCurdefault ,'int').",  
   					CreditAccount=".GetSQLValueString($CreditAccount ,'text').",  
   					CashCur=".GetSQLValueString($CashCur ,'text').",  
   					CashCurDefault=".GetSQLValueString($CashCurDefault ,'int').", 
   					CashAccount=".GetSQLValueString($CashAccount ,'text').", 
   					CheckCur=".GetSQLValueString($CheckCur ,'text').", 
   					
   					CheckCurDefault=".GetSQLValueString($CheckCurDefault ,'int').",  
   					CheckAccount=".GetSQLValueString($CheckAccount ,'text').",  
   					TipsAccount=".GetSQLValueString($TipsAccount ,'text').",  
   					VatAccount=".GetSQLValueString($VatAccount ,'text').",  
   					CreditAccountReturn=".GetSQLValueString($CreditAccountReturn ,'text').",  
   					CreditCurReturnDefault=".GetSQLValueString($CreditCurReturnDefault ,'int').", 
   					
   					CreditCurReturn=".GetSQLValueString($CreditCurReturn ,'text').",  
   					CHARGES=".GetSQLValueString($CHARGES ,'int').", 
   					DiscountAccount=".GetSQLValueString($DiscountAccount ,'text').",  
   					Creditaccountvat=".GetSQLValueString($Creditaccountvat ,'text').",  
   					DirectStockDebit=".GetSQLValueString($DirectStockDebit ,'text').",  
   					DirectStockCredit=".GetSQLValueString($DirectStockCredit ,'text').", 
   					DEBITACC=".GetSQLValueString($DEBITACC ,'text').",  
   					
   					CustomsCurDefault=".GetSQLValueString($CustomsCurDefault ,'int').",  
   					CustomsAccount=".GetSQLValueString($CustomsAccount ,'text').",  
   					CustomsCur=".GetSQLValueString($CustomsCur ,'text').",  
   					BillsAccount=".GetSQLValueString($BillsAccount ,'text').",  
   					BillsCur=".GetSQLValueString($BillsCur ,'text').",  
   					BillsCurDefault=".GetSQLValueString($BillsCurDefault ,'int').", 
   					DEBITcUR=".GetSQLValueString($DEBITcUR ,'text').",  
   					
   					DebitCurDefault=".GetSQLValueString($DebitCurDefault ,'int').",  
   					TipsMaxBase1=".GetSQLValueString($TipsMaxBase1 ,'double').",  
   					WithPriceDefault=".GetSQLValueString($WithPriceDefault ,'int').",  
   					PrintPreview=".GetSQLValueString($PrintPreview ,'int').",  
   					CREDITVATRETURN=".GetSQLValueString($CREDITVATRETURN ,'text').", 
   					SALESTTC=".GetSQLValueString($SALESTTC ,'int').",  
   					DirectStockCurrency_Code=".GetSQLValueString($DirectStockCurrency_Code ,'text').", 
   					
   					SalesSetup=".GetSQLValueString($SalesSetup ,'int').",  
   					Setup_LedgerNumber=".GetSQLValueString($Setup_LedgerNumber ,'text').",  
   					SalesJV_PrintedDateTime=".GetSQLValueString($SalesJV_PrintedDateTime ,'int').", 
   					
   					SalesJV_PrintFolio=".GetSQLValueString($SalesJV_PrintFolio ,'int').",  
   					Sale_Remark=".GetSQLValueString($Sale_Remark ,'text').",  
   					SalesJV_DefaultCur=".GetSQLValueString($SalesJV_DefaultCur ,'text').",  
   					Sale_PrinterLPTPort=".GetSQLValueString($Sale_PrinterLPTPort ,'int').",  
   					SALE_PrintBottomLabel=".GetSQLValueString($SALE_PrintBottomLabel ,'text').", 
   					
   					Sale_DisplayLedDefault=".GetSQLValueString($Sale_DisplayLedDefault ,'int').",  
   					Sale_COMPortDefault=".GetSQLValueString($Sale_COMPortDefault ,'int').", 
   					SalesJV_VatAccount=".GetSQLValueString($SalesJV_VatAccount ,'text').",  
   					Sale_CalculateWeight=".GetSQLValueString($Sale_CalculateWeight ,'int').",  
   					SalesJV_MaxDiscountPer=".GetSQLValueString($SalesJV_MaxDiscountPer ,'double').",  
   					Sales_MaxDiscountPer=".GetSQLValueString($Sales_MaxDiscountPer ,'double').", 
   					Sale_Acctax1=".GetSQLValueString($Sale_Acctax1 ,'text').",  
   					Sale_Acctax2=".GetSQLValueString($Sale_Acctax2 ,'text').",  
   					Sale_Acctax3=".GetSQLValueString($Sale_Acctax3 ,'text').",  
   					Sale_Acctax4=".GetSQLValueString($Sale_Acctax4 ,'text').",  
   					Sale_Acctax5=".GetSQLValueString($Sale_Acctax5 ,'text').",  
   					PromotionAccount=".GetSQLValueString($PromotionAccount ,'text').",  
   					
   					DiscountFromItemGroup=".GetSQLValueString($DiscountFromItemGroup ,'int').", 
   					Sale_ExchangeSellPrice=".GetSQLValueString($Sale_ExchangeSellPrice ,'int').",  
   					Synchronized=".GetSQLValueString($Synchronized ,'int').", 
   					Barcode=".GetSQLValueString($Barcode ,'int').",  
   					DisplayTransferInDR=".GetSQLValueString($DisplayTransferInDR ,'int').",  
   					NoneStandardBarcode=".GetSQLValueString($NoneStandardBarcode ,'int').",  
   					AutoGenerateSizeMeasure=".GetSQLValueString($AutoGenerateSizeMeasure ,'int').",  
   					EnableDeliveryConfirmed=".GetSQLValueString($EnableDeliveryConfirmed ,'int').", 
   					EnablePricePerUnit=".GetSQLValueString($EnablePricePerUnit ,'int').", 
   					Sale_SequentialRefViaCST=".GetSQLValueString($Sale_SequentialRefViaCST ,'int').",  
   					Sale_SeperateLines=".GetSQLValueString($Sale_SeperateLines ,'int').",  
   					Sale_changeClient=".GetSQLValueString($Sale_changeClient ,'int').",  
   					
   					Sale_CLAAccount=".GetSQLValueString($Sale_CLAAccount21 ,'text').", 
   					Sale_DCTAccount=".GetSQLValueString($Sale_DCTAccount21 ,'text').",  
   					Sale_AWAccount=".GetSQLValueString($Sale_AWAccount21 ,'text').", 
   					Sale_TRPAccount=".GetSQLValueString($Sale_TRPAccount21 ,'text').",  
   					ExportDiscPerJV=".GetSQLValueString($ExportDiscPerJV ,'int').",  
   					Sales_DiscountAcc=".GetSQLValueString($Sales_DiscountAcc21 ,'text').",  
   					
   					LoadItems=".GetSQLValueString($LoadItems ,'int').",  
   					CheckQuantity=".GetSQLValueString($CheckQuantity ,'int').",  
   					TransportAccount=".GetSQLValueString($TransportAccount ,'text').",  
   					ExportTransportToJV=".GetSQLValueString($ExportTransportToJV ,'int').",  
   					Sale_CLAAccount2=".GetSQLValueString($Sale_CLAAccount22 ,'text').",  
   					Sale_DCTAccount2=".GetSQLValueString($Sale_DCTAccount22 ,'text').", 
   					Sale_AWAccount2=".GetSQLValueString($Sale_AWAccount22 ,'text').",  
   					Sale_TRPAccount2=".GetSQLValueString($Sale_TRPAccount22 ,'text').",  
   					Sales_DiscountAcc2=".GetSQLValueString($Sales_DiscountAcc22 ,'text').",  
   					
   					IsoDescription=".GetSQLValueString($IsoDescription ,'text').",  
   					IsoDlvDescription=".GetSQLValueString($IsoDlvDescription ,'text').", 
   					Delivery_packPrice=".GetSQLValueString($Delivery_packPrice ,'int').",  
   					show_QtySorder=".GetSQLValueString($show_QtySorder ,'int').",  
   					BonusAccount=".GetSQLValueString($BonusAccount ,'text').",  
   					ExportBonusToJV=".GetSQLValueString($ExportBonusToJV ,'int').",  
   					InvoiceComment=".GetSQLValueString($InvoiceComment ,'text').", 
   					WaybillComment=".GetSQLValueString($WaybillComment ,'text').",  
   					Sale_MinPendingQty=".GetSQLValueString($Sale_MinPendingQty ,'double').",  
   					Sale_MaxExceedQty=".GetSQLValueString($Sale_MaxExceedQty ,'double').",  
   					Sale_MarginPer=".GetSQLValueString($Sale_MarginPer ,'double').", 
   					
   					VATAccountNonStock=".GetSQLValueString($VATAccountNonStock ,'text').",  
   					SorderComment=".GetSQLValueString($SorderComment ,'text').",  
   					PrintDeliveryByWarehouse=".GetSQLValueString($PrintDeliveryByWarehouse ,'int').", 
   					PriceDecimalBase=".GetSQLValueString($PriceDecimalBase ,'int').",  
   					ShowCostCentLayout=".GetSQLValueString($ShowCostCentLayout ,'int').",  
   					VatAccountPOS=".GetSQLValueString($VatAccountPOS ,'text').", 
   					
   					VATAccountNonStockPOS=".GetSQLValueString($VATAccountNonStockPOS ,'text').",  
   					CreditAccountNonStock=".GetSQLValueString($CreditAccountNonStock ,'text').", 
   					CreditAccountVATNonStock=".GetSQLValueString($CreditAccountVATNonStock ,'text').",  
   					CreditReturnNonStock=".GetSQLValueString($CreditReturnNonStock ,'text').",  
   					CreditVATReturnNonStock=".GetSQLValueString($CreditVATReturnNonStock ,'text').", 
   					VatAccountRefundable=".GetSQLValueString($VatAccountRefundable ,'text')." ,  
   					CreditAccountVATRefundable=".GetSQLValueString($CreditAccountVATRefundable ,'text')." ,  
   					packingXNbrOfUnit=".GetSQLValueString($packingXNbrOfUnit,'int')." ";
   					
   					//echo $query_salessetup2;
   					//exit;
   					$result_query_salessetup=mysql_query($query_salessetup2 , $connection) or die(mysql_error());
   }
   header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
    
   //getting the values from the transfer setup
   					
   $DebitAccount3= $_POST["DebitAccount3"];
   $CreditAccount3= $_POST["CreditAccount3"];
   $CurrencyBase3= $_POST["CurrencyBase3"];
   $DefaultCur3= $_POST["DefaultCur3"];
   $Synchronized3= $_POST["Synchronized3"];
   $Barcode3= $_POST["Barcode3"];
   $WithPricedefault3= $_POST["WithPricedefault3"];
   $DirectStockAccPerWH3= $_POST["DirectStockAccPerWH3"];
   $NoneStandardBarcode3= $_POST["NoneStandardBarcode3"];
   $ExportVariation3= $_POST["ExportVariation3"];
   $ShowItemSelling1Base13= $_POST["ShowItemSelling1Base13"];
   $EnablePricePerUnit3= $_POST["EnablePricePerUnit3"];
   $IsoDescription3= $_POST["IsoDescription3"];
   $Warehouse3= $_POST["Warehouse3"];
   $warehouseFG3= $_POST["warehouseFG3"];
   $ShowCostCentLayout3=$_POST["ShowCostCentLayout3"];
   if($Tabnumber == 4){
   $result2 = mysql_query("SELECT * FROM transfersetup" ,  $connection);
   $num_rows2 = mysql_num_rows($result2);
   
   if($num_rows2==0){
   //echo "here";
   $query_insert="insert into transfersetup VALUES('".GetSQLValueString($DebitAccount3,'text')."' ,
   												'".GetSQLValueString($CreditAccount3,'text')."' ,
   												'".GetSQLValueString($CurrencyBase3,'int')."' ,
   												'".GetSQLValueString($WithPricedefaul3,'int')."' ,
   												'".GetSQLValueString($DefaultCur3,'text')."' ,
   												'".GetSQLValueString($DirectStockAccPerWH3,'int')."' , 
   												'".GetSQLValueString($Synchronized3,'int')."' ,
   												'".GetSQLValueString($Barcode3,'int')."' ,
   												'".GetSQLValueString($NoneStandardBarcode3,'int')."' ,
   												'".GetSQLValueString($ExportVariation3,'int')."' ,
   												'".GetSQLValueString($ShowItemSelling1Base13,'int')."' ,
   												'".GetSQLValueString($EnablePricePerUnit3,'int')."' , 
   												'".GetSQLValueString($IsoDescription3,'text')."' ,
   												'".GetSQLValueString($ShowCostCentLayout3,'int')."' ,
   												'".GetSQLValueString($Warehouse3,'text')."' ,
   												'".GetSQLValueString($warehouseFG3,'text')."')";
   //echo $query_insert;
   //exit;
   $resultcurrency=mysql_query($query_insert , $connection) or die(mysql_error());
   }
   else{
   // update transfersetup
   $queryupdatetransfersetup="UPDATE 	transfersetup   
   							SET		DebitAccount=".GetSQLValueString($DebitAccount3,'text').", 
   									CreditAccount=".GetSQLValueString($CreditAccount3,'text').", 
   									CurrencyBase=".GetSQLValueString($CurrencyBase3,'int').",  
   									WithPricedefault=".GetSQLValueString($WithPricedefault3,'int').",  
   									DEFAULTCUR=".GetSQLValueString($DefaultCur3,'text')." , 
   									DirectStockAccPerWH=".GetSQLValueString($DirectStockAccPerWH3,'int').",  
   									Synchronized=".GetSQLValueString($Synchronized3,'int').",  
   									Barcode=".GetSQLValueString($Barcode3,'int')." ,  
   									NoneStandardBarcode=".GetSQLValueString($NoneStandardBarcode3,'int').", 
   									ExportVariation=".GetSQLValueString($ExportVariation3,'int').", 
   									ShowItemSelling1Base1=".GetSQLValueString($ShowItemSelling1Base13,'int').",  
   									EnablePricePerUnit=".GetSQLValueString($EnablePricePerUnit3,'int').", 
   									IsoDescription=".GetSQLValueString($IsoDescription3,'text').",  
   									ShowCostCentLayout=".GetSQLValueString($ShowCostCentLayout3,'int').",  
   									Warehouse=".GetSQLValueString($Warehouse3,'text').",  
   									warehouseFG=".GetSQLValueString($WarehouseFG3,'text')." "; 
   //echo $queryupdatetransfersetup;
   //exit;
   $resultcurrency=mysql_query($queryupdatetransfersetup , $connection) or die(mysql_error());
   }
   header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   //get Trans Setup values
   
   $VatAccount51=$_POST['VatAccount51'];
   $AUXAccount51=$_POST['AUXAccount51'];
   $DEBITACCOUNTFROM51=$_POST['DEBITACCOUNTFROM51'];
   $DEBITACCOUNTTO51=$_POST['DEBITACCOUNTTO51'];
   
   $CREDITACCOUNTFROM51=$_POST['CREDITACCOUNTFROM51'];
   
   $CREDITACCOUNTTO51=$_POST['CREDITACCOUNTTO51'];
   $DEFAULTCUR51=$_POST['DEFAULTCUR51'];
   $Voucher_PrintFolio51=$_POST['Voucher_PrintFolio51'];
   
   $Voucher_PrintJVRef51=$_POST['Voucher_PrintJVRef51'];
   $Voucher_PrintDateTime51=$_POST['Voucher_PrintDateTime51'];
   $Voucher_AutoCalcAmnt51=$_POST['Voucher_AutoCalcAmnt51'];
   
   $Voucher_ShowDescription251=$_POST['Voucher_ShowDescription251'];
   $SeparateAccounts51=$_POST['SeparateAccounts51'];
   $Synchronized51=$_POST['Synchronized51'];
   
   $DefaultCostcenter51=$_POST['DefaultCostcenter51'];
   $DefaultProject51=$_POST['DefaultProject51'];
   $IsoDescription51=$_POST['IsoDescription51'];
   $JournalType51=$_POST['JournalType51'];
   
   if($Tabnumber==5){
   
   	$queryupdatetrans="update transsetup 
   						set VatAccount=".GetSQLValueString($VatAccount51,'text').", 
   							AUXAccount=".GetSQLValueString($AUXAccount51,'text').", 
   							DEBITACCOUNTFROM=".GetSQLValueString($DEBITACCOUNTFROM51,'text').", 
   							DEBITACCOUNTTO=".GetSQLValueString($DEBITACCOUNTTO51,'text').", 
   
   							CREDITACCOUNTFROM=".GetSQLValueString($CREDITACCOUNTFROM51,'text').", 
   
   							CREDITACCOUNTTO=".GetSQLValueString($CREDITACCOUNTTO51,'text').", 
   							DEFAULTCUR=".GetSQLValueString($DEFAULTCUR51,'text').", 
   							Voucher_PrintFolio=".GetSQLValueString($Voucher_PrintFolio51,'int').", 
   
   							Voucher_PrintJVRef=".GetSQLValueString($Voucher_PrintJVRef51,'int').", 
   							Voucher_PrintDateTime=".GetSQLValueString($Voucher_PrintDateTime51,'int').", 
   							Voucher_AutoCalcAmnt=".GetSQLValueString($Voucher_AutoCalcAmnt51,'int').", 
   
   							Voucher_ShowDescription2=".GetSQLValueString($Voucher_ShowDescription251,'int').", 
   							SeparateAccounts=".GetSQLValueString($SeparateAccounts51,'int').", 
   							Synchronized=".GetSQLValueString($Synchronized51,'int').", 
   
   							DefaultCostcenter=".GetSQLValueString($DefaultCostcenter51,'text').", 
   							DefaultProject=".GetSQLValueString($DefaultProject51,'text').", 
   							IsoDescription=".GetSQLValueString($IsoDescription51,'text').", 
   							JournalType=".GetSQLValueString($JournalType51,'text')."
   							
   							where JournalType='$JournalType51'";
   							
   							//echo $queryupdatetrans ;
   							//exit;
   	$resulttrans=mysql_query($queryupdatetrans,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   
   
   //get sendreceive setup values
   $Table_Name61=$_POST['Table_Name61'];
   $SendReceive_Type61=$_POST['SendReceive_Type61'];
   $SndRec_Id61=$_POST['SndRec_Id61'];
   $Master_Table61=$_POST['Master_Table61'];
   $Master_Field61=$_POST['Master_Field61'];
   
   $Table_SecondaryKey61=$_POST['Table_SecondaryKey61'];
   $Table_PrimaryKey61=$_POST['Table_PrimaryKey61'];
   $Field_name61=$_POST['Field_name61'];
   $SndRec_OldBatch61=$_POST['SndRec_OldBatch61'];
   
   $Synchronized61=$_POST['Synchronized61'];
   $Table_Alias61=$_POST['Table_Alias61'];
   $Master_Alias61=$_POST['Master_Alias61'];
   $Station_Name61=$_POST['Station_Name61'];
   $Table_Primary61=$_POST['Table_Primary61'];
   
   $Primary_Alias61=$_POST['Primary_Alias61'];
   $Table_Level61=$_POST['Table_Level61'];
   
   
   if($Tabnumber == 8){
   	$getvalues="select * from sendreceivesetup";
   	$resultsrsetup=mysql_query($getvalues,$connection);
   	$num_rows2 = mysql_num_rows($resultsrsetup);
   
   	if($num_rows2==0){
   		
   		$queryupdatesrsetup="insert into sendreceivesetup (Table_Name, SendReceive_Type, SndRec_Id, Master_Table, Master_Field, Table_SecondaryKey, Table_PrimaryKey, Field_name,
   															SndRec_OldBatch, Synchronized, Table_Alias, Master_Alias, Station_Name, Table_Primary, Primary_Alias, Table_Level)
   											values(	".GetSQLValueString($Table_Name61,'text').", 
   													".GetSQLValueString($SendReceive_Type61,'text').", 
   													".GetSQLValueString($SndRec_Id61,'double').", 
   													".GetSQLValueString($Master_Table61,'text').", 
   													".GetSQLValueString($Master_Field61,'text').", 
   													".GetSQLValueString($Table_SecondaryKey61,'text').", 
   													".GetSQLValueString($Table_PrimaryKey61,'text').", 
   													".GetSQLValueString($Field_name61,'text').", 
   													".GetSQLValueString($SndRec_OldBatch61,'int').", 
   													".GetSQLValueString($Synchronized61,'int').", 
   													".GetSQLValueString($Table_Alias61,'text').", 
   													".GetSQLValueString($Master_Alias61,'text').", 
   													".GetSQLValueString($Station_Name61,'text').", 
   													".GetSQLValueString($Table_Primary61,'text').", 
   													".GetSQLValueString($Primary_Alias61,'text').", 
   													".GetSQLValueString($Table_Level61,'int').")";
   		//echo $queryupdatesrsetup;
   		//exit;
   		$result=mysql_query($queryupdatesrsetup,$connection);
   	}
   	else{
   	$queryupdatesrsetup="update sendreceivesetup 
   						set Table_Name=".GetSQLValueString($Table_Name61,'text').", 
   							SendReceive_Type=".GetSQLValueString($SendReceive_Type61,'text').", 
   							SndRec_Id=".GetSQLValueString($SndRec_Id61,'double').", 
   							Master_Table=".GetSQLValueString($Master_Table61,'text').", 
   							Master_Field=".GetSQLValueString($Master_Field61,'text').", 
   
   							Table_SecondaryKey=".GetSQLValueString($Table_SecondaryKey61,'text').", 
   							Table_PrimaryKey=".GetSQLValueString($Table_PrimaryKey61,'text').", 
   							Field_name=".GetSQLValueString($Field_name61,'text').", 
   							SndRec_OldBatch=".GetSQLValueString($SndRec_OldBatch61,'int').", 
   
   							Synchronized=".GetSQLValueString($Synchronized61,'int').", 
   							Table_Alias=".GetSQLValueString($Table_Alias61,'text').", 
   							Master_Alias=".GetSQLValueString($Master_Alias61,'text').", 
   							Station_Name=".GetSQLValueString($Station_Name61,'text').", 
   							Table_Primary=".GetSQLValueString($Table_Primary61,'text').", 
   
   							Primary_Alias=".GetSQLValueString($Primary_Alias61,'text').", 
   							Table_Level=".GetSQLValueString($Table_Level61,'int')." ";
   							
   							//echo $queryupdatesrsetup ;
   							//exit;
   	$resultsrsetup=mysql_query($queryupdatesrsetup,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   	}
   }
   
   //get synchrosetup values
   $SynchroStp_Id71=$_POST['SynchroStp_Id71'];
   $Table_Name71=$_POST['Table_Name71'];
   $Master_Table71=$_POST['Master_Table71'];
   $Master_Field71=$_POST['Master_Field71']; 
   $Table_SecondaryKey71=$_POST['Table_SecondaryKey71'];
   $Table_PrimaryKey71=$_POST['Table_PrimaryKey71'];
   $Field_name71=$_POST['Field_name71'];
   $Status_IsUpdate71=$_POST['Status_IsUpdate71'];
   $Status_IsInsert71=$_POST['Status_IsInsert71'];
   $Status_IsDelete71=$_POST['Status_IsDelete71'];
   $Table_Primary71=$_POST['Table_Primary71'];
   $Table_Alias71=$_POST['Table_Alias71']; 
   $Master_Alias71=$_POST['Master_Alias71'];
   $Primary_Alias71=$_POST['Primary_Alias71'];
   $Primary_Field71=$_POST['Primary_Field71'];
   $Table_Level71=$_POST['Table_Level71'];
   $Synchronized71=$_POST['Synchronized71'];
   
   if($actionmode=='synchrosetup' && $Tabnumber == 7){
   	
   	$getvalues="select * from synchrosetup";
   	$result=mysql_query($getvalues,$connection);
   	$num_rows2 = mysql_num_rows($result);
   
   	if($num_rows2==0){
   		
   		$queryinsert="insert into synchrosetup (SynchroStp_Id, Table_Name, Master_Table, Master_Field, Table_SecondaryKey, Table_PrimaryKey, Field_name, Status_IsUpdate, Status_IsInsert,
   												Status_IsDelete, Table_Primary, Table_Alias, Master_Alias, Primary_Alias, Primary_Field, Table_Level, Synchronized)
   											values(	".GetSQLValueString($SynchroStp_Id71,'double').", 
   													".GetSQLValueString($Table_Name71,'text').", 
   													".GetSQLValueString($Master_Table71,'text').", 
   													".GetSQLValueString($Master_Field71,'text').", 
   													".GetSQLValueString($Table_SecondaryKey71,'text').", 
   													".GetSQLValueString($Table_PrimaryKey71,'text').", 
   													".GetSQLValueString($Field_name71,'text').", 
   													".GetSQLValueString($Status_IsUpdate71,'int').", 
   													".GetSQLValueString($Status_IsInsert71,'int').", 
   													".GetSQLValueString($Status_IsDelete71,'int').", 
   													".GetSQLValueString($Table_Primary71,'text').", 
   													".GetSQLValueString($Table_Alias71,'text').", 
   													".GetSQLValueString($Master_Alias71,'text').", 
   													".GetSQLValueString($Primary_Alias71,'text').", 
   													".GetSQLValueString($Primary_Field71,'text').", 
   													".GetSQLValueString($Table_Level71,'int').",
   													".GetSQLValueString($Synchronized71,'int').")";
   		//echo $queryinsert;
   		//exit;
   		$insert_result=mysql_query($queryinsert,$connection);
   	}
   	else{
   		
   		$queryupdate="update synchrosetup set 	SynchroStp_Id=".GetSQLValueString($SynchroStp_Id71,'text').",
   												Table_Name=".GetSQLValueString($Table_Name71,'text').",
   												Master_Table=".GetSQLValueString($Master_Table71,'text').",
   												Master_Field=".GetSQLValueString($Master_Field71,'text').", 
   												Table_SecondaryKey=".GetSQLValueString($Table_SecondaryKey71,'text').",
   												Table_PrimaryKey=".GetSQLValueString($Table_PrimaryKey71,'text').",
   												Field_name=".GetSQLValueString($Field_name71,'text').",
   												Status_IsUpdate=".GetSQLValueString($Status_IsUpdate71,'text').",
   												Status_IsInsert=".GetSQLValueString($Status_IsInsert71,'text').",
   												Status_IsDelete=".GetSQLValueString($Status_IsDelete71,'text').",
   												Table_Primary=".GetSQLValueString($Table_Primary71,'text').",
   												Table_Alias=".GetSQLValueString($Table_Alias71,'text').", 
   												Master_Alias=".GetSQLValueString($Master_Alias71,'text').",
   												Primary_Alias=".GetSQLValueString($Primary_Alias71,'text').",
   												Primary_Field=".GetSQLValueString($Primary_Field71,'text').",
   												Table_Level=".GetSQLValueString($Table_Level71,'text').",
   												Synchronized=".GetSQLValueString($Synchronized71,'text')." ";
   		
   		$update_result=mysql_query($queryupdate,$connection);
   	
   		}
		header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   
   //get Transactionsetup values
   $Auto81=$_POST['Auto81']; 
   $Journal_type81=$_POST['Journal_type81']; 
   $Trans_RMAcc81=$_POST['Trans_RMAcc81']; 
   $Trans_RMVatAcc81=$_POST['Trans_RMVatAcc81']; 
   $Trans_NonRMAcc81=$_POST['Trans_NonRMAcc81']; 
   $Trans_NonRMVatAcc81=$_POST['Trans_NonRMVatAcc81']; 
   $Trans_RMTTCIncAcc81=$_POST['Trans_RMTTCIncAcc81']; 
   $Trans_NonRMTTCIncAcc81=$_POST['Trans_NonRMTTCIncAcc81']; 
   $Trans_Currency81=$_POST['Trans_Currency81']; 
   $Trans_DefaultCur81=$_POST['Trans_DefaultCur81']; 
   $Trans_DirectStkDbt81=$_POST['Trans_DirectStkDbt81']; 
   $Trans_DirectStkCrd81=$_POST['Trans_DirectStkCrd81']; 
   $Trans_DirectStkCur81=$_POST['Trans_DirectStkCur81']; 
   $Group_code81=$_POST['Group_code81']; 
   $Synchronized81=$_POST['Synchronized81']; 
   $CEP_CreditAcc81=$_POST['CEP_CreditAcc81']; 
   $Trans_wasteDebitAcc81=$_POST['Trans_wasteDebitAcc81']; 
   $Trans_wasteCreditAcc81=$_POST['Trans_wasteCreditAcc81']; 
   $Trans_wasteDifferenceAcc81=$_POST['Trans_wasteDifferenceAcc81']; 
   $Trans_DiscountAcc81=$_POST['Trans_DiscountAcc81']; 
   $Trans_PromotionAcc81=$_POST['Trans_PromotionAcc81']; 
   $IsoDescription81=$_POST['IsoDescription81']; 
   $Trans_VATAccount81=$_POST['Trans_VATAccount81']; 
   $trans_Purchasepromotionacc81=$_POST['trans_Purchasepromotionacc81']; 
   $trans_Purchasediscountacc81=$_POST['trans_Purchasediscountacc81']; 
   $Trans_TipsAcc81=$_POST['Trans_TipsAcc81']; 
   $trans_export81=$_POST['trans_export81'];
   
   if($actionmode=='transactionsetup' && $Tabnumber == 6){
   
   	$queryupdatetransaction="update 	transactionsetup 
   								set	  
   										Journal_type   =".GetSQLValueString($Journal_type81,'text')." , 
   										Trans_RMAcc     =".GetSQLValueString($Trans_RMAcc81,'text')."  ,
   										Trans_RMVatAcc   =".GetSQLValueString($Trans_RMVatAcc81,'text')."  ,
   										Trans_NonRMAcc      =".GetSQLValueString($Trans_NonRMAcc81,'text')."  ,
   										Trans_NonRMVatAcc      =".GetSQLValueString($Trans_NonRMVatAcc81,'text')."  ,
   										Trans_RMTTCIncAcc         =".GetSQLValueString($Trans_RMTTCIncAcc81,'text')."  ,
   										Trans_NonRMTTCIncAcc     =".GetSQLValueString($Trans_NonRMTTCIncAcc81,'text')."  ,
   										Trans_Currency           =".GetSQLValueString($Trans_Currency81,'text')."  ,
   										Trans_DefaultCur         =".GetSQLValueString($Trans_DefaultCur81,'int')."  ,
   										Trans_DirectStkDbt        =".GetSQLValueString($Trans_DirectStkDbt81,'text')."  ,
   										Trans_DirectStkCrd        =".GetSQLValueString($Trans_DirectStkCrd81,'text')."  ,
   										Trans_DirectStkCur        =".GetSQLValueString($Trans_DirectStkCur81,'text')."  ,
   										Group_code              =".GetSQLValueString($Group_code81,'text')."  ,
   										Synchronized             =".GetSQLValueString($Synchronized81,'int')."  ,
   										CEP_CreditAcc            =".GetSQLValueString($CEP_CreditAcc81,'text')."  ,
   										Trans_wasteDebitAcc       =".GetSQLValueString($Trans_wasteDebitAcc81,'text')."  ,
   										Trans_wasteCreditAcc     =".GetSQLValueString($Trans_wasteCreditAcc81,'text')."  ,
   										Trans_wasteDifferenceAcc  =".GetSQLValueString($Trans_wasteDifferenceAcc81,'text')."  ,
   										Trans_DiscountAcc       =".GetSQLValueString($Trans_DiscountAcc81,'text')."  ,
   										Trans_PromotionAcc       =".GetSQLValueString($Trans_PromotionAcc81,'text')."  ,
   										IsoDescription            =".GetSQLValueString($IsoDescription81,'text')."  ,
   										Trans_VATAccount          =".GetSQLValueString($Trans_VATAccount81,'text')."  ,
   										trans_Purchasepromotionacc   =".GetSQLValueString($trans_Purchasepromotionacc81,'text')." , 
   										trans_Purchasediscountacc    =".GetSQLValueString($trans_Purchasediscountacc81,'text')."  ,
   										Trans_TipsAcc              =".GetSQLValueString($Trans_TipsAcc81,'text')."  ,
   										trans_export                   =".GetSQLValueString($trans_export81,'text')." 
   										
   										where Auto='$Auto81'";
   								
   						//	echo $queryupdatetransaction ;
   						//	exit;
   	$resulttransaction=mysql_query($queryupdatetransaction,$connection);
   	
   }
   
   //get sorder values
   $WithPriceDefault91=$_POST['WithPriceDefault91']; 
   $ReportTitles91=$_POST['ReportTitles91']; 
   $NEGATIVEQTY91=$_POST['NEGATIVEQTY91']; 
   $Warrantylabel91=$_POST['Warrantylabel91']; 
   $DiscountFromItemGroup91=$_POST['DiscountFromItemGroup91'];
   $Synchronized91=$_POST['Synchronized91']; 
   $Barcode91=$_POST['Barcode91']; 
   $Transfer_WarehouseTo91=$_POST['Transfer_WarehouseTo91']; 
   $EnableSorderConfirmed91=$_POST['EnableSorderConfirmed91']; 
   $VatAccount91=$_POST['VatAccount91']; 
   $CreditCur91=$_POST['CreditCur91']; 
   $CreditCurdefault91=$_POST['CreditCurdefault91']; 
   $CreditAccount91=$_POST['CreditAccount91']; 
   $CreditAccountVAT91=$_POST['CreditAccountVAT91']; 
   $Item_Cliche91=$_POST['Item_Cliche91']; 
   $Item_DieCut91=$_POST['Item_DieCut91']; 
   $Item_ArtWork91=$_POST['Item_ArtWork91']; 
   $Item_transport91=$_POST['Item_transport91']; 
   $QtyApproximate91=$_POST['QtyApproximate91']; 
   $journal_Type91=$_POST['journal_Type91']; 
   $IsoDescription91=$_POST['IsoDescription91']; 
   $Changerefernce91=$_POST['Changerefernce91']; 
   $Sorder_Confirmed91=$_POST['Sorder_Confirmed91']; 
   $Sorder_ReservedQty91=$_POST['Sorder_ReservedQty91']; 
   $Sorder_packPrice91=$_POST['Sorder_packPrice91']; 
   $sorder_bank191=$_POST['sorder_bank191']; 
   $sorder_bank291=$_POST['sorder_bank291']; 
   $sorder_bank391=$_POST['sorder_bank391']; 
   $ShowCostCentLayout91=$_POST['ShowCostCentLayout91']; 
   
   if($actionmode=='sordersetup' && $Tabnumber == 9){
   $queryupdatesorder="update 	sordersetup
   					set 	WithPriceDefault=".GetSQLValueString($WithPriceDefault91,'int')." , 
   							ReportTitles=".GetSQLValueString($ReportTitles91,'int')." , 
   							NEGATIVEQTY=".GetSQLValueString($NEGATIVEQTY91,'int')." , 
   							Warrantylabel=".GetSQLValueString($Warrantylabel91,'text')." , 
   							DiscountFromItemGroup=".GetSQLValueString($DiscountFromItemGroup91,'int').",
   							Synchronized=".GetSQLValueString($Synchronized91,'int')." , 
   							Barcode=".GetSQLValueString($Barcode91,'int')." , 
   							Transfer_WarehouseTo=".GetSQLValueString($Transfer_WarehouseTo91,'text')." , 
   							EnableSorderConfirmed=".GetSQLValueString($EnableSorderConfirmed91,'int')." , 
   							VatAccount=".GetSQLValueString($VatAccount91,'text')." , 
   							CreditCur=".GetSQLValueString($CreditCur91,'text')." , 
   							CreditCurdefault=".GetSQLValueString($CreditCurdefault91,'int')." , 
   							CreditAccount=".GetSQLValueString($CreditAccount91,'text')." , 
   							CreditAccountVAT=".GetSQLValueString($CreditAccountVAT91,'text')." , 
   							Item_Cliche=".GetSQLValueString($Item_Cliche91,'text')." , 
   							Item_DieCut=".GetSQLValueString($Item_DieCut91,'text')." , 
   							Item_ArtWork=".GetSQLValueString($Item_ArtWork91,'text')." , 
   							Item_transport=".GetSQLValueString($Item_transport91,'text')." , 
   							QtyApproximate=".GetSQLValueString($QtyApproximate91,'int')." , 
   							journal_Type=".GetSQLValueString($journal_Type91,'text')." , 
   							IsoDescription=".GetSQLValueString($IsoDescription91,'text')." , 
   							Changerefernce=".GetSQLValueString($Changerefernce91,'int')." , 
   							Sorder_Confirmed=".GetSQLValueString($Sorder_Confirmed91,'int')." , 
   							Sorder_ReservedQty=".GetSQLValueString($Sorder_ReservedQty91,'int')." , 
   							Sorder_packPrice=".GetSQLValueString($Sorder_packPrice91,'int')." , 
   							sorder_bank1=".GetSQLValueString($sorder_bank191,'text')." , 
   							sorder_bank2=".GetSQLValueString($sorder_bank291,'text')." , 
   							sorder_bank3=".GetSQLValueString($sorder_bank391,'text')." , 
   							ShowCostCentLayout=".GetSQLValueString($ShowCostCentLayout91,'int')." ";
   
   							//echo $queryupdatesorder;
   							//exit;
   $resultsorder=mysql_query($queryupdatesorder,$connection);
   	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   
   
   // get Production setup values
   $Currency_code=$_POST['Currency_code10'];
   $Project_code=$_POST['Project_code10'];
   $Costcenter_code=$_POST['Costcenter_code10'];
   $Warehouse_code=$_POST['Warehouse_code10'];
   $DISPLAYBARCODE=$_POST['DISPLAYBARCODE10'];
   $CreditAccount=$_POST['CreditAccount10'];
   $DebitAccount=$_POST['DebitAccount10'];
   $Currencybase=$_POST['Currencybase10'];
   $Setup_DefaultUnitRecipe=$_POST['Setup_DefaultUnitRecipe10'];
   $Setup_NameOfRMW=$_POST['Setup_NameOfRMW10'];
   $Setup_NameOfRMC=$_POST['Setup_NameOfRMC10'];
   $Setup_NameOfMachineOND=$_POST['Setup_NameOfMachineOND10'];
   $Setup_NameOfPaperMachine=$_POST['Setup_NameOfPaperMachine10'];
   $Setup_DefaultPulper=$_POST['Setup_DefaultPulper10'];
   $Setup_WHofCartonProduct=$_POST['Setup_WHofCartonProduct10'];
   $Setup_NbOfHoursShiftCh=$_POST['Setup_NbOfHoursShiftCh10'];
   $Setup_BeginingShiftCh=$_POST['Setup_BeginingShiftCh10'];
   $Setup_DefaultWHChemical=$_POST['Setup_DefaultWHChemical10'];
   $Setup_MaxBobineReference=$_POST['Setup_MaxBobineReference10'];
   $Setup_NameOfMachineON=$_POST['Setup_NameOfMachineON10'];
   $Setup_defaultClient=$_POST['Setup_defaultClient10'];
   $Setup_LockDateFrom=$_POST['Setup_LockDateFrom10'];
   $Setup_LockDateTo=$_POST['Setup_LockDateTo10'];
   $Setup_ProductionCarton=$_POST['Setup_ProductionCarton10'];
   $Setup_GeneratExpenses=$_POST['Setup_GeneratExpenses10'];
   $Setup_DefaultCodeforWaste=$_POST['Setup_DefaultCodeforWaste10'];
   $Setup_DefaultWHWaste=$_POST['Setup_DefaultWHWaste10'];
   $Setup_DefaultCostCentCh=$_POST['Setup_DefaultCostCentCh10'];
   $Setup_DefaultCostCentWast=$_POST['Setup_DefaultCostCentWast10'];
   $Synchronized=$_POST['Synchronized10'];
   $Barcode=$_POST['Barcode10'];
   $Setup_GenerateNonStock=$_POST['Setup_GenerateNonStock10'];
   $Setup_DisableDeductRM=$_POST['Setup_DisableDeductRM10'];
   $GenerateWasteAccount=$_POST['GenerateWasteAccount10'];
   $DisableIdeal=$_POST['DisableIdeal10'];
   $ShowCostCentLayout=$_POST['ShowCostCentLayout10'];
   $Actual_Zero=$_POST['Actual_Zero10'];
   $Production_extraInfo=$_POST['Production_extraInfo10'];
   
   if($actionmode=='productionsetup' && $Tabnumber == 12){
   	$queryupdateproduction="update 	productionsetup
   							set 	Currency_code=".GetSQLValueString($Currency_code10,'text')." , 
   									Project_code=".GetSQLValueString($Project_code10,'text')." , 
   									Costcenter_code=".GetSQLValueString($Costcenter_code10,'text')." , 
   									Warehouse_code=".GetSQLValueString($Warehouse_code10,'text')." , 
   									DISPLAYBARCODE=".GetSQLValueString($DISPLAYBARCODE10,'int')." , 
   									CreditAccount=".GetSQLValueString($CreditAccount10,'text')." , 
   									DebitAccount=".GetSQLValueString($DebitAccount10,'text')." , 
   									Currencybase=".GetSQLValueString($Currencybase10,'text')." , 
   									Setup_DefaultUnitRecipe=".GetSQLValueString($Setup_DefaultUnitRecipe10,'text')." , 
   									Setup_NameOfRMW=".GetSQLValueString($Setup_NameOfRMW10,'text')." , 
   									Setup_NameOfRMC=".GetSQLValueString($Setup_NameOfRMC10,'text')." , 
   									Setup_NameOfMachineOND=".GetSQLValueString($Setup_NameOfMachineOND10,'text')." , 
   									Setup_NameOfPaperMachine=".GetSQLValueString($Setup_NameOfPaperMachine10,'text')." , 
   									Setup_DefaultPulper=".GetSQLValueString($Setup_DefaultPulper10,'text')." , 
   									Setup_WHofCartonProduct=".GetSQLValueString($Setup_WHofCartonProduct10,'text')." , 
   									Setup_NbOfHoursShiftCh=".GetSQLValueString($Setup_NbOfHoursShiftCh10,'double')." , 
   									Setup_BeginingShiftCh=".GetSQLValueString($Setup_BeginingShiftCh10,'text')." , 
   									Setup_DefaultWHChemical=".GetSQLValueString($Setup_DefaultWHChemical10,'text')." , 
   									Setup_MaxBobineReference=".GetSQLValueString($Setup_MaxBobineReference10,'int')." , 
   									Setup_NameOfMachineON=".GetSQLValueString($Setup_NameOfMachineON10,'text')." , 
   									Setup_defaultClient=".GetSQLValueString($Setup_defaultClient10,'text')." , 
   									Setup_LockDateFrom=".GetSQLValueString($Setup_LockDateFrom10,'date')." , 
   									Setup_LockDateTo=".GetSQLValueString($Setup_LockDateTo10,'date')." , 
   									Setup_ProductionCarton=".GetSQLValueString($Setup_ProductionCarton10,'double')." , 
   									Setup_GeneratExpenses=".GetSQLValueString($Setup_GeneratExpenses10,'int')." , 
   									Setup_DefaultCodeforWaste=".GetSQLValueString($Setup_DefaultCodeforWaste10,'text')." , 
   									Setup_DefaultWHWaste=".GetSQLValueString($Setup_DefaultWHWaste10,'text')." , 
   									Setup_DefaultCostCentCh=".GetSQLValueString($Setup_DefaultCostCentCh10,'text')." , 
   									Setup_DefaultCostCentWast=".GetSQLValueString($Setup_DefaultCostCentWast10,'text')." , 
   									Synchronized=".GetSQLValueString($Synchronized10,'int')." , 
   									Barcode=".GetSQLValueString($Barcode10,'int')." , 
   									Setup_GenerateNonStock=".GetSQLValueString($Setup_GenerateNonStock10,'int')." , 
   									Setup_DisableDeductRM=".GetSQLValueString($Setup_DisableDeductRM10,'int')." , 
   									GenerateWasteAccount=".GetSQLValueString($GenerateWasteAccount10,'int')." , 
   									DisableIdeal=".GetSQLValueString($DisableIdeal10,'int')." , 
   									ShowCostCentLayout=".GetSQLValueString($ShowCostCentLayout10,'int')." , 
   									Actual_Zero=".GetSQLValueString($Actual_Zero10,'int')." , 
   									Production_extraInfo=".GetSQLValueString($Production_extraInfo10,'int')."  ";
   									
   									//echo $queryupdateproduction;
   									//exit;
   									
   	$resultproduction=mysql_query($queryupdateproduction,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   
   //Read purchase charges values
   
   $Auto11=$_POST['Auto11']; 
   $Ledger_NumberDebit11=$_POST['Ledger_NumberDebit11']; 
   $Ledger_numberCredit11=$_POST['Ledger_numberCredit11'];
   $Currency_code11=$_POST['Currency_code11']; 
   $Charges_isVat11=$_POST['Charges_isVat11']; 
   $Charge_Type11=$_POST['Charge_Type11'];
   $Synchronized11=$_POST['Synchronized11']; 
   $Distribution_Method11=$_POST['Distribution_Method11'];
   
    
   if($actionmode=='purchasecharges' && $Tabnumber == 13){
   	$querypurchasecharges="update 	purchasechargessetup
   							set  	Ledger_NumberDebit=".GetSQLValueString($Ledger_NumberDebit11,'text').", 
   									Ledger_numberCredit=".GetSQLValueString($Ledger_numberCredit11,'text').",
   									Currency_code=".GetSQLValueString($Currency_code11,'text').", 
   									Charges_isVat=".GetSQLValueString($Charges_isVat11,'int').", 
   									Charge_Type=".GetSQLValueString($Charge_Type11,'text').",
   									Synchronized=".GetSQLValueString($Synchronized11,'int').", 
   									Distribution_Method=".GetSQLValueString($Distribution_Method11,'int')."
   									
   							where 	Auto='$Auto11'";
   			//	echo $querypurchasecharges	;	exit;	
   	$resultpurchasecharges=mysql_query($querypurchasecharges,$connection);						
   	header("Location: ./form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   if ($actionmode =='svpurchasecharges' && $Tabnumber ==13){ 
	   $querysvpurchasecharges = "insert into purchasechargessetup (Ledger_NumberDebit, Ledger_numberCredit, Currency_code, Charges_isVat, Charge_Type, Synchronized, Distribution_Method)".
					" values (".GetSQLValueString($Ledger_NumberDebit11,'text').", ".GetSQLValueString($Ledger_numberCredit11,'text').", ".GetSQLValueString($Currency_code11,'text').", ".GetSQLValueString($Charges_isVat11,'text').", ".GetSQLValueString($Charge_Type11,'text').", ".GetSQLValueString($Synchronized11,'text').", ".GetSQLValueString($Distribution_Method11,'text').");";
     //echo $querysvpurchasecharges;exit;
	  $resultsvpurchasecharges=mysql_query($querysvpurchasecharges,$connection);
	  	header("Location: ./form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	  }
	if ($actionmode =='delpurchasecharges' && $Tabnumber ==13){
		$querydelpurchasecharges = "delete from purchasechargessetup where Auto='$purchasechargesnum'"; 
		$resultdelpurchasecharges=mysql_query($querydelpurchasecharges,$connection);
	  	header("Location: ./form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	  }
   //Read transfer charges values
   
   $Auto18=$_POST['Auto18']; 
   $Ledger_NumberDebit18=$_POST['Ledger_NumberDebit18']; 
   $Ledger_numberCredit18=$_POST['Ledger_numberCredit18'];
   $Currency_code11=$_POST['Currency_code18']; 
   $Charges_isVat11=$_POST['Charges_isVat18']; 
   $Distribution_Method18=$_POST['Distribution_Method18'];
   
   if($actionmode=='transfercharges' && $Tabnumber == 23){
   	$querytransfercharges="update 	transferchargessetup
   							set  	Ledger_NumberDebit=".GetSQLValueString($Ledger_NumberDebit18,'text').", 
   									Ledger_numberCredit=".GetSQLValueString($Ledger_numberCredit18,'text').",
   									Currency_code=".GetSQLValueString($Currency_code18,'text').", 
   									Charges_isVat=".GetSQLValueString($Charges_isVat18,'int').", 
   									Distribution_Method=".GetSQLValueString($Distribution_Method18,'int')."
   									
   							where 	Auto='$Auto18'";
   				//echo $querytransfercharges	;	exit;	
   	$resulttransfercharges=mysql_query($querytransfercharges,$connection);						
   	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
    if ($actionmode =='svtransfercharges' && $Tabnumber ==23){ 
	   $querysvtransfercharges = "insert into transferchargessetup (Ledger_NumberDebit, Ledger_numberCredit, Currency_code, Charges_isVat, Distribution_Method)".
					" values (".GetSQLValueString($Ledger_NumberDebit18,'text').", ".GetSQLValueString($Ledger_numberCredit18,'text').", ".GetSQLValueString($Currency_code18,'text').", ".GetSQLValueString($Charges_isVat18,'text').", ".GetSQLValueString($Distribution_Method18,'text').");";
     //echo $querysvtransfercharges;exit;
	  $resultsvtransfercharges=mysql_query($querysvtransfercharges,$connection);
	  	header("Location: ./form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	  }
	  if ($actionmode =='deltransfercharges' && $Tabnumber ==23){
		$querydeltransfercharges = "delete from transferchargessetup where Auto='$transferchargesnum'"; 
		$resultdeltransfercharges=mysql_query($querydeltransfercharges,$connection);
	  	header("Location: ./form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	  }
   
   
   //Read rmasetup charges values
   $RMA_CheckError=$_POST['RMA_CheckError12'];
   $REMARK_REPORT=$_POST['REMARK_REPORT12'];
   $Synchronized=$_POST['Synchronized12'];
   $Default_Currency=$_POST['Default_Currency12'];
   if($actionmode=='rmasetup' && $Tabnumber == 14){
   	
   	$getvalues="select * from rmasetup";
   	$result=mysql_query($getvalues,$connection);
   	$num_rows2 = mysql_num_rows($result);
   
   	if($num_rows2==0){
   	$queryinsert="insert into rmasetup (RMA_CheckError, REMARK_REPORT,Synchronized,Default_Currency )
   								values (".GetSQLValueString($RMA_CheckError12,'int').",
   										".GetSQLValueString($RMA_CheckError12,'text').",
   										".GetSQLValueString($RMA_CheckError12,'int').",
   										".GetSQLValueString($RMA_CheckError12,'text')." 
   										)";
   									//	echo $queryinsert;exit;
   	$query_insertresult=mysql_query($queryinsert,$connection);
   	
   	}
   	else{
   	$queryrmasetup="update 	rmasetup 
   					set     RMA_CheckError=".GetSQLValueString($RMA_CheckError12,'int').",
   							REMARK_REPORT=".GetSQLValueString($REMARK_REPORT12,'text').", 
   							Synchronized=".GetSQLValueString($Synchronized12,'int').",
   							Default_Currency=".GetSQLValueString($Default_Currency12,'text')." ";
   							
   							//echo $queryrmasetup;exit;
   	$resultrmasetup=mysql_query($queryrmasetup,$connection);
   	}
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
   }
   
   //read receiptsetup values 
   $VATAccount13=$_POST['VATAccount13']; 
   $AUXAccount13=$_POST['AUXAccount13']; 
   $DEBITACCOUNTFROM13=$_POST['DEBITACCOUNTFROM13']; 
   $DEBITACCOUNTTO13=$_POST['DEBITACCOUNTTO13']; 
   $CREDITACCOUNTFROM13=$_POST['CREDITACCOUNTFROM13']; 
   $CREDITACCOUNTTO13=$_POST['CREDITACCOUNTTO13']; 
   $DEFAULTCUR13=$_POST['DEFAULTCUR13']; 
   $Voucher_PrintFolio13=$_POST['Voucher_PrintFolio13']; 
   $Voucher_PrintJVRef13=$_POST['Voucher_PrintJVRef13']; 
   $Voucher_PrintDateTime13=$_POST['Voucher_PrintDateTime13']; 
   $Voucher_AutoCalcAmnt13=$_POST['Voucher_AutoCalcAmnt13']; 
   $Voucher_ShowDescription213=$_POST['Voucher_ShowDescription213']; 
   $SeparateAccounts13=$_POST['SeparateAccounts13']; 
   $Synchronized13=$_POST['Synchronized13']; 
   $DefaultCostcenter13=$_POST['DefaultCostcenter13']; 
   $DefaultProject13=$_POST['DefaultProject13']; 
   $IsoDescription13=$_POST['IsoDescription13']; 
   $Chk_CommissionAcc13=$_POST['Chk_CommissionAcc13'];
   
   if($actionmode=='receiptsetup' && $Tabnumber == 15){
   $updatereceipt="update 	receiptsetup 
					set 	VATAccount=".GetSQLValueString($VATAccount13,'text').", 
							AUXAccount=".GetSQLValueString($AUXAccount13,'text').", 
							DEBITACCOUNTFROM=".GetSQLValueString($DEBITACCOUNTFROM13,'text').", 
							DEBITACCOUNTTO=".GetSQLValueString($DEBITACCOUNTTO13,'text').", 
							CREDITACCOUNTFROM=".GetSQLValueString($CREDITACCOUNTFROM13,'text').", 
							CREDITACCOUNTTO=".GetSQLValueString($CREDITACCOUNTTO13,'text').", 
							DEFAULTCUR=".GetSQLValueString($DEFAULTCUR13,'text').", 
							Voucher_PrintFolio=".GetSQLValueString($Voucher_PrintFolio13,'int').", 
							Voucher_PrintJVRef=".GetSQLValueString($Voucher_PrintJVRef13,'int').", 
							Voucher_PrintDateTime=".GetSQLValueString($Voucher_PrintDateTime13,'int').", 
							Voucher_AutoCalcAmnt=".GetSQLValueString($Voucher_AutoCalcAmnt13,'int').", 
							Voucher_ShowDescription2=".GetSQLValueString($Voucher_ShowDescription213,'int').", 
							SeparateAccounts=".GetSQLValueString($SeparateAccounts13,'int').", 
							Synchronized=".GetSQLValueString($Synchronized13,'int').", 
							DefaultCostcenter=".GetSQLValueString($DefaultCostcenter13,'text').", 
							DefaultProject=".GetSQLValueString($DefaultProject13,'text').", 
							IsoDescription=".GetSQLValueString($IsoDescription13,'text').", 
							Chk_CommissionAcc=".GetSQLValueString($Chk_CommissionAcc13,'text')." ";
						//	echo $updatereceipt;exit;
  $resultreceipt=mysql_query($updatereceipt,$connection);		
header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;  
   }
   
   
  //read diffechngsetup values
	$Ledger_Number14=$_POST['Ledger_Number14'];
	$Ledger_Type14=$_POST['Ledger_Type14'];
	
	if($actionmode=='differexchange' && $Tabnumber == 16){

	$query_update="update 	diffexchngsetup
					set  	Ledger_Number=".GetSQLValueString($Ledger_Number14,'text').",
							Ledger_Type=".GetSQLValueString($Ledger_Type14,'int')." 
					where 	Ledger_Number='$Ledger_Number14'";
					
				//	echo $query_update; exit;
	$result=mysql_query($query_update,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}
	
// by rodolphe
	   
		    

	if($actionmode=='updatesalesjvsetup' && $Tabnumber == 24){
 
  $Cost_N = $_POST['Cost_N'];
		$Supplier_N = $_POST['Supplier_N'];
		$Income_N = $_POST['Income_N'];

 $incomeaccountfound = 0;
 
 //
 $query_sql= "select CostAccount as _Coac,SupplierAccount as _Suac from salesjvsetup where IncomeAccount = $Income_N  ";
 

	 
$result_sql=mysql_query($query_sql , $connection) or die(mysql_error());
while($row_sql=mysql_fetch_array($result_sql)){
	extract($row_sql);
}	
 //
 
	if ( $_Coac != "" ||  $_Suac != "")
		$incomeaccountfound = 1;
	
	
	
	 
 if ($incomeaccountfound == 1)
 {
	$query_update="update 	salesjvsetup
					set  	CostAccount=".GetSQLValueString($Cost_N ,'text').",
							SupplierAccount=".GetSQLValueString($Supplier_N,'text')." 
					where 	IncomeAccount='$Income_N'";
					
				//	echo $query_update; exit;
	$result=mysql_query($query_update,$connection);
 }
 else
 {
	 $query_insert = "insert into salesjvsetup (IncomeAccount,CostAccount,SupplierAccount) values (".GetSQLValueString($Income_N ,'text')."
	 ,".GetSQLValueString($Cost_N ,'text').",".GetSQLValueString($Supplier_N ,'text').")";
	// echo $query_insert; exit;
	 $result=mysql_query($query_insert,$connection);
 }
	
	
	
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}


	if($actionmode=='deletesalesjvsetup' && $Tabnumber == 24){
 
  
   
  // trigger_error($income_account);
 
	$query_update="delete from salesjvsetup where  IncomeAccount = $income_account ";
					
				//	echo $query_update; exit;
	$result=mysql_query($query_update,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}
	
	
	
	//read   deliverystatussetup values
	$id15=$_POST['id15'];
	$name15=$_POST['name15'];
	$deliverystatus_level15=$_POST['deliverystatus_level15'];
	if($actionmode=='deliverystatus' && $Tabnumber == 17){ 
	$query_update="update deliverystatus_setup
					set 	name=".GetSQLValueString($name15,'text').",
							deliverystatus_level=".GetSQLValueString($deliverystatus_level15,'double')." 
					where 	id='$id15' ";
					//echo $query_update; exit;
	$result=mysql_query($query_update,$connection);
header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}
	
	 //read   budgetsetup values
	$BdgtSetup_PriceTerms16=$_POST['BdgtSetup_PriceTerms16'];
	$BdgtSetup_OfferValidity16=$_POST['BdgtSetup_OfferValidity16'];
	$BdgtSetup_PaymentTerms16=$_POST['BdgtSetup_PaymentTerms16'];
	$DefaultProfitPer16=$_POST['DefaultProfitPer16'];
	$Synchronized16=$_POST['Synchronized16'];
	
	if($actionmode=='budgetsetup' && $Tabnumber == 18){
	$getvalues="select * from budgetsetup";
   	$result=mysql_query($getvalues,$connection);
   	$num_rows2 = mysql_num_rows($result);
   
   	if($num_rows2==0){
   	$queryinsert="insert into budgetsetup (BdgtSetup_PriceTerms, BdgtSetup_OfferValidity,BdgtSetup_PaymentTerms,DefaultProfitPer,Synchronized )
   								values (".GetSQLValueString($BdgtSetup_PriceTerms16,'text').",
   										".GetSQLValueString($BdgtSetup_OfferValidity16,'text').",
   										".GetSQLValueString($BdgtSetup_PaymentTerms16,'text').",
   										".GetSQLValueString($DefaultProfitPer16,'double').",
										".GetSQLValueString($Synchronized16,'int')."
   										)";
   										//echo $queryinsert;
   										//exit;
   	$query_insertresult=mysql_query($queryinsert,$connection);
   	
   	}
	
	$query_update="update 	budgetsetup
					set 	BdgtSetup_PriceTerms=".GetSQLValueString($BdgtSetup_PriceTerms16,'text').",
							BdgtSetup_OfferValidity=".GetSQLValueString($BdgtSetup_OfferValidity16,'text').",
							BdgtSetup_PaymentTerms=".GetSQLValueString($BdgtSetup_PaymentTerms16,'text').",
							DefaultProfitPer=".GetSQLValueString($DefaultProfitPer16,'double').",
							Synchronized=".GetSQLValueString($Synchronized16,'int')."
					";
	$result=mysql_query($query_update,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}
	
	
	//read   acctypesetup values
	$AccTypeSetupInc17=$_POST['AccTypeSetupInc17'];
	$Type_Code17=$_POST['Type_Code17'];
	$Type_name17=$_POST['Type_name17'];
	$GeneratedType_code17=$_POST['GeneratedType_code17'];
	$GeneratedType_Name17=$_POST['GeneratedType_Name17'];
	$Ledger_Number17=$_POST['Ledger_Number17'];
	$Warehouse_code17=$_POST['Warehouse_code17'];
	$Ledger_activity17=$_POST['Ledger_activity17'];
	$GenerateWithGroup17=$_POST['GenerateWithGroup17'];
	$Synchronized17=$_POST['Synchronized17'];
	
	if($actionmode=='acctypesetup' && $Tabnumber == 19){ 
		$getvalues="select * from acctypesetup";
		$result=mysql_query($getvalues,$connection);
		$num_rows2 = mysql_num_rows($result);
   
		if($num_rows2==0){ 
			$queryinsert="insert into acctypesetup (AccTypeSetupInc, Type_Code,Type_name,GeneratedType_code,GeneratedType_Name,Ledger_Number,Warehouse_code,
			Ledger_activity,GenerateWithGroup,Synchronized)
									values (".GetSQLValueString($AccTypeSetupInc17,'int').",
											".GetSQLValueString($Type_Code17,'text').",
											".GetSQLValueString($Type_name17,'text').",
											".GetSQLValueString($GeneratedType_code17,'text').",
											".GetSQLValueString($GeneratedType_Name17,'text').",
											".GetSQLValueString($Ledger_Number17,'text').",
											".GetSQLValueString($Warehouse_code17,'text').",
											".GetSQLValueString($Ledger_activity17,'int').",
											".GetSQLValueString($GenerateWithGroup17,'int').",
											".GetSQLValueString($Synchronized17,'int')."
											)";
									//	echo $queryinsert;exit;
			$query_insertresult=mysql_query($queryinsert,$connection);
		
		}
			$query_update="update 	acctypesetup
						set 	AccTypeSetupInc=	".GetSQLValueString($AccTypeSetupInc17,'int').",
								Type_Code=	".GetSQLValueString($Type_Code17,'text').",
								Type_name=	".GetSQLValueString($Type_name17,'text').",
								GeneratedType_code=	".GetSQLValueString($GeneratedType_code17,'text').",
								GeneratedType_Name=	".GetSQLValueString($GeneratedType_Name17,'text').",
								Ledger_Number=	".GetSQLValueString($Ledger_Number17,'text').",
								Warehouse_code=	".GetSQLValueString($Warehouse_code17,'text').",
								Ledger_activity=	".GetSQLValueString($Ledger_activity17,'int').",
								GenerateWithGroup=	".GetSQLValueString($GenerateWithGroup17,'int').",
								Synchronized=	".GetSQLValueString($Synchronized17,'int')."
							";
						//	echo $query_update; exit;
			$result=mysql_query($query_update,$connection);
     header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	}



if($actionmode=='editdoe'){

$currency_codedoe=$_GET['currency_code'];
//$currency_namedoe=$_POST['currency_namedoe'.$currency_codedoe];
$currency_naturedoe=$_POST['currency_naturedoe'.$currency_codedoe];
$ratedoe=$_POST['ratedoe'.$currency_codedoe];
$paritydoe=$_POST['paritydoe'.$currency_codedoe];
$synchrinizeddoe=$_POST['synchrinizeddoe'.$currency_codedoe];

//echo $currency_namedoe; exit;

$query="update  differenceexchange 
		set   	Currency_nature=".GetSQLValueString($currency_naturedoe,'int').",
				Rate=".GetSQLValueString($ratedoe,'double').",
				Parity=".GetSQLValueString($paritydoe,'double').", 
				Synchronized=".GetSQLValueString($synchrinizeddoe,'int')." 
		where currency_code='$currency_codedoe'";
	
$result=mysql_query($query,$connection);	

}

if($actionmode=='addaccountledgerea'){
	$ledger_numberex=$_GET['ledger_numberex'];
	$query="insert into diffexchngsetup (Ledger_Number, Ledger_Type) values (".GetSQLValueString($ledger_numberex,'int')." ,'0')";
	$result=mysql_query($query,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
}
if($actionmode=='deleteledgerea'){
	$ledger_numberex=$_GET['ledgernumberex'];
	$query="delete from diffexchngsetup where ledger_number='$ledger_numberex' ";
	$result=mysql_query($query,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
}

if($actionmode=='addaccountledgeria'){
	$ledger_numberia=$_GET['ledger_numberia'];
	$query="insert into diffexchngsetup (Ledger_Number, Ledger_Type) values (".GetSQLValueString($ledger_numberia,'int')." ,'1')";
	$result=mysql_query($query,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
}
if($actionmode=='deleteledgeria'){
	$ledger_numberia=$_GET['ledgernumberia'];
	$query="delete from diffexchngsetup where ledger_number='$ledger_numberia'";
	$result=mysql_query($query,$connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
	//echo $query;echo "Edit Ia"; exit;
}


if($actionmode=='getallcurrency'){
	
	$query="insert into differenceexchange (Currency_code, Currency_name, Currency_nature, Rate, Parity, Synchronized)
			SELECT 	a.Currency_code, a.Currency_name, a.Currency_nature, b.curdt_rate,b.curdt_parity, a.Synchronized 
			from 	currency a
			left join curdt b on b.Currency_code=a.Currency_code
			WHERE 	a.currency_code NOT IN (SELECT currency_code FROM differenceexchange)";
	$result=mysql_query($query,$connection);
}



// generating difference of exchange
if($actionmode=='doe'){
	
$tdate			= $_POST['tdate'];
$project_code	= $_POST['txtProjectCode'];
$Costcenter		= $_POST['txtCostCentCode'];
$negative		= $_POST['fromledgerdoe'];
$positive		= $_POST['toledgerdoe'];
$close_pro_cost	= $_POST['close_pro_cost'];

$project_code = ''.$project_code;
if ($project_code == '')
	$project_code = "null";
else $project_code = "'".$project_code."'";

$Costcenter = ''.$Costcenter;
if ($Costcenter == '')
	$Costcenter = "null";
else $Costcenter = "'".$Costcenter."'";

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

	$querysetup  = "select base1, base2 from setup ";
	$resultsetup = mysql_query($querysetup,$connection) or die(mysql_error());
	$rowsetup	 = mysql_fetch_row($resultsetup);
	$base1 		 = $rowsetup[0];
	$base2 		 = $rowsetup[1];
	
	$queryb1 = "call DifferenceOfExchangeQ ('$tdate', '$base1', $project_code, $Costcenter, '$positive', '$negative', '$close_pro_cost', '$module_ReferenceByCostcenter', 0, '".$_SESSION['dbName']."', '".$_SESSION['dbLabel']."', '".$_SESSION['useraccount']."', '".$_SESSION['username']."', '$FI_BelongsToGrp', @JvId)";
	//echo $queryb1;exit;
	$resultb1 = mysql_query($queryb1, $connection);
	$queryb2 = "call DifferenceOfExchangeQ ('$tdate', '$base2', $project_code, $Costcenter, '$positive', '$negative', '$close_pro_cost', '$module_ReferenceByCostcenter', 0, '".$_SESSION['dbName']."', '".$_SESSION['dbLabel']."', '".$_SESSION['useraccount']."', '".$_SESSION['username']."', '$FI_BelongsToGrp', @JvId)";
	$resultb2 = mysql_query($queryb2, $connection);
	header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber");
   exit;
}



if($actionmode=='refrenumber'){
	$querysetup = "set @x=0; ";
	$resultdt=mysql_query($querysetup, $connection) or die(mysql_error());
	$rowdt=mysql_fetch_row($resultdt);
	
/*	if($renumberVal == 1){
		
		$queryupdate = "update journal
						set Journal_RefGovernment = @x:=@x+1
						where (date_format(Journal_date,'%Y-%m-%d') >= concat(YEAR(CURDATE()),'-01-01')
						and date_format(Journal_date,'%Y-%m-%d') <= date_format(now(),'%Y-%m-%d') )
						and if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef') order by Journal_date asc;";
		$resupdate = mysql_query($queryupdate,$connection);		
		$updateseq = "update sequence set Journal_RefGovernment = (select max(Journal_RefGovernment)
						from journal where if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef')) 
						where if('$txtCostCentCodeRef'='',1=1,Costcenter = '$txtCostCentCodeRef') ";	
		$resseq = mysql_query($updateseq,$connection);
	}*/
	if($renumberVal == 2){
		$nfromdate = explode('/',$fromdate);
		$fromdate = $nfromdate[2]."-".$nfromdate[1]."-".$nfromdate[0]; 
		if($todate != ''){
		$ntodate = explode('/',$todate);
		$todate = $ntodate[2]."-".$ntodate[1]."-".$ntodate[0];
		}
		$queryupdate = "update journal
						set Journal_RefGovernment = @x:=@x+1
						where (date_format(Journal_date,'%Y-%m-%d') >= '$fromdate'
						and if('$todate' ='' ,1=1,date_format(Journal_date,'%Y-%m-%d') <= '$todate' ))
						and if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef') order by Journal_date asc;";
		$resupdate = mysql_query($queryupdate,$connection);		
		$updateseq = "update sequence set Journal_RefGovernment = (select max(Journal_RefGovernment)
						from journal where if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef')) 
						where if('$txtCostCentCodeRef'='',1=1,Costcenter = '$txtCostCentCodeRef') ";	
		$resseq = mysql_query($updateseq,$connection);
	}
	if($renumberVal == 3){
		
		$queryupdate = "update journal
						set Journal_RefGovernment = @x:=@x+1
						where (Journal_RefGovernment >= '$fromref'
						and if('$toref' ='' ,1=1,Journal_RefGovernment <= '$toref' ))
						and if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef') order by Journal_date asc;";
		$resupdate = mysql_query($queryupdate,$connection);		
		$updateseq = "update sequence set Journal_RefGovernment = (select max(Journal_RefGovernment)
						from journal where if('$txtCostCentCodeRef'='',1=1,Costcent_Code = '$txtCostCentCodeRef')) 
						where if('$txtCostCentCodeRef'='',1=1,Costcenter = '$txtCostCentCodeRef') ";	
		$resseq = mysql_query($updateseq,$connection);
	}
	//exit;
}





   $Tabnumber=$_POST['Tabnumber'];	
   $Tabnumber=$_GET['Tabnumber'];	
  // header("Location: ./../contract/form_utilities.php?Tabnumber=$Tabnumber&Auto11=$Auto11&Ledger_Number14=$Ledger_Number14&id15=$id15");
   					
   			
   ?>
