<? header('Content-type: text/xml'); 
      $idRestaurantIN = 6;

?>
<rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Pig N Whistle, Eagle Street</title>
<link>http://www.pignwhistle.com.au/EagleStreet/index.xml</link>
<description>Pig N Whistle is the best Pub on the riverside in Eagle Street, Brisbane, whether you are looking for a fun night out, good food or your next function venue.</description>
<dc:language>en-gb</dc:language>
<dc:rights>Copyright 2002 Pig N Whistle.</dc:rights>
<dc:date>2005-12-17T17:30:04+10:00</dc:date>

<admin:generatorAgent rdf:resource="http://www.pignwhistle.com.au/feed/" />
<admin:errorReportsTo rdf:resource="mailto:rsshelp@pignwhistle.com.au"/>
<sy:updatePeriod>weekly</sy:updatePeriod>
<sy:updateFrequency>3</sy:updateFrequency>
<sy:updateBase>2005-12-17T17:30+10:00</sy:updateBase>

<?php
  include_once $_SERVER['DOCUMENT_ROOT'].'/c/pignwhistle.incl.php';
  include_once TXLOCATIONDATA.'/mysqlVariables.txt';

  $connection = mysql_connect(NMHOST, NMUSER, TXPASSWORD);
  mysql_select_db(NMDATABASEPIG, $connection);

  $txQuery = 'SELECT idEvent, txTitleEvent, dsEvent, dtStartDisplayEvent ';
  $txQuery .= ' FROM event ';
  $txQuery .= ' WHERE ';
  $txQuery .= ' ( ';
  $txQuery .= " dtEndDisplayEvent =  '0000-00-00 00:00:00' ";
  $txQuery .= ' OR  dtEndDisplayEvent >= '."'".date('Y-m-d H:i:s')."'";
  $txQuery .= ' ) ';
  $txQuery .= ' AND ( ';
  $txQuery .= " dtStartDisplayEvent =  '0000-00-00 00:00:00' ";
  $txQuery .= ' OR  dtStartDisplayEvent <= '."'".date('Y-m-d H:i:s')."' ";
  $txQuery .= '   ) ';
  $txQuery .= '  AND (idRestaurant = '.$idRestaurantIN.')';

//writeEventEntry('the query', $txQuery);

  $result = mysql_query($txQuery);
  
  if (false !== $result) {
    $lsEvents = array();
    while ($row = mysql_fetch_object($result)) {
      writeEventEntry(stripslashes($row->txTitleEvent), stripslashes($row->dsEvent));
    }
    mysql_free_result($result);
  }
  
  $txDays = 'SunMonTueWedThuFriSat';
  $dtNow = time();
  $noDayRoot = date('j', $dtNow) - strpos ( $txDays, date('D', $dtNow) )/3;
      
// sunday 
      $dtSunday =  mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+0, date('Y', $dtNow) );
      if ($dtSunday < $dtNow) {$dtSunday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+0+7, date('Y', $dtNow) ); }
      $lsResults[0]['title'] = 'Jazz and Beef, 12.30pm '.date('l F j', $dtSunday);
      $lsResults[0]['desc'] = 'Sundays at the Pig 1824 6 hour Slow Roasted Butt of Beef &amp; Live Jazz in the Garden from 12.30pm, relax with a pint or glass of wine and let the smooth tones overcome you.';

// monday
      $dtMonday =  mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+1, date('Y', $dtNow) );
      if ($dtMonday < $dtNow) {$dtMonday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+1+7, date('Y', $dtNow) ); }
      $lsResults[1]['title'] = date('l F j', $dtMonday).' - Traditional British Food, all day!';
      $lsResults[1]['desc'] = '<p align="left">Breakfast from 7am</p>'."\n".'<p align="left">Lunch 11.30 - 3pm</p>'."\n".'<p align="left">Dinner 5pm - Late</p>';

// tuesday
      $dtTuesday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+2, date('Y', $dtNow) );
      if ($dtTuesday < $dtNow) {$dtTuesday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+2+7, date('Y', $dtNow) ); }
      $lsResults[2]['title'] = date('l F j', $dtTuesday).' - Traditional British Food, all day!';
      $lsResults[2]['desc'] = '<p>Breakfast from 7am</p>'."\n".'<p>Lunch 11.30 - 3pm</p>'."\n".'<p>Dinner 5pm - Late</p>';

// no wednesday display
      $dtWednesday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+3, date('Y', $dtNow) );
      if ($dtWednesday < $dtNow) {$dtWednesday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+3+7, date('Y', $dtNow) ); }
      $lsResults[3]['title'] = 'HUMP DAY TRIVIA @ 12.45 '.date('l F j', $dtWednesday);
      $lsResults[3]['desc'] = '<p> Please note: To guarantee a table for your team please call before 10.30 to book. Win fantastic prizes! </p>';

// thursday
      $dtThursday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+4, date('Y', $dtNow) );
      if ($dtThursday < $dtNow) {$dtThursday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+4+7, date('Y', $dtNow) ); }
      $lsResults[4]['title'] = 'EXPRESS TRIVIA @ 12.45 '.date('l F j', $dtThursday);
      $lsResults[4]['desc'] = '<p> Please note: To guarantee a table for your team please call before 10.30 to book. Win fantastic prizes! </p>'."\n";

// friday 
      $dtFriday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+5, date('Y', $dtNow) );
      if ($dtFriday < $dtNow) {$dtFriday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+5+7, date('Y', $dtNow) ); }
      $lsResults[5]['title'] = date('l F j', $dtFriday).' - wind down the week with lunch at the Pig';
      $lsResults[5]['desc'] = '<p><img style="float: left" class="left" src="http://www.pignwhistle.com.au/EagleStreet/images/friday1.jpg" width="274" height="151" alt=""> <strong>Lunch Special:</strong> Weebollabolla Shorthorns Grass Fed &amp; Grain assisted, Prime Cuts of Beef.<br><strong>After 3pm:</strong> Book for min 20 people &amp; receive a complimentary platter of food when you mention this offer.</p><p>Please note: Lunch Bookings close on a Friday @ 11.30, due to large number of bookings we have to handle &amp; the time it takes to set up. </p>'."\n";
      
// saturday
      $dtSaturday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+6, date('Y', $dtNow) );
      if ($dtSaturday < $dtNow) {$dtSaturday = mktime ( 0 , 0, 0, date('n', $dtNow), $noDayRoot+6+7, date('Y', $dtNow) ); }
      $lsResults[6]['title'] = date('l F j', $dtSaturday).' - Sports, Sports, Sports!';
      $lsResults[6]['desc'] = '<p>Saturday is for sports coverage on large screens and TVs throughout. </p>';
      
      for ($jj=0; $jj<=sizeof($lsResults); $jj++) {
        if (isset($lsResults[$jj]['title']) && 0 < sizeof($lsResults[$jj]['title'])) {
          writeEventEntry($lsResults[$jj]['title'], $lsResults[$jj]['desc']);
        }
      }

?>

</channel>
</rss>

<?php
  function writeEventEntry($txTitleEventIN, $dsEventIN) {
?>
<item>
  <title><?php echo $txTitleEventIN; ?></title>
  <link>http://www.pignwhistle.com.au/EagleStreet/</link>
  <description>Events at Pig N Whistle Eagle St</description>
  <content:encoded><![CDATA[
<?php echo $dsEventIN; ?>
<hr style="clear: both;" />
<p>Subscribe to events for our other pubs at <a href="http://www.pignwhistle.com.au/feed/">http://www.pignwhistle.com.au/feed/</a>.</p>
  ]]></content:encoded>
</item>

<?php
  }
?>