<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  if(!isset($title)) $title = $TEXT['upr-title'];

  require_once "../config_a.php";
  require_once "../utils/functions.php";
  require_once "../utils/top_adm.php";

  if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}
?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tr align="right">
<td><img alt="<?php echo $TEXT['add-new']; ?>" align="bottom" src="../skins/<?php echo $result2['skin']; ?>/add.png" /><a class="bold_it tooltip4" href="addform.php" ><?php echo $TEXT['add-new']; ?><span><?php echo $TEXT['add-new-tit']; ?><small></small></span></a></td>
</tr>
<tr align="right">
<td><img alt="<?php echo $TEXT['upr-recod']; ?>" align="bottom" src="../skins/<?php echo $result2['skin']?>/pass.png" /><a class="bold_it tooltip4" href="recodform.php" ><?php echo $TEXT['upr-recod']; ?><span><?php echo $TEXT['upr-recod-tit']; ?><small></small></span></a></td>
</tr>
</table>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="90%">
<?php
     $query_body = "SELECT 
     tbl_upr.*,
     tbl_srv.srv_id,
     tbl_srv.name AS srv_name,
     tbl_srv.descr AS srv_descr
     FROM tbl_upr
     JOIN tbl_srv ON tbl_upr.srv_id=tbl_srv.srv_id
     ORDER BY tbl_srv.name, tbl_upr.usr ";
     $result_body = mysql_query($query_body);
     if(!$result_body) {puterror($result2['skin'],$TEXT['error-tbl3']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysql_num_rows($result_body)>0);
         {
           echo "<thead><tr class='tableheadercat'>
            <td>".$TEXT['srv-name']."</td>
            <td>".$TEXT['upr-type']."</td>
            <td>".$TEXT['user-tit']."</td>
            <td>".$TEXT['srv-vkl-tit']."</td>
            <td colspan=2>".$TEXT['global-action']."</td>
                 </tr></thead><tbody id='tab'>";
             while($result_body_addr = mysql_fetch_array($result_body,MYSQL_ASSOC))
               {
              $edit = "<a class='tooltip4' href=passform.php?addr_id=".$result_body_addr['addr_id']." >".$TEXT['edit-new']."<span>".$TEXT['edit-tit']."<small></small></span></a>";

              $delete_pic = "<img alt='delete' src='../skins/".$result2['skin']."/delete.png' />";
              $delete = $delete_pic."&nbsp;<a class='tooltip4' href=delete.php?addr_id=".$result_body_addr['addr_id']." >".$TEXT['delete-new']."<span>".$TEXT['delete-tit']."<small></small></span></a>";

              $online = "<img alt='online' src='../skins/".$result2['skin']."/online.png' />";
              $offline = "<img alt='offline' src='../skins/".$result2['skin']."/offline.png' />";
              $edit_pic = "<img alt='edit' src='../skins/".$result2['skin']."/edit.png' />";

              if($result_body_addr['vkl_upr'] == 1) $vkl = $online;
                else $vkl = $offline;

              if($result_body_addr['vkl_upr'] == '0') $strvisible = "<a class='tooltip4' href=on.php?addr_id=".$result_body_addr['addr_id']." >".$vkl."<span>".$TEXT['srv-vkluchit']."<small></small></span></a>";
                else $strvisible = "<a class='tooltip4' href=off.php?addr_id=".$result_body_addr['addr_id']." >".$vkl."<span>".$TEXT['srv-vikluchit']."<small></small></span></a>";

              if($result_body_addr['comanda'] == "scp") $comanda = $TEXT['upr-vnesh'];
                else $comanda = $TEXT['upr-vnutr'];

              if(trim($result_body_addr['srv_descr'] !== ""))
              {
           ?>
           <tr>
              <td><?php echo $result_body_addr['srv_name']; ?>&nbsp;(<?php echo $result_body_addr['srv_descr']; ?>)</td>
              <td><?php echo $comanda; ?></td>
              <td><?php echo $result_body_addr['usr']; ?></td>
              <td align="center"><?php echo $strvisible; ?></td>
              <td align="center"><?php echo $edit_pic; ?>&nbsp;<?php echo $edit; ?></td>
              <td align="center"><?php echo $delete; ?></td>
           </tr>
           <?php
              }
              else
              {
             ?>
           <tr>
              <td><?php echo $result_body_addr['srv_name']; ?></td>
              <td><?php echo $comanda; ?></td>
              <td><?php echo $result_body_addr['usr']; ?></td>
              <td align="center"><?php echo $strvisible; ?></td>
              <td align="center"><?php echo $edit_pic; ?>&nbsp;<?php echo $edit; ?></td>
              <td align="center"><?php echo $delete; ?></td>
           </tr>
           <?php
              }
            }
         }
?>
</tbody>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>