<?php
  ///////////////////////////////////////////////////
  //2010 (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['kat-title'];
  $helppage = $TEXT['kat-help'];

  require_once "../config.php";
  require_once "../util/top_layer1.php";

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

  if(!isset($title)) $title = $TEXT['kat-title'];
  if(!isset($button)) $button = $TEXT['btn_add'];
  if(!isset($action)) $action = "add.php";
  if(!isset($visible)) $visible = "checked";

  if(!empty($_GET['zh_str_id']))
  {
    $query_kat = "SELECT * FROM `tbl_zhurn_strukt` WHERE `zh_str_id`='".$_GET['zh_str_id']."' ";
     $result_kat = mysql_query($query_kat);
      if(!$result_kat) puterror2($TEXT['error-tbl40']);
        $result_k = mysql_fetch_array($result_kat);

    $parent = $result_k['zh_str_id'];
  }
  else
  {
    $parent = 0;
  }

$query_pos = "SELECT MAX(position) AS max_pos FROM `tbl_zhurn_strukt` WHERE `parent`='".$parent."' ";
  $result_pos = mysql_query($query_pos);
    if(!$result_pos) puterror2($TEXT['error-tbl40']);
     $pos = mysql_fetch_array($result_pos);
     $position = $pos['max_pos'] + 10;

?>
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
<tr><td class=useraddedit><?php echo $TEXT['menu-btn33']; ?></td><td class=useraddedit><input size=30 maxlength=255 class=inputmandatory type=text name=strukt_name /></td></tr>
<tr><td class=useraddedit><?php echo $TEXT['tbl-position']; ?></td><td class=useraddedit><input size=5 maxlength=5 class=inputmandatory type=text name=position value="<?php echo $position; ?>" /></td></tr>
<tr><td class=useraddedit><?php echo $TEXT['tbl-show']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?> /></td></tr>
<tr><td></td><td>
    <input type=hidden name=parent value=<?php echo $parent; ?> />
    <input class="button" type=submit value='<?php echo $button; ?>' />
    </td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>