<?php

session_start();

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

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

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

$default_company = $_POST['default_company'];
$default_year = $_POST['default_year'];
$UserList = $_POST['UserList'];
$txtUserSchema = $_POST['txtUserSchema'];
$isSuperUser = $_POST['isSuperUser'];
$like_user = $_POST['like_user'];

$mode 			 = $_POST['mode']; 				if($mode == '') 			$mode 			= $_GET['mode'];
$actionmode 	 = $_POST['actionmode']; 		if($actionmode == '') 		$actionmode 	= $_GET['actionmode'];
$user_code  	 = $_POST['user_code']; 		if($user_code == '') 		$user_code 		= $_GET['user_code'];
$login_language  = $_POST['login_language']; 	if($login_language == '')	$login_language = $_GET['login_language'];

if($login_language == '') $login_language = "English";

if($isSuperUser == '') $isSuperUser = 0;
//echo $user_first_login; exit;

if($user_first_login == '') { $user_first_login = 0; }

if($user_expiry == '') { $user_expiry = 0; }

if ($mode == 'insertHOD'){
	$hodusercode = $_GET['hodusercode'];
	$user_code 	 = $_GET['user_code'];
	
	$chkuser = "select 1 from ".$_SESSION['dbLabel'].".users where user_account = '$hodusercode' ";
	$reschkuser = mysql_query($chkuser, $connection);
	$numr = mysql_num_rows($reschkuser);
	if ($numr == 0){
		$message = "User $hodusercode Doesn't Exists as User!";
	}
	else {
		$querychk = "select 1 from ".$_SESSION['dbLabel'].".HOD_Users where hod_code = '$user_code' and user_code = '$hodusercode' ";
		$reschk = mysql_query($querychk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr > 0){
			$message = "User $hodusercode already exists!";
		} else {
			$insert = "insert into ".$_SESSION['dbLabel'].".HOD_Users (hod_code, user_code) values ('$user_code', '$hodusercode') ";
			$result = mysql_query($insert, $connection);
		}
	}
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	userHODGrid('', $user_code, $connection);
	exit;
	
} else if ($mode == 'updateHOD'){
	$hod_id 	 = $_GET['hod_id'];
	$hodusercode = $_GET['hodusercode'];
	$user_code 	 = $_GET['user_code'];
	
	$chkuser = "select 1 from ".$_SESSION['dbLabel'].".users where user_account = '$hodusercode' ";
	$reschkuser = mysql_query($chkuser, $connection);
	$numr = mysql_num_rows($reschkuser);
	if ($numr == 0){
		$message = "User $hodusercode Doesn't Exists as User!";
	}
	else {	
		$querychk = "select 1 from ".$_SESSION['dbLabel'].".HOD_Users where hod_code = '$user_code' and user_code = '$hodusercode' and hod_id <> $hod_id ";
		$reschk = mysql_query($querychk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr > 0){
			$message = "User $hodusercode already exists!";
		} else {
			$update = "update ".$_SESSION['dbLabel'].".HOD_Users set hod_code = '$user_code', user_code = '$hodusercode' where hod_id = $hod_id ";
			$result = mysql_query($update, $connection);
		}
	}	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	userHODGrid('', $user_code, $connection);
	exit;
}
else if ($mode == 'deleteHOD'){
	$hod_id 	 = $_GET['hod_id'];
	$user_code 	 = $_GET['user_code'];
	
	$deleteRecord = "delete from ".$_SESSION['dbLabel'].".HOD_Users where hod_id = $hod_id ";
	$result = mysql_query($deleteRecord, $connection);
	
	if (!$result){
		$message = "Error While Deleting Record!";
	}
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	userHODGrid('', $user_code, $connection);
	exit;
}
else if ($mode == 'clearHOD'){
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	userHODGrid('', $user_code, $connection);
	exit;
}

// Costcent Access Tab insert / update / delete / Clear
if ($mode=='saveCostcentAcc' && $user_code != ''){
	$cAccid 		  = $_GET['cAccid'];
	$costcentcode 	  = $_GET['cpcode'];
	$costcentincluded = $_GET['cpincluded'];
	
	if ($costcentincluded == '') $costcentincluded = 0;
	
	$errorExists = 0;
	
	$chkc = "select 1 from ".$_SESSION['dbName'].".costcent where costcent_code = '$costcentcode'";
	$reschk = mysql_query($chkc, $connection);
	$numr = mysql_num_rows($reschk);
	if ($numr == 0 ){
		$errorExists = 1;
		$message = "Cannot Insert Record! Check Costcenter!";
	}
		
	if ($cAccid == '' && $errorExists == 0){
		$chk = "select 1 from ".$_SESSION['dbLabel'].".costcentstk where costcent_code = '$costcentcode' and  user_account = '$user_code' ";
		$reschk = mysql_query($chk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr == 0){
			$insert = "insert into ".$_SESSION['dbLabel'].".costcentstk (user_account, costcent_code, costcent_include) values ('$user_code', '$costcentcode', $costcentincluded)";
			$res = mysql_query($insert, $connection);
		} else {
			$message = "Cannot Insert Record! $costcentcode Already Exists for user $user_code!";
		}
			
	} else if ($cAccid != '' && $errorExists == 0) {
		$chk = "select 1 from ".$_SESSION['dbLabel'].".costcentstk where costcent_code = '$costcentcode' and  user_account = '$user_code' and id <> $cAccid  ";
		$reschk = mysql_query($chk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr == 0){
			$update = "update ".$_SESSION['dbLabel'].".costcentstk set user_account = '$user_code', costcent_code = '$costcentcode', costcent_include = $costcentincluded  where id = $cAccid ";
			$res = mysql_query($update, $connection);
		} else {
			$message = "Cannot Insert Record! $costcentcode Already Exists for user $user_code!";
		}
		
	}
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	costcentAccessGrid('', $user_code, $connection);
	exit;
}
else if ($mode=='editCostcentAcc' && $user_code != ''){
	$cAccid 		  = $_GET['cAccid'];
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	costcentAccessGrid($cAccid, $user_code, $connection);
	exit;
}
else if ($mode=='deleteCostcentAcc' && $user_code != ''){
	$cAccid 		  = $_GET['cAccid'];
	$del = "delete from ".$_SESSION['dbLabel'].".costcentstk where id = $cAccid ";
	$res = mysql_query($del, $connection);
	$message = mysql_error();
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	costcentAccessGrid('', $user_code, $connection);
	exit;
}
else if ($mode=='clearCostcentAcc' && $user_code != ''){
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	costcentAccessGrid('', $user_code, $connection);
	exit;
}

if ($mode == 'saveProjectAcc' && $user_code != '' ){
	$cAccid 		  = $_GET['cAccid'];
	$projectcode 	  = $_GET['cpcode'];
	$projectincluded  = $_GET['cpincluded'];
	
	if ($projectincluded == '') $projectincluded = 0;
	
	$errorExists = 0;
	
	$chkc = "select 1 from ".$_SESSION['dbName'].".project where project_code = '$projectcode'";
	$reschk = mysql_query($chkc, $connection);
	$numr = mysql_num_rows($reschk);
	if ($numr == 0 ){
		$errorExists = 1;
		$message = "Cannot Insert Record! Check Project!";
	}
		
	if ($cAccid == '' && $errorExists == 0){
		$chk = "select 1 from ".$_SESSION['dbLabel'].".projectstk where project_code = '$projectcode' and  user_account = '$user_code' ";
		$reschk = mysql_query($chk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr == 0){
			$insert = "insert into ".$_SESSION['dbLabel'].".projectstk (user_account, project_code, project_include) values ('$user_code', '$projectcode', $projectincluded)";
			$res = mysql_query($insert, $connection);
		} else {
			$message = "Cannot Insert Record! $projectcode Already Exists for user $user_code!";
		}
			
	} else if ($cAccid != '' && $errorExists == 0) {
		$chk = "select 1 from ".$_SESSION['dbLabel'].".projectstk where project_code = '$projectcode' and  user_account = '$user_code' and id <> $cAccid  ";
		$reschk = mysql_query($chk, $connection);
		$numr = mysql_num_rows($reschk);
		
		if ($numr == 0){
			$update = "update ".$_SESSION['dbLabel'].".projectstk set user_account = '$user_code', project_code = '$projectcode', project_include = $projectincluded  where id = $cAccid ";
			$res = mysql_query($update, $connection);
		} else {
			$message = "Cannot Insert Record! $projectcode Already Exists for user $user_code!";
		}
		
	}
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	ProjectAccessGrid('', $user_code, $connection);
	exit;
}
else if ($mode=='editProjectAcc' && $user_code != ''){
	$cAccid 		  = $_GET['cAccid'];
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	ProjectAccessGrid($cAccid, $user_code, $connection);
	exit;
}
else if ($mode=='deleteProjectAcc' && $user_code != ''){
	$cAccid 		  = $_GET['cAccid'];
	$del = "delete from ".$_SESSION['dbLabel'].".projectstk where id = $cAccid ";
	$res = mysql_query($del, $connection);
	$message = mysql_error();
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	ProjectAccessGrid('', $user_code, $connection);
	exit;
}
else if ($mode=='clearProjectAcc' && $user_code != ''){
	
	echo "[BRK]";
	echo $message;
	echo "[BRK]";
	ProjectAccessGrid('', $user_code, $connection);
	exit;
}
// Emails Tab insert / update / delete / Clear

if($mode=='Emails' && $actionmode=='saveEmail' && $user_code != ''){
	$email_id = $_GET['email_id'];
	$emailaddr = $_GET['emailaddr'];
		
	if($email_id == ''){
		$query = "insert into  ".$_SESSION['dbLabel'].".users_emails (user_account, email_address) values ('$user_code', '$emailaddr');";
		$res = mysql_query($query,$connection);
	} else if($email_id != ''){
		$query = "update  ".$_SESSION['dbLabel'].".users_emails set user_account = '$user_code', email_address = '$emailaddr' where email_id = $email_id;";
		$res = mysql_query($query,$connection);
	}
	
	echo "[BRK]";
	SubmitUserEmails('', $user_code, $connection);
	echo "[BRK]";
	ShowUserEmails('', $user_code, $connection);
	exit;
}
else if($mode=='Emails' && $actionmode=='deleteEmail'){
	$email_id = $_GET['email_id'];
		
	if($email_id != ''){
		$query = "delete from  ".$_SESSION['dbLabel'].".users_emails where email_id = $email_id;";
		$res = mysql_query($query,$connection);
	}
	
	echo "[BRK]";
	SubmitUserEmails('', $user_code, $connection);
	echo "[BRK]";
	ShowUserEmails('', $user_code, $connection);
	exit;
}

