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

$title = $TEXT['login-title'];

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

if($result2['administrator'] == 0 && $result2['user'] == 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" href="addform.php" title="<?php echo $TEXT['add-new-tit']; ?>"><?php echo $TEXT['add-new']; ?></a></td>
</tr>
</table>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="90%">
<?php
     $query_body = "SELECT tbl_logins.*, tbl_domain.*
     FROM `tbl_logins`
     LEFT JOIN tbl_domain ON tbl_logins.dom_id=tbl_domain.dom_id
     ORDER BY familiya, name, otchestvo ";
     $result_body = mysqli_query($dbcnx,$query_body);
     if(!$result_body) {puterror($result2['skin'],$TEXT['error-tbl7']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysqli_num_rows($result_body)>0)
         {
           echo "<thead ><tr class='tableheadercat'>
            <td>".$TEXT['login-name']."</td>
            <td>".$TEXT['login-fullname']."</td>
            <td>".$TEXT['user-tit']."</td>
            <td>".$TEXT['admin-tit']."</td>
            <td colspan=2>".$TEXT['global-action']."</td>
                 </tr></thead><tbody id='tab'>";
             while($result_body_logins = mysqli_fetch_array($result_body,MYSQLI_ASSOC))
               {
              $edit = "<a href=editform.php?login_id=".$result_body_logins['login_id']." title='".$TEXT['edit-tit']."'>".$TEXT['edit-new']."</a>";

              if(mysqli_num_rows($result_body)==1)
              {
              $delete_pic = "<img alt='картинка' src='../skins/".$result2['skin']."/nodelete.png' />";
              $delete =$delete_pic."&nbsp;".$TEXT['delete-new'];
              }
              else
              {
                $delete_pic = "<img alt='картинка' src='../skins/".$result2['skin']."/delete.png' />";
                $delete = $delete_pic."&nbsp;<a href=delete.php?login_id=".$result_body_logins['login_id']." title='".$TEXT['delete-tit']."'>".$TEXT['delete-new']."</a>";
              }
              $yes = "<img alt='картинка' src='../skins/".$result2['skin']."/yes.png' />";
              $no = "<img alt='картинка' src='../skins/".$result2['skin']."/no.png' />";
              $edit_pic = "<img alt='картинка' src='../skins/".$result2['skin']."/edit.png' />";
              
              $usr_name = $result_body_logins['familiya']." ".$result_body_logins['name']." ".$result_body_logins['otchestvo'];

              if($result_body_logins['administrator'] == 1) {$administrator = $yes;}
                else {$administrator = $no;}

              if($result_body_logins['maintenance'] == "yes") {$maint_checkbox = "<img alt='maintenance' src='../skins/".$result2['skin']."/pass16.png' >";}
                else {$maint_checkbox = "";}

              if($result_body_logins['user'] == 1) {$user = $yes;}
                else {$user = $no;}
              $email = $result_body_logins['e_mail']."@".$result_body_logins['domain'];
           ?>
           <tr>
              <td><a href=mailto:<?php echo $email; ?>><?php echo $result_body_logins['login']; ?></a></td>
              <td><?php echo $maint_checkbox." ".$usr_name; ?></td>
              <td align="center"><?php echo $user; ?></td>
              <td align="center"><?php echo $administrator; ?></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";
?>