<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/content/d/i/l/dillonharley/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 records
  list($newvehiclesRecords, $newvehiclesMetaData) = getRecords(array(
    'tableName'   => 'newvehicles',
    'perPage'     => '10',
    'where' => 'active=1',
  ));

?>
<!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>VEHICLE RESULTS BARE</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>Vehicles - List Page Viewer</h1>
    <?php foreach ($newvehiclesRecords as $record): ?>
      NewUsed: <?php echo $record['newused'] ?><br/>
      Year: <?php echo $record['year'] ?><br/>
      Make: <?php echo join(', ', getListLabels('newvehicles', 'make', $record['make'])); ?><br/>
      Model: <?php echo $record['model'] ?><br/>
      Family: <?php echo $record['family'] ?><br/>
      Price: <?php echo $record['price'] ?><br/>
      Engine: <?php echo $record['engine'] ?><br/>
      Color: <?php echo $record['color'] ?><br/>
      Security: <?php echo join(', ', getListLabels('newvehicles', 'security', $record['security'])); ?><br/>
      Miles: <?php echo $record['miles'] ?><br/>
      ListText: <?php echo $record['ListText'] ?><br/>
      _link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


      <!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        <?php foreach ($record['images'] as $upload): ?>
          <?php if ($upload['hasThumbnail']): ?>
            <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

          <?php elseif ($upload['isImage']): ?>
            <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

          <?php else: ?>
            <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

          <?php endif ?>
        <?php endforeach ?>
      <!-- STEP2a: /Display Uploads -->


      <hr/>
    <?php endforeach ?>

    <?php if ($newvehiclesMetaData['invalidPageNum']): ?>
      Results page '<?php echo $newvehiclesMetaData['page']?>' not found, <a href="<?php echo $newvehiclesMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
    <?php elseif (!$newvehiclesRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->


  <!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
    <?php if ($newvehiclesMetaData['prevPage']): ?>
      <a href="<?php echo $newvehiclesMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
    <?php else: ?>
      &lt;&lt; prev
    <?php endif ?>

    - page <?php echo $newvehiclesMetaData['page'] ?> of <?php echo $newvehiclesMetaData['totalPages'] ?> -

    <?php if ($newvehiclesMetaData['nextPage']): ?>
      <a href="<?php echo $newvehiclesMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
    <?php else: ?>
      next &gt;&gt;
    <?php endif ?>
  <!-- /STEP3: Display Page Links -->


</body>
</html>
