<?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['support36'];
  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($result2['master'] == 1) puterror2($TEXT['error-supp11']);

  if(empty($_GET['organizaciya'])) $_GET['organizaciya'] = "";
  if(empty($_GET['tema'])) $_GET['tema'] = "";
  if(empty($_GET['time'])) $_GET['time'] = "";

  if(strlen($_GET['organizaciya'])>255) puterror2($TEXT['error-supp25']);
  if(strlen($_GET['tema'])>255) puterror2($TEXT['error-supp26']);
  if(strlen($_GET['time'])>4) puterror2($TEXT['error-supp27']);
  $_GET['organizaciya'] = rep($_GET['organizaciya']);
  $_GET['tema'] = rep($_GET['tema']);
  $_GET['time'] = rep($_GET['time']);

  if(!empty($_GET['organizaciya'])) $organizaciya = " AND organizaciya = '".$_GET['organizaciya']."'";
   else $organizaciya = "";

  if($_GET['time'] == 30) $time = " AND time_isp < '30' ";
  if($_GET['time'] == 60) $time = " AND time_isp BETWEEN '30' AND '60' ";
  if($_GET['time'] == 300) $time = " AND time_isp BETWEEN '61' AND '300' ";
  if($_GET['time'] == 1440) $time = " AND time_isp BETWEEN '301' AND '1440' ";
  if($_GET['time'] == 1441) $time = " AND time_isp > '1441' ";
  if($_GET['time'] == "") $time = "";

  if($_GET['time'] == 30) $time_header = "<br />".$TEXT['support80']."&nbsp;<span class='grn'>".$TEXT['support58']."</span>";
  if($_GET['time'] == 60) $time_header = "<br />".$TEXT['support80']."&nbsp;<span class='grn'>".$TEXT['support59']."</span>";
  if($_GET['time'] == 300) $time_header = "<br />".$TEXT['support80']."&nbsp;<span class='grn'>".$TEXT['support60']."</span>";
  if($_GET['time'] == 1440) $time_header = "<br />".$TEXT['support80']."&nbsp;<span class='grn'>".$TEXT['support61']."</span>";
  if($_GET['time'] == 1441) $time_header = "<br />".$TEXT['support80']."&nbsp;<span class='grn'>".$TEXT['support62']."</span>";
  if(empty($_GET['time'])) $time_header = "";
  if($_GET['time'] == "") $time_header = "";

  if(!empty($_GET['organizaciya'])) $big = $TEXT['support75']."<span class='grn'>".$_GET['organizaciya']."</span>.<br />".$TEXT['support77']."<span class='grn'>".$_GET['tema']."</span><br />";
   else $big = $TEXT['support76']."<br /><span class='grn'>".$_GET['tema']."</span>".$time_header;
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr align="center"><td class="supp_iniz">&nbsp;<?php echo $big; ?></td></tr>
<tr>
    <td align="center">
      <table class="table" border="1" width="60%" cellpadding="1" cellspacing="1">
       <tr class="tableheadercat">
        <td><?php echo $TEXT['support30']; ?></td>
        <td><?php echo $TEXT['support65']; ?></td>
       </tr>
       <?php
       $query_total = "SELECT DISTINCT `user` FROM `tbl_supp_archive` WHERE `tema` = '".$_GET['tema']."' ".$organizaciya." ".$time." ORDER BY user ";
        $tot_tmp = mysql_query($query_total);
         if(!$tot_tmp) puterror2($TEXT['error-tbl25']);
           while($sost2 = mysql_fetch_array($tot_tmp,MYSQL_ASSOC))
           {
             $query_total2 = mysql_query("SELECT COUNT(arch_id) FROM tbl_supp_archive WHERE tema = '".$_GET['tema']."' AND user = '".$sost2['user']."' ".$organizaciya." ".$time." ");
              $tema = mysql_result($query_total2, 0);

            echo "<tr class='texttable'>
              <td><a href='rpt_mast_usr.php?user=".$sost2['user']."&tema=".$_GET['tema']."&org=".$_GET['organizaciya']."&time=".$_GET['time']."' title='".$TEXT['support14']."'>".$sost2['user']."</a></td>
              <td>".$tema."</td>
            </tr>";
           }
        ?>
        </table>
      </td>
   </tr>
</table>
</body>
</html>