<?php
  ///////////////////////////////////////////////////
  //2011 (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['bllst-text4'];
  $helppage = $TEXT['bllst-text4'];

  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($button)) $button = $TEXT['btn_del'];
  if(!isset($action)) $action = "delete-tip.php";
  if(!isset($button2)) $button2 = $TEXT['btn_back'];
  if(!isset($action2)) $action2 = "index-tip.php";
  if(empty($_GET['tip_id'])) $_GET['tip_id'] = "";
  if(empty($_POST['tip_id'])) $_POST['tip_id'] = "";
?>
<table class="table" border="0" cellpadding="2" cellspacing="0" width="60%">
<?php
  if(strlen($_GET['tip_id'])>11) puterror2($TEXT['error-tip4']);
  if(strlen($_POST['tip_id'])>11) puterror2($TEXT['error-tip4']);
  $_GET['tip_id'] = rep($_GET['tip_id']);
  $_POST['tip_id'] = rep($_POST['tip_id']);

  $old_tip_id = $_GET['tip_id'];
  $old_inst_tip_id = $_POST['tip_id'];

  if(empty($_GET['tip_id'])) $tip_id = $old_inst_tip_id;
    else $tip_id = $old_tip_id;

  $query = "SELECT `tip_name` FROM `tbl_tip_resurs` WHERE `tip_id`='$tip_id'";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl38']);
       if (mysql_num_rows($result)>0);
         {
          $result_tip_name = mysql_fetch_array($result);
           echo "<tr class='delit'><td>".$TEXT['tip-now'].$result_tip_name['tip_name']."</td></tr>";
          }
?>
</table>
<?php
  $query2 = "SELECT `tip_id`, `resource` FROM tbl_resource WHERE tip_id=".$_GET['tip_id']."";
  $result2 = mysql_query($query2);
  if(!$result2) puterror2($TEXT['error-tbl26']);
    $num_rows = mysql_num_rows($result2);
       if($num_rows>0)
          {
           echo "<p><u>".$TEXT['global-title3']."</u></p>
            <table class='table' border='1' cellpadding='3' cellspacing='0' width='40%'>
            <tr class='tableheadercat'>
            <td>".$TEXT['analiz-msg-text']."</td>
            <td>".$TEXT['supp-num-zay']."</td>
            <td>".$TEXT['tbl-action']."</td>
                 </tr>";

           while($result_tipoyanie2 = mysql_fetch_array($result2))
                {
                 $res_tip = $result_tipoyanie2['tipoyanie'];
                 $edit = "<a href=edittipform.php?tip_id=".$result_tipoyanie2['tip_id']."&zay_id=".$result_tipoyanie2['zay_id']." title='".$TEXT['tbl-edit2-tit']."'>".$TEXT['tbl-edit2']."</a>";
            ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
            <td><b><i><?php echo $res_tip; ?></i></b></td>
            <td><?php echo $result_tipoyanie2['zay_id']; ?></td>
            <td><?php echo $edit; ?></td>
                 </tr>
           <?php
                }
	    ?>
	    </table>
	    <?php
          }
          if($num_rows !== 0) $action_end = $action2;
          else $action_end = $action;

          if($num_rows !== 0) $button_end = $button2;
          else $button_end = $button;

?>
</table>
<form enctype='multipart/form-data' action=<?php echo $action_end; ?> method=post>
<table align='center'>
<tr><td></td><td>
<input class=button type=submit value='<?php echo $button_end; ?>' />
<input type=hidden name=tip_id value='<?php echo $old_tip_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>