<?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-title2'];
  $helppage = $TEXT['nd-help2'];

  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($button)) $button = $TEXT['btn_add'];
  if(!isset($action)) $action = "adddoc.php";
  if(!isset($showhide)) $visible = "checked";

  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'];

  $query = "SELECT MAX(position) AS position FROM `tbl_documents` WHERE `razd_id`='".$_GET['razd_id']."' ";
     $query_tmp = mysql_query($query);
       if(!$query_tmp) puterror2($TEXT['error-tbl18']);
       $res = mysql_fetch_array($query_tmp);
       $pos = $res['position'] + 1;
?>
<form  enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
  <tr><td class="useraddedit"><?php echo $TEXT['nd-field1']; ?></td><td class="useraddedit"><input size=50 maxlength=200 class="inputmandatory" type=text name=name /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-descr']; ?></td><td class="useraddedit"><textarea class=input cols="50" rows="5" name=descrip ></textarea></td></tr>
  <tr><td class="useraddedit"><nobr><?php echo $TEXT['tbl-doc']; ?></nobr></td><td class="useraddedit"><input class="inputmandatory"  type=file name=document /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-position']; ?></td><td class="useraddedit"><input size=11 maxlength=11 class="inputmandatory" type=text name=position value="<?php echo $pos; ?>" /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['global-visible']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?> /></td></tr>
  <tr><td></td><td>
  <input class="button" type=submit value='<?php echo $button; ?>' />
  <input type=hidden name=razd_id value='<?php echo $razd_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>