else if($mode=='Emails' && $actionmode=='editEmail'){
	$email_id = $_GET['email_id'];
		
	echo "[BRK]";
	SubmitUserEmails($email_id, $user_code, $connection);
	echo "[BRK]";
	ShowUserEmails($email_id, $user_code, $connection);
	exit;
}
else if($mode=='notify' && $actionmode=='setNotification' && $user_code != ''){
	$notification_type   = $_GET['notification_type'];
	$view_access 		 = $_GET['view_access'];
	$notification_daysno = $_GET['notification_daysno'];
	if($notification_daysno == '') $notification_daysno = "null";
	
	$query = "select NotifyAccess_Id
			from ".$_SESSION['dbName'].".notification_type as notification_type
			inner join  ".$_SESSION['dbLabel'].".Notification_Access as Notification_Access on Notification_Access.Notification_Name = notification_type.Notification_Name
			where upper(user_code)=upper('$user_code') and notification_type.Notification_Name = '$notification_type';";
	//echo $query;exit;
	$result = mysql_query($query,$connection);
	$rownum = mysql_num_rows($result);
	if($rownum == 0){
		$insert = "insert into ".$_SESSION['dbLabel'].".Notification_Access (user_code, Notification_Name, View_Access, nbrOfDays) values ('$user_code','$notification_type',$view_access, $notification_daysno )";
		//echo $insert;exit;
		//echo $insert;exit;
		$result = mysql_query($insert,$connection);
	} else {
		$row = mysql_fetch_row($result);
		$NotifyAccess_Id = $row[0];
		$update = "update ".$_SESSION['dbLabel'].".Notification_Access set View_Access = $view_access, nbrOfDays = $notification_daysno where NotifyAccess_Id = $NotifyAccess_Id;";
		//echo $update;exit;
		$result = mysql_query($update,$connection);
	}
	
	
	exit;
}
if($mode==''  && $like_user==''){
	if($deliverystatus_level=='') $deliverystatus_level=0;
	$uppercase = preg_match('@[A-Z]@', $user_password2);
$lowercase = preg_match('@[a-z]@', $user_password2);
$number    = preg_match('@[0-9]@', $user_password2);
$special = preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/', $user_password2);

if($user_complex_password == 1){
if($uppercase && $lowercase && $number && $special &&  strlen($user_password2) >= 8) {
	$query="insert into users (User_account,User_name,FullName,Description,User_IsGroup,User_Group,DefaultComp,DefaultYear,User_Password,deliverystatus_level,user_deactivate";
	if($user_deactivate == 1){
	   $query = $query.",user_deactivate_date";
	}
	$query = $query. ", user_complex_password, user_expiry";
	if($user_code == $user_password2){
	   $query = $query.", user_first_login"; 
	}
	if($user_engineer != "")
		$query = $query.", user_engineer ";
	$query = $query. ") values ('".$user_code."','".$user_name."','".$full_name."','".$user_description."','".$user_isgroup."','".$user_group."','".$default_company."','".$default_year."',";
			
	if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."') ";
	else
		$query=$query."'".$user_password2."' ";		
		
		$query=$query.",'".$deliverystatus_level."', '".$user_deactivate."'";		
    if($user_deactivate == 1){
	   $query = $query.", now()";
	}
	$query=$query." , '".$user_complex_password."', '".$user_expiry."', '".$user_first_login."'";
	if($user_code == $user_password2){
	   $query = $query.", '1'"; 
	}
	if($user_engineer != "")
		$query = $query.", '$user_engineer'";
	$query = $query.")";
	//echo $query;exit;
	$result=mysql_query($query,$connection);
	$User_id = mysql_insert_id($connection);
	$message= mysql_error();
	}
	else
	{
	    $message= "Password should contain at least 8 characters having at least one alphabetical, one numerical value, one special character, one lower case letter, and one upper case letter.";
	}
	}
	else
	{
	if($fullaccess=='1' || $fullaccess==''){
	  $query="insert into users (User_account,User_name,FullName,Description,User_IsGroup,User_Group,DefaultComp,DefaultYear,User_Password,deliverystatus_level,user_deactivate";
	if($user_deactivate == 1){
	   $query = $query.",user_deactivate_date";
	}
	$query = $query. ", user_complex_password, user_expiry";
	if($user_code == $user_password2){
	   $query = $query.", user_first_login"; 
	}
	if($user_engineer != "")
		$query = $query.", user_engineer ";
	$query = $query. ") values ('".$user_code."','".$user_name."','".$full_name."','".$user_description."','".$user_isgroup."','".$user_group."','".$default_company."','".$default_year."',";
			
	if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."') ";
	else
		$query=$query."'".$user_password2."' ";		
		
		$query=$query.",'".$deliverystatus_level."', '".$user_deactivate."'";		
    if($user_deactivate == 1){
	   $query = $query.", now()";
	}
	$query=$query." , '".$user_complex_password."', '".$user_expiry."'";
	if($user_code == $user_password2){
	   $query = $query.", '1'"; 
	}
	if($user_engineer != ""){
		$query = $query.", '$user_engineer'";
	}
	$query = $query.")";
	//echo $query;exit;
	$result=mysql_query($query,$connection);
	$User_id = mysql_insert_id($connection);
	$message= mysql_error();
	}else{
		$query="insert into users
		select
		'".$user_name."', '".$user_code."',";
		
		
		if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."'), ";
		else
		$query=$query."'".$user_password2."', ";
		
		$query=$query."'".$full_name."','".$user_description."', DefaultComp, DefaultYear, Access, Access_UserManager, User_Signature, FullAccess, User_IsGroup, User_Group, Utilities, InvCreditLimit, Discount, DiscountMsgWarning, ModifyBelongsToGrp, User_logedintoinventory, User_logedintoaccounting, User_logedintopayroll, user_groupacc, user_email, user_query, BRANCH_CODE, employee_id, user_admin, deliverystatus_level, user_expirydate, user_deactivate, user_deactivate_date, user_complex_password, user_expiry, user_first_login, user_engineer, user_engineerqc, userType, user_type, user_securityChecked
		from users
		where user_account='".$like_user."'
		";

		$result=mysql_query($query,$connection);
		// echo $query3;exit;
	
		$User_id = mysql_insert_id($connection);
		$message= mysql_error();
	}
	// echo $query;exit;
	}
	//echo $UserList; exit;
	if($UserList != "")
	{
		$query_deletelogin  = "delete from login where Login_Schema = '$txtUserSchema' and user_account = '$user_code'";
		$result_deletelogin = mysql_query($query_deletelogin, $connection);
		$query_login = "insert into login (User_Name, User_account, Login_Schema, User_password, Fullname, Description, Print, Access, Login_Delete, Login_Append, Costcenter, Project, Currency, Ledger, Budget, Keyboard_Layout, Language, DefaultComp, DefaultYear, FullAccess, USR_CompanyAccess, USR_UserManager, USR_AppPriv, USR_FormAccess, USR_ReportOption, RMA_In, RMA_Out, ModifyVAT, InvCreditLimit, Login_Edit, DisplayBoth, Discount, DiscountMsgWarning, Post, Promotion, ReturnQuantity, Login_CardNo, login_belongstogrp, ModifyBelongsToGrp, Bdgt_Reference, User_Signature, RetailInvoice, FC_CashRegister, FC_CashRegisterApp, FC_CashRegisterDel, FC_CashRegisterMod, FI_SalesVAT, FI_ReturnSalesVAT, FI_PurchasesVAT, FI_PurchasesVATMod, FI_ReturnPurchasesVAT, FA_SalesJvVAT, FA_PurchaseJV, FA_PurchaseJVMod, FA_PurchaseJVDel, FA_PurchaseJVApp, FA_PurchaseJVVAT, U_TransferItem, FI_SalesCheckSalesman, FI_RSalesCheckSalesman, FC_CashRegisterScroll, FC_CashRegisterCredit, FC_CashRegisterCheck, FC_CashRegisterCoupon, FC_CashRegisterCustomer, FC_CashRegisterCash, FC_CashRegisterDisc, FC_CashRegisterProm, FC_CashRegisterQtyRet, FI_Sizes, FI_SizesDel, FI_SizesMod, FI_SizesApp, RA_ListOfPurchaseJv, FA_PurchaseJVCharge, FA_PrefixJV, Closing_RetailReport, FI_Color, FI_ColorMod, FI_ColorDel, FI_ColorApp, FI_ItemSelling1, FI_ItemSelling2, FI_ItemSelling3, FI_ItemSelling4, FI_ItemSelling5, FI_SOrderWithPrice, FI_SalesWithPrice, FC_PermToCancelCash, FI_ClientSalesmanComm, FI_SalebelowLandedCost, FC_CashRegisterClient, RI_LISTOFDUEITEMS, RA_StatementofProject, RA_ProfitandLoss, RA_PurchasesandSalesJV, RI_ListofItems, RI_ListofRMA, RI_InvoiceProject, RI_SalesStatistics, RA_ListofDueInvoices, FI_ShowCostPrice, FA_BalanceJV, Reports, Rep_General, Rep_Inventory, Rep_Accounting, RA_SalesmanComm, FC_RetailReport, RA_RequiredCostcenter, FA_LedgerAccess, ExporttoExcel, FixJVofSales, ModifyingOldTransactions, DailyInvoiceModification, FI_DIFFCOMPANY, AskBeforeCloseInv, AskBeforeCloseAcc, ShowDepositJVBtn, Show_group, Fi_itemselling6, Fc_forcingvendor, Rc_cashFlow, RC_ListOfInvoices, RC_SalesmenCommission, RC_ItemsSizes, FC_ShowBtnOpenDrawer, FC_AddClient, RC_ForcingUserAccount, FA_FIPAddress, FA_IPAddressApp, FA_IPAddressDel, FA_IPAddressMod, FA_IPAddPermToExceedCL, RA_ListOfInvoices, FA_ManagingRequiredCost, U_RePostTransaction, FC_AddCustomer, FC_ConfirmCustomer, FA_PaymentRqst, FA_PaymentRqstApp, FA_PaymentRqstMod, FA_PaymentRqstDel, FA_Client, FA_ClientDel, FA_ClientApp, FA_ClientMod, FA_ClientCreditLimit, FA_Currency, FA_CurrencyDel, FA_CurrencyApp, FA_CurrencyMod, FA_Supplier, FA_SupplierDel, FA_SupplierApp, FA_SupplierMod, FA_Project, FA_ProjectDel, FA_ProjectMod, FA_ProjectApp, FA_CostCenter, FA_CostCenterDel, FA_CostCenterMod, FA_CostCenterApp, RA_AccountReconciliation, FA_SalesJVModRef, LockedPeriod, AllowLockedPeriod, FI_PreProduction, FI_PreProductionMod, FI_PreProductionApp, FI_PreProductionDel, FP_Insurance, FP_InsuranceMod, FP_InsuranceApp, FP_InsuranceDel, FI_WayBill, FI_WayBillDel, FI_WayBillApp, FI_WayBillMod, FP_DetailGenerateDel, RI_YearlySales, RI_TrackingRMA, RI_InvByEntryNo, RI_ListOfDeliveryQty, RI_OpInvForNewYear, DirectConsumption, RI_PorderReport, RI_ClientsSalesReport, ClientIP_Del, ClientIP_Mod, ClientIP_App, ClientIP_EndDate, ClientIP_LastTransDate, RI_YearlyPurchases, LockedPeriodDays, Rp_ReportR3, FI_SupplierGrp, FI_SupplierGrpApp, FI_SupplierGrpDel, FI_SupplierGrpMod, FI_ClientGrp, FI_ClientGrpApp, FI_ClientGrpDel, FI_ClientGrpMod, FA_ConfirmJV, FI_RVPostTransaction, FI_PVPostTransaction, FI_CVPostTransaction, FI_DVPostTransaction, FU_ClosingPeriod, FI_RepostPurchase, FI_RepostPReturn, FI_RepostSales, FI_RepostSReturn, FI_RepostDeliveries, FI_RepostDReturn, FI_RepostPorder, FI_RepostSorder, FI_RepostAdjustment, FP_ShowSalaryMvt, RI_listofPICharges, FP_ArabicReports, FP_EmpArabicInfo, FI_ITransfer, FI_ITransferApp, FI_ITransferMod, FI_ITransferDel, FI_PorderPurRequest, FI_SupplierGrpPurRequest, FP_Grades, FP_GradesApp, FP_GradesDel, FP_GradesMod, FP_Dept, FP_DeptApp, FP_DeptDel, FP_DeptMod, FP_Fpreemp, FP_preempApp, FP_preempDel, FP_preempMod, FP_Attendance, FP_Overtime, FP_AnalysisReport, FP_Project, FP_ProjectApp, FP_ProjectDel, FP_ProjectMod, FA_ExceedBudgetLimit, U_SendReceiveCriteria, RI_CltSaleR_ShowSalesman, RI_SaleR_ShowSalesman, Inventory, Accounting, PayRoll, Utilities, FA_Journal, FA_JournalApp, FA_JournalDel, FA_JournalMod, FA_Payment, FA_PaymentApp, FA_PaymentDel, FA_PaymentMod, FA_Receipt, FA_ReceiptDel, FA_ReceiptMod, FA_ReceiptApp, FA_CreditNote, FA_CreditNoteApp, FA_CreditNoteDel, FA_CreditNoteMod, FA_DebitNote, FA_DebitNoteDel, FA_DebitNoteMod, FA_DebitNoteApp, FA_FixedAssets, FA_FixedAssetsDel, FA_FixedAssetsMod, FA_FixedAssetsApp, FA_Charging, FA_ChargingDel, FA_ChargingMod, FA_ChargingApp, FA_ReportOptions, FA_Ledger, FA_LedgerDel, FA_LedgerMod, FA_LedgerApp, CurrencyDel, CurrencyApp, CurrencyMod, CostcenterDel, CostcenterMod, CostcenterApp, ProjectDel, ProjectMod, ProjectApp, Clients, ClientsDel, ClientsApp, ClientsMod, ClientsCreditLimit, FA_Budget, FA_BudgetDel, FA_BudgetMod, FA_BudgetApp, FA_AccountType, FA_AccountTypeDel, FA_AccountTypeMod, FA_AccountTypeApp, FA_SalesJV, FA_SalesJVMod, FA_SalesJVApp, FA_SalesJVDel, RA_GeneralLedger, RA_TransactionJV, RA_ListofRecPayDebCred, RA_ListofCheckBills, RA_IncomeStatBalanceSheet, RA_FinancialSummary, RA_MonthDistBudgetForCast, RA_TrialBalance, RA_StatementofAccount, RA_Aging, RA_PrePayment, RA_Amortization, RA_StatmentofDocument, RA_StatmentofCostcenter, RA_CreditLimitRoster, RA_IncomeStmt, RA_Query, FI_PurchaseOrder, FI_PurchaseOrderDel, FI_PurchaseOrderApp, FI_PurchaseOrderMod, FI_Purchases, FI_PurchasesDel, FI_PurchasesMod, FI_PurchasesApp, FI_ReturnPurchase, FI_ReturnPurchaseDel, FI_ReturnPurchaseMod, FI_ReturnPurchaseApp, FI_Rma, FI_RmaDel, FI_RmaApp, FI_RmaMod, FI_ReturnRma, FI_ReturnRmaDel, FI_ReturnRmaApp, FI_ReturnRmaMod, FI_SalesOrder, FI_SalesOrderDel, FI_SalesOrderApp, FI_SalesOrderMod, FI_Sales, FI_SalesDel, FI_SalesApp, FI_SalesMod, FI_SalesPrintReceipt, FI_ReturnSales, FI_ReturnSalesApp, FI_ReturnSalesMod, FI_ReturnSalesDel, FI_ReturnSalesPrintPay, FI_Delivery, FI_DeliveryDel, FI_DeliveryMod, FI_DeliveryApp, FI_ReturnDelivery, FI_ReturnDeliveryDel, FI_ReturnDeliveryApp, FI_ReturnDeliveryMod, FI_Transfer, FI_TransferDel, FI_TransferApp, FI_TransferMod, FI_Production, FI_ProductionDel, FI_ProductionApp, FI_ProductionMod, FI_Adjustment, FI_AdjustmentDel, FI_AdjustmentApp, FI_AdjustmentMod, FI_ReportOptions, FI_Items, FI_ItemsDel, FI_ItemsApp, FI_ItemsMod, FI_Warehouse, FI_WarehouseDel, FI_WarehouseMod, FI_WarehouseApp, FI_Area, FI_AreaDel, FI_AreaMod, FI_AreaApp, FI_Category, FI_CategoryDel, FI_CategoryApp, FI_CategoryMod, FI_Grouping, FI_GroupingDel, FI_GroupingApp, FI_GroupingMod, FI_SubGrouping, FI_SubGroupingDel, FI_SubGroupingMod, FI_SubGroupingApp, FI_Suppliers, FI_SuppliersDel, FI_SuppliersMod, FI_SuppliersApp, FI_Salesmen, FI_SalesmenDel, FI_SalesmenApp, FI_SalesmenMod, RI_SatementofItems, RI_Inventory, RI_ProfitperItems, RI_SalesReports, RI_PurchaseReports, RI_ListTransaction, RI_Packing, RI_ListofProduction, RI_ExpiryDate, RI_Options, RI_Query, FP_Employee, FP_EmployeeDel, FP_EmployeeMod, FP_EmployeeApp, FP_Bonus, FP_BonusDel, FP_BonusMod, FP_BonusApp, FP_Vacation, FP_VacationDel, FP_VacationMod, FP_VacationApp, FP_Loan, FP_LoanDel, FP_LoanMod, FP_LoanApp, FP_AttendanceDel, FP_AttendanceMod, FP_AttendanceApp, FP_Generate, FP_GenerateApp, FP_GenerateDel, FP_GenerateMod, FP_ReportOptions, FP_Parameters, FP_ParametersDel, FP_ParametersApp, FP_ParametersMod, RP_Employee, RP_TimeSheet, RP_CollectionofRepPay, RP_Evaluation, RP_BankStatement, RP_Query, U_NewYear, U_DeleteYear, U_CloseYear, U_NewCompany, U_DeleteCompany, U_CloseCompany, U_PostToLedger, U_PostToItems, U_PostToChecksAndBills, U_TransferAccount, U_DistributingCostcenter, U_ReNumberJV, U_FillSetupFile, U_RebuildIndexAcc, U_RebuildIndexInv, U_RebuildIndexPay, U_BackupFile, U_MergerDataBase, U_Trace, U_Query, U_CashRegister, U_Ports, FI_SellingPriceInItems, FI_CostPriceInItems, CGI, Access_UserManager, U_RebuildIndexAccLab, LoginAccess_DirYear, LoginAccess_Company, Posted, RI_Invoices, RI_ItemsPerWarehouseSize, FI_SorderConfirmed, Synchro, FA_Banks, FA_BankApp, FA_BankDel, FA_BankMod, RA_AgingOfClientInvoices, RA_FinancialAccounts, FI_DeliveryConfirmed, FI_PorderConfirmed, Login_ShowLoggedUser, Login_modAdjIsInvoice, FI_PricePerUnit, FC_CashRegisterSearch, FC_CashRegScrollPrint, FC_CashRegisterCancel, FC_CashRegisterPosting, FC_CashRegScrollOk, FA_SkipReference, FI_PurchaseRequest, FI_PurchaseRequestApp, FI_PurchaseRequestMod, FI_PurchaseRequestDel, FI_RepostRequest, FI_IN, FI_OUT, FI_INDel, FI_OUTDel, FI_INMod, FI_OUTMod, FI_INapp, FI_Outapp, login_AllowTimer, FI_ModConfirmedPO, FI_DelConfirmedPO, FI_StkEval, FI_StkEvalMod, FI_StkEvalApp, Fi_StkEvalDel, PRqst_Approvedby,  FI_Transportation, FI_TransportationApp, FI_TransportationMod, FI_TransportationDel, Login_Decimal, Unmodify_SellingPrice, RI_StkMovement, RA_AvgDays, RA_SalesJV, RA_PurchasesJV, FI_SorderCanceledQty, ShowTransaction, FA_ClientPaymentTerms, FA_Transformation, FA_TransformationAPP, FA_TransformationMod, FA_TransformationDel, FA_ProdRatio, FA_ProdRatioAPP, FA_ProdRatioMod, FA_ProdRatioDEL, Login_negativeQty, FI_BudgetInvDel, FI_BudgetInvMod, FI_BudgetInvApp, FI_FBudgetInv, FI_BudgetInvSetupDel, FI_BudgetInvSetupMod, FI_BudgetInvSetupApp, FI_FBudgetInvSetup, FI_BudgetInvAmendmentDel, FI_BudgetInvAmendmentMod, FI_BudgetInvAmendmentApp, FI_FBudgetInvAmendment, FA_transactionpaymnetrqst, FA_transactionpaymnetrqstdel, FA_transactionpaymnetrqstapp, FA_transactionpaymnetrqstmod, FI_stockeval, FI_stockevalapp, FI_stockevaldel, FI_stockevalmod, FI_CEPtable, FI_CEPtableapp, FI_CEPtabledel, FI_CEPtablemod, EDataCom, U_costcentertransfer, U_projecttransfer, Unmodify_SorderPrice, FI_deliveryrelease, fpr_changeweight, login_disapprovesorder, FI_DeliveryReleaseMod, FI_DeliveryReleaseDel, FI_DeliveryReleaseApp, RA_TabSheetPaymentRqst, RA_TabSheetBudget, RA_unmovedAcounts, RA_TabSheetMonthlyAmount, RA_InterrestRate, RI_TranspPage, RI_TabSheetexport, RI_TabSheetrma, RI_BudgetInvTabSheet, FA_DailyReport, RI_tabsheetbooksbalance, RI_PurchaseCategory, RP_generate, RP_Costcenter, RP_TaxeDeclare, FC_CashRegisterAskPrint, FI_SorderPosQty, RI_Aging, fastprintarchive, fastprinttransaction, FI_PurchaseCategory, FI_DeliverySalesPrice, FI_SorderRejectUnconfirmed, Login_AllowPrice, FI_Grn, FI_GrnDel, FI_GrnMod, FI_GrnApp, FI_RepRestrictProject, FI_RepRestrictCostcenter, FI_RepRestrictWarehouse, Login_ModifyAllPending, Login_ModifyDiscount, FA_Contra, FA_ContraApp, FA_ContraMod, FA_ContraDel, FI_SellingPriceModifyInItems, FI_RmGrn, FI_RmGrnDel, FI_RmGrnMod, FI_RmGrnApp, FI_RmTransfer, FI_IRmTransferDel, FI_RmTransferMod, Fi_RmTransferapp, FI_ReturnGrn, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_ReturnGrnApp, ri_commissionbygroup, FI_RMASheetRMA, FI_RMASheetPending, FI_RMAReturnSheetReturnRMA, FI_RMAReturnSheetRMA, FI_SalebelowCost, FI_SaleBelowDiscount, FI_SaleDiscountPer, FI_SalesOrderModDelConfirmed, FI_ShipmentMod, FI_ShipmentDel, Login_ModifySellingPrice, FI_SorderAskConfirm, Default_Project, Default_Costcent, production, Login_FastPrint, FI_Shipment, FI_Shipmentconfirmed, RI_GrnReports, FI_SalebelowLandedCostWarning, FI_MessageCenter, FC_SearchByCashRegister, RA_AgingOfSupplierInvoices, RA_StatisticsReport, RI_InvComparisonReport, login_queries, login_queiresEdit, RI_TargetRebateReport, RI_SalesOrderReport, RI_YEARLYCOMPARATIVEREPORT, RA_YEARLYCOMPARATIVEREPORT, FC_DiscountPerLimit, FI_ProductionTemp, FI_ProductionTempApp, FI_ProductionTempDel, FI_ProductionTempMod, FI_Charges, FI_ChargesApp, FI_ChargesMod, FI_ChargesDel, RI_INVENTORY2, FI_ProductionReq, FI_ProductionReqApp, FI_ProductionReqDel, FI_ProductionReqMod, FP_EmployeeRequest, FI_AllowEditIfDelivered, Login_CancelSorder, Allow_MinimumPrice, FC_Restaurant, FC_OnlineWeb, FC_Hotel, FA_TOPVAT, FI_FrmRestrictWarehouse, Login_Daily, Login_Weekly, Login_Monthly, Login_Limit, AllowedPaymentDirect, Branch_Manager, FI_ChangeInvoiceClient, FI_ChangeInvoiceItems, FA_Amortization, Logistics, FL_Proforma, FL_ProformaSetup, FL_ProformaMod, FL_ProformaDel, FL_ProformaApp, FL_ProformaSetupMod, FL_ProformaSetupDel, FL_ProformaSetupApp, FA_InvoicesAllocation, FI_SalesmenCommission, FI_VehcileLoad, FI_RetrunSaleOrder, FI_ReturnPurchaseOrder, FI_PRETransfer, CRM, FI_PRequestConfirmed, FI_PurchaseRequestItems, FA_Invoicing, FI_TransferRequest, FI_AdjustmentRequest, FI_OUTREQUEST, FI_OutappRequest, Login_FastPrintRequest, FC_CashRegisterClosing, FC_ShowBtnCancel, Fi_VehicleWeightChange, FC_CashRegisterDelItem, approved_level, RI_SoldbySalesman, FI_CustomerF, FI_CustomerDel, FI_CustomerApp, FI_CustomerMod, fi_pendingpurchaserequest, fi_pendingtransferrequest, fi_pendingadjustmentrequest, FA_TransferFunds, login_maturitydate, AdjustmentRequestApproved_Level, PrequestApproved_Level, fi_pendingpurchaseorder, PorderApproved_Level, TransferRequestApproved_Level, fi_transferstockout, fi_purchasestockout, FI_ItemPricing, RI_TopClientsSuppliers, Fi_POS, Perc_CreditLimit, RA_Statistics, RI_Statistics, FA_INTERRESTRATE, FI_Statistics, FI_SorderAllowConfirmCash, FC_Tracking, FI_vehicle, FI_VehicleCharges, FI_Place, FI_VehicleMovement, FI_Employee, Fi_vehicleservice, Fi_vehiclefueltype, Fi_VehicleMovementReport, Fi_vehicletype, FU_DataTransfer, Login_Mobile, FM_Visits, RM_DailyVisits, FM_Mobiles, Login_TipsMaxAmount, PR_default, PO_default, TR_default, AD_default, PR_status1, PR_status2, PR_status3, PR_status4, PR_status5, PR_status6, PR_status7, PR_status8, PR_status9, PR_status10, PR_status11, TR_status1, TR_status2, TR_status3, AD_status1, AD_status2, AD_status3, PO_status1, PO_status2, PO_status3, PO_status4, PO_status5, FC_ShowAllTables, PR_status12, PO_status6, PO_status7, FI_PendingPaymentRequest, PaymentRqstApproved_Level, PYR_default, PYR_status1, PYR_status2, PYR_status3, Login_MinAllowCostPer, Login_MaxAllowCostPer, FC_CashRegisterMenu, FC_CashRegisterHold, FC_RetailStatistics, FC_SalesAnalysis, FI_ShowPriceHistory, FI_DeliveryStatus, FI_heatNo, FI_StockOutRequest, FC_RetailViewer, login_areqapprove, login_preqapprove, login_preqreject, login_prequndproc, login_pordapprove, login_pordreject, login_treqapprove, login_treqreject, login_areqreject, RI_Adjustment, DeliveryStatus_Type, FI_DeliveryStatusFrom, FI_DeliveryStatusTo, FI_SetDeliveryStatus, FI_ModInvStatusDlv, Login_Purchase_Pending, Login_location, PR_status13, Retail_Cancel, FI_itemTransfer, FC_PostingByCashRegister, RI_Procurement)

		select '".$user_name."', '".$user_code."', Login_Schema, '".$user_password2."', '".$full_name."', Description, Print, Access, Login_Delete, Login_Append, Costcenter, Project, Currency, Ledger, Budget, Keyboard_Layout, Language, DefaultComp, DefaultYear, FullAccess, USR_CompanyAccess, USR_UserManager, USR_AppPriv, USR_FormAccess, USR_ReportOption, RMA_In, RMA_Out, ModifyVAT, InvCreditLimit, Login_Edit, DisplayBoth, Discount, DiscountMsgWarning, Post, Promotion, ReturnQuantity, Login_CardNo, login_belongstogrp, ModifyBelongsToGrp, Bdgt_Reference, User_Signature, RetailInvoice, FC_CashRegister, FC_CashRegisterApp, FC_CashRegisterDel, FC_CashRegisterMod, FI_SalesVAT, FI_ReturnSalesVAT, FI_PurchasesVAT, FI_PurchasesVATMod, FI_ReturnPurchasesVAT, FA_SalesJvVAT, FA_PurchaseJV, FA_PurchaseJVMod, FA_PurchaseJVDel, FA_PurchaseJVApp, FA_PurchaseJVVAT, U_TransferItem, FI_SalesCheckSalesman, FI_RSalesCheckSalesman, FC_CashRegisterScroll, FC_CashRegisterCredit, FC_CashRegisterCheck, FC_CashRegisterCoupon, FC_CashRegisterCustomer, FC_CashRegisterCash, FC_CashRegisterDisc, FC_CashRegisterProm, FC_CashRegisterQtyRet, FI_Sizes, FI_SizesDel, FI_SizesMod, FI_SizesApp, RA_ListOfPurchaseJv, FA_PurchaseJVCharge, FA_PrefixJV, Closing_RetailReport, FI_Color, FI_ColorMod, FI_ColorDel, FI_ColorApp, FI_ItemSelling1, FI_ItemSelling2, FI_ItemSelling3, FI_ItemSelling4, FI_ItemSelling5, FI_SOrderWithPrice, FI_SalesWithPrice, FC_PermToCancelCash, FI_ClientSalesmanComm, FI_SalebelowLandedCost, FC_CashRegisterClient, RI_LISTOFDUEITEMS, RA_StatementofProject, RA_ProfitandLoss, RA_PurchasesandSalesJV, RI_ListofItems, RI_ListofRMA, RI_InvoiceProject, RI_SalesStatistics, RA_ListofDueInvoices, FI_ShowCostPrice, FA_BalanceJV, Reports, Rep_General, Rep_Inventory, Rep_Accounting, RA_SalesmanComm, FC_RetailReport, RA_RequiredCostcenter, FA_LedgerAccess, ExporttoExcel, FixJVofSales, ModifyingOldTransactions, DailyInvoiceModification, FI_DIFFCOMPANY, AskBeforeCloseInv, AskBeforeCloseAcc, ShowDepositJVBtn, Show_group, Fi_itemselling6, Fc_forcingvendor, Rc_cashFlow, RC_ListOfInvoices, RC_SalesmenCommission, RC_ItemsSizes, FC_ShowBtnOpenDrawer, FC_AddClient, RC_ForcingUserAccount, FA_FIPAddress, FA_IPAddressApp, FA_IPAddressDel, FA_IPAddressMod, FA_IPAddPermToExceedCL, RA_ListOfInvoices, FA_ManagingRequiredCost, U_RePostTransaction, FC_AddCustomer, FC_ConfirmCustomer, FA_PaymentRqst, FA_PaymentRqstApp, FA_PaymentRqstMod, FA_PaymentRqstDel, FA_Client, FA_ClientDel, FA_ClientApp, FA_ClientMod, FA_ClientCreditLimit, FA_Currency, FA_CurrencyDel, FA_CurrencyApp, FA_CurrencyMod, FA_Supplier, FA_SupplierDel, FA_SupplierApp, FA_SupplierMod, FA_Project, FA_ProjectDel, FA_ProjectMod, FA_ProjectApp, FA_CostCenter, FA_CostCenterDel, FA_CostCenterMod, FA_CostCenterApp, RA_AccountReconciliation, FA_SalesJVModRef, LockedPeriod, AllowLockedPeriod, FI_PreProduction, FI_PreProductionMod, FI_PreProductionApp, FI_PreProductionDel, FP_Insurance, FP_InsuranceMod, FP_InsuranceApp, FP_InsuranceDel, FI_WayBill, FI_WayBillDel, FI_WayBillApp, FI_WayBillMod, FP_DetailGenerateDel, RI_YearlySales, RI_TrackingRMA, RI_InvByEntryNo, RI_ListOfDeliveryQty, RI_OpInvForNewYear, DirectConsumption, RI_PorderReport, RI_ClientsSalesReport, ClientIP_Del, ClientIP_Mod, ClientIP_App, ClientIP_EndDate, ClientIP_LastTransDate, RI_YearlyPurchases, LockedPeriodDays, Rp_ReportR3, FI_SupplierGrp, FI_SupplierGrpApp, FI_SupplierGrpDel, FI_SupplierGrpMod, FI_ClientGrp, FI_ClientGrpApp, FI_ClientGrpDel, FI_ClientGrpMod, FA_ConfirmJV, FI_RVPostTransaction, FI_PVPostTransaction, FI_CVPostTransaction, FI_DVPostTransaction, FU_ClosingPeriod, FI_RepostPurchase, FI_RepostPReturn, FI_RepostSales, FI_RepostSReturn, FI_RepostDeliveries, FI_RepostDReturn, FI_RepostPorder, FI_RepostSorder, FI_RepostAdjustment, FP_ShowSalaryMvt, RI_listofPICharges, FP_ArabicReports, FP_EmpArabicInfo, FI_ITransfer, FI_ITransferApp, FI_ITransferMod, FI_ITransferDel, FI_PorderPurRequest, FI_SupplierGrpPurRequest, FP_Grades, FP_GradesApp, FP_GradesDel, FP_GradesMod, FP_Dept, FP_DeptApp, FP_DeptDel, FP_DeptMod, FP_Fpreemp, FP_preempApp, FP_preempDel, FP_preempMod, FP_Attendance, FP_Overtime, FP_AnalysisReport, FP_Project, FP_ProjectApp, FP_ProjectDel, FP_ProjectMod, FA_ExceedBudgetLimit, U_SendReceiveCriteria, RI_CltSaleR_ShowSalesman, RI_SaleR_ShowSalesman, Inventory, Accounting, PayRoll, Utilities, FA_Journal, FA_JournalApp, FA_JournalDel, FA_JournalMod, FA_Payment, FA_PaymentApp, FA_PaymentDel, FA_PaymentMod, FA_Receipt, FA_ReceiptDel, FA_ReceiptMod, FA_ReceiptApp, FA_CreditNote, FA_CreditNoteApp, FA_CreditNoteDel, FA_CreditNoteMod, FA_DebitNote, FA_DebitNoteDel, FA_DebitNoteMod, FA_DebitNoteApp, FA_FixedAssets, FA_FixedAssetsDel, FA_FixedAssetsMod, FA_FixedAssetsApp, FA_Charging, FA_ChargingDel, FA_ChargingMod, FA_ChargingApp, FA_ReportOptions, FA_Ledger, FA_LedgerDel, FA_LedgerMod, FA_LedgerApp, CurrencyDel, CurrencyApp, CurrencyMod, CostcenterDel, CostcenterMod, CostcenterApp, ProjectDel, ProjectMod, ProjectApp, Clients, ClientsDel, ClientsApp, ClientsMod, ClientsCreditLimit, FA_Budget, FA_BudgetDel, FA_BudgetMod, FA_BudgetApp, FA_AccountType, FA_AccountTypeDel, FA_AccountTypeMod, FA_AccountTypeApp, FA_SalesJV, FA_SalesJVMod, FA_SalesJVApp, FA_SalesJVDel, RA_GeneralLedger, RA_TransactionJV, RA_ListofRecPayDebCred, RA_ListofCheckBills, RA_IncomeStatBalanceSheet, RA_FinancialSummary, RA_MonthDistBudgetForCast, RA_TrialBalance, RA_StatementofAccount, RA_Aging, RA_PrePayment, RA_Amortization, RA_StatmentofDocument, RA_StatmentofCostcenter, RA_CreditLimitRoster, RA_IncomeStmt, RA_Query, FI_PurchaseOrder, FI_PurchaseOrderDel, FI_PurchaseOrderApp, FI_PurchaseOrderMod, FI_Purchases, FI_PurchasesDel, FI_PurchasesMod, FI_PurchasesApp, FI_ReturnPurchase, FI_ReturnPurchaseDel, FI_ReturnPurchaseMod, FI_ReturnPurchaseApp, FI_Rma, FI_RmaDel, FI_RmaApp, FI_RmaMod, FI_ReturnRma, FI_ReturnRmaDel, FI_ReturnRmaApp, FI_ReturnRmaMod, FI_SalesOrder, FI_SalesOrderDel, FI_SalesOrderApp, FI_SalesOrderMod, FI_Sales, FI_SalesDel, FI_SalesApp, FI_SalesMod, FI_SalesPrintReceipt, FI_ReturnSales, FI_ReturnSalesApp, FI_ReturnSalesMod, FI_ReturnSalesDel, FI_ReturnSalesPrintPay, FI_Delivery, FI_DeliveryDel, FI_DeliveryMod, FI_DeliveryApp, FI_ReturnDelivery, FI_ReturnDeliveryDel, FI_ReturnDeliveryApp, FI_ReturnDeliveryMod, FI_Transfer, FI_TransferDel, FI_TransferApp, FI_TransferMod, FI_Production, FI_ProductionDel, FI_ProductionApp, FI_ProductionMod, FI_Adjustment, FI_AdjustmentDel, FI_AdjustmentApp, FI_AdjustmentMod, FI_ReportOptions, FI_Items, FI_ItemsDel, FI_ItemsApp, FI_ItemsMod, FI_Warehouse, FI_WarehouseDel, FI_WarehouseMod, FI_WarehouseApp, FI_Area, FI_AreaDel, FI_AreaMod, FI_AreaApp, FI_Category, FI_CategoryDel, FI_CategoryApp, FI_CategoryMod, FI_Grouping, FI_GroupingDel, FI_GroupingApp, FI_GroupingMod, FI_SubGrouping, FI_SubGroupingDel, FI_SubGroupingMod, FI_SubGroupingApp, FI_Suppliers, FI_SuppliersDel, FI_SuppliersMod, FI_SuppliersApp, FI_Salesmen, FI_SalesmenDel, FI_SalesmenApp, FI_SalesmenMod, RI_SatementofItems, RI_Inventory, RI_ProfitperItems, RI_SalesReports, RI_PurchaseReports, RI_ListTransaction, RI_Packing, RI_ListofProduction, RI_ExpiryDate, RI_Options, RI_Query, FP_Employee, FP_EmployeeDel, FP_EmployeeMod, FP_EmployeeApp, FP_Bonus, FP_BonusDel, FP_BonusMod, FP_BonusApp, FP_Vacation, FP_VacationDel, FP_VacationMod, FP_VacationApp, FP_Loan, FP_LoanDel, FP_LoanMod, FP_LoanApp, FP_AttendanceDel, FP_AttendanceMod, FP_AttendanceApp, FP_Generate, FP_GenerateApp, FP_GenerateDel, FP_GenerateMod, FP_ReportOptions, FP_Parameters, FP_ParametersDel, FP_ParametersApp, FP_ParametersMod, RP_Employee, RP_TimeSheet, RP_CollectionofRepPay, RP_Evaluation, RP_BankStatement, RP_Query, U_NewYear, U_DeleteYear, U_CloseYear, U_NewCompany, U_DeleteCompany, U_CloseCompany, U_PostToLedger, U_PostToItems, U_PostToChecksAndBills, U_TransferAccount, U_DistributingCostcenter, U_ReNumberJV, U_FillSetupFile, U_RebuildIndexAcc, U_RebuildIndexInv, U_RebuildIndexPay, U_BackupFile, U_MergerDataBase, U_Trace, U_Query, U_CashRegister, U_Ports, FI_SellingPriceInItems, FI_CostPriceInItems, CGI, Access_UserManager, U_RebuildIndexAccLab, LoginAccess_DirYear, LoginAccess_Company, Posted, RI_Invoices, RI_ItemsPerWarehouseSize, FI_SorderConfirmed, Synchro, FA_Banks, FA_BankApp, FA_BankDel, FA_BankMod, RA_AgingOfClientInvoices, RA_FinancialAccounts, FI_DeliveryConfirmed, FI_PorderConfirmed, Login_ShowLoggedUser, Login_modAdjIsInvoice, FI_PricePerUnit, FC_CashRegisterSearch, FC_CashRegScrollPrint, FC_CashRegisterCancel, FC_CashRegisterPosting, FC_CashRegScrollOk, FA_SkipReference, FI_PurchaseRequest, FI_PurchaseRequestApp, FI_PurchaseRequestMod, FI_PurchaseRequestDel, FI_RepostRequest, FI_IN, FI_OUT, FI_INDel, FI_OUTDel, FI_INMod, FI_OUTMod, FI_INapp, FI_Outapp, login_AllowTimer, FI_ModConfirmedPO, FI_DelConfirmedPO, FI_StkEval, FI_StkEvalMod, FI_StkEvalApp, Fi_StkEvalDel, PRqst_Approvedby,  FI_Transportation, FI_TransportationApp, FI_TransportationMod, FI_TransportationDel, Login_Decimal, Unmodify_SellingPrice, RI_StkMovement, RA_AvgDays, RA_SalesJV, RA_PurchasesJV, FI_SorderCanceledQty, ShowTransaction, FA_ClientPaymentTerms, FA_Transformation, FA_TransformationAPP, FA_TransformationMod, FA_TransformationDel, FA_ProdRatio, FA_ProdRatioAPP, FA_ProdRatioMod, FA_ProdRatioDEL, Login_negativeQty, FI_BudgetInvDel, FI_BudgetInvMod, FI_BudgetInvApp, FI_FBudgetInv, FI_BudgetInvSetupDel, FI_BudgetInvSetupMod, FI_BudgetInvSetupApp, FI_FBudgetInvSetup, FI_BudgetInvAmendmentDel, FI_BudgetInvAmendmentMod, FI_BudgetInvAmendmentApp, FI_FBudgetInvAmendment, FA_transactionpaymnetrqst, FA_transactionpaymnetrqstdel, FA_transactionpaymnetrqstapp, FA_transactionpaymnetrqstmod, FI_stockeval, FI_stockevalapp, FI_stockevaldel, FI_stockevalmod, FI_CEPtable, FI_CEPtableapp, FI_CEPtabledel, FI_CEPtablemod, EDataCom, U_costcentertransfer, U_projecttransfer, Unmodify_SorderPrice, FI_deliveryrelease, fpr_changeweight, login_disapprovesorder, FI_DeliveryReleaseMod, FI_DeliveryReleaseDel, FI_DeliveryReleaseApp, RA_TabSheetPaymentRqst, RA_TabSheetBudget, RA_unmovedAcounts, RA_TabSheetMonthlyAmount, RA_InterrestRate, RI_TranspPage, RI_TabSheetexport, RI_TabSheetrma, RI_BudgetInvTabSheet, FA_DailyReport, RI_tabsheetbooksbalance, RI_PurchaseCategory, RP_generate, RP_Costcenter, RP_TaxeDeclare, FC_CashRegisterAskPrint, FI_SorderPosQty, RI_Aging, fastprintarchive, fastprinttransaction, FI_PurchaseCategory, FI_DeliverySalesPrice, FI_SorderRejectUnconfirmed, Login_AllowPrice, FI_Grn, FI_GrnDel, FI_GrnMod, FI_GrnApp, FI_RepRestrictProject, FI_RepRestrictCostcenter, FI_RepRestrictWarehouse, Login_ModifyAllPending, Login_ModifyDiscount, FA_Contra, FA_ContraApp, FA_ContraMod, FA_ContraDel, FI_SellingPriceModifyInItems, FI_RmGrn, FI_RmGrnDel, FI_RmGrnMod, FI_RmGrnApp, FI_RmTransfer, FI_IRmTransferDel, FI_RmTransferMod, Fi_RmTransferapp, FI_ReturnGrn, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_ReturnGrnApp, ri_commissionbygroup, FI_RMASheetRMA, FI_RMASheetPending, FI_RMAReturnSheetReturnRMA, FI_RMAReturnSheetRMA, FI_SalebelowCost, FI_SaleBelowDiscount, FI_SaleDiscountPer, FI_SalesOrderModDelConfirmed, FI_ShipmentMod, FI_ShipmentDel, Login_ModifySellingPrice, FI_SorderAskConfirm, Default_Project, Default_Costcent, production, Login_FastPrint, FI_Shipment, FI_Shipmentconfirmed, RI_GrnReports, FI_SalebelowLandedCostWarning, FI_MessageCenter, FC_SearchByCashRegister, RA_AgingOfSupplierInvoices, RA_StatisticsReport, RI_InvComparisonReport, login_queries, login_queiresEdit, RI_TargetRebateReport, RI_SalesOrderReport, RI_YEARLYCOMPARATIVEREPORT, RA_YEARLYCOMPARATIVEREPORT, FC_DiscountPerLimit, FI_ProductionTemp, FI_ProductionTempApp, FI_ProductionTempDel, FI_ProductionTempMod, FI_Charges, FI_ChargesApp, FI_ChargesMod, FI_ChargesDel, RI_INVENTORY2, FI_ProductionReq, FI_ProductionReqApp, FI_ProductionReqDel, FI_ProductionReqMod, FP_EmployeeRequest, FI_AllowEditIfDelivered, Login_CancelSorder, Allow_MinimumPrice, FC_Restaurant, FC_OnlineWeb, FC_Hotel, FA_TOPVAT, FI_FrmRestrictWarehouse, Login_Daily, Login_Weekly, Login_Monthly, Login_Limit, AllowedPaymentDirect, Branch_Manager, FI_ChangeInvoiceClient, FI_ChangeInvoiceItems, FA_Amortization, Logistics, FL_Proforma, FL_ProformaSetup, FL_ProformaMod, FL_ProformaDel, FL_ProformaApp, FL_ProformaSetupMod, FL_ProformaSetupDel, FL_ProformaSetupApp, FA_InvoicesAllocation, FI_SalesmenCommission, FI_VehcileLoad, FI_RetrunSaleOrder, FI_ReturnPurchaseOrder, FI_PRETransfer, CRM, FI_PRequestConfirmed, FI_PurchaseRequestItems, FA_Invoicing, FI_TransferRequest, FI_AdjustmentRequest, FI_OUTREQUEST, FI_OutappRequest, Login_FastPrintRequest, FC_CashRegisterClosing, FC_ShowBtnCancel, Fi_VehicleWeightChange, FC_CashRegisterDelItem, approved_level, RI_SoldbySalesman, FI_CustomerF, FI_CustomerDel, FI_CustomerApp, FI_CustomerMod, fi_pendingpurchaserequest, fi_pendingtransferrequest, fi_pendingadjustmentrequest, FA_TransferFunds, login_maturitydate, AdjustmentRequestApproved_Level, PrequestApproved_Level, fi_pendingpurchaseorder, PorderApproved_Level, TransferRequestApproved_Level, fi_transferstockout, fi_purchasestockout, FI_ItemPricing, RI_TopClientsSuppliers, Fi_POS, Perc_CreditLimit, RA_Statistics, RI_Statistics, FA_INTERRESTRATE, FI_Statistics, FI_SorderAllowConfirmCash, FC_Tracking, FI_vehicle, FI_VehicleCharges, FI_Place, FI_VehicleMovement, FI_Employee, Fi_vehicleservice, Fi_vehiclefueltype, Fi_VehicleMovementReport, Fi_vehicletype, FU_DataTransfer, Login_Mobile, FM_Visits, RM_DailyVisits, FM_Mobiles, Login_TipsMaxAmount, PR_default, PO_default, TR_default, AD_default, PR_status1, PR_status2, PR_status3, PR_status4, PR_status5, PR_status6, PR_status7, PR_status8, PR_status9, PR_status10, PR_status11, TR_status1, TR_status2, TR_status3, AD_status1, AD_status2, AD_status3, PO_status1, PO_status2, PO_status3, PO_status4, PO_status5, FC_ShowAllTables, PR_status12, PO_status6, PO_status7, FI_PendingPaymentRequest, PaymentRqstApproved_Level, PYR_default, PYR_status1, PYR_status2, PYR_status3, Login_MinAllowCostPer, Login_MaxAllowCostPer, FC_CashRegisterMenu, FC_CashRegisterHold, FC_RetailStatistics, FC_SalesAnalysis, FI_ShowPriceHistory, FI_DeliveryStatus, FI_heatNo, FI_StockOutRequest, FC_RetailViewer, login_areqapprove, login_preqapprove, login_preqreject, login_prequndproc, login_pordapprove, login_pordreject, login_treqapprove, login_treqreject, login_areqreject, RI_Adjustment, DeliveryStatus_Type, FI_DeliveryStatusFrom, FI_DeliveryStatusTo, FI_SetDeliveryStatus, FI_ModInvStatusDlv, Login_Purchase_Pending, Login_location, PR_status13, Retail_Cancel, FI_itemTransfer, FC_PostingByCashRegister, RI_Procurement from login where User_account = '".$UserList."'";
		if($txtUserSchema != "")
		{
			$query_login = $query_login." and Login_Schema = '".$txtUserSchema."'";
		}
		//echo $query_login; exit;
		$result_login = mysql_query($query_login, $connection);
		
		$query_dir = "insert into listuserdir select '".$user_code."', '".$user_name."', CompanyName, Diryear, AllowLockedPeriod, LockedPeriod, LockedPeriodDays, LockViewPeriod, ViewPeriodDate, ViewLockDaily, ViewNumberOfDays from listuserdir where Usercode = '".$UserList."'";
	    if($txtUserSchema != "")
		{
			$query_dir = $query_dir." and concat(CompanyName, '_', Diryear) = '".$txtUserSchema."'";
		}
		//echo $query_dir; exit;
		$result_dir = mysql_query($query_dir, $connection);
	}
	//echo $query;exit;
	}
	



