<?php
  ///////////////////////////////////////////////////
  //Телефонный справочник
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  //определяем локаль пришедшего и подставляем нужный язык.
  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if (is_file ("../../lang/".$lang.".php")) include "../../lang/".$lang.".php";
     else include "../../lang/ru.php";

  //Соединяемся с базой данных
  require_once "../../config.php";

  if(empty($_GET['user_id'])) puterror2($TEXT['error-usr1']);
  if(strlen($_GET['user_id'])>11) puterror2($TEXT['error-usr2']);
  $_GET['user_id'] = rep($_GET['user_id']);

?>
<html>
<head>
<meta http-equiv="Expires" content="Mon, 23 May 1995 02:00:00 GMT" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="<?php echo $description; ?>" />
<meta name="keywords" content="<?php echo $keywords; ?>" />
<link rel="icon" href="../../Favicon/user.ico" type="image/x-icon" />
<link rel="shortcut icon" href="../../Favicon/user.ico" type="image/x-icon" />
<title><?php echo $TEXT['global-usr']; ?></title>
<link rel="StyleSheet" type="text/css" href="../../utils/reader.css" />
</head>
<?php
  //объявляем переменную
  $dog = "@";

  //Извлекаем данные
  $query = "SELECT tbl_users.user_id, tbl_users.room, tbl_users.familiya, tbl_users.name, tbl_users.otchestvo, tbl_users.mail, tbl_users.phone_mob, tbl_users.phone_int, tbl_users.phone_city, tbl_users.photo, tbl_dolzhnost.dolzhnost, tbl_domain.domain, tbl_city.city, tbl_street.street, tbl_house.house, tbl_organizaciya.organizaciya, tbl_upravlenie.upravlenie, tbl_otdel.otdel 
FROM tbl_users 
JOIN tbl_dolzhnost ON tbl_users.dol_id=tbl_dolzhnost.dol_id 
JOIN tbl_domain ON tbl_users.dom_id=tbl_domain.dom_id 
JOIN tbl_city ON tbl_users.city_id=tbl_city.city_id 
JOIN tbl_street ON tbl_users.str_id=tbl_street.str_id 
JOIN tbl_house ON tbl_users.house_id=tbl_house.house_id 
JOIN tbl_organizaciya ON tbl_users.org_id=tbl_organizaciya.org_id 
JOIN tbl_upravlenie ON tbl_users.upr_id=tbl_upravlenie.upr_id 
JOIN tbl_otdel ON tbl_users.otd_id=tbl_otdel.otd_id 
WHERE user_id = '".$_GET['user_id']."'";
  $users = mysql_query($query);
         if(!$users) puterror2($TEXT['error-tbl2']);
            $user = mysql_fetch_array($users);

               $room = $user['room'];
               $familiya = $user['familiya'];
               $name = $user['name'];
               $otchestvo = $user['otchestvo'];
               $mail = $user['mail'];
               $phone_mob = $user['phone_mob'];
               $phone_int = $user['phone_int'];
               $phone_city = $user['phone_city'];
               $res_dol = $user['dolzhnost'];
               $res_dom = $user['domain'];
               $email = $mail.$dog.$res_dom;
               $res_cit = $user['city'];
               $res_str = $user['street'];
               $res_hou = $user['house'];
               $res_org = $user['organizaciya'];
               $res_upr = $user['upravlenie'];
               $res_otd = $user['otdel'];

               //Переменная для фото
                 if (!empty($user['photo']) && $user['photo']!="-") $result_image = "<img width='130' height='185' src='../../photo/".$user['photo']."' />";
                   else $result_image = "<img width='130' height='185' class=photo src='../../img/nophoto.png' />";

     // Под контактное лицо оформляем отдельную таблицу
        echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'> ";
        echo "<tr valign=top><td width='30%' rowspan='12' class='texttable'>$result_image</td></tr>";
        if(!empty($familiya)) echo "<tr align=top><td width='80%'><h2><b>$familiya&nbsp;$name&nbsp;$otchestvo</b></h2></td></tr>";
        echo "<tr width='70%' valign=top><td width='100%' class='texttable'>".$TEXT['user-adrr']."<b>&nbsp;<i>".$TEXT['user-city']."&nbsp;$res_cit, ".$TEXT['user-str']."&nbsp;$res_str,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ".$TEXT['user-home']."$res_hou,&nbsp;".$TEXT['user-room']."$room</i></b></td></tr>";
        if(!empty($res_org)) echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['search-org']."<b>&nbsp;<i>$res_org</i></b></td></tr>";
        if(!empty($res_upr) && $res_upr!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['search-upr']."<b>&nbsp;<i>$res_upr</i></b></td></tr>";
        if(!empty($res_otd) && $res_otd!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['search-otd']."<b>&nbsp;<i>$res_otd</i></b></td></tr>";
        if(!empty($res_dol) && $res_dol!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['search-dol']."<b>&nbsp;<i>$res_dol</i></b></td></tr>";
        if(!empty($phone_mob) && $phone_mob!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['user-tel-mob']."<b>&nbsp;<i>$phone_mob</i></b></td></tr>";
        if(!empty($phone_city) && $phone_city!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['user-tel-city']."<b>&nbsp;<i>$phone_city</i></b></td></tr>";
        if(!empty($phone_int) && $phone_int!=="-") echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['user-tel-int']."<b>&nbsp;<i>$phone_int</i></b></td></tr>";
        if(!empty($mail)) echo "<tr valign=top><td width='80%' class='texttable'>".$TEXT['user-e-mail']."<i>&nbsp;<b><a href=mailto:$email>$email</i></b></td></tr>";
        echo "<tr valign=right><td width='80%' class='texttable'><b><a href=# onClick='self.close()' title='".$TEXT['user-close-tit']."'>".$TEXT['user-close']."</a></b></td></tr>";
        echo "</table>";
?>
</body>
</html>