<?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/blakem/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 records from 'product_types'
  list($product_typesRecords, $product_typesMetaData) = getRecords(array(
    'tableName'   => 'product_types',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

  // load detail record from 'products'
  list($productsRecords, $productsMetaData) = getRecords(array(
    'tableName'   => 'products',
    'loadUploads' => true,
    'allowSearch' => true,
    'limit'       => '1',
  ));
  $detailRecord = @$productsRecords[0]; // get first record

  // load list records from 'products'
  list($productsRecords, $productsMetaData) = getRecords(array(
    'tableName'   => 'products',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
  
  // load record from 'contact_person'
  list($contact_personRecords, $contact_personMetaData) = getRecords(array(
    'tableName'   => 'contact_person',
    'where' 	  => "num = '". intval($detailRecord['rep']) ."'" , 
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  
  $contact_personRecord = @$contact_personRecords[0]; // get first record
   
  // load record from 'snippets'
  list($snippetsRecords, $snippetsMetaData) = getRecords(array(
    'tableName'   => 'snippets',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $snippetsRecord = @$snippetsRecords[0]; // get first record
  if (!$snippetsRecord) { dieWith404("Record not found!"); } // show error message if no record found  


?>