else if($mode=='edit'){
	if($deliverystatus_level=='') $deliverystatus_level=0;
	
	$uppercase = preg_match('@[A-Z]@', $user_password2);
$lowercase = preg_match('@[a-z]@', $user_password2);
$number    = preg_match('@[0-9]@', $user_password2);
$special = preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/', $user_password);

if($user_complex_password == 1){
if($uppercase && $lowercase && $number && $special &&  strlen($user_password2) >= 8) {
	
	$query_check = "select * from users where User_accout = '".$user_code."'";
	$result_check = mysql_query($query_check, $connection);
	$row_check = mysql_fetch_assoc($result_check);
	$query="update users set User_account='".$user_code."',
							User_name='".$user_name."',
							FullName='".$full_name."',
							Description='".$user_description."',
							User_IsGroup='".$user_isgroup."',
							deliverystatus_level='".$deliverystatus_level."',
							User_Group='".$user_group."',
							DefaultComp='".$default_company."',
							DefaultYear='".$default_year."',
							user_deactivate='".$user_deactivate."', 
							user_expiry='".$user_expiry."',
							user_first_login='".$user_first_login."',";
							if($user_engineer != "")
								$query .= "user_engineer='".$user_engineer."',";
							$query .= "User_Password =";
		
	if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."') ";
	else
		$query=$query."'".$user_password2."' ";	

    if($user_deactivate == 1)
    {
	    $query = $query.", user_deactivate_date = now()";
    }	
	else
	{
	    $query = $query.", user_deactivate_date = '0000-00-00'";
	}
	
	if($row_check['User_Password'] != $user_password2)
	{
	   $query = $query.", user_expirydate = DATE_ADD(now(),INTERVAL 180 DAY)";
	}
	$query = $query." , user_complex_password = '".$user_complex_password."'";
	if($user_code == $user_password2){
	   $query = $query.", user_first_login = '1'"; 
	}
	else
	{
	    $query = $query.", user_first_login = '0'"; 
	}
	$query = $query.", user_engineerqc = '$user_engineerqc'"; 
	$query=$query."  where user_account='".$user_codePrv."'";
    
	//echo $query; exit;
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	
	if ($FI_DeliveryStatusFrom == '') $FI_DeliveryStatusFrom=1;
	if ($FI_DeliveryStatusTo == '') $FI_DeliveryStatusTo=4;
	if($FI_SetDeliveryStatus == '') $FI_SetDeliveryStatus=0;
	if($FI_DeliveryStatus == '') $FI_DeliveryStatus=0;
	if($Login_Purchase_Pending == '') $Login_Purchase_Pending=0;
	if($Login_location == '') $Login_location=0;
	$q = "update login set FI_DeliveryStatus=$FI_DeliveryStatus, FI_SetDeliveryStatus = $FI_SetDeliveryStatus, FI_DeliveryStatusFrom=$FI_DeliveryStatusFrom, 
		  FI_DeliveryStatusTo=$FI_DeliveryStatusTo, Login_Purchase_Pending=$Login_Purchase_Pending, Login_location=$Login_location, is_superUser = $isSuperUser,
		  language = '$login_language' where User_account = '$user_codePrv'"; 
	$res = mysql_query($q, $connection);
	$rw = mysql_fetch_row($res);
	$message= $message." ".mysql_error();
	}
	else
	{
	   $message= "Password should contain at least 8 characters having at least one alphabetical, one numerical value, one special character, one lower case letter, and one upper case letter.";
	}
	}
	else
	{
	$query_check = "select * from users where User_account = '".$user_code."'"; 
	$result_check = mysql_query($query_check, $connection);
	$row_check = mysql_fetch_assoc($result_check);
	$query="update users set User_account='".$user_code."',
							User_name='".$user_name."',
							FullName='".$full_name."',
							Description='".$user_description."',
							User_IsGroup='".$user_isgroup."',
							deliverystatus_level='".$deliverystatus_level."',
							User_Group='".$user_group."',
							DefaultComp='".$default_company."',
							DefaultYear='".$default_year."',
							user_deactivate='".$user_deactivate."',
                            user_expiry='".$user_expiry."',		
                            user_first_login='".$user_first_login."',";
                            if($user_engineer != "")
								$query .= "user_engineer='".$user_engineer."',";
							$query .= "User_Password =";
		
	if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."') ";
	else
		$query=$query."'".$user_password2."' ";	

    if($user_deactivate == 1)
    {
	    $query = $query.", user_deactivate_date = now()";
    }	
	else
	{
	    $query = $query.", user_deactivate_date = '0000-00-00'";
	}
	
	if($row_check['User_Password'] != $user_password2)
	{
	   $query = $query.", user_expirydate = DATE_ADD(now(),INTERVAL 180 DAY)";
	}
	$query = $query." , user_complex_password = '".$user_complex_password."'";
	if($user_code == $user_password2){
	   $query = $query.", user_first_login = '1'"; 
	}
	else
	{
	    $query = $query.", user_first_login = '0'"; 
	}
	$query = $query.", user_engineerqc = '$user_engineerqc'"; 
	$query=$query."  where user_account='".$user_codePrv."'";
    
	
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	
	if ($FI_DeliveryStatusFrom == '') $FI_DeliveryStatusFrom=1;
	if ($FI_DeliveryStatusTo == '') $FI_DeliveryStatusTo=4;
	if($FI_SetDeliveryStatus == '') $FI_SetDeliveryStatus=0;
	if($FI_DeliveryStatus == '') $FI_DeliveryStatus=0;
	if($Login_Purchase_Pending == '') $Login_Purchase_Pending=0;
	if($Login_location == '') $Login_location=0;
	$q = "update login set FI_DeliveryStatus=$FI_DeliveryStatus, FI_SetDeliveryStatus = $FI_SetDeliveryStatus, FI_DeliveryStatusFrom=$FI_DeliveryStatusFrom, 
		  FI_DeliveryStatusTo=$FI_DeliveryStatusTo, Login_Purchase_Pending=$Login_Purchase_Pending, Login_location=$Login_location, is_superUser = $isSuperUser,
		  language = '$login_language', RI_Transfer = '$RI_Transfer' where User_account = '$user_codePrv'"; //echo $q;exit;
	$res = mysql_query($q, $connection);
	$rw = mysql_fetch_row($res);
	$message= $message." ".mysql_error();
	}
//	echo $q;exit;
	}


else if($mode=='deleteuser'){

	$deleteuser = "delete from users where User_account='".$usercode."'";
	//echo $deleteuser;exit;
	$result=mysql_query($deleteuser,$connection);
	$errornum= mysql_errno();
		
	if($errornum=='1451') {
		$message="Delete Not Allowed . User is used .";
	}
	if($result){
		$query="Delete from login where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from listuserdir where Usercode='".$usercode."'";
		$result=mysql_query($query,$connection);

		$query="Delete from loginstk where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);

		$query="Delete from ledgerstk where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from ledgerrepstk where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from costcentstk where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from projectstk where user_account='".$usercode."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
	}
}

