<?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-ed'];
  $helppage = $TEXT['supp-step-ed-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($button)) $button = $TEXT['btn_edit'];
  if(!isset($action)) $action = "editmarsh.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']);
  if(empty($_GET['step_id'])) puterror2($TEXT['error-marsh17']);
  if(strlen($_GET['step_id'])>11) puterror2($TEXT['error-marsh18']);
  $_GET['step_id'] = rep($_GET['step_id']);

  $old_step_id = $_GET['step_id'];
  $old_mar_id = $_GET['mar_id'];

  $query = "SELECT * FROM `tbl_step` WHERE `step_id`='".$_GET['step_id']."' ";
     $query_tmp = mysql_query($query);
       if(!$query_tmp) puterror2($TEXT['error-tbl43']);
       $res = mysql_fetch_array($query_tmp,MYSQL_ASSOC);
       $logika = $res['logika'];

?>
<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" value="<?php echo $res['step_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))
                {
                 if($user['login_id'] == $res['login_id'])
                   $chk = "<option selected value=".$user['login_id'].">".$user['fullname']." &#040;".$user['login']."&#041; ";
                    else $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' <?php if($logika =='1') echo "selected"?>><?php echo $TEXT['logic-marsh1']; ?>
  <option value='2' <?php if($logika =='2') echo "selected"?>><?php echo $TEXT['logic-marsh2']; ?>
  <option value='3' <?php if($logika =='3') echo "selected"?>><?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))
                {
                 if($tema['tema_id'] == $res['tema_id'])
                   $chk2 = "<option selected value=".$tema['tema_id'].">".$tema['tema']."";
                    else $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 $res['position']; ?>" /></td></tr>
  <tr><td></td><td>
<input type=hidden name=step_id value='<?php echo $old_step_id; ?>' />
<input type=hidden name=mar_id value='<?php echo $old_mar_id; ?>' />
<input class="button" type=submit value='<?php echo $button; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>