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

  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['nd-title7'];
  if(!isset($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "edit.php";

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

  $old_razd_id = $_GET['razd_id'];

  $query = "SELECT * FROM `tbl_razdel` WHERE `razd_id`='".$_GET['razd_id']."' ";
  $result = mysql_query($query);
  if (!$result) puterror2($TEXT['error-tbl15']);
   $result2 = mysql_fetch_array($result);
         $razdel = $result2['razdel'];
         $position = $result2['position'];
         $old_org_id = $result2['org_id'];

?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class="useraddedit"><?php echo $TEXT['nd-field9']; ?></td><td class="useraddedit"><input size=30 maxlength=200 class="inputmandatory" type=text name=razdel value='<?php echo $razdel; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['nd-field10']; ?></td><td class="useraddedit"><input size=5 maxlength=11 class="inputmandatory" type=text name=position value='<?php echo $position; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['org-field1']; ?></td>
    <td class="useraddedit"><select class="inputmandatory" name="org_id">
    <?php
        $query2 = "SELECT * FROM `tbl_organizaciya` ORDER BY organizaciya ";
        $org_tmp = mysql_query($query2);
          if(!$org_tmp) puterror2($TEXT['error-tbl7']);
              while($org = mysql_fetch_array($org_tmp))
                {
                 if($org['org_id'] == $old_org_id)
                   $chk = "<option selected value=".$org['org_id'].">".$org['organizaciya'];
                 else 
		   $chk = "<option value=".$org['org_id'].">".$org['organizaciya'];
                 echo $chk;
                }
    ?>
    </select></td></tr>
<tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=razd_id value='<?php echo $old_razd_id; ?>' />
<input type=hidden name=old_org_id value='<?php echo $old_org_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>