<?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['meet-del'];
  $helppage = "";

  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_del'];
  if(!isset($action)) $action = "delete.php";
  if(!isset($button2)) $button2 = $TEXT['btn_back'];
  if(!isset($action2)) $action2 = "index.php";
  if(empty($_GET['room_id'])) $_GET['room_id'] = "";
//  if(empty($_POST['room_id'])) $_POST['room_id'] = "";
?>
<table class="table" border="0" cellpadding="2" cellspacing="0" width="60%" >
<?php
  if(strlen($_GET['room_id'])>11) puterror2($TEXT['meet-err-edit3']);
  if(strlen($_POST['room_id'])>11) puterror2($TEXT['meet-err-edit3']);
  $_GET['room_id'] = rep($_GET['room_id']);
  $_POST['room_id'] = rep($_POST['room_id']);

  $old_room_id = $_GET['room_id'];
  $old_doc_room_id = $_POST['room_id'];

  if(empty($_GET['room_id'])) $razd_id = $old_doc_room_id;
    else $room_id = $old_room_id;

  $query = "SELECT `room_name` FROM `tbl_meet_room` WHERE `room_id`='$room_id'";
  $result = mysql_query($query);
  if(!$result) puterror2($TEXT['error-tbl48']);
       if(mysql_num_rows($result)>0);
         {
          $result_razdel = mysql_fetch_array($result);
           echo "<tr class='delit'><td>".$TEXT['meet-now'].$result_razdel['room_name']."</td></tr>";
          }
?>
</table>
<?php
  $query2 = "SELECT
tbl_meet_event.room_id,
tbl_meet_event.meet_name,
tbl_meet_event.evnt_id,
tbl_meet_room.room_id,
tbl_meet_room.room_name
FROM tbl_meet_event
JOIN tbl_meet_room ON tbl_meet_event.room_id=tbl_meet_room.room_id
WHERE tbl_meet_event.room_id='$room_id'";
  $result2 = mysql_query($query2);
  if(!$result2) puterror2($TEXT['error-tbl49']);
    $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['evnt-name']."</td>
            <td>".$TEXT['tbl-action']."</td>
                 </tr>";

           while($result_documents = mysql_fetch_array($result2))
                {
                 $res_razd = $result_documents['meet_name'];
                 $edit = "<a href=delevnt.php?room_id=".$result_documents['room_id']."&amp;evnt_id=".$result_documents['evnt_id']." title='".$TEXT['tbl-delete']."'>".$TEXT['tbl-delete']."</a>";
            ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
            <td><?php echo $result_documents['meet_name']; ?></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=room_id value='<?php echo $old_room_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>