<?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(!isset($button)) $button = $TEXT['support50'];
  if(!isset($action)) $action = "zayavka_arch.php";

  if($result2['user'] == 1) puterror2($TEXT['error-supp11']);
  if($result2['master'] == 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.*,
       tbl_supp_srochnost.srochnost,
       tbl_supp_sostoyanie.sostoyanie,
       tbl_supp_tema.tema,
       tbl_step.logika
	   FROM tbl_supp_zayavka
	   JOIN tbl_supp_srochnost ON tbl_supp_zayavka.sroch_id=tbl_supp_srochnost.sroch_id
	   JOIN tbl_supp_sostoyanie ON tbl_supp_zayavka.sost_id=tbl_supp_sostoyanie.sost_id
	   JOIN tbl_supp_tema ON tbl_supp_zayavka.tema_id=tbl_supp_tema.tema_id
       LEFT JOIN tbl_step ON tbl_supp_zayavka.mar_id=tbl_step.mar_id AND tbl_supp_zayavka.step=tbl_step.position
	   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' width='16' height='16' class=photo src='img/filesave.png' /></a>";
                else $file_image = $TEXT['error-photo-no'];

      if($zayavka['logika'] == "1" || $zayavka['logika'] == "") $logika = "<img alt='".$TEXT['logic-marsh1']."' src='../admin/img/logik-otkl.png' />";
      elseif($zayavka['logika'] == "2") $logika = "<img alt='".$TEXT['logic-marsh2']."' src='../admin/img/logik-and.png' />";
       else $logika = "<img alt='".$TEXT['logic-marsh3']."' src='../admin/img/logik-or.png' />";

                    $srochnost = $zayavka['srochnost'];
                    $sostoyanie = $zayavka['sostoyanie'];
                    $tema2 = $zayavka['tema'];
                    $old_tema_id = $zayavka['tema_id'];
                    $old_mast_id = $zayavka['mast_id'];
                    $old_sost_id = $zayavka['sost_id'];
                    $old_sroch_id = $zayavka['sroch_id'];
                    $zay_id_old = $_GET['zay_id'];
                    $org_id = $zayavka['org_id'];

               if(!empty($zayavka['man_id']))
                {
               $query6 = "SELECT `login_id`, `fullname` FROM `tbl_logins` WHERE `login_id` = '".$zayavka['man_id']."'";
                $man_tmp = mysql_query($query6);
                  if(!$man_tmp) puterror2($TEXT['error-tbl20']);
                   $manager = mysql_fetch_array($man_tmp,MYSQL_ASSOC);
                    $manager2 = $manager['fullname'];
                 } else $manager2 = $TEXT['error-photo-no'];

               if(!empty($zayavka['mast_id']))
                {
               $query6 = "SELECT `login_id`, `fullname` FROM `tbl_logins` WHERE `login_id` = '".$zayavka['mast_id']."'";
                $mast_tmp = mysql_query($query6);
                  if(!$mast_tmp) puterror2($TEXT['error-tbl20']);
                   $master = mysql_fetch_array($mast_tmp,MYSQL_ASSOC);
                    $master2 = $master['fullname'];
                 } else $master2 = $TEXT['error-photo-no'];
?>
<table class="table" border="0" cellpadding="0" cellspacing="0" width="99%">
<tr><td class="supp_iniz">&nbsp;<?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']);
         if(mysql_num_rows($users) > 0)
          {
            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' />";
            }
             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>";
                 echo "<tr width='70%' valign=top><td width='80%' class='about'>".$TEXT['user-adrr']."<span class='texttableusr'>&nbsp;".$TEXT['user-city']."&nbsp; $res_cit, ".$TEXT['user-str']."&nbsp;$res_str,&nbsp; ".$TEXT['user-home']."$res_hou,&nbsp; ".$TEXT['user-room']."$room</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>";
        }
          else echo "<span class='about'>&nbsp;&nbsp;".$TEXT['support120']."</span>";
   ?>
      </td>
   </tr>
   <tr>
      <td>
        <form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
      <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']; ?> <?php echo $logika; ?></legend>
          <table align='center' border='0' width='100%' cellpadding='0' cellspacing='0'>
             <tr><td align="right" width="30%" class="support">&nbsp;</td><td class="support" width="80%" align="left">&nbsp;</td></tr>
             <tr><td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support40']; ?>&nbsp;</td>
                 <td width="70%" class="support_ob4" align="left"><?php echo $sostoyanie; ?></td>
             </tr>
             <tr><td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support41']; ?>&nbsp;</td>
                 <td width="70%" class="support_ob4" align="left"><?php echo $srochnost; ?></td>
             </tr>
             <tr><td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support13']; ?>&nbsp;</td>
                 <td width="70%" class="support_ob4" align="left"><?php echo $tema2; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support14']; ?>&nbsp;</td>
               <td class="support_ob3" width="80%" align="left"><?= nl2br($zayavka['problema']); ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support46']; ?>&nbsp;</td>
               <td class="support_ob7" width="80%" align="left"><?= nl2br($zayavka['reshenie']); ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support42']; ?>&nbsp;</td>
               <td class="support_ob4" width="80%" align="left">&nbsp;<?php echo $manager2; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support43']; ?>&nbsp;</td>
               <td class="support_ob4" width="80%" align="left">&nbsp;<?php echo $master2; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support53']; ?>&nbsp;</td>
               <td class="support_ob2" width="80%" align="left"><?php echo $zayavka['data_post']; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support55']; ?>&nbsp;</td>
               <td class="support_ob" width="80%" align="left"><?php echo $zayavka['data_k_isp']; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support54']; ?>&nbsp;</td>
               <td class="support_ob4" width="80%" align="left"><?php echo $zayavka['data_close']; ?></td>
             </tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;<?php echo $TEXT['support47']; ?>&nbsp;</td>
               <td class="support_ob4" width="80%" align="left"><?php echo $zayavka['time_isp']; ?>&nbsp;<?php echo $TEXT['support48']; ?></td>
             </tr>
             <tr><td align="right" width="30%" class="support">&nbsp;</td><td class="support" width="80%" align="left">&nbsp;</td></tr>
             <tr>
               <td align="right" width="30%" class="support">&nbsp;</td>
	       <td align="left" class=support>
             <?php
             if($zayavka['parent'] == 0)
             {
             ?>
             <ul id="nav">
             <li><a href="#"><?php echo $TEXT['support50']; ?></a>
              <?php
              if($zayavka['ob_type'] == 5)
              {
              ?>
               <ul>
                <li><a href="zayavka_arch_steps.php?zay_id=<?php echo $zay_id_old; ?>&amp;p=2" class=link title="<?php echo $TEXT['support51']; ?>"><b><?php echo $TEXT['support50']; ?></b></a></li>
                <li><a href="zayavka_arch_steps.php?zay_id=<?php echo $zay_id_old; ?>&amp;p=1" class=link title="<?php echo $TEXT['support51']; ?>"><b><?php echo $TEXT['support118']; ?></b></a></li>
                <li><a href="zayavka.php?zay_id=<?php echo $zay_id_old; ?>" class=link title="<?php echo $TEXT['support97']; ?>"><b><?php echo $TEXT['support96']; ?></b></a></li>
              </ul>
              <?php
              }
             else
               {
               ?>
               <ul>
                 <li><a href="zayavka_arch.php?zay_id=<?php echo $zay_id_old; ?>&amp;p=2" class=link title="<?php echo $TEXT['support51']; ?>"><b><?php echo $TEXT['support50']; ?></b></a></li>
                 <li><a href="zayavka_arch.php?zay_id=<?php echo $zay_id_old; ?>&amp;p=1" class=link title="<?php echo $TEXT['support51']; ?>"><b><?php echo $TEXT['support118']; ?></b></a></li>
                 <li><a href="zayavka.php?zay_id=<?php echo $zay_id_old; ?>" class=link title="<?php echo $TEXT['support97']; ?>"><b><?php echo $TEXT['support96']; ?></b></a></li>
               </ul>
               <?php
               }
             }
               ?>
               </li>
             </ul></td>
             </tr>
          </table>
       </fieldset>
     </td>
     </tr>
     </table>
      </td>
   </tr>
</table>
</form>
</body>
</html>