<?php
  ///////////////////////////////////////////////////
  //2012 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("lang/".$lang.".php")) include "lang/".$lang.".php";
     else include "lang/ru.php";

  $title=$titlepage=$TEXT['meet-title'];

  require_once "config.php";
  require_once "utils/top_meet_detail.php";

  if(empty($_GET['evnt_id'])) puterror($TEXT['meet-err-edit2']);
  if(strlen($_GET['evnt_id'])>11) puterror($TEXT['meet-err-edit3']);

  if(!empty($_GET['org_id'])) 
  {
  $org_resource = " AND tbl_meet_room.org_id = ".$_GET['org_id']." ";
  $old_org_id = $_GET['org_id'];
  }
   else {
         $query_org_no = "SELECT `org_id` FROM `tbl_organizaciya` WHERE `organizaciya` = '-' ";
           $org_no = mysql_query($query_org_no);
            if(!$org_no) puterror($TEXT['error-tbl7']);
              $result_org_no = mysql_fetch_array($org_no,MYSQL_ASSOC);
              $org_resource = " AND tbl_meet_room.org_id = ".$result_org_no['org_id']." ";
              $old_org_id = $result_org_no['org_id'];
        }

  $query1 = "SELECT
      tbl_meet_room.*
      FROM tbl_meet_room
      WHERE tbl_meet_room.room_id = '".$_GET['room_id']."' ".$org_resource."";
  $result = mysql_query($query1);
    if(!$result) puterror(mysql_error());
      {
       if(mysql_num_rows($result)>0);
        {
           while($razd = mysql_fetch_array($result))
           {
            $sm = preg_replace("/\.\.+./","",$razd['room_photo']);
             if(!empty($razd['room_photo']) && file_exists($sm)) $ima = "<td width='10%'><img alt='".$razd['room_photo']."' width='185' heigh='130' src='".$sm."' /></td>";
               else $ima = "<td></td>";

           $razd['room_descr'] = str_replace(":smile:","<img alt='картинка' src='img/smile.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":tongue:","<img alt='картинка' src='img/tongue.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":wink:","<img alt='картинка' src='img/wink.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":wassat:","<img alt='картинка' src='img/wassat.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":sad:","<img alt='картинка' src='img/sad.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":crying:","<img alt='картинка' src='img/crying.png' align=middle border=0>",$razd['room_descr']);
           $razd['room_descr'] = str_replace(":angry:","<img alt='картинка' src='img/angry.png' align=middle border=0>",$razd['room_descr']);

           echo "<table border='0' width='80%' cellpadding='0' cellspacing='0' align='left' class='formainmeet2'>
                        <tr><td></td><td></td></tr>
                        <tr>
                        ".$ima."
                        <td>
                        <table border='0' width='95%' cellpadding='0' cellspacing='0' align='left'>
                            <tr><td>&nbsp;</td><td><span class='meetname'>".$razd['room_name']."</span></td><td></td></tr>
                            <tr><td>&nbsp;</td><td><br /><span class='news3'>".$TEXT['search-descr']."&#58;</span></td><td></td></tr>
                            <tr><td>&nbsp;</td><td>".nl2br($razd['room_descr'])."</td><td></td></tr>
                            <tr><td colspan=3></td></tr>
                        </table>
                        </td></tr>
                        <tr><td></td><td></td></tr>
                        </table><br /><br />";

           }
        }
      }

      $query_z = "SELECT
          tbl_meet_event.evnt_id,
          tbl_meet_event.room_id,
          tbl_meet_event.usr_id,
          tbl_meet_event.meet_name,
          tbl_meet_event.meet_visible,
          YEAR(tbl_meet_event.meet_data) AS meet_year,
          MONTH(tbl_meet_event.meet_data) AS meet_month,
          DAY(tbl_meet_event.meet_data) AS meet_day,
          tbl_meet_event.time_start,
          tbl_meet_event.time_stop,
          tbl_meet_event.time_start_min,
          tbl_meet_event.time_stop_min,
          tbl_meet_event.meet_descr
          FROM tbl_meet_event
          WHERE tbl_meet_event.evnt_id = '".$_GET['evnt_id']."' ";
      $zayavka = mysql_query($query_z);
       if(!$zayavka) puterror($TEXT['error-tbl49']);
        if(mysql_num_rows($zayavka) > 0)
        {
         while($zay = mysql_fetch_array($zayavka,MYSQL_ASSOC))
         {
          $tema_full = $zay['meet_name'];

           $zay['meet_descr'] = str_replace(":smile:","<img alt='картинка' src='img/smile.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":tongue:","<img alt='картинка' src='img/tongue.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":wink:","<img alt='картинка' src='img/wink.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":wassat:","<img alt='картинка' src='img/wassat.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":sad:","<img alt='картинка' src='img/sad.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":crying:","<img alt='картинка' src='img/crying.png' align=middle border=0>",$zay['meet_descr']);
           $zay['meet_descr'] = str_replace(":angry:","<img alt='картинка' src='img/angry.png' align=middle border=0>",$zay['meet_descr']);

           $date_day = $zay['meet_day'];
           $date_month = $zay['meet_month'];
           $date_year = $zay['meet_year'];
           $year = $TEXT['year'];
          if($zay['meet_year'] == "" || $zay['meet_year'] == "0") $data_r = "---";
            else $data_r = (date("$date_day $month[$date_month] $date_year $year "));

          $query_z2 = "SELECT familiya, name, otchestvo, user_id FROM tbl_users WHERE user_id = '".$zay['usr_id']."' ";
                $zayavka2 = mysql_query($query_z2);
                  if(!$zayavka2) puterror($TEXT['error-tbl2']);
                   if(mysql_num_rows($zayavka2) > 0)
                    {
                     while($zay2 = mysql_fetch_array($zayavka2,MYSQL_ASSOC))
                     {
                      $full_name = "<a class='support24' href=# onClick=\"window.open('user.php?user_id=".$zay2['user_id']."','popup','top=".$TEXT['user-top'].",left=".$TEXT['user-left'].",width=".$TEXT['user-width'].",height=".$TEXT['user-height'].",status=no,scrollbars=no,location=no,menubar=no,toolbar=no')\" title = ".$TEXT['global-usr'].">".$zay2['familiya']." ".$zay2['name']." ".$zay2['otchestvo']."</a>";
                     }
                    }

          echo "<table border='0' width='80%' cellpadding='0' cellspacing='0' align='left' class='meetrows'>";
          echo "<tr align='left'><td class='meetname'><br />".$tema_full."</td></tr>
                    <tr align='left'><td><hr width='80%' align='left' /></td></tr>
                    <tr align='left'><td>".$TEXT['search-date']." - ".$data_r."</td></tr>
                    <tr align='left'><td>".$TEXT['meet-time1']." - ".$zay['time_start']."&#58;".$zay['time_start_min']."</td></tr>
                    <tr align='left'><td>".$TEXT['meet-time2']." - ".$zay['time_stop']."&#58;".$zay['time_stop_min']."</td></tr>
                    <tr align='left'><td>".$TEXT['support30']." - ".$full_name."</td></tr>
                    <tr align='left'><td><br /><span class='news3'>".$TEXT['meet-text']."&#58;</span></td></tr>
                    <tr align='left'><td class='meetdesc'>".nl2br($zay['meet_descr'])."</td></tr></table>";
         }
       }
?>
</div>
<?php
  require_once "utils/bottom.php";
?>