<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'gfcmsadmin/lib/viewer_functions.php';
  $dirsToCheck = array('C:/inetpub/wwwroot/','','../','../../','../../../');
  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 records from 'directory'
  list($directoryRecords, $directoryMetaData) = getRecords(array(
    'tableName'   => 'directory',
	'perPage'     => '10',
    'loadUploads' => true,
    'allowSearch' => true,
  ));

?><!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>Directory</title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

 </head>
<body>
<form action="campus.html" method="post">Quick Search: <input type="text" value="" name="last_name,first_name,department_01,department_02,department_03,department_04,title,fieldname_prefix, fieldname_keyword, fieldname_query" /> <input type="submit" value="Search" name="submit" /></form><br/>  
<a href="http://www.gfcmsu.edu/directories/departments.html">Browse By Department</a><br/><br/>
<table>
<?php foreach ($directoryRecords as $record): ?>
<tr>
<td style="padding-right: 20px; height: 175px;">
<?php foreach ($record['photo'] as $index => $upload): ?>
<img style="min-width:150px; min-height:150px;" src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="150px" height="150px" alt="" />
<?php break; //only show one image ?>
<?php endforeach ?>
<?php if(!$record['photo']) : // if there is no image uploaded, show this image ?>
<img src="images/default1.png" width="150px" height="150px" alt="" />
<?php endif; ?>
</td>
<td style="padding-right: 20px;">
<strong>
<?php echo htmlencode($record['first_name']) ?>&nbsp;
<?php echo htmlencode($record['last_name']) ?>
</strong>
<br/>
<?php echo htmlencode($record['title']) ?>
<br/>
<?php echo htmlencode($record['department_01']) ?><br/>
<?php if($record['department_02']) : ?>
<?php echo htmlencode($record['department_02']) ?>
<?php endif; ?>
</td>
<td>
Office: <?php echo htmlencode($record['office_number']) ?><br/>
Phone: <?php echo htmlencode($record['phone']) ?><br/>
Email: <?php echo '<a href="mailto:'.htmlencode($record['email']).'">'.htmlencode($record['email']).'</a>'; ?>
</td>
</tr>
<?php endforeach ?>
</table>
<?php if (!$directoryRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
	<hr/>
<?php if ($directoryMetaData['prevPage']): ?>
      <a href="<?php echo $directoryMetaData['prevPageLink'] ?>">&lt;&lt;  prev</a>
    <?php else: ?>
      &lt;&lt; prev
    <?php endif ?>

    &nbsp;- page <?php echo $directoryMetaData['page'] ?> of <?php echo $directoryMetaData['totalPages'] ?> -&nbsp;

    <?php if ($directoryMetaData['nextPage']): ?>
      <a href="<?php echo $directoryMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
    <?php else: ?>
      next &gt;&gt;
    <?php endif ?>
</body>
</html>