if($actionmode=='AddSchema'){
	fbegin();
	
	if($fullaccess=='1' || $fullaccess==''){
	$query="insert into listuserdir(Usercode,Username,CompanyName,Diryear) 
	select '".$user_code."','".$user_name."',CompanyName,Diryear from directories where concat(CompanyName,'_',Diryear)='".$txtSchema."'";
	// echo $query;exit;
	$result=mysql_query($query,$connection);
	$message= mysql_error();



	}else{

		$query="insert into listuserdir
		select
		'".$user_code."','".$user_name."', CompanyName, Diryear, AllowLockedPeriod, LockedPeriod, LockedPeriodDays, 
		LockViewPeriod, ViewPeriodDate, ViewLockDaily, ViewNumberOfDays, FU_ProjectManagement, FU_DocumentTypes, 
		FC_ChangeRetailDate, FI_DeliveryWaybill, FI_VehicleMovementv2, FI_VehicleMovementReportv2, FC_viewAllZReport,
		FI_Recipes, FI_OUT2, FI_IN2, FI_Out2app, FI_IN2app, FI_OUT2Del, FI_IN2Del, FI_OUT2Mod, FI_IN2Mod, 
		FI_SellingPriceAdjust, FU_ProjectTemplateForm, FI_confirmPurchase, FI_confirmReturnPurchase, 
		FU_ListOfProjects, FI_PurAdminMod, FI_PurAdminDel, FI_EditPorderSearch, FI_ProductDescription, 
		RI_YearlyPurchases, RI_YearlyPurchasesOrder, FI_ShowPriceBase1, FI_BPPlan, FI_SellingPricePromo,
		FI_EditProductionSearch, FI_EditGRNSearch, FI_SuperUser_AdjustPorder, FI_itemLocApp, FI_itemLocMod, 
		FI_itemLocDel, FC_CashRegisterEditOnPrint, FC_CashRegisterTools, FI_bulkitemminmaxAdjust, FA_JobVisit, 
		FA_JobVisitApp, FA_JobVisitMod, FA_JobVisitDel, FA_JobVisitreport, FI_Repairsheet, FI_RepairsheetAPP, 
		FI_RepairsheetMOD, FI_RepairsheetDEL, FI_WorkOrderDel, FI_WorkOrderMod, FI_WorkOrderApp, FI_WorkOrder, 
		FI_WorkOrderReqDel, FI_WorkOrderReqMod, FI_WorkOrderReqApp, FI_WorkOrderReq, FI_CheckList, FI_Slippass, 
		FC_CashRegisterModitem, FI_StockTake, FI_StockTake_Mod, FI_StockTake_Del, FI_StockTake_App, 
		FA_ChangeBelongToGroup, FU_Setup
		from listuserdir
		where usercode='".$like_user."' and upper(concat(CompanyName,'_',Diryear))='".$txtSchema."' 
		";
	
		$result=mysql_query($query,$connection);
		// echo $query;exit;
	
		$message= mysql_error();

	
		
	}
	// echo $query;exit;
	
	if($result && $fullaccess=='1'){
		$query="insert into login(User_account,User_name,Login_Schema,Fullname,Description,User_password,
		FA_AccountType,FA_AccountTypeApp,FA_AccountTypeMod,FA_AccountTypeDel,".
		" FA_FixedAssets,FA_FixedAssetsApp,FA_FixedAssetsMod,FA_FixedAssetsDel,".
		" FI_Area,FI_AreaApp,FI_AreaMod,FI_AreaDel,".
		" FA_Banks,FA_BankApp,FA_BankMod,FA_BankDel,".
		" FA_Budget,FA_BudgetApp,FA_BudgetMod,FA_BudgetDel,".
		" FA_Charging,FA_ChargingApp,FA_ChargingMod,FA_ChargingDel,".
		" FA_Contra,FA_ContraApp,FA_ContraMod,FA_ContraDel,".
		" FA_Costcenter,FA_CostcenterApp,FA_CostcenterMod,FA_CostcenterDel,".
		" FA_CreditNote,FA_CreditNoteApp,FA_CreditNoteMod,FA_CreditNoteDel,".
		" FA_Currency,FA_CurrencyApp,FA_CurrencyMod,FA_CurrencyDel,".
		" FA_DebitNote,FA_DebitNoteApp,FA_DebitNoteMod,FA_DebitNoteDel,".
		" RA_FinancialAccounts,".
		" FA_Journal,FA_JournalApp,FA_JournalMod,FA_JournalDel,".
		" FA_InvoicesAllocation,".
		" FA_Ledger,FA_LedgerApp,FA_LedgerMod,FA_LedgerDel,".
		" FA_Payment,FA_PaymentApp,FA_PaymentMod,FA_PaymentDel,".
		" FA_PaymentRqst,FA_PaymentRqstApp,FA_PaymentRqstMod,FA_PaymentRqstDel,".
		" FA_Project,FA_ProjectApp,FA_ProjectMod,FA_ProjectDel,".
		" FA_PurchaseJV,FA_PurchaseJVApp,FA_PurchaseJVMod,FA_PurchaseJVDel,".
		" FA_Receipt,FA_ReceiptApp,FA_ReceiptMod,FA_ReceiptDel,".
		" FA_ReportOptions,".
		" FA_SalesJV,FA_SalesJVApp,FA_SalesJVMod,FA_SalesJVDel,".
		" FA_transactionpaymnetrqst,FA_transactionpaymnetrqstApp,FA_transactionpaymnetrqstMod,FA_transactionpaymnetrqstDel,".
		" FI_Adjustment,FI_AdjustmentApp,FI_AdjustmentMod,FI_AdjustmentDel,".
		" FI_FBudgetInv,FI_BudgetInvApp,FI_BudgetInvMod,FI_BudgetInvDel,".
		" FI_FBudgetInvAmendment,FI_BudgetInvAmendmentApp,FI_BudgetInvAmendmentMod,FI_BudgetInvAmendmentDel,".
		" FI_FBudgetInvSetup,FI_BudgetInvSetupApp,FI_BudgetInvSetupMod,FI_BudgetInvSetupDel,".
		" FI_Category,FI_CategoryApp,FI_CategoryMod,FI_CategoryDel,".
		" FI_CEPtable,FI_CEPtableApp,FI_CEPtableMod,FI_CEPtableDel,".
		" FI_Charges,FI_ChargesApp,FI_ChargesMod,FI_ChargesDel,".
		" Clients,ClientsApp,ClientsMod,ClientsDel,".
		" FI_ClientGrp,FI_ClientGrpApp,FI_ClientGrpMod,FI_ClientGrpDel,".
		" FI_Delivery,FI_DeliveryApp,FI_DeliveryMod,FI_DeliveryDel,".
		" FI_Grouping,FI_GroupingApp,FI_GroupingMod,FI_GroupingDel,".
		" FI_Items,FI_ItemsApp,FI_ItemsMod,FI_ItemsDel ,".
		" FI_Production,FI_ProductionApp,FI_ProductionMod,FI_ProductionDel,".
		" FI_ProductionReq,FI_ProductionReqApp,FI_ProductionReqMod,FI_ProductionReqDel,".
		" FI_ProductionTemp,FI_ProductionTempApp,FI_ProductionTempMod,FI_ProductionTempDel,".
		" FI_Purchases,FI_PurchasesApp,FI_PurchasesMod,FI_PurchasesDel,".
		" FI_ReportOptions,".
		" FI_PurchaseOrder,FI_PurchaseOrderApp,FI_PurchaseOrderMod,FI_PurchaseOrderDel,".
		" FI_PurchaseRequest,FI_PurchaseRequestApp,FI_PurchaseRequestMod,FI_PRequestConfirmed,FI_PurchaseRequestDel,".
		" FI_ReturnDelivery,FI_ReturnDeliveryApp,FI_ReturnDeliveryMod,FI_ReturnDeliveryDel,".
		" FI_ReturnPurchase,FI_ReturnPurchaseApp,FI_ReturnPurchaseMod,FI_ReturnPurchaseDel,".
		" FI_ReturnRma,FI_ReturnRmaApp,FI_ReturnRmaMod,FI_ReturnRmaDel,".
		" FI_ReturnSales,FI_ReturnSalesApp,FI_ReturnSalesMod,FI_ReturnSalesDel,".
		" FI_RmTransfer,FI_RmTransferApp,FI_RmTransferMod,FI_IRmTransferDel,".
		" FI_Rma,FI_RmaApp,FI_RmaMod,FI_RmaDel,".
		" FI_Sales,FI_SalesApp,FI_SalesMod,FI_SalesDel,".
		" FI_SalesOrder,FI_SalesOrderApp,FI_SalesOrderMod,FI_SalesOrderDel,".
		" FI_Salesmen,FI_SalesmenApp,FI_SalesmenMod,FI_SalesmenDel,".
		" FI_Shipment,FI_ShipmentMod,FI_ShipmentDel,".
		" FI_stockeval,FI_stockevalApp,FI_stockevalMod,FI_stockevalDel,".
		" FI_SubGrouping,FI_SubGroupingApp,FI_SubGroupingMod,FI_SubGroupingDel,".
		" FI_Suppliers,FI_SuppliersApp,FI_SuppliersMod,FI_SuppliersDel,".
		" FI_SupplierGrp,FI_SupplierGrpApp,FI_SupplierGrpMod,FI_SupplierGrpDel,".
		" FI_Transfer,FI_TransferApp,FI_TransferMod,FI_TransferDel,".
		" FI_ITransfer,FI_ITransferApp,FI_ITransferMod,FI_ITransferDel,".
		" FI_Transportation,FI_TransportationApp,FI_TransportationMod,FI_TransportationDel,".
		" FI_Warehouse,FI_WarehouseApp,FI_WarehouseMod,FI_WarehouseDel,".
		" FI_WayBill,FI_WayBillApp,FI_WayBillMod,FI_WayBillDel,".
		" FP_Attendance,FP_AttendanceApp,FP_AttendanceMod,FP_AttendanceDel,".
		" FP_Bonus,FP_BonusApp,FP_BonusMod,FP_BonusDel,".
		" FP_Dept,FP_DeptApp,FP_DeptMod,FP_DeptDel,".
		" FP_Employee,FP_EmployeeApp,FP_EmployeeMod,FP_EmployeeDel,".
		" FP_Generate,FP_GenerateApp,FP_GenerateMod,FP_GenerateDel,".
		" FP_Grades,FP_GradesApp,FP_GradesMod,FP_GradesDel,".
		" FP_Insurance,FP_InsuranceApp,FP_InsuranceMod,FP_InsuranceDel,".
		" FP_Loan,FP_LoanApp,FP_LoanMod,FP_LoanDel,".
		" FP_Parameters,FP_ParametersApp,FP_ParametersMod,FP_ParametersDel,".
		" FP_Fpreemp,FP_preempApp,FP_preempMod,FP_preempDel,".
		" FP_Project,FP_ProjectApp,FP_ProjectMod,FP_ProjectDel,".
		" FP_ReportOptions,".
		" FP_Vacation,FP_VacationApp,FP_VacationMod,FP_VacationDel,".
		" Access_UserManager, ".
		" RA_StatementofAccount,".
		" RA_Trialbalance,".
		" RA_StatementofProject,".
		" RA_StatmentofCostcenter,".
		" RA_Aging,".
		" RA_AgingOfSupplierInvoices,".
		" RA_AgingOfClientInvoices,".
		
		" FA_DailyReport,".
		" RA_StatisticsReport,".
		" RA_SalesJV,".
		" RA_TransactionJV,".
		" RA_PurchasesJV,".
		" RA_GeneralLedger,".
		" RI_ListTransaction,".
		" RI_Inventory,".
		" RI_SalesReports,".
		" FI_PorderPurRequest,".
		" RI_SatementofItems,".
		" RI_YearlySales,".
		" RI_TrackingRMA,".
		" RI_Aging,".
		" RI_InvComparisonReport,".
		" RI_TargetRebateReport,".
		" RI_PorderReport,".
		" RI_PurchaseReports,".
		" RI_SalesOrderReport,RI_GrnReports,RI_ListofProduction,Edatacom,Accounting,Inventory,FI_SalebelowLandedCost,".
		" fastprinttransaction,Posted,PRqst_Approvedby,ExporttoExcel,FI_ShowCostPrice,FA_LedgerAccess,DailyInvoiceModification,FixJVofSales,ShowTransaction,ModifyingOldTransactions,".
		" ShowDepositJVBtn,FA_ManagingRequiredCost,AskBeforeCloseAcc,Show_group,RA_RequiredCostcenter,Login_negativeQty,AskBeforeCloseInv,ModifyVAT,RI_OpInvForNewYear,Login_ModifyAllPending,".
		" Login_modAdjIsInvoice,FI_PricePerUnit,Login_ShowLoggedUser,Login_ModifyDiscount,FI_RepRestrictProject,FI_RepRestrictCostcenter,FI_RepRestrictWarehouse,
		Login_Decimal,FI_PurchaseCategory,Unmodify_SellingPrice,Unmodify_SorderPrice,".

		" FA_ExceedBudgetLimit,FI_RVPostTransaction,FI_RepostAdjustment,ClientsCreditLimit, FI_DeliverySalesPrice,FI_SellingPriceInItems, ".
		" FI_CostPriceInItems,FI_ItemSelling1,FI_ItemSelling2,FI_ItemSelling3,FI_ItemSelling4,FI_ItemSelling5,FI_ItemSelling6,FI_PurchasesVATMod,FI_RepostPurchase, ".
		" FI_PorderConfirmed,FI_DelConfirmedPO,FI_ModConfirmedPO,FI_RepostPorder,FI_ReturnPurchasesVAT,FI_RepostPReturn,FI_RMAReturnSheetReturnRMA,FI_RMAReturnSheetRMA,  ".
		
		" FI_RSalesCheckSalesman,FI_ReturnSalesVAT,FI_ReturnSalesPrintPay,FI_RepostSReturn,FI_RMASheetPending ,FI_RMASheetRMA,FI_SalesCheckSalesman,FI_SalesVAT,FI_SalesWithPrice,  ".
		" FI_SalesPrintReceipt,FI_RepostSales,FI_SOrderWithPrice,FI_SorderCanceledQty,FI_SorderConfirmed,login_disapprovesorder, Login_AllowPrice, ".
		" FI_RepostSorder,FI_SorderPosQty,FP_DetailGenerateDel,FP_AnalysisReport,FP_ArabicReports,RP_BankStatement,RP_CollectionofRepPay,RP_Employee,RP_Evaluation, ". 
		
		" FP_Overtime,RP_Query,RP_TimeSheet,Rep_Accounting,Rep_Inventory,Rep_General,RA_Amortization,RA_AvgDays,RA_TabSheetBudget,RA_CreditLimitRoster, ".
		" RA_IncomeStmt,RA_IncomeStatBalanceSheet,FA_InterrestRate,RA_ListofCheckBills,RA_ListofDueInvoices,RA_ListofRecPayDebCred,RA_MonthDistBudgetForCast, ".
		" RA_TabSheetPaymentRqst,RA_PrePayment,RA_ProfitandLoss,RA_Query,RA_AccountReconciliation,RA_SalesmanComm,RA_unmovedAcounts,RI_tabsheetbooksbalance, ".
		" RI_BudgetInvTabSheet,RI_TabSheetexport,RI_InvByEntryNo,RI_Invoices,RI_ItemsPerWarehouseSize,RI_ListOfDeliveryQty,RI_LISTOFDUEITEMS,RI_ListofItems,RI_listofPICharges, ". 
		
		" RI_ListofRMA,RI_Packing,RI_ProfitperItems,RI_Query,RI_SalesStatistics,RI_SoldbySalesman,RI_StkMovement,RI_TranspPage,RI_CltSaleR_ShowSalesman,FC_CashRegister, ".
		" FC_CashRegisterApp,FC_CashRegisterMod,FC_CashRegisterDel,FC_AddClient,FC_CashRegisterCoupon,FC_CashRegisterCustomer,FC_CashRegisterCancel,FC_CashRegisterCheck, ".
		" FC_ConfirmCustomer,FC_CashRegisterCredit,FC_CashRegisterDisc,Fc_forcingvendor,FC_PermToCancelCash,FC_CashRegisterPosting,Promotion,ReturnQuantity, ".
		" FC_CashRegisterScroll,FC_CashRegScrollOk,FC_CashRegScrollPrint,FC_CashRegisterSearch,FC_ShowBtnOpenDrawer,Rc_cashFlow,Closing_RetailReport,RC_ForcingUserAccount, ". 
		" RC_ItemsSizes,RC_ListOfInvoices,RC_SalesmenCommission,RI_InvoiceProject,FI_Shipmentconfirmed,RA_TabSheetMonthlyAmount,RI_SaleR_ShowSalesman,RI_TabSheetrma, Costcenter, ".
		" CostcenterApp,CostcenterMod,CostcenterDel,Currency,CurrencyMod,CurrencyDel,CurrencyApp,
		U_BackupFile,U_CashRegister,U_CloseCompany,U_CloseYear,FU_ClosingPeriod,U_DeleteCompany,U_DeleteYear,U_DistributingCostcenter,U_FillSetupFile, ".
		"   U_MergerDataBase,U_NewCompany,U_NewYear,U_Ports,U_PostToChecksAndBills,U_PostToItems,U_PostToLedger,U_ReNumberJV, ".
		"   U_TransferAccount,U_TransferItem,FA_FIPAddress,FA_IPAddressApp,FA_IPAddressMod,FA_IPAddressDel, ". 		
		"   FI_PurchaseRequestItems,fi_pendingpurchaserequest,fi_pendingtransferrequest,fi_pendingadjustmentrequest,login_maturitydate, ". 		
		"  FI_Grn, FI_GrnApp, FI_GrnDel, FI_GrnMod, FI_ReturnGrn, FI_ReturnGrnApp, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_SorderAllowConfirmCash,FC_Tracking,Fi_POS,Utilities,RI_Statistics,RetailInvoice,RA_Statistics, language ".
		")".

	
			" values ('".$user_code."','".$user_name."','".$txtSchema."','".$full_name."','".$user_description."',";
			
		if ($config['EncryptPassMod'] == 1)
			$query=$query."encryptpassword('".$user_password2."'), ";
		else
			$query=$query."'".$user_password2."', ";	
			
		$query=$query." 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,".
						" 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
						,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
						'$login_language' ";
			
		$query=$query." )";
	
		$result=mysql_query($query,$connection);
		//echo $query;
		//exit;
		if($result) fcommit();
		else frollback();
	}
	else if($result && $fullaccess==''){
		$query="insert into login(User_account,User_name,Login_Schema,Fullname,Description,User_password,
		FA_AccountType,FA_AccountTypeApp,FA_AccountTypeMod,FA_AccountTypeDel,".
		" FA_FixedAssets,FA_FixedAssetsApp,FA_FixedAssetsMod,FA_FixedAssetsDel,".
		" FI_Area,FI_AreaApp,FI_AreaMod,FI_AreaDel,".
		" FA_Banks,FA_BankApp,FA_BankMod,FA_BankDel,".
		" FA_Budget,FA_BudgetApp,FA_BudgetMod,FA_BudgetDel,".
		" FA_Charging,FA_ChargingApp,FA_ChargingMod,FA_ChargingDel,".
		" FA_Contra,FA_ContraApp,FA_ContraMod,FA_ContraDel,".
		" FA_Costcenter,FA_CostcenterApp,FA_CostcenterMod,FA_CostcenterDel,".
		" FA_CreditNote,FA_CreditNoteApp,FA_CreditNoteMod,FA_CreditNoteDel,".
		" FA_Currency,FA_CurrencyApp,FA_CurrencyMod,FA_CurrencyDel,".
		" FA_DebitNote,FA_DebitNoteApp,FA_DebitNoteMod,FA_DebitNoteDel,".
		" RA_FinancialAccounts,".
		" FA_Journal,FA_JournalApp,FA_JournalMod,FA_JournalDel,".
		" FA_InvoicesAllocation,".
		" FA_Ledger,FA_LedgerApp,FA_LedgerMod,FA_LedgerDel,".
		" FA_Payment,FA_PaymentApp,FA_PaymentMod,FA_PaymentDel,".
		" FA_PaymentRqst,FA_PaymentRqstApp,FA_PaymentRqstMod,FA_PaymentRqstDel,".
		" FA_Project,FA_ProjectApp,FA_ProjectMod,FA_ProjectDel,".
		" FA_PurchaseJV,FA_PurchaseJVApp,FA_PurchaseJVMod,FA_PurchaseJVDel,".
		" FA_Receipt,FA_ReceiptApp,FA_ReceiptMod,FA_ReceiptDel,".
		" FA_ReportOptions,".
		" FA_SalesJV,FA_SalesJVApp,FA_SalesJVMod,FA_SalesJVDel,".
		" FA_transactionpaymnetrqst,FA_transactionpaymnetrqstApp,FA_transactionpaymnetrqstMod,FA_transactionpaymnetrqstDel,".
		" FI_Adjustment,FI_AdjustmentApp,FI_AdjustmentMod,FI_AdjustmentDel,".
		" FI_FBudgetInv,FI_BudgetInvApp,FI_BudgetInvMod,FI_BudgetInvDel,".
		" FI_FBudgetInvAmendment,FI_BudgetInvAmendmentApp,FI_BudgetInvAmendmentMod,FI_BudgetInvAmendmentDel,".
		" FI_FBudgetInvSetup,FI_BudgetInvSetupApp,FI_BudgetInvSetupMod,FI_BudgetInvSetupDel,".
		" FI_Category,FI_CategoryApp,FI_CategoryMod,FI_CategoryDel,".
		" FI_CEPtable,FI_CEPtableApp,FI_CEPtableMod,FI_CEPtableDel,".
		" FI_Charges,FI_ChargesApp,FI_ChargesMod,FI_ChargesDel,".
		" Clients,ClientsApp,ClientsMod,ClientsDel,".
		" FI_ClientGrp,FI_ClientGrpApp,FI_ClientGrpMod,FI_ClientGrpDel,".
		" FI_Delivery,FI_DeliveryApp,FI_DeliveryMod,FI_DeliveryDel,".
		" FI_Grouping,FI_GroupingApp,FI_GroupingMod,FI_GroupingDel,".
		" FI_Items,FI_ItemsApp,FI_ItemsMod,FI_ItemsDel ,".
		" FI_Production,FI_ProductionApp,FI_ProductionMod,FI_ProductionDel,".
		" FI_ProductionReq,FI_ProductionReqApp,FI_ProductionReqMod,FI_ProductionReqDel,".
		" FI_ProductionTemp,FI_ProductionTempApp,FI_ProductionTempMod,FI_ProductionTempDel,".
		" FI_Purchases,FI_PurchasesApp,FI_PurchasesMod,FI_PurchasesDel,".
		" FI_ReportOptions,".
		" FI_PurchaseOrder,FI_PurchaseOrderApp,FI_PurchaseOrderMod,FI_PurchaseOrderDel,".
		" FI_PurchaseRequest,FI_PurchaseRequestApp,FI_PurchaseRequestMod,FI_PRequestConfirmed,FI_PurchaseRequestDel,".
		" FI_ReturnDelivery,FI_ReturnDeliveryApp,FI_ReturnDeliveryMod,FI_ReturnDeliveryDel,".
		" FI_ReturnPurchase,FI_ReturnPurchaseApp,FI_ReturnPurchaseMod,FI_ReturnPurchaseDel,".
		" FI_ReturnRma,FI_ReturnRmaApp,FI_ReturnRmaMod,FI_ReturnRmaDel,".
		" FI_ReturnSales,FI_ReturnSalesApp,FI_ReturnSalesMod,FI_ReturnSalesDel,".
		" FI_RmTransfer,FI_RmTransferApp,FI_RmTransferMod,FI_IRmTransferDel,".
		" FI_Rma,FI_RmaApp,FI_RmaMod,FI_RmaDel,".
		" FI_Sales,FI_SalesApp,FI_SalesMod,FI_SalesDel,".
		" FI_SalesOrder,FI_SalesOrderApp,FI_SalesOrderMod,FI_SalesOrderDel,".
		" FI_Salesmen,FI_SalesmenApp,FI_SalesmenMod,FI_SalesmenDel,".
		" FI_Shipment,FI_ShipmentMod,FI_ShipmentDel,".
		" FI_stockeval,FI_stockevalApp,FI_stockevalMod,FI_stockevalDel,".
		" FI_SubGrouping,FI_SubGroupingApp,FI_SubGroupingMod,FI_SubGroupingDel,".
		" FI_Suppliers,FI_SuppliersApp,FI_SuppliersMod,FI_SuppliersDel,".
		" FI_SupplierGrp,FI_SupplierGrpApp,FI_SupplierGrpMod,FI_SupplierGrpDel,".
		" FI_Transfer,FI_TransferApp,FI_TransferMod,FI_TransferDel,".
		" FI_ITransfer,FI_ITransferApp,FI_ITransferMod,FI_ITransferDel,".
		" FI_Transportation,FI_TransportationApp,FI_TransportationMod,FI_TransportationDel,".
		" FI_Warehouse,FI_WarehouseApp,FI_WarehouseMod,FI_WarehouseDel,".
		" FI_WayBill,FI_WayBillApp,FI_WayBillMod,FI_WayBillDel,".
		" FP_Attendance,FP_AttendanceApp,FP_AttendanceMod,FP_AttendanceDel,".
		" FP_Bonus,FP_BonusApp,FP_BonusMod,FP_BonusDel,".
		" FP_Dept,FP_DeptApp,FP_DeptMod,FP_DeptDel,".
		" FP_Employee,FP_EmployeeApp,FP_EmployeeMod,FP_EmployeeDel,".
		" FP_Generate,FP_GenerateApp,FP_GenerateMod,FP_GenerateDel,".
		" FP_Grades,FP_GradesApp,FP_GradesMod,FP_GradesDel,".
		" FP_Insurance,FP_InsuranceApp,FP_InsuranceMod,FP_InsuranceDel,".
		" FP_Loan,FP_LoanApp,FP_LoanMod,FP_LoanDel,".
		" FP_Parameters,FP_ParametersApp,FP_ParametersMod,FP_ParametersDel,".
		" FP_Fpreemp,FP_preempApp,FP_preempMod,FP_preempDel,".
		" FP_Project,FP_ProjectApp,FP_ProjectMod,FP_ProjectDel,".
		" FP_ReportOptions,".
		" FP_Vacation,FP_VacationApp,FP_VacationMod,FP_VacationDel,".
		" Access_UserManager, ".
		" RA_StatementofAccount,".
		" RA_Trialbalance,".
		" RA_StatementofProject,".
		" RA_StatmentofCostcenter,".
		" RA_Aging,".
		" RA_AgingOfSupplierInvoices,".
		" RA_AgingOfClientInvoices,".
		
		" FA_DailyReport,".
		" RA_StatisticsReport,".
		" RA_SalesJV,".
		" RA_TransactionJV,".
		" RA_PurchasesJV,".
		" RA_GeneralLedger,".
		" RI_ListTransaction,".
		" RI_Inventory,".
		" RI_SalesReports,".
		" FI_PorderPurRequest,".
		" RI_SatementofItems,".
		" RI_YearlySales,".
		" RI_TrackingRMA,".
		" RI_Aging,".
		" RI_InvComparisonReport,".
		" RI_TargetRebateReport,".
		" RI_PorderReport,".
		" RI_PurchaseReports,".
		" RI_SalesOrderReport,RI_GrnReports,RI_ListofProduction,Edatacom,Accounting,Inventory,FI_SalebelowLandedCost,".
		" fastprinttransaction,Posted,PRqst_Approvedby,ExporttoExcel,FI_ShowCostPrice,FA_LedgerAccess,DailyInvoiceModification,FixJVofSales,ShowTransaction,ModifyingOldTransactions,".
		" ShowDepositJVBtn,FA_ManagingRequiredCost,AskBeforeCloseAcc,Show_group,RA_RequiredCostcenter,Login_negativeQty,AskBeforeCloseInv,ModifyVAT,RI_OpInvForNewYear,Login_ModifyAllPending,".
		" Login_modAdjIsInvoice,FI_PricePerUnit,Login_ShowLoggedUser,Login_ModifyDiscount,FI_RepRestrictProject,FI_RepRestrictCostcenter,FI_RepRestrictWarehouse,
		Login_Decimal,FI_PurchaseCategory,Unmodify_SellingPrice,Unmodify_SorderPrice,".

		" FA_ExceedBudgetLimit,FI_RVPostTransaction,FI_RepostAdjustment,ClientsCreditLimit, FI_DeliverySalesPrice,FI_SellingPriceInItems, ".
		" FI_CostPriceInItems,FI_ItemSelling1,FI_ItemSelling2,FI_ItemSelling3,FI_ItemSelling4,FI_ItemSelling5,FI_ItemSelling6,FI_PurchasesVATMod,FI_RepostPurchase, ".
		" FI_PorderConfirmed,FI_DelConfirmedPO,FI_ModConfirmedPO,FI_RepostPorder,FI_ReturnPurchasesVAT,FI_RepostPReturn,FI_RMAReturnSheetReturnRMA,FI_RMAReturnSheetRMA,  ".
		
		" FI_RSalesCheckSalesman,FI_ReturnSalesVAT,FI_ReturnSalesPrintPay,FI_RepostSReturn,FI_RMASheetPending ,FI_RMASheetRMA,FI_SalesCheckSalesman,FI_SalesVAT,FI_SalesWithPrice,  ".
		" FI_SalesPrintReceipt,FI_RepostSales,FI_SOrderWithPrice,FI_SorderCanceledQty,FI_SorderConfirmed,login_disapprovesorder, Login_AllowPrice, ".
		" FI_RepostSorder,FI_SorderPosQty,FP_DetailGenerateDel,FP_AnalysisReport,FP_ArabicReports,RP_BankStatement,RP_CollectionofRepPay,RP_Employee,RP_Evaluation, ". 
		
		" FP_Overtime,RP_Query,RP_TimeSheet,Rep_Accounting,Rep_Inventory,Rep_General,RA_Amortization,RA_AvgDays,RA_TabSheetBudget,RA_CreditLimitRoster, ".
		" RA_IncomeStmt,RA_IncomeStatBalanceSheet,FA_InterrestRate,RA_ListofCheckBills,RA_ListofDueInvoices,RA_ListofRecPayDebCred,RA_MonthDistBudgetForCast, ".
		" RA_TabSheetPaymentRqst,RA_PrePayment,RA_ProfitandLoss,RA_Query,RA_AccountReconciliation,RA_SalesmanComm,RA_unmovedAcounts,RI_tabsheetbooksbalance, ".
		" RI_BudgetInvTabSheet,RI_TabSheetexport,RI_InvByEntryNo,RI_Invoices,RI_ItemsPerWarehouseSize,RI_ListOfDeliveryQty,RI_LISTOFDUEITEMS,RI_ListofItems,RI_listofPICharges, ". 
		
		" RI_ListofRMA,RI_Packing,RI_ProfitperItems,RI_Query,RI_SalesStatistics,RI_SoldbySalesman,RI_StkMovement,RI_TranspPage,RI_CltSaleR_ShowSalesman,FC_CashRegister, ".
		" FC_CashRegisterApp,FC_CashRegisterMod,FC_CashRegisterDel,FC_AddClient,FC_CashRegisterCoupon,FC_CashRegisterCustomer,FC_CashRegisterCancel,FC_CashRegisterCheck, ".
		" FC_ConfirmCustomer,FC_CashRegisterCredit,FC_CashRegisterDisc,Fc_forcingvendor,FC_PermToCancelCash,FC_CashRegisterPosting,Promotion,ReturnQuantity, ".
		" FC_CashRegisterScroll,FC_CashRegScrollOk,FC_CashRegScrollPrint,FC_CashRegisterSearch,FC_ShowBtnOpenDrawer,Rc_cashFlow,Closing_RetailReport,RC_ForcingUserAccount, ". 
		" RC_ItemsSizes,RC_ListOfInvoices,RC_SalesmenCommission,RI_InvoiceProject,FI_Shipmentconfirmed,RA_TabSheetMonthlyAmount,RI_SaleR_ShowSalesman,RI_TabSheetrma, Costcenter, ".
		" CostcenterApp,CostcenterMod,CostcenterDel,Currency,CurrencyMod,CurrencyDel,CurrencyApp,
		U_BackupFile,U_CashRegister,U_CloseCompany,U_CloseYear,FU_ClosingPeriod,U_DeleteCompany,U_DeleteYear,U_DistributingCostcenter,U_FillSetupFile, ".
		"   U_MergerDataBase,U_NewCompany,U_NewYear,U_Ports,U_PostToChecksAndBills,U_PostToItems,U_PostToLedger,U_ReNumberJV, ".
		"   U_TransferAccount,U_TransferItem,FA_FIPAddress,FA_IPAddressApp,FA_IPAddressMod,FA_IPAddressDel, ". 		
		"   FI_PurchaseRequestItems,fi_pendingpurchaserequest,fi_pendingtransferrequest,fi_pendingadjustmentrequest,login_maturitydate, ". 		
		"  FI_Grn, FI_GrnApp, FI_GrnDel, FI_GrnMod, FI_ReturnGrn, FI_ReturnGrnApp, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_SorderAllowConfirmCash,FC_Tracking,Fi_POS, language ".
		") " 
				." values ('".$user_code."','".$user_name."','".$txtSchema."','".$full_name."','".$user_description."',";
			
		if ($config['EncryptPassMod'] == 1)
			$query=$query."encryptpassword('".$user_password2."'), ";
		else
			$query=$query."'".$user_password2."', ";
				$query=$query." 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,".
						" 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
						,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, '$login_language' ";
				$query=$query." )";	

		$result=mysql_query($query,$connection);
		//echo$query;exit;
	
		if($result) fcommit();
		else frollback();
	
	}else if($result && $fullaccess=='2'){

		
		$query="insert into login
			select '".$user_name."', '".$user_code."', '".$txtSchema."',";
		
		
		if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."'), ";
		else
		$query=$query."'".$user_password2."', ";

		
		
		$query=$query."'".$full_name."','".$user_description."'
		, Print, Access, Login_Delete, Login_Append, Costcenter, Project, Currency, 
		Ledger, Budget, Keyboard_Layout, '$login_language', DefaultComp, DefaultYear, 
		FullAccess, USR_CompanyAccess, USR_UserManager, USR_AppPriv, USR_FormAccess, 
		USR_ReportOption, RMA_In, RMA_Out, ModifyVAT, InvCreditLimit, Login_Edit, DisplayBoth,
		 Discount, DiscountMsgWarning, Post, Promotion, ReturnQuantity, Login_CardNo, login_belongstogrp, 
		 ModifyBelongsToGrp, Bdgt_Reference, User_Signature, RetailInvoice, FC_CashRegister, FC_CashRegisterApp,
		  FC_CashRegisterDel, FC_CashRegisterMod, FI_SalesVAT, FI_ReturnSalesVAT, FI_PurchasesVAT, FI_PurchasesVATMod, FI_ReturnPurchasesVAT, FA_SalesJvVAT, FA_PurchaseJV, FA_PurchaseJVMod, FA_PurchaseJVDel, FA_PurchaseJVApp, FA_PurchaseJVVAT, U_TransferItem, FI_SalesCheckSalesman, FI_RSalesCheckSalesman, FC_CashRegisterScroll, FC_CashRegisterCredit, 
		  FC_CashRegisterCheck, FC_CashRegisterCoupon, FC_CashRegisterCustomer, FC_CashRegisterCash, 
		  FC_CashRegisterDisc, FC_CashRegisterProm, FC_CashRegisterQtyRet, FI_Sizes, FI_SizesDel, FI_SizesMod, 
		  FI_SizesApp, RA_ListOfPurchaseJv, FA_PurchaseJVCharge, FA_PrefixJV, Closing_RetailReport, FI_Color, FI_ColorMod, FI_ColorDel, FI_ColorApp, FI_ItemSelling1, FI_ItemSelling2, FI_ItemSelling3, FI_ItemSelling4, FI_ItemSelling5, FI_SOrderWithPrice, FI_SalesWithPrice, FC_PermToCancelCash, FI_ClientSalesmanComm, FI_SalebelowLandedCost, FC_CashRegisterClient, RI_LISTOFDUEITEMS, RA_StatementofProject, RA_ProfitandLoss, RA_PurchasesandSalesJV, RI_ListofItems, RI_ListofRMA, RI_InvoiceProject, RI_SalesStatistics, RA_ListofDueInvoices, FI_ShowCostPrice, FA_BalanceJV, Reports, Rep_General, Rep_Inventory, Rep_Accounting, RA_SalesmanComm, FC_RetailReport, RA_RequiredCostcenter, FA_LedgerAccess, ExporttoExcel, FixJVofSales, ModifyingOldTransactions, DailyInvoiceModification, FI_DIFFCOMPANY, AskBeforeCloseInv, AskBeforeCloseAcc, ShowDepositJVBtn, Show_group, Fi_itemselling6, Fc_forcingvendor, Rc_cashFlow, RC_ListOfInvoices, RC_SalesmenCommission, RC_ItemsSizes, FC_ShowBtnOpenDrawer, FC_AddClient, RC_ForcingUserAccount, FA_FIPAddress, FA_IPAddressApp, FA_IPAddressDel, FA_IPAddressMod, FA_IPAddPermToExceedCL, RA_ListOfInvoices, FA_ManagingRequiredCost, U_RePostTransaction, FC_AddCustomer, FC_ConfirmCustomer, FA_PaymentRqst, FA_PaymentRqstApp, FA_PaymentRqstMod, FA_PaymentRqstDel, FA_Client, FA_ClientDel, FA_ClientApp, FA_ClientMod, FA_ClientCreditLimit, FA_Currency, FA_CurrencyDel, FA_CurrencyApp, FA_CurrencyMod, FA_Supplier, FA_SupplierDel, FA_SupplierApp, FA_SupplierMod, FA_Project, FA_ProjectDel, FA_ProjectMod, FA_ProjectApp, FA_CostCenter, FA_CostCenterDel, FA_CostCenterMod, FA_CostCenterApp, RA_AccountReconciliation, FA_SalesJVModRef, LockedPeriod, AllowLockedPeriod, FI_PreProduction, FI_PreProductionMod, FI_PreProductionApp, FI_PreProductionDel, FP_Insurance, FP_InsuranceMod, FP_InsuranceApp, FP_InsuranceDel, FI_WayBill, FI_WayBillDel, FI_WayBillApp, FI_WayBillMod, FP_DetailGenerateDel, RI_YearlySales, RI_InvByEntryNo, RI_ListOfDeliveryQty, RI_OpInvForNewYear, DirectConsumption, RI_PorderReport, RI_ClientsSalesReport, ClientIP_Del, ClientIP_Mod, ClientIP_App, ClientIP_EndDate, ClientIP_LastTransDate, RI_YearlyPurchases, LockedPeriodDays, Rp_ReportR3, FI_SupplierGrp, FI_SupplierGrpApp, FI_SupplierGrpDel, FI_SupplierGrpMod, FI_ClientGrp, FI_ClientGrpApp, FI_ClientGrpDel, FI_ClientGrpMod, FA_ConfirmJV, FI_RVPostTransaction, FI_PVPostTransaction, FI_CVPostTransaction, FI_DVPostTransaction, FU_ClosingPeriod, FI_RepostPurchase, FI_RepostPReturn, FI_RepostSales, FI_RepostSReturn, FI_RepostDeliveries, FI_RepostDReturn, FI_RepostPorder, FI_RepostSorder, FI_RepostAdjustment, FP_ShowSalaryMvt, RI_listofPICharges, FP_ArabicReports, FP_EmpArabicInfo, FI_ITransfer, FI_ITransferApp, FI_ITransferMod, FI_ITransferDel, FI_PorderPurRequest, FI_SupplierGrpPurRequest, FP_Grades, FP_GradesApp, FP_GradesDel, FP_GradesMod, FP_Dept, FP_DeptApp, FP_DeptDel, FP_DeptMod, FP_Fpreemp, FP_preempApp, FP_preempDel, FP_preempMod, FP_Attendance, FP_Overtime, FP_AnalysisReport, FP_Project, FP_ProjectApp, FP_ProjectDel, FP_ProjectMod, FA_ExceedBudgetLimit, U_SendReceiveCriteria, RI_CltSaleR_ShowSalesman, RI_SaleR_ShowSalesman, Inventory, Accounting, PayRoll, Utilities, FA_Journal, FA_JournalApp, FA_JournalDel, FA_JournalMod, FA_Payment, FA_PaymentApp, FA_PaymentDel, FA_PaymentMod, FA_Receipt, FA_ReceiptDel, FA_ReceiptMod, FA_ReceiptApp, FA_CreditNote, FA_CreditNoteApp, FA_CreditNoteDel, FA_CreditNoteMod, FA_DebitNote, FA_DebitNoteDel, FA_DebitNoteMod, FA_DebitNoteApp, FA_FixedAssets, FA_FixedAssetsDel, FA_FixedAssetsMod, FA_FixedAssetsApp, FA_Charging, FA_ChargingDel, FA_ChargingMod, FA_ChargingApp, FA_ReportOptions, FA_Ledger, FA_LedgerDel, FA_LedgerMod, FA_LedgerApp, CurrencyDel, CurrencyApp, CurrencyMod, CostcenterDel, CostcenterMod, CostcenterApp, ProjectDel, ProjectMod, ProjectApp, Clients, ClientsDel, ClientsApp, ClientsMod, ClientsCreditLimit, FA_Budget, FA_BudgetDel, FA_BudgetMod, FA_BudgetApp, FA_AccountType, FA_AccountTypeDel, FA_AccountTypeMod, FA_AccountTypeApp, FA_SalesJV, FA_SalesJVMod, FA_SalesJVApp, FA_SalesJVDel, RA_GeneralLedger, RA_TransactionJV, RA_ListofRecPayDebCred, RA_ListofCheckBills, RA_IncomeStatBalanceSheet, RA_FinancialSummary, RA_MonthDistBudgetForCast, RA_TrialBalance, RA_StatementofAccount, RA_Aging, RA_PrePayment, RA_Amortization, RA_StatmentofDocument, RA_StatmentofCostcenter, RA_CreditLimitRoster, RA_IncomeStmt, RA_Query, FI_PurchaseOrder, FI_PurchaseOrderDel, FI_PurchaseOrderApp, FI_PurchaseOrderMod, FI_Purchases, FI_PurchasesDel, FI_PurchasesMod, FI_PurchasesApp, FI_ReturnPurchase, FI_ReturnPurchaseDel, FI_ReturnPurchaseMod, FI_ReturnPurchaseApp, FI_Rma, FI_RmaDel, FI_RmaApp, FI_RmaMod, FI_ReturnRma, FI_ReturnRmaDel, FI_ReturnRmaApp, FI_ReturnRmaMod, FI_SalesOrder, FI_SalesOrderDel, FI_SalesOrderApp, FI_SalesOrderMod, FI_Sales, FI_SalesDel, FI_SalesApp, FI_SalesMod, FI_SalesPrintReceipt, FI_ReturnSales, FI_ReturnSalesApp, FI_ReturnSalesMod, FI_ReturnSalesDel, FI_ReturnSalesPrintPay, FI_Delivery, FI_DeliveryDel, FI_DeliveryMod, FI_DeliveryApp, FI_ReturnDelivery, FI_ReturnDeliveryDel, FI_ReturnDeliveryApp, FI_ReturnDeliveryMod, FI_Transfer, FI_TransferDel, FI_TransferApp, FI_TransferMod, FI_Production, FI_ProductionDel, FI_ProductionApp, FI_ProductionMod, FI_Adjustment, FI_AdjustmentDel, FI_AdjustmentApp, FI_AdjustmentMod, FI_ReportOptions, FI_Items, FI_ItemsDel, FI_ItemsApp, FI_ItemsMod, FI_Warehouse, FI_WarehouseDel, FI_WarehouseMod, FI_WarehouseApp, FI_Area, FI_AreaDel, FI_AreaMod, FI_AreaApp, FI_Category, FI_CategoryDel, FI_CategoryApp, FI_CategoryMod, FI_Grouping, FI_GroupingDel, FI_GroupingApp, FI_GroupingMod, FI_SubGrouping, FI_SubGroupingDel, FI_SubGroupingMod, FI_SubGroupingApp, FI_Suppliers, FI_SuppliersDel, FI_SuppliersMod, FI_SuppliersApp, FI_Salesmen, FI_SalesmenDel, FI_SalesmenApp, FI_SalesmenMod, RI_SatementofItems, RI_Inventory, RI_ProfitperItems, RI_SalesReports, RI_PurchaseReports, RI_ListTransaction, RI_Packing, RI_ListofProduction, RI_ExpiryDate, RI_Options, RI_Query, FP_Employee, FP_EmployeeDel, FP_EmployeeMod, FP_EmployeeApp, FP_Bonus, FP_BonusDel, FP_BonusMod, FP_BonusApp, FP_Vacation, FP_VacationDel, FP_VacationMod, FP_VacationApp, FP_Loan, FP_LoanDel, FP_LoanMod, FP_LoanApp, FP_AttendanceDel, FP_AttendanceMod, FP_AttendanceApp, FP_Generate, FP_GenerateApp, FP_GenerateDel, FP_GenerateMod, FP_ReportOptions, FP_Parameters, FP_ParametersDel, FP_ParametersApp, FP_ParametersMod, RP_Employee, RP_TimeSheet, RP_CollectionofRepPay, RP_Evaluation, RP_BankStatement, RP_Query, U_NewYear, U_DeleteYear, U_CloseYear, U_NewCompany, U_DeleteCompany, U_CloseCompany, U_PostToLedger, U_PostToItems, U_PostToChecksAndBills, U_TransferAccount, U_DistributingCostcenter, U_ReNumberJV, U_FillSetupFile, U_RebuildIndexAcc, U_RebuildIndexInv, U_RebuildIndexPay, U_BackupFile, U_MergerDataBase, U_Trace, U_Query, U_CashRegister, U_Ports, FI_SellingPriceInItems, FI_CostPriceInItems, CGI, Access_UserManager, U_RebuildIndexAccLab, LoginAccess_DirYear, LoginAccess_Company, Posted, RI_Invoices, RI_ItemsPerWarehouseSize, FI_SorderConfirmed, Synchro, FA_Banks, FA_BankApp, FA_BankDel, FA_BankMod, RA_AgingOfClientInvoices, RA_FinancialAccounts, FI_DeliveryConfirmed, FI_PorderConfirmed, Login_ShowLoggedUser, Login_modAdjIsInvoice, FI_PricePerUnit, FC_CashRegisterSearch, FC_CashRegScrollPrint, FC_CashRegisterCancel, FC_CashRegisterPosting, FC_CashRegScrollOk, FA_SkipReference, FI_purchaseRequest, FI_purchaseRequestDel, FI_purchaseRequestApp, FI_purchaseRequestMod, FI_RepostRequest, FI_IN, FI_OUT, FI_INDel, FI_OUTDel, FI_INMod, FI_OUTMod, FI_INapp, FI_Outapp, login_AllowTimer, FI_ModConfirmedPO, FI_DelConfirmedPO, FI_StkEval, FI_StkEvalMod, FI_StkEvalApp, Fi_StkEvalDel, Default_Project, Default_Costcent, PRqst_Approvedby, FI_Transportation, FI_TransportationApp, FI_TransportationMod, FI_TransportationDel, Login_Decimal, Unmodify_SellingPrice, RI_StkMovement, RA_AvgDays, RA_SalesJV, RA_PurchasesJV, FI_SorderCanceledQty, ShowTransaction, fpr_changeweight, FA_ClientPaymentTerms, FA_Transformation, FA_TransformationAPP, FA_TransformationMod, FA_TransformationDel, FA_ProdRatio, FA_ProdRatioAPP, FA_ProdRatioMod, FA_ProdRatioDEL, Login_negativeQty, FI_BudgetInvDel, FI_BudgetInvMod, FI_BudgetInvApp, FI_FBudgetInv, FI_BudgetInvSetupDel, FI_BudgetInvSetupMod, FI_BudgetInvSetupApp, FI_FBudgetInvSetup, FI_BudgetInvAmendmentDel, FI_BudgetInvAmendmentMod, FI_BudgetInvAmendmentApp, FI_FBudgetInvAmendment, EDataCom, FA_transactionpaymnetrqst, FA_transactionpaymnetrqstdel, FA_transactionpaymnetrqstapp, FA_transactionpaymnetrqstmod, FI_stockeval, FI_stockevalapp, FI_stockevaldel, FI_stockevalmod, FI_CEPtable, FI_CEPtableapp, FI_CEPtabledel, FI_CEPtablemod, U_costcentertransfer, U_projecttransfer, Unmodify_SorderPrice, FI_deliveryrelease, login_disapprovesorder, FI_DeliveryReleaseMod, FI_DeliveryReleaseDel, FI_DeliveryReleaseApp, FA_DailyReport, RA_TabSheetPaymentRqst, RA_TabSheetBudget, RA_unmovedAcounts, RA_TabSheetMonthlyAmount, RA_InterrestRate, RI_PurchaseCategory, RI_TranspPage, 
		  RI_TabSheetexport, RI_TabSheetrma, RI_tabsheetbooksbalance, RI_BudgetInvTabSheet, FI_SorderPosQty, FI_PurchaseCategory, FI_DeliverySalesPrice, FI_SorderRejectUnconfirmed, Login_AllowPrice, FI_Grn, FI_GrnDel, FI_GrnMod, FI_GrnApp, FC_CashRegisterAskPrint, FI_RepRestrictProject, FI_RepRestrictCostcenter, FI_RepRestrictWarehouse, Login_ModifyAllPending, RI_Aging, fastprintarchive, fastprinttransaction, Login_ModifyDiscount, FA_Contra, FA_ContraApp, FA_ContraMod, FA_ContraDel, FI_RmGrn, FI_RmGrnDel, FI_RmGrnMod, FI_RmGrnApp, FI_RmTransfer, FI_IRmTransferDel, FI_RmTransferMod, Fi_RmTransferapp, FI_SellingPriceModifyInItems, FI_ReturnGrn, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_ReturnGrnApp, production, RP_generate, RP_TaxeDeclare, RI_CommissionByGroup, FI_RMASheetRMA, FI_RMASheetPending, FI_RMAReturnSheetReturnRMA, FI_RMAReturnSheetRMA, Login_FastPrint, Login_ModifySellingPrice, FI_SorderAskConfirm, FI_SalebelowCost, FI_SaleBelowDiscount, FI_SaleDiscountPer, 
		  FI_SalesOrderModDelConfirmed, FI_Shipment, FI_Shipmentconfirmed, FI_ShipmentMod, FI_ShipmentDel, RI_GrnReports, FI_SalebelowLandedCostWarning, FI_MessageCenter, FC_SearchByCashRegister, RA_AgingOfSupplierInvoices, RA_StatisticsReport, RI_InvComparisonReport, login_queries, login_queiresEdit, RI_TargetRebateReport, RI_SalesOrderReport, RI_YEARLYCOMPARATIVEREPORT, RA_YEARLYCOMPARATIVEREPORT, FC_DiscountPerLimit, FI_ProductionTemp, FI_ProductionTempApp, FI_ProductionTempDel, FI_ProductionTempMod, FI_Charges, FI_Vehicle, FI_VehicleApp, FI_VehicleDel, FI_VehicleMod, FI_VehicleCharges, FI_VehicleChargesApp, FI_VehicleChargesDel, FI_VehicleChargesMod, FI_Place, FI_PlaceApp, FI_PlaceDel, FI_PlaceMod, FI_Employee, FI_EmployeeApp, FI_EmployeeDel, FI_EmployeeMod, Fi_vehicleservice, FI_VehicleServiceApp, FI_VehicleServiceDel, FI_VehicleServiceMod, FI_VehicleFuelType, FI_VehicleFuelTypeApp, FI_VehicleFuelTypeDel, FI_VehicleFuelTypeMod, FC_Tracking, FI_VehicleType, FI_VehicleTypeApp, FI_VehicleTypeDel, FI_VehicleTypeMod, FI_VehicleMOvement, FI_VehicleMovementDel, FI_VehicleMovementMod, FI_VehicleMovementApp, FI_ChargesApp, RI_INVENTORY2, FI_ChargesMod, FI_ChargesDel, FI_ProductionReq, FI_ProductionReqApp, FI_ProductionReqDel, FI_ProductionReqMod, FP_EmployeeRequest, FI_AllowEditIfDelivered, Login_CancelSorder, Allow_MinimumPrice, Login_Daily, Login_Weekly, Login_Monthly, Login_Limit, AllowedPaymentDirect, Branch_Manager, FI_ChangeInvoiceClient, FI_ChangeInvoiceItems, FA_TOPVAT, FI_FrmRestrictWarehouse, FP_Leave, FP_LeaveApp, FP_LeaveMod, FP_LeaveDel, FA_Amortization, logistics, FI_SalesmenCommission, FA_InvoicesAllocation, FI_VehcileLoad, FI_RetrunSaleOrder, FI_ReturnPurchaseOrder, CRM, FI_PRequestConfirmed, FI_PurchaseRequestItems, FI_PRETransfer, FA_Invoicing, FI_AdjustmentRequest, FI_OUTREQUEST, FI_OutappRequest, Login_FastPrintRequest, FI_TransferRequest, Fi_VehicleWeightChange, FC_CashRegisterClosing, FC_ShowBtnCancel, FC_CashRegisterDelItem, approved_level, FL_Proforma, FL_ProformaSetup, FL_ProformaMod, FL_ProformaDel, FL_ProformaApp, FL_ProformaSetupMod, FL_ProformaSetupDel, FL_ProformaSetupApp, fi_pendingpurchaserequest, fi_pendingtransferrequest, fi_pendingadjustmentrequest, FA_TransferFunds, fi_pendingpurchaseorder, PorderApproved_Level, PrequestApproved_Level, TransferRequestApproved_Level, AdjustmentRequestApproved_Level, RI_SoldbySalesman, FI_CustomerF, FI_CustomerDel, FI_CustomerApp, FI_CustomerMod, Fi_POS, RI_TopClientsSuppliers, fi_transferstockout, fi_purchasestockout, FI_ItemPricing, Perc_CreditLimit, RA_Statistics, RI_Statistics, FA_INTERRESTRATE, FI_statistics, FI_SorderAllowConfirmCash, Fi_VehicleMovementReport, Login_Mobile, FM_Visits, RM_DailyVisits, FM_Mobiles, FU_DataTransfer, FC_CashRegisterGift, FC_CashRegisterVoid, FC_CashRegisterWaste, FC_CashRegisterSetup, login_maturitydate, Login_TipsMaxAmount, Login_PReqApprove, Login_PReqReject, Login_PReqUndProc, Login_POrdApprove, Login_POrdReject, Login_TReqApprove, Login_TReqReject, Login_AReqApprove, Login_AReqReject, FI_PurchaseRequestItemPR, FI_PurchaseRequestItemAD, FI_PurchaseRequestItemPO, FI_PurchaseRequestItemTR, PR_default, PO_default, TR_default, AD_default, PR_status1, PR_status2, PR_status3, PR_status4, PR_status5, PR_status6, PR_status7, PR_status8, PR_status9, PR_status10, PR_status11, TR_status1, TR_status2, TR_status3, AD_status1, AD_status2, AD_status3, PO_status1, PO_status2, PO_status3, PO_status4, PO_status5, FC_ShowAllTables, PR_status12, PO_status6, PO_status7, FI_PendingPaymentRequest, PaymentRqstApproved_Level, PYR_default, PYR_status1, PYR_status2, PYR_status3, Login_MinAllowCostPer, Login_MaxAllowCostPer, FC_CashRegisterMenu, FC_CashRegisterHold, FI_ShowPriceHistory, FC_RetailStatistics, FC_SalesAnalysis, FI_DeliveryStatus, FI_heatNo, FI_StockOutRequest, Login_porderLimit, FC_RetailViewer, RI_Adjustment, PR_status13, Login_Purchase_Pending, User_confirm, FI_SetDeliveryStatus, FI_DeliveryStatusFrom, FI_DeliveryStatusTo, FI_ModInvStatusDlv, Login_location, Retail_Cancel, FI_itemTransfer, RI_Procurement, warehouse_excluded, FU_SalesmenTracking, FI_SalesmanDailyVisit, FU_Reason, FU_DeleteTempReceipt, FI_RetailCashOut, FI_Visit, RI_Visit, FI_ArchiveReports, FI_ReportsOptions, FI_PurchaseRequestItemsPR, FI_PurchaseRequestItemsPO, FI_PurchaseRequestItemsTR, FI_PurchaseRequestItemsAD, FC_SalesStatistic, FI_RoutingList, FA_PurchaseOrderJV, FI_NotRoutingList, FI_PorderJVConfirmed, RI_PricingList, FA_PurchaseOrderJVapp, FA_PurchaseOrderJVmod, FA_PurchaseOrderJVdel, FI_ReturnDeliveryConfirm, FA_SellingPrice, RI_ReportOptions, FI_DeleteMobileSorders, FI_DeleteMobileInvoices, FI_DeleteMobileReturnInvoices, is_superUser, FI_SalesOrderConfirm2, FI_CalculateRMReport, ShowBankInfo, ShowInsuranceInfo, FI_MultiplePosting, FI_DeliveryStatusItems, FI_FactoryProduction, login_outconfirm, FI_ItemAuction, FI_SupplierItemAuction, FI_ItemAuctionHall, FI_RMALocations, FI_RMAPendingItems, FI_ReturnRMAPendingItems, FI_ReturnRMALocations, FI_ReturnRMAReception, FI_RMAReport, FI_PreReceipt, FI_MaterialRequisition, FI_MaterialReqDel, FI_MaterialReqMod, FI_MaterialReqToPurchaseReq, MR_default, MR_status1, MR_status2, MR_status3, MR_status4, FI_PostPurchase, archiving, manifest, FA_PrePayment, SO_AssignUsers, FA_JournalPrintingAsk, ShowSalaryInfo, FI_QtyBudget, RI_Transfer, login_upload, FA_SourceFunds, FI_Tender, FI_TenderDel, FI_TenderMod, FI_TenderApp, RI_Tender, FI_SendNotification, FI_Paymentmode, trans_ModAfterPost, FU_MobileAccess, FI_DailyRoutSalesman, FA_JournalType, RI_TrackingRMA, RI_collectionReport, FI_FOLLOWUP, FS_UserSupportApp, FS_TicketProblemApp, FS_TicketSupportApp, FS_TicketVisitApp, FS_LocationSetupApp, FL_Logistic, FL_OperationLogisticApp, FS_TypeSetupApp, FL_OperationLogisticSetupApp, FL_TransporterLogisticsApp, FL_WaybillLogisticsApp, FL_ClosingFileLogisticsApp, Login_SOrderNegativeQty, Login_FLClientTracking, FA_SalesOrderJv, FA_SalesOrderJVDel, FA_SalesOrderJVMod, FA_SalesOrderJVApp, FI_SorderJVConfirmed, FS_TicketReport, FS_CloseTicket, FS_CompleteTicket, FI_RENTINVOICE, FI_RENTINVOICEApp, FI_RENTINVOICEMod, FI_RENTINVOICEDel, FU_Reminder, FU_ReminderApp, FU_ReminderMod, FU_ReminderDel, FI_ChangingTyre, RI_RentInvoice, FI_ChangingTyreApp, FI_ChangingTyreMod, FI_ChangingTyreDel, FI_SorderCancelAllQty, FI_productioncostvar, FI_SalesOrderDelItems, FI_itemlocation, FC_STAFF ";
		$query=$query." from login where User_account='$like_user' and Login_Schema='$txtSchema' ";

		
		// ") " 
		// 		." values ('".$user_code."','".$user_name."','".$txtSchema."','".$full_name."','".$user_description."',";
			
		// if ($config['EncryptPassMod'] == 1)
		// 	$query=$query."encryptpassword('".$user_password2."'), ";
		// else
		// 	$query=$query."'".$user_password2."', ";
		// 		$query=$query." 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,".
		// 				" 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
		// 				,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, '$login_language' ";
		// 		$query=$query." )";	

		$result=mysql_query($query,$connection);
		// echo $query;exit;
	
		if($result) fcommit();
		else frollback();


		
		
		$query3="insert into users
		select
		'".$user_name."', '".$user_code."',";
		
		
		if ($config['EncryptPassMod'] == 1)
		$query3=$query3."encryptpassword('".$user_password2."'), ";
		else
		$query3=$query3."'".$user_password2."', ";
		
		$query3=$query3."'".$full_name."','".$user_description."', DefaultComp, DefaultYear, Access, Access_UserManager, User_Signature, FullAccess, User_IsGroup, User_Group, Utilities, InvCreditLimit, Discount, DiscountMsgWarning, ModifyBelongsToGrp, User_logedintoinventory, User_logedintoaccounting, User_logedintopayroll, user_groupacc, user_email, user_query, BRANCH_CODE, employee_id, user_admin, deliverystatus_level, user_expirydate, user_deactivate, user_deactivate_date, user_complex_password, user_expiry, user_first_login, user_engineer, user_engineerqc, userType, user_type, user_securityChecked
		from users
		where user_account='".$like_user."'
		";

		$result3=mysql_query($query3,$connection);
		// echo $query3;exit;
	
		if($result3) fcommit();
		else frollback();

		$query4="insert into loginstk
		select
		'".$user_code."', project_code, costcent_code, group_code, subGroup_code, ID, Default_Project, Default_Costcenter, warehouse_code, project, costcenter, groups, subgroup, towarehouse_code, default_warehouse, default_warehouse_code, MasterProject, MasterCostCenter, ClientSalesmen, Machine_Code, Default_Machine, ShowReportHeader, TransferWH, empgroup, projectDt_id, projectDt_table, STRICTCOSTCENT, company_name
		from loginstk
		where user_account='".$like_user."'
		";

		$result4=mysql_query($query4,$connection);
		// echo $query4;exit;
	
		if($result4) fcommit();
		else frollback();
		
		$query5="insert into ledgerstk
		select
		'', '".$user_code."', ledger_number, ledger_include
		from ledgerstk
		where user_account='".$like_user."'
		";

		$result5=mysql_query($query5,$connection);
		// echo $query5;exit;
	
		if($result5) fcommit();
		else frollback();
		
		$query6="insert into ledgerrepstk
		select
		'', '".$user_code."', ledger_number, ledger_include
		from ledgerrepstk
		where user_account='".$like_user."'
		";

		$result6=mysql_query($query6,$connection);
		// echo $query6;exit;
	
		if($result6) fcommit();
		else frollback();


		$query7="insert into costcentstk
		select
		'', '".$user_code."', costcent_code, costcent_include, Reportshow, Formshowledger_number, ledger_include
		from costcentstk
		where user_account='".$like_user."'
		";

		$result7=mysql_query($query7,$connection);
		// echo $query7;exit;
	
		if($result7) fcommit();
		else frollback();
		

		$query8="insert into projectstk
		select
		'', '".$user_code."', project_code, project_include, Reportshow, Formshow
		from projectstk
		where user_account='".$like_user."'
		";

		$result8=mysql_query($query8,$connection);
		// echo $query8;exit;
	
		if($result8) fcommit();
		else frollback();

		
	}
	else if(!$result) frollback();
	
	$vTabFocus='Company/Year';
}

