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

$title=$titlepage = $TEXT['tip-izd-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="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_tip_izd` WHERE use_prog='1' ORDER BY `position`, `tip_izd`";
     $result10 = mysqli_query($dbcnx,$query10);
     if(!$result10) {puterror($result2['skin'],$TEXT['error-tbl15']); require_once "../utils/bottom_adm.php"; exit();}
       if(mysqli_num_rows($result10)>0)
         {
           echo " <thead>
              <tr class='tableheadercat'>
                 <td>".$TEXT['tbl-tip-izd']."</td>
                 <td>".$TEXT['book-lang-pos']."</td>
                 <td colspan=3>".$TEXT['tbl-action']."</td>
              </tr>
             </thead><tbody id='tab'>";
             while($result_tip_izd = 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?tip_izd_id=".$result_tip_izd['tip_izd_id']." title='".$TEXT['edit-tit']."'>".$TEXT['edit-new']."</a>";

              $query_book_tip_izd = mysqli_query($dbcnx,"SELECT COUNT(tip_izd_id) AS c_tip_izd_id FROM tbl_book WHERE tip_izd_id='".$result_tip_izd['tip_izd_id']."'");
	      $coun_book_tip_izd = mysqli_fetch_array($query_book_tip_izd);
              if($coun_book_tip_izd['c_tip_izd_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?tip_izd_id=".$result_tip_izd['tip_izd_id']." title='".$TEXT['delete-tit']."'>".$TEXT['delete-new']."</a>";
                 }

               $move_up = "<a href=up-down.php?izd_id=".$result_tip_izd['tip_izd_id']."&amp;position=".$result_tip_izd['position']."&amp;moving=up title='".$TEXT['global-up-down-tit']."'><img src='../skins/".$result2['skin']."/up.png' height='16' width='16' align='top' /></a>";
               $move_down = "<a href=up-down.php?izd_id=".$result_tip_izd['tip_izd_id']."&amp;position=".$result_tip_izd['position']."&amp;moving=down title='".$TEXT['global-up-down-tit']."'><img src='../skins/".$result2['skin']."/down.png' height='16' width='16' align='top' /></a>";
           ?>
           <tr>
              <td><?php echo $result_tip_izd['tip_izd']; ?></td>
              <td><?php echo $result_tip_izd['position']; ?></td>
              <td><?php echo $move_up; ?> <?php echo $move_down; ?></td>
              <td><?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
            </tr>
           <?php
               }
               echo "</tbody>";
         }
?>
</table>
<?php
require_once "../utils/bottom_adm.php";
?>