<?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 = 'admin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/bluemoon/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 detail record from 'a2b_bikes'
  list($a2b_bikesRecords, $a2b_bikesMetaData) = getRecords(array(
    'tableName'   => 'a2b_bikes',
    'where'       => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $detailRecord = @$a2b_bikesRecords[0]; // get first record
  if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found

  // load list records from 'a2b_bikes'
  list($a2b_bikesRecords, $a2b_bikesMetaData) = getRecords(array(
    'tableName'   => 'a2b_bikes',
    'loadUploads' => false,
    '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          { margin-top: 0px; font-family: arial; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
	 .rightCol{border-left: 2px outset #FFFF00;}
	.leftCol{font-family: Sans Serif;color: #FFFFFF;background-color: #003366;margin-left: 0px;margin-top: 0px;margin-width: 0px;border-right: 2px ridge #FFFF00;}
    
  </style>
 </head>
<body>
<table border="0" align="center" width="1200" cellspacing="2" cellpadding="4">
 <tr>
 <td width="200" class="leftCol"></td>
  <td valign="top">
 <!-- STEP2: Display Record Detail (Paste this where you want your record details)   
 
-->
    <b>Record Detail</b><br/>
	 <blockquote>
        <?php foreach ($detailRecord['images'] as $index => $upload): ?>
          Upload Url: <?php echo $upload['urlPath'] ?><br/>
          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
         
      Record Number: <?php echo htmlencode($detailRecord['num']) ?><br/>
      Name: <?php echo htmlencode($detailRecord['name']) ?><br/>
      Price: <?php echo htmlencode($detailRecord['price']) ?><br/>
      Product ID/SKU: <?php echo htmlencode($detailRecord['product_id_sku']) ?><br/>
     
      Description: <?php echo $detailRecord['description']; ?><br/>
      _link : <a href="<?php echo $detailRecord['_link'] ?>"><?php echo $detailRecord['_link'] ?></a><br/>

      <!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        
       
          <!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.

          Thumb Url: <?php echo $upload['thumbUrlPath'] ?><br/><br/>
          Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

          Image Tags:<br/>
          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
          <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

          info1 (Title) : <?php echo htmlencode($upload['info1']) ?><br/>
          info2 (Caption) : <?php echo htmlencode($upload['info2']) ?><br/><br/>

          Extension: <?php echo $upload['extension'] ?><br/>
          isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          <hr/>
          // end uploads comment tag -->

        <?php endforeach ?>
        </blockquote>
      <!-- STEP2a: /Display Uploads -->


  <a href="mailto:?subject=<?php echo urlencode(thisPageUrl()) ?>">Email this Page</a>
  <!-- /STEP2: Display Record Detail -->

  

  </td>
  
  <td class="rightCol" width="200" valign="top">
<!-- STEP2: Display Record List (Paste this where you want your record list) -->
    <b>Record List</b><br/>

    <?php foreach ($a2b_bikesRecords as $listRecord): ?>
      <?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
      <?php if ($isSelected) { print "<b>"; } ?>
      <a href="<?php echo htmlencode($listRecord['_link']) ?>"><?php echo htmlencode($listRecord['name']) ?></a><br/>
      <?php if ($isSelected) { print "</b>"; } ?>
    <?php endforeach ?>

    <?php if (!$a2b_bikesRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Record List -->
 
  </td>
 </tr>
 <tr>
    <td class="footer" colspan="3"></td>
 </tr>
</table>

</body>
</html>