<?php

include('config.inc.php');
include('Functions_UserAccess.php');
include('function.inc.php');

session_start();

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



	

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass'])
		or die("Could not connect to DB");
		
	$query_access="select access_id,language_id
					from accesslabelslogistics.access
					where access_code='01' ";
			//		echo$query_access;
	$result_access = mysql_query($query_access, $connection) or die(mysql_error());				
	$row_access=mysql_fetch_row($result_access);
	$numrow=mysql_num_rows($result_access);
	$user_id=$row_access[0];
	$access_language=$row_access[1];

//	$data = split("_",$HTTP_SESSION_VARS['dbName']);
//	echo $data[0].$data[1].$data[2].$data[3];
	
	
	
$_SESSION['useraccount']="01";
$_SESSION['accessid']=$user_id;
$_SESSION['languageid']=$access_language;
$_SESSION['dbLabel1']=$config['accesslogistics'];

//_SESSION['dbName']='logistics_acc2013';
$data = split("_",$_SESSION['dbName']);
///Getting company type & id
		$query_companytype="select company_type,accessschema.company_id,companies.company_code,diryear from ".$_SESSION['dbLabel1'].".companies 
							inner join ".$_SESSION['dbLabel1'].".accessschema on ".$_SESSION['dbLabel1'].".accessschema.company_id=".$_SESSION['dbLabel1'].".companies.company_id
							where upper(accessschema_name)=upper('$data[0]')";
		//echo$query_companytype;
		$result_companytype = mysql_query($query_companytype, $connection);	
		$row_comp=mysql_fetch_row($result_companytype);
		$company_type=$row_comp[0];
		$login_company=$row_comp[1];
		$login_companyName=$row_comp[2];
		
$_SESSION['logincompany']=$login_company;
$_SESSION['logincompanyname']=$login_companyName;
$_SESSION['loginyear']=$data[1];


$query_accessschema="select accessschema_id from ".$_SESSION['dbLabel1'].".accessschema where access_id='".$user_id."'
						and upper(accessschema_name)=upper('$data[0]')";
		//	echo$query_accessschema;exit;
	$result_accessschema = mysql_query($query_accessschema, $connection);	
	$row_schema=mysql_fetch_row($result_accessschema);
	$accessschema_id=$row_schema[0];						
						
						
$_SESSION['accessschemaid']=$accessschema_id;

header("location:../../logistics/contract/menu.php");













































function current_server_time($connection){

  $string="Select date_format(NOW(),'%Y-%m-%d %h:%i %p') ";
  $result=mysql_query($string,$connection) or die(mysql_error());
  $now=mysql_fetch_row($result);

  return $now;
}

?>