<?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";

  $title=$titlepage=$TEXT['support33'];

  require_once "../config.php";
  require_once "top.php";

  ?>
  <title><?php echo $title; ?></title>
  <link rel="StyleSheet" type="text/css" href="../utils/reader.css" />
  </head>
  <body leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0" topmargin="0" >
  <?php
  if($result2['user'] == 1) puterror2($TEXT['error-supp11']);

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

       $query_zaya = "SELECT tbl_supp_zayavka.pic_tr, 
       tbl_supp_zayavka.problema, 
       tbl_supp_zayavka.tema_id, 
       tbl_supp_zayavka.usr_id,
       tbl_supp_tema.tema 
       FROM tbl_supp_zayavka 
       JOIN tbl_supp_tema ON tbl_supp_zayavka.tema_id=tbl_supp_tema.tema_id 
       WHERE tbl_supp_zayavka.zay_id = '".$_GET['zay_id']."'";
       $zaya = mysql_query($query_zaya);
         if(!$zaya) puterror2($TEXT['error-tbl26']);
            $zayavka = mysql_fetch_array($zaya,MYSQL_ASSOC);

              if(!empty($zayavka['pic_tr']) && $zayavka['pic_tr']!="-") $file_image = "<a href='../".$zayavka['pic_tr']."' target=_blank title='".$TEXT['support26']."'><img alt='picture' src='../img/filesave.png' /></a>";
                else $file_image = $TEXT['support28'];
                $tema2 = $zayavka['tema'];
?>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="97%">
<tr><td class="supp_iniz"><?php echo $TEXT['support30']; ?></td></tr>
<tr>
    <td>
       <?php
       $dog = "@";

       $query = "SELECT tbl_users.user_id, tbl_users.org_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 tbl_users.user_id = '".$zayavka['usr_id']."'";
       $users = mysql_query($query);
         if(!$users) puterror2($TEXT['error-tbl2']);
            while($user = mysql_fetch_array($users,MYSQL_ASSOC))
            {
               $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'];
               $user_full = $user['familiya']." ".$user['name']." ".$user['otchestvo'];
               $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'];
               $org_id =  $user['org_id'];
               $res_upr = $user['upravlenie'];
               $res_otd = $user['otdel'];

                 if(!empty($user['photo']) && $user['photo']!="-") $result_image = "&nbsp;&nbsp;&nbsp;<img alt='picture' width='130' height='185' class=photo src='".$user['photo']."' />";
                   else $result_image = "&nbsp;&nbsp;&nbsp;<img alt='picture' width='130' height='185' class=photo src='../img/nophoto.png' />";

                   if(!empty($res_cit) && $res_cit!=="-"){$cit = "&nbsp;".$TEXT['user-city']."&nbsp;".$res_cit.",&nbsp;";}
                    else $cit = "";

                   if(!empty($res_str) && $res_str!=="-"){$str = $TEXT['user-str']."&nbsp;".$res_str.",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";}
                     else $str = "";

                   if(!empty($res_hou) && $res_hou!=="-"){$hou = $TEXT['user-home']." ".$res_hou;}
                     else $hou = "";

                   if(!empty($room) && $room!=="-"){$rum = ",&nbsp;".$TEXT['user-room']." ".$room;}
                     else $rum = "";

            }
             echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'> ";
              echo "<tr valign=top><td width='15%' rowspan='12'>$result_image</td></tr>";
               if(!empty($familiya)) echo "<tr align=top><td width='80%' class='texttableusrtit'>$familiya&nbsp; $name&nbsp; $otchestvo</td></tr>";
                 if($cit!=="" || $str !== "" || $hou !== "" || $rum !== "")  echo "<tr valign=top><td width='80%' class='about'>".$TEXT['user-adrr']."<span class='texttableusr'>".$cit."".$str."".$hou."".$rum."</span></td></tr>";
                  if(!empty($res_org)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['search-org']."<span class='texttableusr'>&nbsp;$res_org</span></td></tr>";
                   if(!empty($res_upr) && $res_upr!=="-") echo "<tr valign=top><td width='80%' class='about'>".$TEXT['search-upr']."<span class='texttableusr'>&nbsp;$res_upr</span></td></tr>";
                    if(!empty($res_otd) && $res_otd!=="-") echo "<tr valign=top><td width='80%' class='about'>".$TEXT['search-otd']."<span class='texttableusr'>&nbsp;$res_otd</span></td></tr>";
                     if(!empty($res_dol)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['search-dol']."<span class='texttableusr'>&nbsp;$res_dol</span></td></tr>";
                      if(!empty($phone_mob)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['user-tel-mob']."<span class='texttableusr'>&nbsp;$phone_mob</span></td></tr>";
                       if(!empty($phone_city)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['user-tel-city']."<span class='texttableusr'>&nbsp;<a href='callto://$phone_city'>$phone_city</a></span></td></tr>";
                        if(!empty($phone_int)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['user-tel-int']."<span class='texttableusr'>&nbsp;<a href='callto://$phone_int'>$phone_int</a></span></td></tr>";
                         if(!empty($mail)) echo "<tr valign=top><td width='80%' class='about'>".$TEXT['user-e-mail']."<span class='texttableusr'>&nbsp;<a href=mailto:$email>$email</span></td></tr>";
                           echo "</table>";
   ?>
      </td>
   </tr>
   <tr>
      <td>
    <table align='center' border='0' width='97%' cellpadding='0' cellspacing='0'><hr /><tr>
      <td>
         <fieldset class='zayavka' >
         <legend align="left"><?php echo $TEXT['support1']; ?> <?php echo $_GET['zay_id']; ?></legend>
          <table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
             <tr><td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support13']; ?></td>
                 <td width="70%" class="support_ob4" align="left">&nbsp;&nbsp;<?php echo $tema2; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support14']; ?></td>
               <td class="support_ob3" width="70%" align="left">&nbsp;&nbsp;<?= $zayavka['problema']; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support26']; ?></td>
               <td class="flop" width="70%" align="left">&nbsp;&nbsp;<?php echo $file_image; ?></td>
             </tr>
          </table>
       </fieldset>
     </td>
     </tr>
     </table>
      </td>
   </tr>
</table>
</body>
</html>