<?php
  ///////////////////////////////////////////////////
  //2007 (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=$titlepage = $TEXT['nd-title3'];
  $helppage = $TEXT['nd-help3'];
  require_once "../config.php";
  require_once "../util/top_layer1.php";

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(empty($_GET['razd_id'])) puterror2($TEXT['error-nd16']);
  if(strlen($_GET['razd_id'])>11) puterror2($TEXT['error-nd13']);
  $_GET['razd_id'] = rep($_GET['razd_id']);

  $razd_id = $_GET['razd_id'];
?>
 <img alt="<?php echo $TEXT['nd-add-new']; ?>" src= "../img/insert.png" height="15" align="top" /><a class="boldit" href="adddocform.php?razd_id=<?php echo $razd_id; ?>" title="<?php echo $TEXT['nd-add-new-tit']; ?>"><?php echo $TEXT['nd-add-new']; ?></a>
 <br />
 <br />
 <span class="tabledata"><?php echo $TEXT['nd-text1']; ?></span>
 <?php
  $query = "SELECT * FROM `tbl_documents` WHERE `razd_id`='".$_GET['razd_id']."' ORDER BY `position`";
     $query2 = mysql_query($query);
       if(!$query2) puterror2($TEXT['error-tbl14']);
        if(mysql_num_rows($query2)>0)
        {
  ?>
  <table class="table" width="100%" border="1" cellpadding=5 cellspacing=0>
  <?php
           echo "<tr class='tableheadercat'>
                     <td>".$TEXT['tbl-doc-name']."</td>
                     <td>".$TEXT['tbl-link']."</td>
                     <td>".$TEXT['tbl-position']."</td>
                     <td>".$TEXT['tbl-date']."</td>
                     <td>".$TEXT['tbl-visible']."</td>
                     <td>".$TEXT['count-view']."</td>
                     <td colspan=4>".$TEXT['tbl-action']."</td>
                 </tr>";

    while($documents = mysql_fetch_array($query2,MYSQL_ASSOC))
    {
    if($documents['visible'] == 'hide') $strvisible = "<a href=showdoc.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']." title='".$TEXT['tbl-show-tit2']."'>".$TEXT['tbl-show']."</a>";
     else $strvisible = "<a href=hidedoc.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']." title='".$TEXT['tbl-hide-tit2']."'>".$TEXT['tbl-hide']."</a>";

    if($documents['visible']=='show') $doc_vis="<img alt='show' src='../img/show.png' height='16' width='16' align='top' />";
     else $doc_vis="<img alt='hide' src='../img/hide.png' height='16' width='16' align='top' />";

      if(!empty($documents['path']) &&
         $documents['path']!="-" &&
         file_exists("../".$documents['path']))
      {
        $document = "<a href='../".$documents['path']."' target=_blank title='".$documents['description']."'' >".$TEXT['tbl-doc']."</a>";
      }
      else $document = $TEXT['tbl-doc-no'];

      $edit = "<a href=editdocform2.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']." title='".$TEXT['tbl-edit-tit-doc']."'>".$TEXT['tbl-edit']."</a>";
      $delete = "<a href=deldoc.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']." title='".$TEXT['tbl-delete-tit-doc']."'>".$TEXT['tbl-delete']."</a>";
      $move_up = "<a href=up-down-doc.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']."&amp;position=".$documents['position']."&amp;moving=up title='".$TEXT['global-up-down-tit']."'><img alt='up' src='../img/up.png' height='16' width='16' align='top' /></a>";
      $move_down = "<a href=up-down-doc.php?doc_id=".$documents['doc_id']."&amp;razd_id=".$_GET['razd_id']."&amp;position=".$documents['position']."&amp;moving=down title='".$TEXT['global-up-down-tit']."'><img alt='down' src='../img/down.png' height='16' width='16' align='top' /></a>";
      ?>
      <tr class="tabledata" onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
        <td class="boldit"><?php echo $documents['name']; ?></td>
        <td><?php echo $document; ?></td>
        <td><?php echo $documents['position']; ?></td>
        <td><?php echo $documents['data']; ?></td>
        <td><?php echo $doc_vis; ?></td>
        <td><?php echo $documents['count_view']; ?></td>
        <td><?php echo $strvisible; ?></td>
        <td><?php echo $move_up; ?> <?php echo $move_down; ?></td>
        <td><?php echo $edit; ?></td>
        <td><?php echo $delete; ?></td>
      </tr>
      <?php
    }
  }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>