<?php
///////////////////////////////////////////////////
//2010 (C)
//Карпухин Павел
///////////////////////////////////////////////////
require_once "../utils/chlang.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) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}
?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr align="right">
<td><img alt="<?php echo $TEXT['add-new']; ?>" 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 * FROM `tbl_logins` 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-login']."</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))
               {
              $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='".$TEXT['global-lock']."' src='../skins/".$result2['skin']."/nodelete.png' >";
              $delete =$delete_pic."&nbsp;".$TEXT['delete-new'];
              }
              else
              {
                $delete_pic = "<img alt='".$TEXT['delete-new']."' 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>";
              }

              //$maint_checkbox = "<img alt='yes' src='../skins/".$result2['skin']."/pass16.png' >";
              $yes = "<img alt='yes' src='../skins/".$result2['skin']."/yes.png' >";
              $no = "<img alt='no' src='../skins/".$result2['skin']."/no.png' >";
              $edit_pic = "<img alt='".$TEXT['edit-new']."' src='../skins/".$result2['skin']."/edit.png' >";
              $usr_name = "<a href='info.php?login_id=".$result_body_logins['login_id']."&amp;st=1' title='".$TEXT['aut-title-info']."'>".$result_body_logins['familiya']." ".$result_body_logins['name']." ".$result_body_logins['otchestvo']."</a>";

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

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

              if($result_body_logins['maintenance'] == "yes") {$maint_checkbox = "<img alt='maintenance' src='../skins/".$result2['skin']."/pass16.png' >";}
                else {$maint_checkbox = "";}
           ?>
           <tr>
              <td><?php echo $maint_checkbox." ".$result_body_logins['login']; ?></td>
              <td><?php echo $usr_name; ?></td>
              <td><?php echo $user; ?></td>
              <td><?php echo $administrator; ?></td>
              <td><?php echo $edit_pic; ?>&nbsp;<?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
           </tr>
           <?php
               }
         }
?>
</tbody>
</table>
<?php
  require_once "../utils/bottom_adm.php";
?>