else if($actionmode=='RemoveSchema'){
	$query="delete from listuserdir 
			 where upper(concat(CompanyName,'_',Diryear))=upper('".$txtSchemaAssigned."') and usercode='".$user_code."'";
	//echo$query;exit;		
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	
	if($result){
		$query="delete from login  where upper(Login_Schema)=upper('".$txtSchemaAssigned."') and user_account='".$user_code."'";
		//echo$query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from loginstk where user_account='".$user_code."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);

		$query="Delete from ledgerstk where user_account='".$user_code."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from ledgerrepstk where user_account='".$user_code."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from costcentstk where user_account='".$user_code."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
		
		$query="Delete from projectstk where user_account='".$user_code."'";
		//echo $query;exit;
		$result=mysql_query($query,$connection);
	}
	$txtSchemaAssigned='';
	$txtApplication='';
	$vTabFocus='Company/Year';
}

if($like_user!=''){

	
		
	$query="insert into login
	select '".$user_name."', '".$user_code."', Login_Schema,";


if ($config['EncryptPassMod'] == 1)
$query=$query."encryptpassword('".$user_password2."'), ";
else
$query=$query."'".$user_password2."', ";



$query=$query."'".$full_name."','".$user_description."'
, Print, Access, Login_Delete, Login_Append, Costcenter, Project, Currency, 
Ledger, Budget, Keyboard_Layout, '$login_language', DefaultComp, DefaultYear, 
FullAccess, USR_CompanyAccess, USR_UserManager, USR_AppPriv, USR_FormAccess, 
USR_ReportOption, RMA_In, RMA_Out, ModifyVAT, InvCreditLimit, Login_Edit, DisplayBoth,
 Discount, DiscountMsgWarning, Post, Promotion, ReturnQuantity, Login_CardNo, login_belongstogrp, 
 ModifyBelongsToGrp, Bdgt_Reference, User_Signature, RetailInvoice, FC_CashRegister, FC_CashRegisterApp,
  FC_CashRegisterDel, FC_CashRegisterMod, FI_SalesVAT, FI_ReturnSalesVAT, FI_PurchasesVAT, FI_PurchasesVATMod, FI_ReturnPurchasesVAT, FA_SalesJvVAT, FA_PurchaseJV, FA_PurchaseJVMod, FA_PurchaseJVDel, FA_PurchaseJVApp, FA_PurchaseJVVAT, U_TransferItem, FI_SalesCheckSalesman, FI_RSalesCheckSalesman, FC_CashRegisterScroll, FC_CashRegisterCredit, 
  FC_CashRegisterCheck, FC_CashRegisterCoupon, FC_CashRegisterCustomer, FC_CashRegisterCash, 
  FC_CashRegisterDisc, FC_CashRegisterProm, FC_CashRegisterQtyRet, FI_Sizes, FI_SizesDel, FI_SizesMod, 
  FI_SizesApp, RA_ListOfPurchaseJv, FA_PurchaseJVCharge, FA_PrefixJV, Closing_RetailReport, FI_Color, FI_ColorMod, FI_ColorDel, FI_ColorApp, FI_ItemSelling1, FI_ItemSelling2, FI_ItemSelling3, FI_ItemSelling4, FI_ItemSelling5, FI_SOrderWithPrice, FI_SalesWithPrice, FC_PermToCancelCash, FI_ClientSalesmanComm, FI_SalebelowLandedCost, FC_CashRegisterClient, RI_LISTOFDUEITEMS, RA_StatementofProject, RA_ProfitandLoss, RA_PurchasesandSalesJV, RI_ListofItems, RI_ListofRMA, RI_InvoiceProject, RI_SalesStatistics, RA_ListofDueInvoices, FI_ShowCostPrice, FA_BalanceJV, Reports, Rep_General, Rep_Inventory, Rep_Accounting, RA_SalesmanComm, FC_RetailReport, RA_RequiredCostcenter, FA_LedgerAccess, ExporttoExcel, FixJVofSales, ModifyingOldTransactions, DailyInvoiceModification, FI_DIFFCOMPANY, AskBeforeCloseInv, AskBeforeCloseAcc, ShowDepositJVBtn, Show_group, Fi_itemselling6, Fc_forcingvendor, Rc_cashFlow, RC_ListOfInvoices, RC_SalesmenCommission, RC_ItemsSizes, FC_ShowBtnOpenDrawer, FC_AddClient, RC_ForcingUserAccount, FA_FIPAddress, FA_IPAddressApp, FA_IPAddressDel, FA_IPAddressMod, FA_IPAddPermToExceedCL, RA_ListOfInvoices, FA_ManagingRequiredCost, U_RePostTransaction, FC_AddCustomer, FC_ConfirmCustomer, FA_PaymentRqst, FA_PaymentRqstApp, FA_PaymentRqstMod, FA_PaymentRqstDel, FA_Client, FA_ClientDel, FA_ClientApp, FA_ClientMod, FA_ClientCreditLimit, FA_Currency, FA_CurrencyDel, FA_CurrencyApp, FA_CurrencyMod, FA_Supplier, FA_SupplierDel, FA_SupplierApp, FA_SupplierMod, FA_Project, FA_ProjectDel, FA_ProjectMod, FA_ProjectApp, FA_CostCenter, FA_CostCenterDel, FA_CostCenterMod, FA_CostCenterApp, RA_AccountReconciliation, FA_SalesJVModRef, LockedPeriod, AllowLockedPeriod, FI_PreProduction, FI_PreProductionMod, FI_PreProductionApp, FI_PreProductionDel, FP_Insurance, FP_InsuranceMod, FP_InsuranceApp, FP_InsuranceDel, FI_WayBill, FI_WayBillDel, FI_WayBillApp, FI_WayBillMod, FP_DetailGenerateDel, RI_YearlySales, RI_InvByEntryNo, RI_ListOfDeliveryQty, RI_OpInvForNewYear, DirectConsumption, RI_PorderReport, RI_ClientsSalesReport, ClientIP_Del, ClientIP_Mod, ClientIP_App, ClientIP_EndDate, ClientIP_LastTransDate, RI_YearlyPurchases, LockedPeriodDays, Rp_ReportR3, FI_SupplierGrp, FI_SupplierGrpApp, FI_SupplierGrpDel, FI_SupplierGrpMod, FI_ClientGrp, FI_ClientGrpApp, FI_ClientGrpDel, FI_ClientGrpMod, FA_ConfirmJV, FI_RVPostTransaction, FI_PVPostTransaction, FI_CVPostTransaction, FI_DVPostTransaction, FU_ClosingPeriod, FI_RepostPurchase, FI_RepostPReturn, FI_RepostSales, FI_RepostSReturn, FI_RepostDeliveries, FI_RepostDReturn, FI_RepostPorder, FI_RepostSorder, FI_RepostAdjustment, FP_ShowSalaryMvt, RI_listofPICharges, FP_ArabicReports, FP_EmpArabicInfo, FI_ITransfer, FI_ITransferApp, FI_ITransferMod, FI_ITransferDel, FI_PorderPurRequest, FI_SupplierGrpPurRequest, FP_Grades, FP_GradesApp, FP_GradesDel, FP_GradesMod, FP_Dept, FP_DeptApp, FP_DeptDel, FP_DeptMod, FP_Fpreemp, FP_preempApp, FP_preempDel, FP_preempMod, FP_Attendance, FP_Overtime, FP_AnalysisReport, FP_Project, FP_ProjectApp, FP_ProjectDel, FP_ProjectMod, FA_ExceedBudgetLimit, U_SendReceiveCriteria, RI_CltSaleR_ShowSalesman, RI_SaleR_ShowSalesman, Inventory, Accounting, PayRoll, Utilities, FA_Journal, FA_JournalApp, FA_JournalDel, FA_JournalMod, FA_Payment, FA_PaymentApp, FA_PaymentDel, FA_PaymentMod, FA_Receipt, FA_ReceiptDel, FA_ReceiptMod, FA_ReceiptApp, FA_CreditNote, FA_CreditNoteApp, FA_CreditNoteDel, FA_CreditNoteMod, FA_DebitNote, FA_DebitNoteDel, FA_DebitNoteMod, FA_DebitNoteApp, FA_FixedAssets, FA_FixedAssetsDel, FA_FixedAssetsMod, FA_FixedAssetsApp, FA_Charging, FA_ChargingDel, FA_ChargingMod, FA_ChargingApp, FA_ReportOptions, FA_Ledger, FA_LedgerDel, FA_LedgerMod, FA_LedgerApp, CurrencyDel, CurrencyApp, CurrencyMod, CostcenterDel, CostcenterMod, CostcenterApp, ProjectDel, ProjectMod, ProjectApp, Clients, ClientsDel, ClientsApp, ClientsMod, ClientsCreditLimit, FA_Budget, FA_BudgetDel, FA_BudgetMod, FA_BudgetApp, FA_AccountType, FA_AccountTypeDel, FA_AccountTypeMod, FA_AccountTypeApp, FA_SalesJV, FA_SalesJVMod, FA_SalesJVApp, FA_SalesJVDel, RA_GeneralLedger, RA_TransactionJV, RA_ListofRecPayDebCred, RA_ListofCheckBills, RA_IncomeStatBalanceSheet, RA_FinancialSummary, RA_MonthDistBudgetForCast, RA_TrialBalance, RA_StatementofAccount, RA_Aging, RA_PrePayment, RA_Amortization, RA_StatmentofDocument, RA_StatmentofCostcenter, RA_CreditLimitRoster, RA_IncomeStmt, RA_Query, FI_PurchaseOrder, FI_PurchaseOrderDel, FI_PurchaseOrderApp, FI_PurchaseOrderMod, FI_Purchases, FI_PurchasesDel, FI_PurchasesMod, FI_PurchasesApp, FI_ReturnPurchase, FI_ReturnPurchaseDel, FI_ReturnPurchaseMod, FI_ReturnPurchaseApp, FI_Rma, FI_RmaDel, FI_RmaApp, FI_RmaMod, FI_ReturnRma, FI_ReturnRmaDel, FI_ReturnRmaApp, FI_ReturnRmaMod, FI_SalesOrder, FI_SalesOrderDel, FI_SalesOrderApp, FI_SalesOrderMod, FI_Sales, FI_SalesDel, FI_SalesApp, FI_SalesMod, FI_SalesPrintReceipt, FI_ReturnSales, FI_ReturnSalesApp, FI_ReturnSalesMod, FI_ReturnSalesDel, FI_ReturnSalesPrintPay, FI_Delivery, FI_DeliveryDel, FI_DeliveryMod, FI_DeliveryApp, FI_ReturnDelivery, FI_ReturnDeliveryDel, FI_ReturnDeliveryApp, FI_ReturnDeliveryMod, FI_Transfer, FI_TransferDel, FI_TransferApp, FI_TransferMod, FI_Production, FI_ProductionDel, FI_ProductionApp, FI_ProductionMod, FI_Adjustment, FI_AdjustmentDel, FI_AdjustmentApp, FI_AdjustmentMod, FI_ReportOptions, FI_Items, FI_ItemsDel, FI_ItemsApp, FI_ItemsMod, FI_Warehouse, FI_WarehouseDel, FI_WarehouseMod, FI_WarehouseApp, FI_Area, FI_AreaDel, FI_AreaMod, FI_AreaApp, FI_Category, FI_CategoryDel, FI_CategoryApp, FI_CategoryMod, FI_Grouping, FI_GroupingDel, FI_GroupingApp, FI_GroupingMod, FI_SubGrouping, FI_SubGroupingDel, FI_SubGroupingMod, FI_SubGroupingApp, FI_Suppliers, FI_SuppliersDel, FI_SuppliersMod, FI_SuppliersApp, FI_Salesmen, FI_SalesmenDel, FI_SalesmenApp, FI_SalesmenMod, RI_SatementofItems, RI_Inventory, RI_ProfitperItems, RI_SalesReports, RI_PurchaseReports, RI_ListTransaction, RI_Packing, RI_ListofProduction, RI_ExpiryDate, RI_Options, RI_Query, FP_Employee, FP_EmployeeDel, FP_EmployeeMod, FP_EmployeeApp, FP_Bonus, FP_BonusDel, FP_BonusMod, FP_BonusApp, FP_Vacation, FP_VacationDel, FP_VacationMod, FP_VacationApp, FP_Loan, FP_LoanDel, FP_LoanMod, FP_LoanApp, FP_AttendanceDel, FP_AttendanceMod, FP_AttendanceApp, FP_Generate, FP_GenerateApp, FP_GenerateDel, FP_GenerateMod, FP_ReportOptions, FP_Parameters, FP_ParametersDel, FP_ParametersApp, FP_ParametersMod, RP_Employee, RP_TimeSheet, RP_CollectionofRepPay, RP_Evaluation, RP_BankStatement, RP_Query, U_NewYear, U_DeleteYear, U_CloseYear, U_NewCompany, U_DeleteCompany, U_CloseCompany, U_PostToLedger, U_PostToItems, U_PostToChecksAndBills, U_TransferAccount, U_DistributingCostcenter, U_ReNumberJV, U_FillSetupFile, U_RebuildIndexAcc, U_RebuildIndexInv, U_RebuildIndexPay, U_BackupFile, U_MergerDataBase, U_Trace, U_Query, U_CashRegister, U_Ports, FI_SellingPriceInItems, FI_CostPriceInItems, CGI, Access_UserManager, U_RebuildIndexAccLab, LoginAccess_DirYear, LoginAccess_Company, Posted, RI_Invoices, RI_ItemsPerWarehouseSize, FI_SorderConfirmed, Synchro, FA_Banks, FA_BankApp, FA_BankDel, FA_BankMod, RA_AgingOfClientInvoices, RA_FinancialAccounts, FI_DeliveryConfirmed, FI_PorderConfirmed, Login_ShowLoggedUser, Login_modAdjIsInvoice, FI_PricePerUnit, FC_CashRegisterSearch, FC_CashRegScrollPrint, FC_CashRegisterCancel, FC_CashRegisterPosting, FC_CashRegScrollOk, FA_SkipReference, FI_purchaseRequest, FI_purchaseRequestDel, FI_purchaseRequestApp, FI_purchaseRequestMod, FI_RepostRequest, FI_IN, FI_OUT, FI_INDel, FI_OUTDel, FI_INMod, FI_OUTMod, FI_INapp, FI_Outapp, login_AllowTimer, FI_ModConfirmedPO, FI_DelConfirmedPO, FI_StkEval, FI_StkEvalMod, FI_StkEvalApp, Fi_StkEvalDel, Default_Project, Default_Costcent, PRqst_Approvedby, FI_Transportation, FI_TransportationApp, FI_TransportationMod, FI_TransportationDel, Login_Decimal, Unmodify_SellingPrice, RI_StkMovement, RA_AvgDays, RA_SalesJV, RA_PurchasesJV, FI_SorderCanceledQty, ShowTransaction, fpr_changeweight, FA_ClientPaymentTerms, FA_Transformation, FA_TransformationAPP, FA_TransformationMod, FA_TransformationDel, FA_ProdRatio, FA_ProdRatioAPP, FA_ProdRatioMod, FA_ProdRatioDEL, Login_negativeQty, FI_BudgetInvDel, FI_BudgetInvMod, FI_BudgetInvApp, FI_FBudgetInv, FI_BudgetInvSetupDel, FI_BudgetInvSetupMod, FI_BudgetInvSetupApp, FI_FBudgetInvSetup, FI_BudgetInvAmendmentDel, FI_BudgetInvAmendmentMod, FI_BudgetInvAmendmentApp, FI_FBudgetInvAmendment, EDataCom, FA_transactionpaymnetrqst, FA_transactionpaymnetrqstdel, FA_transactionpaymnetrqstapp, FA_transactionpaymnetrqstmod, FI_stockeval, FI_stockevalapp, FI_stockevaldel, FI_stockevalmod, FI_CEPtable, FI_CEPtableapp, FI_CEPtabledel, FI_CEPtablemod, U_costcentertransfer, U_projecttransfer, Unmodify_SorderPrice, FI_deliveryrelease, login_disapprovesorder, FI_DeliveryReleaseMod, FI_DeliveryReleaseDel, FI_DeliveryReleaseApp, FA_DailyReport, RA_TabSheetPaymentRqst, RA_TabSheetBudget, RA_unmovedAcounts, RA_TabSheetMonthlyAmount, RA_InterrestRate, RI_PurchaseCategory, RI_TranspPage, 
  RI_TabSheetexport, RI_TabSheetrma, RI_tabsheetbooksbalance, RI_BudgetInvTabSheet, FI_SorderPosQty, FI_PurchaseCategory, FI_DeliverySalesPrice, FI_SorderRejectUnconfirmed, Login_AllowPrice, FI_Grn, FI_GrnDel, FI_GrnMod, FI_GrnApp, FC_CashRegisterAskPrint, FI_RepRestrictProject, FI_RepRestrictCostcenter, FI_RepRestrictWarehouse, Login_ModifyAllPending, RI_Aging, fastprintarchive, fastprinttransaction, Login_ModifyDiscount, FA_Contra, FA_ContraApp, FA_ContraMod, FA_ContraDel, FI_RmGrn, FI_RmGrnDel, FI_RmGrnMod, FI_RmGrnApp, FI_RmTransfer, FI_IRmTransferDel, FI_RmTransferMod, Fi_RmTransferapp, FI_SellingPriceModifyInItems, FI_ReturnGrn, FI_ReturnGrnDel, FI_ReturnGrnMod, FI_ReturnGrnApp, production, RP_generate, RP_TaxeDeclare, RI_CommissionByGroup, FI_RMASheetRMA, FI_RMASheetPending, FI_RMAReturnSheetReturnRMA, FI_RMAReturnSheetRMA, Login_FastPrint, Login_ModifySellingPrice, FI_SorderAskConfirm, FI_SalebelowCost, FI_SaleBelowDiscount, FI_SaleDiscountPer, 
  FI_SalesOrderModDelConfirmed, FI_Shipment, FI_Shipmentconfirmed, FI_ShipmentMod, FI_ShipmentDel, RI_GrnReports, FI_SalebelowLandedCostWarning, FI_MessageCenter, FC_SearchByCashRegister, RA_AgingOfSupplierInvoices, RA_StatisticsReport, RI_InvComparisonReport, login_queries, login_queiresEdit, RI_TargetRebateReport, RI_SalesOrderReport, RI_YEARLYCOMPARATIVEREPORT, RA_YEARLYCOMPARATIVEREPORT, FC_DiscountPerLimit, FI_ProductionTemp, FI_ProductionTempApp, FI_ProductionTempDel, FI_ProductionTempMod, FI_Charges, FI_Vehicle, FI_VehicleApp, FI_VehicleDel, FI_VehicleMod, FI_VehicleCharges, FI_VehicleChargesApp, FI_VehicleChargesDel, FI_VehicleChargesMod, FI_Place, FI_PlaceApp, FI_PlaceDel, FI_PlaceMod, FI_Employee, FI_EmployeeApp, FI_EmployeeDel, FI_EmployeeMod, Fi_vehicleservice, FI_VehicleServiceApp, FI_VehicleServiceDel, FI_VehicleServiceMod, FI_VehicleFuelType, FI_VehicleFuelTypeApp, FI_VehicleFuelTypeDel, FI_VehicleFuelTypeMod, FC_Tracking, FI_VehicleType, FI_VehicleTypeApp, FI_VehicleTypeDel, FI_VehicleTypeMod, FI_VehicleMOvement, FI_VehicleMovementDel, FI_VehicleMovementMod, FI_VehicleMovementApp, FI_ChargesApp, RI_INVENTORY2, FI_ChargesMod, FI_ChargesDel, FI_ProductionReq, FI_ProductionReqApp, FI_ProductionReqDel, FI_ProductionReqMod, FP_EmployeeRequest, FI_AllowEditIfDelivered, Login_CancelSorder, Allow_MinimumPrice, Login_Daily, Login_Weekly, Login_Monthly, Login_Limit, AllowedPaymentDirect, Branch_Manager, FI_ChangeInvoiceClient, FI_ChangeInvoiceItems, FA_TOPVAT, FI_FrmRestrictWarehouse, FP_Leave, FP_LeaveApp, FP_LeaveMod, FP_LeaveDel, FA_Amortization, logistics, FI_SalesmenCommission, FA_InvoicesAllocation, FI_VehcileLoad, FI_RetrunSaleOrder, FI_ReturnPurchaseOrder, CRM, FI_PRequestConfirmed, FI_PurchaseRequestItems, FI_PRETransfer, FA_Invoicing, FI_AdjustmentRequest, FI_OUTREQUEST, FI_OutappRequest, Login_FastPrintRequest, FI_TransferRequest, Fi_VehicleWeightChange, FC_CashRegisterClosing, FC_ShowBtnCancel, FC_CashRegisterDelItem, approved_level, FL_Proforma, FL_ProformaSetup, FL_ProformaMod, FL_ProformaDel, FL_ProformaApp, FL_ProformaSetupMod, FL_ProformaSetupDel, FL_ProformaSetupApp, fi_pendingpurchaserequest, fi_pendingtransferrequest, fi_pendingadjustmentrequest, FA_TransferFunds, fi_pendingpurchaseorder, PorderApproved_Level, PrequestApproved_Level, TransferRequestApproved_Level, AdjustmentRequestApproved_Level, RI_SoldbySalesman, FI_CustomerF, FI_CustomerDel, FI_CustomerApp, FI_CustomerMod, Fi_POS, RI_TopClientsSuppliers, fi_transferstockout, fi_purchasestockout, FI_ItemPricing, Perc_CreditLimit, RA_Statistics, RI_Statistics, FA_INTERRESTRATE, FI_statistics, FI_SorderAllowConfirmCash, Fi_VehicleMovementReport, Login_Mobile, FM_Visits, RM_DailyVisits, FM_Mobiles, FU_DataTransfer, FC_CashRegisterGift, FC_CashRegisterVoid, FC_CashRegisterWaste, FC_CashRegisterSetup, login_maturitydate, Login_TipsMaxAmount, Login_PReqApprove, Login_PReqReject, Login_PReqUndProc, Login_POrdApprove, Login_POrdReject, Login_TReqApprove, Login_TReqReject, Login_AReqApprove, Login_AReqReject, FI_PurchaseRequestItemPR, FI_PurchaseRequestItemAD, FI_PurchaseRequestItemPO, FI_PurchaseRequestItemTR, PR_default, PO_default, TR_default, AD_default, PR_status1, PR_status2, PR_status3, PR_status4, PR_status5, PR_status6, PR_status7, PR_status8, PR_status9, PR_status10, PR_status11, TR_status1, TR_status2, TR_status3, AD_status1, AD_status2, AD_status3, PO_status1, PO_status2, PO_status3, PO_status4, PO_status5, FC_ShowAllTables, PR_status12, PO_status6, PO_status7, FI_PendingPaymentRequest, PaymentRqstApproved_Level, PYR_default, PYR_status1, PYR_status2, PYR_status3, Login_MinAllowCostPer, Login_MaxAllowCostPer, FC_CashRegisterMenu, FC_CashRegisterHold, FI_ShowPriceHistory, FC_RetailStatistics, FC_SalesAnalysis, FI_DeliveryStatus, FI_heatNo, FI_StockOutRequest, Login_porderLimit, FC_RetailViewer, RI_Adjustment, PR_status13, Login_Purchase_Pending, User_confirm, FI_SetDeliveryStatus, FI_DeliveryStatusFrom, FI_DeliveryStatusTo, FI_ModInvStatusDlv, Login_location, Retail_Cancel, FI_itemTransfer, RI_Procurement, warehouse_excluded, FU_SalesmenTracking, FI_SalesmanDailyVisit, FU_Reason, FU_DeleteTempReceipt, FI_RetailCashOut, FI_Visit, RI_Visit, FI_ArchiveReports, FI_ReportsOptions, FI_PurchaseRequestItemsPR, FI_PurchaseRequestItemsPO, FI_PurchaseRequestItemsTR, FI_PurchaseRequestItemsAD, FC_SalesStatistic, FI_RoutingList, FA_PurchaseOrderJV, FI_NotRoutingList, FI_PorderJVConfirmed, RI_PricingList, FA_PurchaseOrderJVapp, FA_PurchaseOrderJVmod, FA_PurchaseOrderJVdel, FI_ReturnDeliveryConfirm, FA_SellingPrice, RI_ReportOptions, FI_DeleteMobileSorders, FI_DeleteMobileInvoices, FI_DeleteMobileReturnInvoices, is_superUser, FI_SalesOrderConfirm2, FI_CalculateRMReport, ShowBankInfo, ShowInsuranceInfo, FI_MultiplePosting, FI_DeliveryStatusItems, FI_FactoryProduction, login_outconfirm, FI_ItemAuction, FI_SupplierItemAuction, FI_ItemAuctionHall, FI_RMALocations, FI_RMAPendingItems, FI_ReturnRMAPendingItems, FI_ReturnRMALocations, FI_ReturnRMAReception, FI_RMAReport, FI_PreReceipt, FI_MaterialRequisition, FI_MaterialReqDel, FI_MaterialReqMod, FI_MaterialReqToPurchaseReq, MR_default, MR_status1, MR_status2, MR_status3, MR_status4, FI_PostPurchase, archiving, manifest, FA_PrePayment, SO_AssignUsers, FA_JournalPrintingAsk, ShowSalaryInfo, FI_QtyBudget, RI_Transfer, login_upload, FA_SourceFunds, FI_Tender, FI_TenderDel, FI_TenderMod, FI_TenderApp, RI_Tender, FI_SendNotification, FI_Paymentmode, trans_ModAfterPost, FU_MobileAccess, FI_DailyRoutSalesman, FA_JournalType, RI_TrackingRMA, RI_collectionReport, FI_FOLLOWUP, FS_UserSupportApp, FS_TicketProblemApp, FS_TicketSupportApp, FS_TicketVisitApp, FS_LocationSetupApp, FL_Logistic, FL_OperationLogisticApp, FS_TypeSetupApp, FL_OperationLogisticSetupApp, FL_TransporterLogisticsApp, FL_WaybillLogisticsApp, FL_ClosingFileLogisticsApp, Login_SOrderNegativeQty, Login_FLClientTracking, FA_SalesOrderJv, FA_SalesOrderJVDel, FA_SalesOrderJVMod, FA_SalesOrderJVApp, FI_SorderJVConfirmed, FS_TicketReport, FS_CloseTicket, FS_CompleteTicket, FI_RENTINVOICE, FI_RENTINVOICEApp, FI_RENTINVOICEMod, FI_RENTINVOICEDel, FU_Reminder, FU_ReminderApp, FU_ReminderMod, FU_ReminderDel, FI_ChangingTyre, RI_RentInvoice, FI_ChangingTyreApp, FI_ChangingTyreMod, FI_ChangingTyreDel, FI_SorderCancelAllQty, FI_productioncostvar, FI_SalesOrderDelItems, FI_itemlocation, FC_STAFF ";
$query=$query." from login where User_account='$like_user'  ";


// ") " 
// 		." values ('".$user_code."','".$user_name."','".$txtSchema."','".$full_name."','".$user_description."',";
	
// if ($config['EncryptPassMod'] == 1)
// 	$query=$query."encryptpassword('".$user_password2."'), ";
// else
// 	$query=$query."'".$user_password2."', ";
// 		$query=$query." 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,".
// 				" 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
// 				,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, '$login_language' ";
// 		$query=$query." )";	

$result=mysql_query($query,$connection);
// echo $query;exit;

if($result) fcommit();
else frollback();


$query2="insert into listuserdir
		select
		'".$user_code."','".$user_name."', CompanyName, Diryear, AllowLockedPeriod, LockedPeriod, LockedPeriodDays, 
		LockViewPeriod, ViewPeriodDate, ViewLockDaily, ViewNumberOfDays, FU_ProjectManagement, FU_DocumentTypes, 
		FC_ChangeRetailDate, FI_DeliveryWaybill, FI_VehicleMovementv2, FI_VehicleMovementReportv2, FC_viewAllZReport,
		FI_Recipes, FI_OUT2, FI_IN2, FI_Out2app, FI_IN2app, FI_OUT2Del, FI_IN2Del, FI_OUT2Mod, FI_IN2Mod, 
		FI_SellingPriceAdjust, FU_ProjectTemplateForm, FI_confirmPurchase, FI_confirmReturnPurchase, 
		FU_ListOfProjects, FI_PurAdminMod, FI_PurAdminDel, FI_EditPorderSearch, FI_ProductDescription, 
		RI_YearlyPurchases, RI_YearlyPurchasesOrder, FI_ShowPriceBase1, FI_BPPlan, FI_SellingPricePromo,
		FI_EditProductionSearch, FI_EditGRNSearch, FI_SuperUser_AdjustPorder, FI_itemLocApp, FI_itemLocMod, 
		FI_itemLocDel, FC_CashRegisterEditOnPrint, FC_CashRegisterTools, FI_bulkitemminmaxAdjust, FA_JobVisit, 
		FA_JobVisitApp, FA_JobVisitMod, FA_JobVisitDel, FA_JobVisitreport, FI_Repairsheet, FI_RepairsheetAPP, 
		FI_RepairsheetMOD, FI_RepairsheetDEL, FI_WorkOrderDel, FI_WorkOrderMod, FI_WorkOrderApp, FI_WorkOrder, 
		FI_WorkOrderReqDel, FI_WorkOrderReqMod, FI_WorkOrderReqApp, FI_WorkOrderReq, FI_CheckList, FI_Slippass, 
		FC_CashRegisterModitem, FI_StockTake, FI_StockTake_Mod, FI_StockTake_Del, FI_StockTake_App, 
		FA_ChangeBelongToGroup, FU_Setup
		from listuserdir
		where usercode='".$like_user."' 
		";
	
		$result2=mysql_query($query2,$connection);
		// echo $query;exit;
	
		$message= mysql_error();

$query3="insert into users
select
'".$user_name."', '".$user_code."',";


if ($config['EncryptPassMod'] == 1)
$query3=$query3."encryptpassword('".$user_password2."'), ";
else
$query3=$query3."'".$user_password2."', ";

$query3=$query3."'".$full_name."','".$user_description."', DefaultComp, DefaultYear, Access, Access_UserManager, User_Signature, FullAccess, User_IsGroup, User_Group, Utilities, InvCreditLimit, Discount, DiscountMsgWarning, ModifyBelongsToGrp, User_logedintoinventory, User_logedintoaccounting, User_logedintopayroll, user_groupacc, user_email, user_query, BRANCH_CODE, employee_id, user_admin, deliverystatus_level, user_expirydate, user_deactivate, user_deactivate_date, user_complex_password, user_expiry, user_first_login, user_engineer, user_engineerqc, userType, user_type, user_securityChecked
from users
where user_account='".$like_user."'
";

$result3=mysql_query($query3,$connection);
// echo $query3;exit;

if($result3) fcommit();
else frollback();

$query4="insert into loginstk
select
'".$user_code."', project_code, costcent_code, group_code, subGroup_code, ID, Default_Project, Default_Costcenter, warehouse_code, project, costcenter, groups, subgroup, towarehouse_code, default_warehouse, default_warehouse_code, MasterProject, MasterCostCenter, ClientSalesmen, Machine_Code, Default_Machine, ShowReportHeader, TransferWH, empgroup, projectDt_id, projectDt_table, STRICTCOSTCENT, company_name
from loginstk
where user_account='".$like_user."'
";

$result4=mysql_query($query4,$connection);
// echo $query4;exit;

if($result4) fcommit();
else frollback();

$query5="insert into ledgerstk
select
'', '".$user_code."', ledger_number, ledger_include
from ledgerstk
where user_account='".$like_user."'
";

$result5=mysql_query($query5,$connection);
// echo $query5;exit;

if($result5) fcommit();
else frollback();

$query6="insert into ledgerrepstk
select
'', '".$user_code."', ledger_number, ledger_include
from ledgerrepstk
where user_account='".$like_user."'
";

$result6=mysql_query($query6,$connection);
// echo $query6;exit;

if($result6) fcommit();
else frollback();


$query7="insert into costcentstk
select
'', '".$user_code."', costcent_code, costcent_include, Reportshow, Formshowledger_number, ledger_include
from costcentstk
where user_account='".$like_user."'
";

$result7=mysql_query($query7,$connection);
// echo $query7;exit;

if($result7) fcommit();
else frollback();


$query8="insert into projectstk
select
'', '".$user_code."', project_code, project_include, Reportshow, Formshow
from projectstk
where user_account='".$like_user."'
";

$result8=mysql_query($query8,$connection);
// echo $query8;exit;

if($result8) fcommit();
else frollback();





	
}

