<?php require_once "/home/csoccer/public_html/webadmin/lib/viewer_functions.php"; 
 
  // load records 
  list($records,) = getRecords(array( 
    'tableName'   => 'local_schedules',
  )); 
  
    // if the user has supplied "as_csv" in query string 
  if ( $_REQUEST['as_csv']) { 
   
  // specify fields to output 
  $fields = array('age_group', 'home_team', 'away_team', 'field', 'date'); 
   
   $filename = "schedule_".date("Y-m-d_H-i",time());  
    header("Content-type: application/vnd.ms-excel");  
    header("Content-disposition: csv" . date("Y-m-d") . ".csv");  
    header( "Content-disposition: filename=".$filename.".csv");
   
  // output csv header row 
  print(join(',', $fields) . "\n"); 
   
  // loop over records, outputting a row for each 
  foreach ($records as $record) { 
    $row = array(); 
    foreach ($fields as $field) { 
      $value = $record[$field]; 
      // if this value contains a special character, quote and escape it 
      if ( preg_match('/[," \t\n]/', $value) ) { 
        $value = '"' . preg_replace('/"/', '""', $value) . '"'; 
      } 
      array_push($row, $value); 
    } 
    echo(join(',', $row) . "\n"); 
  } 
 
 // exit -- we are finished with the page 
    exit; 
  } 
?>
<?php include_once "/home/network/public_html/sep/index.php" ?>
<!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>
<meta http-equiv="Content-Language" content="en-us">
<title>Schedules</title>
<link rel="shortcut icon" href="../favicon.ico">
<link rel="alternate" type="application/rss+xml" title="Sitemap" href="../sitemap.xml">

</head>

<body link="#0000FF" vlink="#0000FF" alink="#0000FF">

<div align="center"><table border="0" cellpadding="3" cellspacing="3" width="675" id="table1">
		<tr>
			<td colspan="3" style="font-family: Arial; font-size: 8pt"><div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_email">Email Schedule</a>
<a class="addthis_button_print">Print Schedule</a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=csasoccer"></script></td>
			<td colspan="3" style="font-family: Arial; font-size: 8pt" align="right">&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#000000" width="71"><b>
			<font size="2" face="Arial" color="#FFFFFF">Age Group</font></b></td>
			<td bgcolor="#000000" width="172"><b>
			<font size="2" face="Arial" color="#FFFFFF">Date</font></b></td>
			<td bgcolor="#000000" width="91"><b>
			<font size="2" face="Arial" color="#FFFFFF">Time</font></b></td>
			<td bgcolor="#000000" width="130"><b>
			<font size="2" face="Arial" color="#FFFFFF">Home Team</font></b></td>
			<td bgcolor="#000000" width="132"><b>
			<font size="2" face="Arial" color="#FFFFFF">Away Team</font></b></td>
			<td bgcolor="#000000"><b>
			<font size="2" face="Arial" color="#FFFFFF">Field</font></b></td>
		</tr>
		<?php foreach ($local_schedulesRecords as $record): ?>
		<tr>
			<td width="71"><font size="2" face="Arial"><?php echo $record['age_group'] ?></font></td>
			<td width="172"><font size="2" face="Arial"><?php echo date("D, M d, Y", strtotime($record['date'])) ?></font></td>
			<td width="91"><font size="2" face="Arial"><?php echo date("g:i a", strtotime($record['date'])) ?></font></td>
			<td width="130"><font size="2" face="Arial"><a href="schedules/local.php?home_team,away_team_keyword=<?php echo $record['home_team'] ?>"><?php echo $record['home_team'] ?></a></font></td>
			<td width="132"><font size="2" face="Arial"><a href="schedules/local.php?home_team,away_team_keyword=<?php echo $record['away_team'] ?>"><?php echo $record['away_team'] ?></a></font></td>
			<td><font size="2" face="Arial"><?php echo $record['field'] ?></font></td>
		</tr>
		<?php endforeach; ?>
	</table>
</div>

<p align="center"><a href="?as_csv=1&<?php echo $_SERVER['QUERY_STRING'] ?>">Download these results in CSV format</a></p>

</body>

</html>