<?php


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

include("config.inc.php");

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

 
mysql_select_db($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");

$HTTP_SESSION_VARS['tabletd']="usertd"."".$HTTP_SESSION_VARS['useraccount'];

				$query="create table if not exists ".$HTTP_SESSION_VARS['tabletd']."(
				id int(10) NOT NULL auto_increment ,
				transfer_id int(20),
				transferdt_id int(20),
				item_code varchar(20),
				item_description varchar(60),
				transferdt_quantity double,
				TransferDt_Price double,
				relateddt_id bigint,
				TransferDt_WarehouseFrom varchar(15),
				TransferDt_WarehouseTo varchar(15) ,
				serialno_code varchar(40),
				transferdt_remark varchar(100),
				PRIMARY KEY(id))";
				$result=mysql_query($query,$connection)
				or die(mysql_error());
		//echo $query;
		
		if ($p_item_quantity=='')
			$p_item_quantity=0;
		
		if ($p_item_sellingprice1=='')
			$p_item_sellingprice1=0;


		
			
	$quer = "select item_code as item_code, item_description as item_description,item_sellingprice1 as item_sellingprice1 from items where item_code = '".$$itemcode."'";
						$result=mysql_query($quer,$connection) or die(mysql_error());
						while($rows=mysql_fetch_array($result)){
								extract($rows);
								}
						$query = "insert into ".$HTTP_SESSION_VARS['tabletd']."(transfer_id,item_code,item_description,transferdt_quantity,TransferDt_Price
								,TransferDt_WarehouseFrom,TransferDt_WarehouseTo,transferdt_remark,serialno_code) values(
							  '".$transferid."'
							   ,'".$p_item_code."'
							  ,'".$p_item_description."'
							  ,'".$p_item_quantity."'
							  ,".$p_item_sellingprice1."
							   ,'".$fromwarehouse."'
							  ,'".$towarehouse."'
							  ,'".$p_transferdt_remark."'
							  ,''
							  )";
						//echo $query."<br>";	  
						$result=mysql_query($query,$connection) or die(mysql_error());
		

header ("Location: transfer_items.php?item=1&transferid=$transferid&fromwarehouse=$fromwarehouse&towarehouse=$towarehouse&process=$process");
?>