if($txtSchemaAssigned!='' ){
	$query="Select count(*) from login where upper(login_schema)=upper('".$txtSchemaAssigned."') and upper(user_account)=upper('".$user_code."')";
	//echo$query;exit;
	$result=mysql_query($query,$connection);
	$row=mysql_fetch_row($result);
	$count=$row[0];
}


if($count==0 && $count!=''){
	
	$query="insert into login(User_account,User_name,Login_Schema,Fullname,Description,User_password) ".
			" values ('".$user_code."','".$user_name."','".$txtSchemaAssigned."','".$full_name."','".$user_description."',";
			
	if ($config['EncryptPassMod'] == 1)
		$query=$query."encryptpassword('".$user_password2."') ";
	else
		$query=$query."'".$user_password2."' ";	
	$query=$query." )";	
	
	//echo$query;exit;	
	$result=mysql_query($query,$connection);	

}

if($txtSchemaAssigned!='' && $actionmode!='AddSchema' ){

if ($prequestapproved_level == '') 			$prequestapproved_level				= "NULL";
if ($porderapproved_level == '') 			$porderapproved_level				= "NULL";
if ($approved_level == '') 					$approved_level						= "NULL";
if ($transferrequestapproved_level == '') 	$transferrequestapproved_level 		= "NULL";
if ($adjustmentrequestapproved_level == '')	$adjustmentrequestapproved_level 	= "NULL";
// echo $FI_RENTINVOICE;exit;
$query="update login set  ".
		" FA_AccountType=$FA_AccountType1,FA_AccountTypeApp=$FA_AccountTypeApp,FA_AccountTypeMod=$FA_AccountTypeMod,FA_AccountTypeDel=$FA_AccountTypeDel,".
		" FA_FixedAssets=$FA_FixedAssets1,FA_FixedAssetsApp=$FA_FixedAssetsApp1,FA_FixedAssetsMod=$FA_FixedAssetsMod,FA_FixedAssetsDel=$FA_FixedAssetsDel,".
		" FI_Area=$FI_Area1,FI_AreaApp=$FI_AreaApp,FI_AreaMod=$FI_AreaMod,FI_AreaDel=$FI_AreaDel,".
		" FA_Banks=$FA_Banks1,FA_BankApp=$FA_BankApp,FA_BankMod=$FA_BankMod,FA_BankDel=$FA_BankDel,".
		" FA_Budget=$FA_Budget1,FA_BudgetApp=$FA_BudgetApp,FA_BudgetMod=$FA_BudgetMod,FA_BudgetDel=$FA_BudgetDel,".
		" FA_Charging=$FA_Charging1,FA_ChargingApp=$FA_ChargingApp,FA_ChargingMod=$FA_ChargingMod,FA_ChargingDel=$FA_ChargingDel,".
		" FA_Contra=$FA_Contra1,FA_ContraApp=$FA_ContraApp,FA_ContraMod=$FA_ContraMod,FA_ContraDel=$FA_ContraDel,".
		" FA_Costcenter=$FA_Costcenter1,FA_CostcenterApp=$FA_CostcenterApp,FA_CostcenterMod=$FA_CostcenterMod,FA_CostcenterDel=$FA_CostcenterDel,".
		" FA_CreditNote=$FA_CreditNote1,FA_CreditNoteApp=$FA_CreditNoteApp,FA_CreditNoteMod=$FA_CreditNoteMod,FA_CreditNoteDel=$FA_CreditNoteDel,".
		" FA_Currency=$FA_Currency1,FA_CurrencyApp=$FA_CurrencyApp,FA_CurrencyMod=$FA_CurrencyMod,FA_CurrencyDel=$FA_CurrencyDel,".
		" FA_DebitNote=$FA_DebitNote1,FA_DebitNoteApp=$FA_DebitNoteApp,FA_DebitNoteMod=$FA_DebitNoteMod,FA_DebitNoteDel=$FA_DebitNoteDel,".
		" RA_FinancialAccounts=$RA_FinancialAccounts1,".
		" FA_Journal=$FA_Journal1,FA_JournalApp=$FA_JournalApp,FA_JournalMod=$FA_JournalMod,FA_JournalDel=$FA_JournalDel,".
		" FA_InvoicesAllocation=$FA_InvoicesAllocation1,".
		" FA_Ledger=$FA_Ledger1,FA_LedgerApp=$FA_LedgerApp,FA_LedgerMod=$FA_LedgerMod,FA_LedgerDel=$FA_LedgerDel,".
		" FA_Payment=$FA_Payment1,FA_PaymentApp=$FA_PaymentApp,FA_PaymentMod=$FA_PaymentMod,FA_PaymentDel=$FA_PaymentDel,".
		" FA_PurchaseOrderJVApp=$FA_PurchaseOrderJVApp,FA_PurchaseOrderJVMod=$FA_PurchaseOrderJVMod,FA_PurchaseOrderJVDel=$FA_PurchaseOrderJVDel,".
		" FA_PaymentRqst=$FA_PaymentRqst1,FA_PurchaseOrderJV=$FA_PurchaseOrderJV1,FA_PaymentRqstApp=$FA_PaymentRqstApp,FA_PaymentRqstMod=$FA_PaymentRqstMod,FA_PaymentRqstDel=$FA_PaymentRqstDel,".
		" FA_Project=$FA_Project1,FA_ProjectApp=$FA_ProjectApp,FA_ProjectMod=$FA_ProjectMod,FA_ProjectDel=$FA_ProjectDel,".
		" FA_PurchaseJV=$FA_PurchaseJV1,FA_PurchaseJVApp=$FA_PurchaseJVApp,FA_PurchaseJVMod=$FA_PurchaseJVMod,FA_PurchaseJVDel=$FA_PurchaseJVDel,".
		" FA_Receipt=$FA_Receipt1,FA_ReceiptApp=$FA_ReceiptApp,FA_ReceiptMod=$FA_ReceiptMod,FA_ReceiptDel=$FA_ReceiptDel,".
		" FA_ReportOptions=$FA_ReportOptions1,".
		" FA_SalesJV=$FA_SalesJV1,FA_SalesJVApp=$FA_SalesJVApp,FA_SalesJVMod=$FA_SalesJVMod,FA_SalesJVDel=$FA_SalesJVDel,".
		" FA_transactionpaymnetrqst=$FA_transactionpaymnetrqst1,FA_transactionpaymnetrqstApp=$FA_transactionpaymnetrqstApp,FA_transactionpaymnetrqstMod=$FA_transactionpaymnetrqstMod,FA_transactionpaymnetrqstDel=$FA_transactionpaymnetrqstDel,".
		" FI_PurchaseRequestItemTR=$FI_PurchaseRequestItemTR,FI_Adjustment=$FI_Adjustment1,FI_AdjustmentApp=$FI_AdjustmentApp,FI_AdjustmentMod=$FI_AdjustmentMod,FI_AdjustmentDel=$FI_AdjustmentDel,".
		" FI_FBudgetInv=$FI_BudgetInv1,FI_BudgetInvApp=$FI_BudgetInvApp,FI_BudgetInvMod=$FI_BudgetInvMod,FI_BudgetInvDel=$FI_BudgetInvDel,".
		" FI_FBudgetInvAmendment=$FI_FBudgetInvAmendment1,FI_BudgetInvAmendmentApp=$FI_BudgetInvAmendmentApp,FI_BudgetInvAmendmentMod=$FI_BudgetInvAmendmentMod,FI_BudgetInvAmendmentDel=$FI_BudgetInvAmendmentDel,".
		" FI_FBudgetInvSetup=$FI_FBudgetInvSetup1,FI_BudgetInvSetupApp=$FI_BudgetInvSetupApp,FI_BudgetInvSetupMod=$FI_BudgetInvSetupMod,FI_BudgetInvSetupDel=$FI_BudgetInvSetupDel,".
		" FI_Category=$FI_Category1,FI_CategoryApp=$FI_CategoryApp,FI_CategoryMod=$FI_CategoryMod,FI_CategoryDel=$FI_CategoryDel,".
		" FI_CEPtable=$FI_CEPtable1,FI_CEPtableApp=$FI_CEPtableApp,FI_CEPtableMod=$FI_CEPtableMod,FI_CEPtableDel=$FI_CEPtableDel,".
		" FI_Charges=$FI_Charges1,FI_ChargesApp=$FI_ChargesApp,FI_ChargesMod=$FI_ChargesMod,FI_ChargesDel=$FI_ChargesDel,".
		" Clients=$Clients1,ClientsApp=$ClientApp,ClientsMod=$ClientMod,ClientsDel=$ClientDel,".
		" FI_ClientGrp=$FI_ClientGrp1,FI_ClientGrpApp=$FI_ClientGrpApp,FI_ClientGrpMod=$FI_ClientGrpMod,FI_ClientGrpDel=$FI_ClientGrpDel,".
		" FI_Delivery=$FI_Delivery1,FI_DeliveryApp=$FI_DeliveryApp,FI_DeliveryMod=$FI_DeliveryMod,FI_DeliveryDel=$FI_DeliveryDel,".
		" FI_Grouping=$FI_Grouping1,FI_GroupingApp=$FI_GroupingApp,FI_GroupingMod=$FI_GroupingMod,FI_GroupingDel=$FI_GroupingDel,".
		" FI_Items=$FI_Items1,FI_ItemsApp=$FI_ItemsApp,FI_ItemsMod=$FI_ItemsMod,FI_ItemsDel=$FI_ItemsDel,".
		" FI_itemlocation=$FI_itemlocation,FI_Production=$FI_Production1,FI_ProductionApp=$FI_ProductionApp,FI_ProductionMod=$FI_ProductionMod,FI_ProductionDel=$FI_ProductionDel,".
		" FI_ProductionReq=$FI_ProductionReq1,FI_ProductionReqApp=$FI_ProductionReqApp,FI_ProductionReqMod=$FI_ProductionReqMod,FI_ProductionReqDel=$FI_ProductionReqDel,".
		" FI_ProductionTemp=$FI_ProductionTemp1,FI_ProductionTempApp=$FI_ProductionTempApp,FI_ProductionTempMod=$FI_ProductionTempMod,FI_ProductionTempDel=$FI_ProductionTempDel,".
		" FI_Purchases=$FI_Purchases1,FI_PurchasesApp=$FI_PurchasesApp,FI_PurchasesMod=$FI_PurchasesMod,FI_PurchasesDel=$FI_PurchasesDel,".
		" FI_Grn=$FI_Grn1,FI_GrnApp=$FI_GrnApp,FI_GrnMod=$FI_GrnMod,FI_GrnDel=$FI_GrnDel,".
		" FI_ReportOptions=$FI_ReportOptions1,".
		" FI_PurchaseOrder=$FI_PurchaseOrder1,FI_PurchaseOrderApp=$FI_PurchaseOrderApp,FI_PurchaseOrderMod=$FI_PurchaseOrderMod,FI_PurchaseOrderDel=$FI_PurchaseOrderDel,".
		" FI_PurchaseRequest=$FI_PurchaseRequest1,FI_PurchaseRequestApp=$FI_PurchaseRequestApp,FI_PurchaseRequestMod=$FI_PurchaseRequestMod,FI_PRequestConfirmed=$FI_PRequestConfirmed,FI_PurchaseRequestDel=$FI_PurchaseRequestDel,".
		" FI_ReturnDelivery=$FI_ReturnDelivery1,FI_ReturnDeliveryApp=$FI_ReturnDeliveryApp,FI_ReturnDeliveryMod=$FI_ReturnDeliveryMod,FI_ReturnDeliveryDel=$FI_ReturnDeliveryDel,".
		" FI_ReturnPurchase=$FI_ReturnPurchase1,FI_ReturnPurchaseApp=$FI_ReturnPurchaseApp,FI_ReturnPurchaseMod=$FI_ReturnPurchaseMod,FI_ReturnPurchaseDel=$FI_ReturnPurchaseDel,".
		" FI_ReturnGrn=$FI_ReturnGrn1,FI_ReturnGrnApp=$FI_ReturnGrnApp,FI_ReturnGrnMod=$FI_ReturnGrnMod,FI_ReturnGrnDel=$FI_ReturnGrnDel,".
		" FI_ReturnRma=$FI_ReturnRma1,FI_ReturnRmaApp=$FI_ReturnRmaApp,FI_ReturnRmaMod=$FI_ReturnRmaMod,FI_ReturnRmaDel=$FI_ReturnRmaDel,".
		" FI_ReturnSales=$FI_ReturnSales1,FI_ReturnSalesApp=$FI_ReturnSalesApp,FI_ReturnSalesMod=$FI_ReturnSalesMod,FI_ReturnSalesDel=$FI_ReturnSalesDel,".
		" FI_RmTransfer=$FI_RRmTransfer1,FI_RmTransferApp=$FI_RmTransferApp,FI_RmTransferMod=$FI_RmTransferMod,FI_IRmTransferDel=$FI_IRmTransferDel,".
		" FI_Rma=$FI_Rma1,FI_RmaApp=$FI_RmaApp,FI_RmaMod=$FI_RmaMod,FI_RmaDel=$FI_RmaDel,".
		" FI_Sales=$FI_Sales1,FI_SalesApp=$FI_SalesApp,FI_SalesMod=$FI_SalesMod,FI_SalesDel=$FI_SalesDel,".
		" FI_SalesOrder=$FI_SalesOrder1,FI_SalesOrderApp=$FI_SalesOrderApp,FI_SalesOrderMod=$FI_SalesOrderMod,FI_SalesOrderDel=$FI_SalesOrderDel,".
		" FI_Salesmen=$FI_Salesmen1,FI_SalesmenApp=$FI_SalesmenApp,FI_SalesmenMod=$FI_SalesmenMod,FI_SalesmenDel=$FI_SalesmenDel,".
		" FI_Shipment=$FI_Shipment1,FI_ShipmentMod=$FI_ShipmentMod,FI_ShipmentDel=$FI_ShipmentDel,".
		" FI_stockeval=$FI_stockeval1,FI_stockevalApp=$FI_stockevalApp,FI_stockevalMod=$FI_stockevalMod,FI_stockevalDel=$FI_stockevalDel,".
		" FI_SubGrouping=$FI_SubGrouping1,FI_SubGroupingApp=$FI_SubGroupingApp,FI_SubGroupingMod=$FI_SubGroupingMod,FI_SubGroupingDel=$FI_SubGroupingDel,".
		" FI_Suppliers=$FI_Suppliers1,FI_SuppliersApp=$FI_SuppliersApp,FI_SuppliersMod=$FI_SuppliersMod,FI_SuppliersDel=$FI_SuppliersDel,".
		" FI_SupplierGrp=$FI_SupplierGrp1,FI_SupplierGrpApp=$FI_SupplierGrpApp,FI_SupplierGrpMod=$FI_SupplierGrpMod,FI_SupplierGrpDel=$FI_SupplierGrpDel,".
		" FI_Transfer=$FI_Transfer1,FI_TransferApp=$FI_TransferApp,FI_TransferMod=$FI_TransferMod,FI_TransferDel=$FI_TransferDel,".
		" FI_ITransfer=$FI_ITransfer1,FI_ITransferApp=$FI_ITransferApp,FI_ITransferMod=$FI_ITransferMod,FI_ITransferDel=$FI_ITransferDel,".
		" FI_Transportation=$FI_Transportation1,FI_TransportationApp=$FI_TransportationApp,FI_TransportationMod=$FI_TransportationMod,FI_TransportationDel=$FI_TransportationDel,".
		" FI_Warehouse=$FI_Warehouse1,FI_WarehouseApp=$FI_WarehouseApp,FI_WarehouseMod=$FI_WarehouseMod,FI_WarehouseDel=$FI_WarehouseDel,".
		" FI_WayBill=$FI_WayBill1,FI_WayBillApp=$FI_WayBillApp,FI_WayBillMod=$FI_WayBillMod,FI_WayBillDel=$FI_WayBillDel,".
		" payroll=$payroll1,FP_Attendance=$FP_Attendance1,FP_AttendanceApp=$FP_AttendanceApp,FP_AttendanceMod=$FP_AttendanceMod,FP_AttendanceDel=$FP_AttendanceDel,".
		" FP_Bonus=$FP_Bonus1,FP_BonusApp=$FP_BonusApp,FP_BonusMod=$FP_BonusMod,FP_BonusDel=$FP_BonusDel,".
		" FP_Dept=$FP_Dept1,FP_DeptApp=$FP_DeptApp,FP_DeptMod=$FP_DeptMod,FP_DeptDel=$FP_DeptDel,".
		" FP_Employee=$FP_Employee1,FP_EmployeeApp=$FP_EmployeeApp,FP_EmployeeMod=$FP_EmployeeMod,FP_EmployeeDel=$FP_EmployeeDel,".
		" FP_Generate=$FP_Generate1,FP_GenerateApp=$FP_GenerateApp,FP_GenerateMod=$FP_GenerateMod,FP_GenerateDel=$FP_GenerateDel,".
		" FP_Grades=$FP_Grades1,FP_GradesApp=$FP_GradesApp,FP_GradesMod=$FP_GradesMod,FP_GradesDel=$FP_GradesDel,".
		" FP_Insurance=$FP_Insurance1,FP_InsuranceApp=$FP_InsuranceApp,FP_InsuranceMod=$FP_InsuranceMod,FP_InsuranceDel=$FP_InsuranceDel,".
		" FP_Loan=$FP_Loan1,FP_LoanApp=$FP_LoanApp,FP_LoanMod=$FP_LoanMod,FP_LoanDel=$FP_LoanDel,".
		" FP_Parameters=$FP_Parameters1,FP_ParametersApp=$FP_ParametersApp,FP_ParametersMod=$FP_ParametersMod,FP_ParametersDel=$FP_ParametersDel,".
		" FP_Fpreemp=$FP_Fpreemp1,FP_preempApp=$FP_preempApp,FP_preempMod=$FP_preempMod,FP_preempDel=$FP_preempDel,".
		" FP_Project=$FP_Project1,FP_ProjectApp=$FP_ProjectApp,FP_ProjectMod=$FP_ProjectMod,FP_ProjectDel=$FP_ProjectDel,".
		" FP_ReportOptions=$FP_ReportOptions1,".
		" FP_Vacation=$FP_Vacation1,FP_VacationApp=$FP_VacationApp,FP_VacationMod=$FP_VacationMod,FP_VacationDel=$FP_VacationDel,".
		
		" RA_StatementofAccount=$RA_StatementofAccount1,".
		" RA_Trialbalance=$RA_Trialbalance1,".
		" RA_StatementofProject=$RA_StatementofProject1,".
		" RA_StatmentofCostcenter=$RA_StatmentofCostcenter1,".
		" RA_Aging=$RA_Aging1,".
		" RA_AgingOfSupplierInvoices=$RA_AgingOfSupplierInvoices1,".
		" RA_AgingOfClientInvoices=$RA_AgingOfClientInvoices1,".
		" RA_FinancialAccounts=$RA_FinancialAccounts1,".
		" FA_DailyReport=$FA_DailyReport1,".
		" RA_StatisticsReport=$RA_StatisticsReport1,".
		" RA_SalesJV=$RA_SalesJV1,".
		" RA_TransactionJV=$RA_TransactionJV1,".
		" RA_PurchasesJV=$RA_PurchasesJV1,".
		" RA_GeneralLedger=$RA_GeneralLedger1,".
		" RI_ListTransaction=$RI_ListTransaction1,".
		" RI_Inventory=$RI_Inventory1,".
		" RI_SalesReports=$RI_SalesReports1,".
		" FI_PorderPurRequest=$FI_PorderPurRequest1,".
		" RI_SatementofItems=$RI_SatementofItems1,".
		" RI_YearlySales=$RI_YearlySales1,".
		" RI_TrackingRMA=$RI_TrackingRMA1,".
		" RI_Aging=$RI_Aging1,".
		" RI_InvComparisonReport=$RI_InvComparisonReport1,".
		" RI_TargetRebateReport=$RI_TargetRebateReport1,".
		" RI_PorderReport=$RI_PorderReport1,".
		" RI_PurchaseReports=$RI_PurchaseReports1,".
		" RI_SalesOrderReport=$RI_SalesOrderReport1, ".
		" RI_GrnReports=$RI_GrnReports1,".
		" RI_ListofProduction=$RI_ListofProduction1, ".
		" FI_SalebelowLandedCost=$FI_SalebelowLandedCost,".
		" fastprinttransaction=$fastprinttransaction,".
		" Posted=$Posted,".
		
		" ExporttoExcel=$ExporttoExcel,".
		" FI_ShowCostPrice=$FI_ShowCostPrice,".
		" Unmodify_SellingPrice=$Unmodify_SellingPrice,".
		" FA_LedgerAccess=$FA_LedgerAccess,".
		" DailyInvoiceModification=$DailyInvoiceModification,".
		" FixJVofSales=$FixJVofSales,".
		" ShowTransaction=$ShowTransaction,".
		" ModifyingOldTransactions=$ModifyingOldTransactions,".
		" ShowDepositJVBtn=$ShowDepositJVBtn,".
		" FA_ManagingRequiredCost=$FA_ManagingRequiredCost,".
		" AskBeforeCloseAcc=$AskBeforeCloseAcc,".
		" Show_group=$Show_group,".
		" RA_RequiredCostcenter=$RA_RequiredCostcenter,".
		" Login_negativeQty=$Login_negativeQty,".
		" AskBeforeCloseInv=$AskBeforeCloseInv,".
		" ModifyVAT=$ModifyVAT,".
		" RI_OpInvForNewYear=$RI_OpInvForNewYear,".
		" Login_ModifyAllPending=$Login_ModifyAllPending,".
		" Login_modAdjIsInvoice=$Login_modAdjIsInvoice,".
		
		" FI_PricePerUnit=$FI_PricePerUnit,".
		" Login_ShowLoggedUser=$Login_ShowLoggedUser,".
		" Login_ModifyDiscount=$Login_ModifyDiscount,".
		" FI_RepRestrictProject=$FI_RepRestrictProject,".
		" FI_RepRestrictCostcenter=$FI_RepRestrictCostcenter,".
		" FI_RepRestrictWarehouse=$FI_RepRestrictWarehouse, ".
		" RMA_In='".$RMA_In."', ".
		" RMA_Out='".$RMA_Out."', ".
		" Login_Decimal='".$Login_Decimal."', ".
		" login_belongstogrp=".$belongtogrp.", ".
		" Accounting='".$Accounting1."', ".
		" Inventory='".$Inventory1."', ".
	
		" Edatacom='".$Edatacom1."', ".
		" Utilities='".$Utilities."', ".
		" U_RePostTransaction='".$U_RePostTransaction."', ".
		" FA_ExceedBudgetLimit=$FA_ExceedBudgetLimit1, ".
		" FI_RVPostTransaction=$FI_RVPostTransaction1, ".
		" FI_RepostAdjustment=$FI_RepostAdjustment1, ".
		" ClientsCreditLimit=$ClientsCreditLimit1, ".
		" FI_DeliverySalesPrice=$FI_DeliverySalesPrice1, ".
		" FI_SellingPriceInItems=$FI_SellingPriceInItems1, ".
		" FI_CostPriceInItems=$FI_CostPriceInItems1, ".
		" FI_ItemSelling1=$FI_ItemSelling1, ".
		" FI_ItemSelling2=$FI_ItemSelling2, ".
		" FI_ItemSelling3=$FI_ItemSelling3, ".
		" FI_ItemSelling4=$FI_ItemSelling4, ".
		" FI_ItemSelling5=$FI_ItemSelling5, ".
		" FI_ItemSelling6=$FI_ItemSelling6, ".
		" FI_PurchaseCategory=$FI_PurchaseCategory1, ".
		" FI_PurchasesVATMod=$FI_PurchasesVATMod1, ".
		" FI_RepostPurchase=$FI_RepostPurchase1, ".
		" FI_PorderConfirmed=$FI_PorderConfirmed1, ".
		" FI_DelConfirmedPO=$FI_DelConfirmedPO1, ".
		" FI_ModConfirmedPO=$FI_ModConfirmedPO1, ".
		" FI_RepostPorder=$FI_RepostPorder1, ".
		" PRqst_Approvedby=$PRqst_Approvedby1,  ".
		" FI_ReturnPurchasesVAT=$FI_ReturnPurchasesVAT1,  ".
		" FI_RepostPReturn=$FI_RepostPReturn1,  ".
		" FI_RMAReturnSheetReturnRMA=$FI_RMAReturnSheetReturnRMA1,  ".
		" FI_RMAReturnSheetRMA=$FI_RMAReturnSheetRMA1,  ".
		" FI_RSalesCheckSalesman=$FI_RSalesCheckSalesman1,  ".
		" FI_ReturnSalesVAT=$FI_ReturnSalesVAT1,  ".
		" FI_ReturnSalesPrintPay=$FI_ReturnSalesPrintPay1,  ".
		" FI_RepostSReturn=$FI_RepostSReturn1 , ".
		" FI_RMASheetPending=$FI_RMASheetPending1 , ".
		" FI_RMASheetRMA=$FI_RMASheetRMA1,  ".
		" FI_SalesCheckSalesman=$FI_SalesCheckSalesman1,  ".
		" FI_SalesVAT=$FI_SalesVAT1,  ".
		" FI_SalesWithPrice=$FI_SalesWithPrice1,  ".
		" FI_SalesPrintReceipt=$FI_SalesPrintReceipt1,  ".
		" FI_RepostSales=$FI_RepostSales1,  ".
		" FI_SOrderWithPrice=$FI_SOrderWithPrice1,  ".
		" FI_SorderCanceledQty=$FI_SorderCanceledQty1 , ".
		" FI_SorderConfirmed=$FI_SorderConfirmed1, ".
		" login_disapprovesorder=$login_disapprovesorder1, ".
		" Unmodify_SorderPrice=$Unmodify_SorderPrice1, ".
		" Login_AllowPrice=$Login_AllowPrice1, ".
		" FI_RepostSorder=$FI_RepostSorder1, ".
		" FI_SorderPosQty=$FI_SorderPosQty1, ".
		" FP_DetailGenerateDel=$FP_DetailGenerateDel1, ".
		" FP_AnalysisReport=$FP_AnalysisReport1, ".
		" FP_ArabicReports=$FP_ArabicReports1, ".
		" RP_BankStatement=$RP_BankStatement1, ".
		" RP_CollectionofRepPay=$RP_CollectionofRepPay1, ".
		" RP_Employee=$RP_Employee1, ".
		" RP_Evaluation=$RP_Evaluation1, ".
		" FP_Overtime=$FP_Overtime1, ".
		" RP_Query=$RP_Query1, ".
		" RP_TimeSheet=$RP_TimeSheet1, ".
		" Rep_Accounting=$Rep_Accounting1, ".
		" Rep_Inventory=$Rep_Inventory1, ".
		" Rep_General=$Rep_General1, ".
		" RA_Amortization=$RA_Amortization1, ".
		" RA_AvgDays=$RA_AvgDays1, ".
		" RA_TabSheetBudget=$RA_TabSheetBudget1, ".
		" RA_CreditLimitRoster=$RA_CreditLimitRoster1, ".
		" RA_IncomeStmt=$RA_IncomeStmt1, ".
		" RA_IncomeStatBalanceSheet=$RA_IncomeStatBalanceSheet1, ".
		" FA_InterrestRate=$FA_InterrestRate1, ".
		" RA_ListofCheckBills=$RA_ListofCheckBills1, ".
		" RA_ListofDueInvoices=$RA_ListofDueInvoices1, ".
		" RA_ListofRecPayDebCred=$RA_ListofRecPayDebCred1, ".
		" RA_MonthDistBudgetForCast=$RA_MonthDistBudgetForCast1, ".
		" RA_TabSheetPaymentRqst=$RA_TabSheetPaymentRqst1, ".
		" RA_PrePayment=$RA_PrePayment1, ".
		
		" RA_Query=$RA_Query1, ".
		" RA_AccountReconciliation=$RA_AccountReconciliation1, ".
		" RA_SalesmanComm=$RA_SalesmanComm1, ".
		" RA_unmovedAcounts=$RA_unmovedAcounts1, ".
		" RI_tabsheetbooksbalance=$RI_tabsheetbooksbalance1, ".
		" RI_BudgetInvTabSheet=$RI_BudgetInvTabSheet1, ".
		" RI_TabSheetexport=$RI_TabSheetexport1, ".
		" RI_InvByEntryNo=$RI_InvByEntryNo1, ".
		" RI_Invoices=$RI_Invoices1, ".
		" RI_ItemsPerWarehouseSize=$RI_ItemsPerWarehouseSize1, ".
		" RI_ListOfDeliveryQty=$RI_ListOfDeliveryQty1, ".
		" RI_LISTOFDUEITEMS=$RI_LISTOFDUEITEMS1, ".
		" RI_ListofItems=$RI_ListofItems1, ".
		" RI_listofPICharges=$RI_listofPICharges1, ".
		" RI_ListofRMA=$RI_ListofRMA1, ".
		" RI_Packing=$RI_Packing1, ".
		" RI_ExpiryDate=$RI_ExpiryDate, ".
		" RI_ProfitperItems=$RI_ProfitperItems1, ".
		" RI_Query=$RI_Query1, ".
		" RI_SalesStatistics=$RI_SalesStatistics1, ".
		" RI_SoldbySalesman=$RI_SoldbySalesman1, ".
		" RI_StkMovement=$RI_StkMovement1, ".
		" RI_TranspPage=$RI_TranspPage1, ".
		" RI_CltSaleR_ShowSalesman=$RI_CltSaleR_ShowSalesman1, ".
		" FC_CashRegister=$FC_CashRegister1, ".
		" FC_CashRegisterApp=$FC_CashRegisterApp, ".
		" FC_CashRegisterMod=$FC_CashRegisterMod, ".
		" FC_CashRegisterDel=$FC_CashRegisterDel, ".
		" FC_RetailReport=$FC_RetailReport, ".
		" FC_RetailStatistics=$FC_RetailStatistics, ".
		" FC_SalesAnalysis=$FC_SalesAnalysis, ".
		" FC_RetailViewer=$FC_RetailViewer, ".
		" FC_SalesStatistic=$FC_SalesStatistic, ".
		" FC_AddClient=$FC_AddClient1, ".
		" FC_CashRegisterCoupon=$FC_CashRegisterCoupon1, ".
		" FC_CashRegisterCustomer=$FC_CashRegisterCustomer1, ".
		" FC_CashRegisterCancel=$FC_CashRegisterCancel1, ".
		" FC_CashRegisterCheck=$FC_CashRegisterCheck1, ".
		" FC_ConfirmCustomer=$FC_ConfirmCustomer1, ".
		" FC_CashRegisterCredit=$FC_CashRegisterCredit1, ".
		" FC_CashRegisterDisc=$FC_CashRegisterDisc1, ".
		" Fc_forcingvendor=$Fc_forcingvendor1, ".
		" FC_PermToCancelCash=$FC_PermToCancelCash1, ".
		" FC_CashRegisterPosting=$FC_PostingByCashRegister1, ".
		" Promotion=$Promotion1, ".
		" ReturnQuantity=$ReturnQuantity1, ".
		" FC_CashRegisterScroll=$FC_CashRegisterScroll1, ".
		" FC_CashRegScrollOk=$FC_CashRegScrollOk1, ".
		" FC_CashRegScrollPrint=$FC_CashRegScrollPrint1, ".
		" FC_CashRegisterSearch=$FC_CashRegisterSearch1, ".
		" FC_ShowBtnOpenDrawer=$FC_ShowBtnOpenDrawer1, ".
		" Rc_cashFlow=$Rc_cashFlow1, ".
		" Closing_RetailReport=$Closing_RetailReport1, ".
		" RC_ForcingUserAccount=$RC_ForcingUserAccount1, ".
		" RC_ItemsSizes=$RC_ItemsSizes1, ".
		" RC_ListOfInvoices=$RC_ListOfInvoices1, ".
		" RC_SalesmenCommission=$RC_SalesmenCommission1, ".
		" RI_InvoiceProject=$RI_InvoiceProject1, ".
		" FI_Shipmentconfirmed=$FI_Shipmentconfirmed1, ".
		" RA_TabSheetMonthlyAmount=$RA_TabSheetMonthlyAmount1, ".
		" RI_SaleR_ShowSalesman=$RI_SaleR_ShowSalesman1, ".
		" RI_TabSheetrma=$RI_TabSheetrma1, ".
		" Costcenter=$Costcenter1, ".
		" CostcenterApp=$CostcenterApp, ".
		" CostcenterMod=$CostcenterMod, ".
		" CostcenterDel=$CostcenterDel, ".
		" Currency=$Currency1, ".
		" CurrencyMod=$CurrencyMod, ".
		" CurrencyDel=$CurrencyDel, ".
		" CurrencyApp=$CurrencyApp, ".
		" U_BackupFile=$U_BackupFile1, ".
		" U_CashRegister=$U_CashRegister1, ".
		" U_CloseCompany=$U_CloseCompany1, ".
		" U_CloseYear=$U_CloseYear1, ".
		" FU_ClosingPeriod=$FU_ClosingPeriod1, ".
		" U_DeleteCompany=$U_DeleteCompany1, ".
		" U_DeleteYear=$U_DeleteYear1, ".
		" U_DistributingCostcenter=$U_DistributingCostcenter1, ".
		" U_FillSetupFile=$U_FillSetupFile1, ".
		" U_MergerDataBase=$U_MergerDataBase1, ".
		" U_NewCompany=$U_NewCompany1, ".
		" U_NewYear=$U_NewYear1, ".
		" U_Ports=$U_Ports1, ".
		" U_PostToChecksAndBills=$U_PostToChecksAndBills1, ".
		" U_PostToItems=$U_PostToItems1, ".
		" U_PostToLedger=$U_PostToLedger1, ".
		" U_ReNumberJV=$U_ReNumberJV1, ".
		" U_TransferAccount=$U_TransferAccount1, ".
		" U_TransferItem=$U_TransferItem1, ".
		" FA_FIPAddress=$FA_FIPAddress1, ".
		" FA_IPAddressApp=$FA_IPAddressApp, ".
		" FA_IPAddressMod=$FA_IPAddressMod, ".
		" FA_IPAddressDel=$FA_IPAddressDel, ".
		" approved_level=$approved_level1, ".
		" Perc_creditlimit=$Perc_creditlimit, ".
		" FI_TransferRequest=$FI_TransferRequest, ".
		" FI_PurchaseRequestItems=$FI_PurchaseRequestItems1, ".
		" fi_pendingpurchaserequest=$fi_pendingpurchaserequest1, ".
		" fi_pendingtransferrequest=$fi_pendingtransferrequest1, ".
		" fi_pendingadjustmentrequest=$fi_pendingadjustmentrequest1, ".
		
		" FI_IN=$FI_IN1, ".
		" FI_INapp=$FI_INapp, ".
		" FI_INMod=$FI_INMod, ".
		" FI_INDel=$FI_INDel, ".
		
		" FI_OUT=$FI_OUT1, ".

	" FI_RENTINVOICE=" .$_POST['FI_RENTINVOICE'] .", ".
	" FI_RENTINVOICEApp=" .$_POST['FI_RENTINVOICEApp'] .", ".	
	" FI_RENTINVOICEMod=" .$_POST['FI_RENTINVOICEMod'] .", ".	 
	" FI_RENTINVOICEDel=" .$_POST['FI_RENTINVOICEDel'] .", ".
	
		" Fi_POS=$Fi_POS, ".
		" RI_Statistics=$RI_Statistics, ".
		" FI_Statistics=$FI_Statistics, ".
		" RA_Statistics=$RA_Statistics, ".
		" FI_Outapp=$FI_Outapp, ".
		" FI_OUTMod=$FI_OUTMod, ".
		" FI_OUTDel=$FI_OUTDel, ".
		" login_maturitydate=$login_maturitydate, ".
		" FI_SorderAllowConfirmCash=$FI_SorderAllowConfirmCash ";
		if($txtApplication=='Inventory' && $txtSchemaAssigned!=''){
			$query=$query." ,prequestapproved_level=$prequestapproved_level ".
					  " ,porderapproved_level=$porderapproved_level ".
					  " ,approved_level=$approved_level ".
					  ",transferrequestapproved_level=$transferrequestapproved_level ".
					  " ,adjustmentrequestapproved_level=$adjustmentrequestapproved_level ";
		}
		$query=$query." ,login_preqapprove=$login_preqapprove ".
		" ,login_preqreject=$login_preqreject ".
		" ,login_prequndproc=$login_prequndproc ".
		" ,login_pordapprove=$login_pordapprove ".
		" ,login_pordreject=$login_pordreject ".
		" ,login_treqapprove=$login_treqapprove ".
		" ,login_treqreject=$login_treqreject ".
		" ,login_areqapprove=$login_areqapprove ".
		" ,login_areqreject=$login_areqreject ".
		" ,FI_Visit=$FI_Visit ".
		" ,FI_ReportsOptions=$FI_ReportsOptions ".
		" ,Budget=$Budget, language = '$login_language', FI_RMAPendingItems = '$FI_RMAPendingItems', FI_RMALocations = '$FI_RMALocations', FA_PrePayment = '$FA_PrePayment' ".
		" ,FA_JournalPrintingAsk = '$FA_JournalPrintingAsk', RI_Transfer = '$RI_Transfer', RI_Adjustment = '$RI_Adjustment' ".
		//" ,DeliveryStatus_Type=$DeliveryStatus_Type ".
		" where upper(login_schema)=upper('".$txtSchemaAssigned."') and upper(user_account)=upper('".$user_code."')";

	$result=mysql_query($query,$connection);
		//  echo $query;exit;
	$message= mysql_error();
	
	
	$query="update login set  Access=$Access1 ".
			" where upper(login_schema)=upper('".$txtSchemaAssigned."') and upper(user_account)=upper('".$user_code."')";	
	$result=mysql_query($query,$connection);
	
	$query="update users set Access_UserManager=$Access_UserManager1 where User_account=upper('".$user_code."') ";		
							
	//	echo$query;exit;					
	$result=mysql_query($query,$connection);
	$message= mysql_error();	
	
	$query2="update listuserdir set 
			FI_StockTake=$FI_StockTake,
			FI_StockTake_App=$FI_StockTake_App,
			FI_StockTake_Mod=$FI_StockTake_Mod,
			FI_StockTake_Del=$FI_StockTake_Del,
			FI_Slippass=$FI_Slippass,
			AllowLockedPeriod=$AllowLockedPeriod,
			FU_Setup=$FU_Setup
			where upper(concat(CompanyName,'_',Diryear))=upper('".$txtSchemaAssigned."') and upper(Usercode)=upper('".$user_code."')";
		// echo$query2;exit;	
	$result2=mysql_query($query2,$connection);
	$message= mysql_error();
}	
	//echo $actionmode; exit;
