<?php
///////////////////////////////////////////////////
//2009 (C)
//Карпухин Павел
///////////////////////////////////////////////////
require_once "../utils/chlang.php";

$title=$titlepage = $TEXT['zal-title'];

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

if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm_film.php"; exit();}
?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="50%">
<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" class="table" border="1" cellpadding="3" cellspacing="0" width="50%">
<?php
     $query10 = "SELECT * FROM `tbl_zal` ORDER BY `zal`";
     $result10 = mysqli_query($dbcnx,$query10);
     if(!$result10) {puterror($result2['skin'],$TEXT['error-tbl11']); require_once "../utils/bottom_adm_film.php"; exit();}
       if(mysqli_num_rows($result10)>0)
         {
           echo " <thead>
              <tr class='tableheadercat'>
                 <td width='60%'>".$TEXT['tbl-zal']."</td>
                 <td colspan=2>".$TEXT['tbl-action']."</td>
              </tr>
             </thead>
             <tbody id='tab'>";
             while($result_zal = mysqli_fetch_array($result10))
               {
              $edit_pic = "<img alt='".$TEXT['edit-new']."' src='../skins/".$result2['skin']."/edit.png' />";
              $edit = $edit_pic."&nbsp;<a href=editform.php?zal_id=".$result_zal['zal_id']." title='".$TEXT['edit-tit']."'>".$TEXT['edit-new']."</a>";

              $query_book_zal = mysqli_query($dbcnx,"SELECT COUNT(zal_id) AS c_zal_id FROM tbl_book WHERE zal_id='".$result_zal['zal_id']."'");
	      $coun_book_zal = mysqli_fetch_array($query_book_zal);
              if($coun_book_zal['c_zal_id'] > 0)
               {
                $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?zal_id=".$result_zal['zal_id']." title='".$TEXT['delete-tit']."'>".$TEXT['delete-new']."</a>";
                 }
           ?>
           <tr>
              <td><?php echo $result_zal['zal']; ?></td>
              <td><?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
            </tr>
           <?php
               }
               echo "</tbody>";
         }
?>
</table>
<?php
require_once "../utils/bottom_adm_film.php";
?>