<?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['supp-step'];
  $helppage = $TEXT['supp-step-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(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 `mar_name` FROM `tbl_marsh` WHERE `mar_id`='".$_GET['mar_id']."' ";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl42']);
   $result_mar = mysql_fetch_array($result,MYSQL_ASSOC);
         $mar = $result_mar['mar_name']."&raquo;";

?>
 <img alt="<?php echo $TEXT['inst-add-new2']; ?>" src= "../img/insert.png" height="15" align="top" /><a class="boldit" href="addmarshform.php?mar_id=<?php echo $mar_id; ?>" title="<?php echo $TEXT['supp-step-help']; ?>"><?php echo $TEXT['supp-step-add'].$mar; ?></a>
 <br />
 <br />
 <span class="tabledata"><?php echo $TEXT['supp-step-text1']; ?></span>
 <?php
  $query = "SELECT 
    tbl_step.*,
    tbl_logins.login,
    tbl_logins.fullname,
    tbl_supp_tema.tema
    FROM tbl_step
    JOIN tbl_logins ON tbl_step.login_id=tbl_logins.login_id
    LEFT JOIN tbl_supp_tema ON tbl_step.tema_id=tbl_supp_tema.tema_id
    WHERE tbl_step.mar_id='".$_GET['mar_id']."'
    ORDER BY tbl_step.position ";
     $query2 = mysql_query($query);
       if(!$query2) puterror2($TEXT['error-tbl43']);
         if(mysql_num_rows($query2)>0)
          {
  ?>
  <table class="table" width="80%" border="1" cellpadding=5 cellspacing=0>
  <?php
   echo "<tr class='tableheadercat'>
          <td>".$TEXT['supp-step-num']."</td>
          <td>".$TEXT['supp-step-name']."</td>
          <td>".$TEXT['logic-marsh-tit2']."</td>
          <td>".$TEXT['supp-tema-title']."</td>
          <td>".$TEXT['login-master']."</td>
          <td colspan=3>".$TEXT['tbl-action']."</td>
         </tr>";

    while($instructions = mysql_fetch_array($query2,MYSQL_ASSOC))
    {
      $edit = "<a href=editmarshform.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']." title='".$TEXT['tbl-edit-tit-inst']."'>".$TEXT['tbl-edit']."</a>";
      $delete = "<a href=delmarsh.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;position=".$instructions['position']." title='".$TEXT['tbl-delete-tit-inst']."'>".$TEXT['tbl-delete']."</a>";
      $move_up = "<a href=up-down-step.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;position=".$instructions['position']."&amp;moving=up title='".$TEXT['global-up-down-tit']."'><img alt='up' src='../img/up.png' height='16' width='16' align='top' /></a>";
      $move_down = "<a href=up-down-step.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;position=".$instructions['position']."&amp;moving=down title='".$TEXT['global-up-down-tit']."'><img alt='down' src='../img/down.png' height='16' width='16' align='top' /></a>";

      if($instructions['logika'] == "1") $logika = "<a href=ravniy-step.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;logika=".$instructions['logika']."&amp;position=".$instructions['position']." title='".$TEXT['logic-marsh-ravno']."'><img alt='".$TEXT['logic-marsh1']."' src='../img/logik-otkl.png' /></a>";
      elseif($instructions['logika'] == "2") $logika = "<a href=ravniy-step.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;logika=".$instructions['logika']."&amp;position=".$instructions['position']." title='".$TEXT['logic-marsh-ravno']."'><img alt='".$TEXT['logic-marsh2']."' src='../img/logik-and.png' /></a>";
       else $logika = "<a href=ravniy-step.php?step_id=".$instructions['step_id']."&amp;mar_id=".$_GET['mar_id']."&amp;logika=".$instructions['logika']."&amp;position=".$instructions['position']." title='".$TEXT['logic-marsh-ravno']."'><img alt='".$TEXT['logic-marsh3']."' src='../img/logik-or.png' /></a>";

     if($instructions['tema'] == "") $tema = "---";
      else $tema = $instructions['tema'];

      ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
             <td><?php echo $instructions['position']; ?></td>
             <td><?php echo $instructions['step_name']; ?></td>
             <td><?php echo $logika; ?></td>
             <td><?php echo $tema; ?></td>
             <td><?php echo $instructions['fullname']; ?> &#040;<?php echo $instructions['login']; ?>&#041;</td>
             <td><?php echo $move_up; ?> <?php echo $move_down; ?></td>
             <td><?php echo $edit; ?></td>
             <td><?php echo $delete; ?></td>
           </tr>
            <?php
    }
  }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>