if($actionmode=='SubmitLocked'){

	if($viewnumberdays=='')
		$viewnumberdays=0;
		
	if (!empty($uptodate))	{
		$uptodate  = explodeword($uptodate);
		$uptodate  = "'$uptodate'";
	}	
	else {$uptodate= 'null';}

	if (!empty($viewperioddate))	{
		$viewperioddate  = explodeword($viewperioddate);
		$viewperioddate  = "'$viewperioddate'";
	}	
	else {$viewperioddate= 'null';}	
		
		
	$query="Select count(*) from listuserdir where upper(concat(CompanyName,Diryear))=upper('".$Companies."') and upper(Usercode)=upper('".$user_code."')";
	//echo$query;exit;
	$result=mysql_query($query,$connection);
	$row=mysql_fetch_row($result);
	$count=$row[0];
	if($onlyallowed=='') $onlyallowed='null';
	if($count==0){
		$query="insert into listuserdir(CompanyName,Diryear,AllowLockedPeriod,LockedPeriod,LockedPeriodDays,LockViewPeriod,ViewPeriodDate,ViewLockDaily,ViewNumberOfDays)
				values('".$companyname."','".$companyyear."',$AllowLockedPeriod,$uptodate,$onlyallowed,$LockViewPeriod,$viewperioddate,$ViewLockDaily,$viewnumberdays)";
			//echo $query; exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	
	}
	else {
		$query="update listuserdir set AllowLockedPeriod=$AllowLockedPeriod,
			LockedPeriod=$uptodate,
			LockedPeriodDays=$onlyallowed,
			LockViewPeriod=$LockViewPeriod,
			ViewPeriodDate=$viewperioddate,
			ViewLockDaily=$ViewLockDaily,
			ViewNumberOfDays=$viewnumberdays,
			FI_StockTake=$FI_StockTake,
			FI_StockTake_App=$FI_StockTake_App,
			FI_StockTake_Mod=$FI_StockTake_Mod,
			FI_StockTake_Del=$FI_StockTake_Del
			where upper(concat(CompanyName,Diryear))=upper('".$Companies."') and upper(Usercode)=upper('".$user_code."')";
		//	echo$query;exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	$vTabFocus='Locked Period';
}

else if($actionmode=='deleteLocked'){
	$query="delete from listuserdir where upper(concat(CompanyName,Diryear))=upper('".$CompaniesYear."') and upper(Usercode)=upper('".$user_code."')";
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	$vTabFocus='Locked Period';
}

else if($actionmode=='SubmitLedgerStk'){

	if($ledgerstkid==''){
		$query="insert into ledgerstk(user_account,ledger_number,ledger_include)
				values('".$user_code."','".$ledger_code."','".$LedgerIncluded."')";
				
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	
	}
	else if($ledgerstkid!=''){
		$query="update ledgerstk set ledger_number='".$ledger_code."',
			ledger_include='".$LedgerIncluded."'
			
			 where id='".$ledgerstkid."'";
		//	echo$query;exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	$vTabFocus='Ledger Access';
}
else if($actionmode=='SubmitProjectLimit'){

	if($projectlimit_id==''){
		$query="insert into ".$_SESSION['dbName'].".projectlimit(user_account,project_code,projectlimit_limit)
				values('".$user_code."','".$projectlimit_project_code."','".$projectlimit_limit."')";
				
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	
	}
	else if($projectlimit_id!=''){
		$query="update ".$_SESSION['dbName'].".projectlimit set project_code='".$projectlimit_project_code."',
			projectlimit_limit='".$projectlimit_limit."'
			
			 where projectlimit_id='".$projectlimit_id."'";
			//echo$query;exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	$vTabFocus='Project Limit';
}

else if($actionmode=='deleteLedgerstk'){
	$query="delete from ledgerstk where id='".$ledgerstk_id."'";
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	$vTabFocus='Ledger Access';
}
else if($actionmode=='deleteProjectLimit'){
	$query="delete from ".$_SESSION['dbName'].".projectlimit where projectlimit_id='".$projectlimitid."'";
	 
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	$vTabFocus='Project Limit';
}

else if($actionmode=='SubmitLedgerRepStk'){

	if($ledgerrepstkid==''){
		$query="insert into ledgerrepstk(user_account,ledger_number,ledger_include)
				values('".$user_code."','".$ledgerrep_code."','".$LedgerReportIncluded."')";
				
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	
	}
	else if($ledgerrepstkid!=''){
		$query="update ledgerrepstk set ledger_number='".$ledgerrep_code."',
			ledger_include='".$LedgerReportIncluded."'
			
			 where id='".$ledgerrepstkid."'";
		//	echo$query;exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	$vTabFocus='Report Ledger Access';
}

else if($actionmode=='deleteLedgerrepstk'){
	$query="delete from ledgerrepstk where id='".$ledgerstkrep_id."'";
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	$vTabFocus='Report Ledger Access';
}

else if($actionmode=='SubmitLoginStk'){

	if($loginstkid==''){
		$query="insert into loginstk(user_account,project_code,costcent_code,
				group_code,subGroup_code,warehouse_code,Default_Project,Default_Costcenter,default_warehouse,ClientSalesmen,MasterProject,MasterCostCenter,towarehouse_code) ".
				" values('".$user_code."','".$project_code."','".$costcenter_code."','".$group_code."','".$subgroup_code."','".$warehouse_code."','$DefaultProject','$DefaultCost','$DefaultWarehouse',
				'".$clientsalesmen."','".$master_project."','".$master_costcent."','".$towarehouse_code."')";
			//echo $query; exit;
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	else if($loginstkid!=''){
		$query="update loginstk set project_code='".$project_code."',
				costcent_code='".$costcenter_code."',
				group_code='".$group_code."',
				subgroup_code='".$subgroup_code."',
				warehouse_code='".$warehouse_code."',
				Default_Project='$DefaultProject',
				Default_Costcenter='$DefaultCost',
				default_warehouse='$DefaultWarehouse',
				ClientSalesmen='".$clientsalesmen."',
				MasterProject='".$master_project."',
				MasterCostCenter='".$master_costcent."',
				towarehouse_code='".$towarehouse_code."'
			 where ID='".$loginstkid."'";
		//echo $query;exit;	
		$result=mysql_query($query,$connection);
		$message= mysql_error();
	}
	$vTabFocus='Item Access';
}

else if($actionmode=='deleteLoginStk'){
	$query="delete from loginstk where id='".$loginstk_id."'";
	$result=mysql_query($query,$connection);
	$message= mysql_error();
	$vTabFocus='Item Access';
}

else if($actionmode=='BorrowFrom'){

	fbegin();
	if($txtUserSchema!=''){
		$query="delete from listuserdir where upper(Usercode)=upper('".$user_code."')";
		$query=$query." and upper(concat(CompanyName,'_',Diryear))='".$txtUserSchema."' ";
		$result=mysql_query($query,$connection);
		
		$query="delete from login where upper(user_account)=upper('".$user_code."')";
		
		$query=$query." and upper(Login_Schema)='".$txtUserSchema."' ";
		//echo$query;
		$result=mysql_query($query,$connection);
	}
	
	$query="insert into listuserdir(Usercode,Username,CompanyName,Diryear,AllowLockedPeriod,LockedPeriod,LockedPeriodDays,LockViewPeriod,ViewPeriodDate,ViewLockDaily,ViewNumberOfDays) ".
			" select '".$user_code."','".$user_name."',CompanyName,Diryear,AllowLockedPeriod,LockedPeriod,LockedPeriodDays,LockViewPeriod,ViewPeriodDate,ViewLockDaily,ViewNumberOfDays ".
			" from listuserdir where upper(Usercode)=upper('".$UserList."')"; 
	if($txtUserSchema!='')
		$query=$query." and upper(concat(CompanyName,'_',Diryear))='".$txtUserSchema."' ";
	//echo $query; exit;
	$result=mysql_query($query,$connection);
	
	$query="drop table test.login"; 
	$result=mysql_query($query,$connection);
	
	$query="create table test.login like login"; 
	$result=mysql_query($query,$connection);
	
	$query="insert into test.login select * from login where upper(user_account)=upper('".$UserList."')  and upper(Login_Schema)='".$txtUserSchema."' "; 
	$result=mysql_query($query,$connection);
	
	$query="update test.login set user_account='".$user_code."' ,user_name='".$user_name."' "; 
	$result=mysql_query($query,$connection);
	
	//echo $query;exit;
	
	$query="insert into login select * from test.login "; 
	//if($txtUserSchema!='')
	//	$query=$query." and upper(Login_Schema)='".$txtUserSchema."' ";
		
	//echo $query;exit;	
	$result=mysql_query($query,$connection);
	
	if($result) fcommit();
	else frollback();
}

$message = ereg_replace(" ", "%20", $message);

if($mode=='deleteuser')
	header ("Location: ./Form_UserManager.php?mode=insert&message=".$message);
else	
header ("Location: ./Form_UserManager.php?user_code=$user_code&mode=editmode&vTabFocus=$vTabFocus&txtSchemaAssigned=$txtSchemaAssigned&txtApplication=$txtApplication&message=".$message);


function fbegin()
{
	mysql_query("START TRANSACTION");
}
function fcommit(){
	mysql_query("COMMIT");
}
function frollback()
{
	mysql_query("ROLLBACK");
}
?>