<?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['supp-step-add1'];
  $helppage = $TEXT['supp-step-add1-tit'];

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

  if(empty($_GET['mar_id'])) puterror2($TEXT['error-marsh16']);
  if(strlen($_GET['mar_id'])>11) puterror2($TEXT['error-marsh13']);
  $_GET['mar_id'] = rep($_GET['mar_id']);

  $mar_id = $_GET['mar_id'];

  $query = "SELECT MAX(position) AS position FROM `tbl_step` WHERE `mar_id`='".$_GET['mar_id']."' ";
     $query_tmp = mysql_query($query);
       if(!$query_tmp) puterror2($TEXT['error-tbl43']);
       $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['supp-step-name']; ?></td><td class="useraddedit"><input size=50 maxlength=200 class="inputmandatory" type=text name=name /></td></tr>
  <tr>
    <td class="useraddedit"><?php echo $TEXT['login-master']; ?></td>
    <td class="useraddedit"><select name="login_id">
    <?php
        $query = "SELECT * FROM `tbl_logins` WHERE `master`='1' ORDER BY fullname, login ";
        $user_tmp = mysql_query($query);
          if(!$user_tmp) puterror2($TEXT['error-tbl20']);
              while($user = mysql_fetch_array($user_tmp,MYSQL_ASSOC))
                {
                 $chk = "<option value=".$user['login_id'].">".$user['fullname']." &#040;".$user['login']."&#041; ";
                 echo $chk;
                }
    ?>
    </select>
    </td>
  </tr>
  <tr><td class="useraddedit"><?php echo $TEXT['logic-marsh-tit']; ?></td><td class="useraddedit">
<select name="logika">
  <option value='1' selected><?php echo $TEXT['logic-marsh1']; ?>
  <option value='2' ><?php echo $TEXT['logic-marsh2']; ?>
  <option value='3' ><?php echo $TEXT['logic-marsh3']; ?>
</select>
</td></tr>
<tr>
    <td class="useraddedit"><?php echo $TEXT['supp-tema-title']; ?></td>
    <td class="useraddedit"><select name="tema_id">
    <?php
        $query2 = "SELECT * FROM `tbl_supp_tema` ORDER BY position ";
        $user_tmp2 = mysql_query($query2);
          if(!$user_tmp2) puterror2($TEXT['error-tbl22']);
              while($tema = mysql_fetch_array($user_tmp2,MYSQL_ASSOC))
                {
                 $chk2 = "<option value=".$tema['tema_id'].">".$tema['tema']." ";
                 echo $chk2;
                }
    ?>
    </select>
    </td>
  </tr>
  <tr><td class="useraddedit"><?php echo $TEXT['supp-step-num']; ?></td><td class="useraddedit"><input size=11 maxlength=11 class="inputmandatory" type=text name=position value="<?php echo $pos; ?>" /></td></tr>
  <tr><td></td><td>
<input class=button type=submit value='<?php echo $button; ?>' />
<input type=hidden name=mar_id value='<?php echo $mar_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>