<?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";
  ?>
  <meta http-equiv='Refresh' content='180; URL=mast_tree.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']);

  $query_zaya_all = mysql_query("SELECT COUNT(zay_id) FROM tbl_supp_zayavka WHERE mast_id = '".$result2['login_id']."' AND ob_type != '2' AND data_post <= NOW() ");
   $zayavka_all = mysql_result($query_zaya_all, 0);
?>
<table width="100%" align="left" border="0" cellspacing="0">
  <tr>
    <td class="support4"><?php echo $TEXT['support43']; ?>:&nbsp;<span class="support_ob5"><?php echo $result2['fullname']; ?></span></td>
  </tr>
  <tr>
    <td>
<table width="100%" align="left" border="0" cellspacing="0">
  <tr><td width="2%">&nbsp;</td><td width="98%"><a class="support2" href='master.php?user_id=<?php echo $result2['login_id']; ?>' target='right'><?php echo $TEXT['support39']; ?>&nbsp;&#171;<?php echo $zayavka_all; ?>&#187;</a></td></tr>
</table>
</td>
    </tr>
     <tr>
        <td class="support4"><?php echo $TEXT['support40']; ?></td>
    </tr>
     <tr>
        <td>
        <table width="100%" align="left" border="0" cellspacing="0">
     <?php
               $query4 = "SELECT tbl_supp_sostoyanie.*, (SELECT COUNT(zay_id) FROM tbl_supp_zayavka WHERE tbl_supp_zayavka.sost_id = tbl_supp_sostoyanie.sost_id AND tbl_supp_zayavka.mast_id = '".$result2['login_id']."' AND tbl_supp_zayavka.ob_type != '2' AND tbl_supp_zayavka.data_post <= NOW()) AS countsost FROM tbl_supp_sostoyanie ORDER BY tbl_supp_sostoyanie.position ";
                $sost_tmp = mysql_query($query4);
                  if(!$sost_tmp) puterror2($TEXT['error-tbl23']);
                    while($sost = mysql_fetch_array($sost_tmp,MYSQL_ASSOC))
                    {
                      if(!empty($sost['pic_sost']) && $sost['pic_sost']!="-") $sost_image = "<img alt='picture' title='".$sost['sostoyanie']."' src='".$sost['pic_sost']."' />";
                       else $sost_image = "";
                      echo "<tr><td width='2%'>&nbsp;</td><td width='98%'>".$sost_image."<a class='support2' href='master.php?sost_id=".$sost['sost_id']."&user_id=".$result2['login_id']."' target='right'>".$sost['sostoyanie']."&nbsp;&#171;".$sost['countsost']."&#187;</a></td></tr>";
                    }
    ?>
        </table>
</td>
    </tr>
     <tr>
        <td class="support4"><?php echo $TEXT['support41']; ?></td>
    </tr>
     <tr>
        <td>
        <table width="100%" align="left" border="0" cellspacing="0">
     <?php
               $query3 = "SELECT tbl_supp_srochnost.*, (SELECT COUNT(zay_id) FROM tbl_supp_zayavka WHERE tbl_supp_zayavka.sroch_id = tbl_supp_srochnost.sroch_id AND tbl_supp_zayavka.mast_id = '".$result2['login_id']."' AND tbl_supp_zayavka.ob_type != '2' AND tbl_supp_zayavka.data_post <= NOW()) AS countsroch FROM tbl_supp_srochnost ORDER BY tbl_supp_srochnost.position ";
               $sroch_tmp = mysql_query($query3);
                if(!$sroch_tmp) puterror2($TEXT['error-tbl24']);
                    while($sroch = mysql_fetch_array($sroch_tmp,MYSQL_ASSOC))
                      {
                      if(!empty($sroch['pic_sr']) && $sroch['pic_sr']!="-") $sroch_image = "<img alt='picture' title='".$sroch['srochnost']."' src='".$sroch['pic_sr']."' />";
                       else $sroch_image = "";
                      echo "<tr><td width='2%'>&nbsp;</td><td width='98%'>".$sroch_image."<a class='support2' href='master.php?sroch_id=".$sroch['sroch_id']."&user_id=".$result2['login_id']."' target='right'>".$sroch['srochnost']."&nbsp;&#171;".$sroch['countsroch']."&#187;</a></td></tr>";
                   }
    ?>
        </table>
</td>
    </tr>
     <tr>
        <td class="support4"><?php echo $TEXT['support101']; ?></td>
    </tr>
     <tr>
        <td>
        <table width="100%" align="left" border="0" cellspacing="0">
     <?php
               $query7  = "SELECT `zay_id`, `sroch_id` FROM `tbl_supp_zayavka` WHERE `ob_type` = '1' AND mast_id = '".$result2['login_id']."' ";
               $zay = mysql_query($query7);
                if(!$zay) puterror2($TEXT['error-tbl26']);
                  while($zay_ob = mysql_fetch_array($zay,MYSQL_ASSOC))
                   {
                   $query_zay_sr_tmp = "SELECT `srochnost` FROM `tbl_supp_srochnost` WHERE `sroch_id` = '".$zay_ob['sroch_id']."'";
                   $zay2 = mysql_query($query_zay_sr_tmp);
                    if(!$zay2) puterror2($TEXT['error-tbl24']);
                    $zay_sr = mysql_fetch_array($zay2,MYSQL_ASSOC);
                    if($zay_sr['srochnost']!=="-") echo "<tr><td width='2%'>&nbsp;</td><td width='98%'><a class='support2' href='master2.php?zay_id=".$zay_ob['zay_id']."' target='right'>".$TEXT['support112']."".$zay_ob['zay_id']."&nbsp;&#171;".$zay_sr['srochnost']."&#187;</a></td></tr>";
                   }
    ?>
        </table>
</td>
</tr>
</table>
</body>
</html>