<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

  // load viewer library
  $libraryPath = 'cmsb/lib/viewer_functions.php';
  $dirsToCheck = array('/home/codyhors/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load record from 'event_schedule_days'
  list($event_schedule_daysRecords, $event_schedule_daysMetaData) = getRecords(array(
    'tableName'   => 'event_schedule_days',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $event_schedule_daysRecord = @$event_schedule_daysRecords[0]; // get first record


  // load records from 'event_schedule2'
  list($event_schedule2Records, $event_schedule2MetaData) = getRecords(array(
    'tableName'   => 'event_schedule2',
	'where'       => "day_of_event LIKE '%\tday1\t%'",
    'loadUploads' => true,
    'allowSearch' => false,
  ));

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <style type="text/css">
    body          { font-family: arial; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
  </style>
 </head>
<body>
  <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
    <h1>Event Schedule</h1>
	
<!--/*DAY 1*/-->
	<div class="list-title"><h2><?php echo htmlencode($event_schedule_daysRecord['1st_day_of_week']) ?> <?php echo htmlencode($event_schedule_daysRecord['event_month']) ?> <?php echo htmlencode($event_schedule_daysRecord['day_1_date']) ?></h2></div>
	
	
    <?php foreach ($event_schedule2Records as $record): ?>
	<?php if (@$_REQUEST['day_of_event:labels'] == 'day1'): ?>
      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Day of Event (values): <?php echo join(', ', $record['day_of_event:values']); ?><br/>
      Day of Event (labels): <?php echo join(', ', $record['day_of_event:labels']); ?><br/>
      Calendar Title: <?php echo htmlencode($record['calendar_title']) ?><br/>
      Event Dates: <?php echo htmlencode($record['event_dates']) ?><br/>
      Event Time: <?php echo htmlencode($record['event_time']) ?><br/>
      Event Blurb: <?php echo htmlencode($record['event_blurb']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Event Start: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
      City: <?php echo htmlencode($record['city']) ?><br/>
      State: <?php echo htmlencode($record['state']) ?><br/>
      Content: <?php echo $record['content']; ?><br/>

		<?php endif ?>
    <?php endforeach ?>


    <?php if (!$event_schedule2Records): ?>
      No records were found!<br/><br/>
    <?php endif ?>

	
<!--/*DAY 2*/-->
	<div class="list-title"><h2><?php echo htmlencode($event_schedule_daysRecord['2nd_day_of_week']) ?> <?php echo htmlencode($event_schedule_daysRecord['event_month']) ?> <?php echo htmlencode($event_schedule_daysRecord['day_2_date']) ?></h2></div>
	
	
    <?php foreach ($event_schedule2Records as $record): ?>
	<?php if (@$_REQUEST['day_of_event:labels'] == 'day2'): ?>
      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Day of Event (values): <?php echo join(', ', $record['day_of_event:values']); ?><br/>
      Day of Event (labels): <?php echo join(', ', $record['day_of_event:labels']); ?><br/>
      Calendar Title: <?php echo htmlencode($record['calendar_title']) ?><br/>
      Event Dates: <?php echo htmlencode($record['event_dates']) ?><br/>
      Event Time: <?php echo htmlencode($record['event_time']) ?><br/>
      Event Blurb: <?php echo htmlencode($record['event_blurb']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Event Start: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
      City: <?php echo htmlencode($record['city']) ?><br/>
      State: <?php echo htmlencode($record['state']) ?><br/>
      Content: <?php echo $record['content']; ?><br/>

		<?php endif ?>
    <?php endforeach ?>


    <?php if (!$event_schedule2Records): ?>
      No records were found!<br/><br/>
    <?php endif ?>

	
<!--/*DAY 3*/-->
	<div class="list-title"><h2><?php echo htmlencode($event_schedule_daysRecord['3rd_day_of_week']) ?> <?php echo htmlencode($event_schedule_daysRecord['event_month']) ?> <?php echo htmlencode($event_schedule_daysRecord['day_3_date']) ?></h2></div>
	
	
    <?php foreach ($event_schedule2Records as $record): ?>
	<?php if (@$_REQUEST['day_of_event:labels'] == 'day3'): ?>
      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Day of Event (values): <?php echo join(', ', $record['day_of_event:values']); ?><br/>
      Day of Event (labels): <?php echo join(', ', $record['day_of_event:labels']); ?><br/>
      Calendar Title: <?php echo htmlencode($record['calendar_title']) ?><br/>
      Event Dates: <?php echo htmlencode($record['event_dates']) ?><br/>
      Event Time: <?php echo htmlencode($record['event_time']) ?><br/>
      Event Blurb: <?php echo htmlencode($record['event_blurb']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Event Start: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
      City: <?php echo htmlencode($record['city']) ?><br/>
      State: <?php echo htmlencode($record['state']) ?><br/>
      Content: <?php echo $record['content']; ?><br/>

		<?php endif ?>
    <?php endforeach ?>


    <?php if (!$event_schedule2Records): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->



</body>
</html>
