<?php  
$path_to_root = "..";
$page_security = 'SA_OPEN';
include_once($path_to_root . "/includes/session.inc");
page(_($help_context = "User info"), true, false, "");
include_once($path_to_root . "/includes/ui.inc");
simple_page_mode(true);



if (isset($_GET["u_id"]))  {
	$selected_id =$_GET["u_id"];
}

start_table(TABLESTYLE, "width=30%");
table_section_title("User detailes");
$result = GetDataJoin("users AS users",array(0=>array("join"=>"LEFT","table_name"=>"tickets AS tickets","conditions"=>"tickets.master_id=users.id")),array("users.real_name AS name","users.email AS email","users.phone AS phone","COUNT(tickets.id) AS posts"),array("users.id"=>$selected_id),null,null,false,false,"0_");

$company =GetDataFilter("master_login_companies",array("company_id"),array("master_id"=>$selected_id),null,null,"0_");
start_row();
foreach ($result as $row) {
	$companies ="";
foreach ($company as $id) {
		$companies.=$db_connections[$id['company_id']]['name'].",";
	}

label_cell(
	"User - <b>".$row['name']."</b>".
	"<br> Companies : <b>".$companies."</b>".
	"<br>E-mail - <b>".$row['email']."</b>".
	"<br>Contact number - <b>".$row['phone']."</b>".
	"<br>Posts - <b>".$row['posts']."</b>","align=center"
	);	
}
end_row();
end_table(1);
end_page();
?>
