<?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 = "editinst.php";

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

  $old_instr_id = $_GET['instr_id'];
  $old_razd_id = $_GET['razd_id'];

  $query = "SELECT tbl_instructions.*, tbl_razdel_instr.razd_id, tbl_razdel_instr.razdel FROM tbl_instructions JOIN tbl_razdel_instr ON tbl_instructions.razd_id=tbl_razdel_instr.razd_id WHERE tbl_instructions.instr_id='".$_GET['instr_id']."' ";
  $result = mysql_query($query);
  if (!$result) puterror2($TEXT['error-tbl18']);
   $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['inst-field7']; ?></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_instr` WHERE `visible` != 'hide' ORDER BY `position`";
        $razdel_tmp = mysql_query($query);
          if(!$razdel_tmp) puterror2($TEXT['error-tbl19']);
              while($razdel = mysql_fetch_array($razdel_tmp))
                {
                 if($razdel['razd_id'] == $old_razd_id)
                   $chk = "<option selected value=".$razdel['razd_id'].">".$razdel['razdel']."";
                    else $chk = "<option value=".$razdel['razd_id'].">".$razdel['razdel']."";
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class=button type=submit value='<?php echo $button; ?>' />
<input type=hidden name=instr_id value='<?php echo $old_instr_id; ?>' />
<input type=hidden name=old_razd_id value='<?php echo $old_razd_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>