<?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['global-title5'];
  $helppage = $TEXT['global-help'];

  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(!isset($title)) $title = $TEXT['global-title5'];
  if(!isset($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "editdoc.php";

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

  $old_doc_id = $_GET['doc_id'];
  $old_razd_id = $_GET['razd_id'];

  $query = "SELECT tbl_documents.*, tbl_razdel.razd_id, tbl_razdel.razdel FROM tbl_documents JOIN tbl_razdel ON tbl_documents.razd_id=tbl_razdel.razd_id WHERE tbl_documents.doc_id='".$_GET['doc_id']."' ";
  $result = mysql_query($query);
  if (!$result) puterror2($TEXT['error-tbl14']);
   $result2 = mysql_fetch_array($result);
         $name = $result2['name'];
         $path = $result2['path'];
         $res_razd = $result2['razdel'];

?>
<p><h3><?php echo $TEXT['nd-now2']; ?><b><?php echo $res_razd; ?></b></h3></p>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-doc-name']; ?></td><td class="userassociation"><?php echo $name; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-razd']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="razd_id">
    <?php
        $query = "SELECT * FROM `tbl_razdel` WHERE `visible` != 'hide' ORDER BY `position`";
        $razdel_tmp = mysql_query($query);
          if(!$razdel_tmp) puterror2($TEXT['error-tbl15']);
              while($razdel = mysql_fetch_array($razdel_tmp))
                {
                 if($razdel['razd_id'] == $razd_id)
                   {
                   $chk = "selected";
                   }
                 else $chk = "";
                 echo "<option ".$chk."value=".$razdel['razd_id'].">".$razdel['razdel']."";
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=doc_id value='<?php echo $old_doc_id; ?>' />
<input type=hidden name=old_razd_id value='<?php echo $old_razd_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>