﻿<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/sites/propertywebsite.com/public_html/property_sales/','','../','../../','../../../');
  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($propertyRecords, $propertyMetaData) = 
   getRecords(array(
    'tableName'   => 'property',
    'perPage'     => '3',
    'orderBy'     => 'date DESC, price',
    'allowSearch' => '1',
  ));


// load latest movers records
  list($moverspropertyRecords, $moverspropertyMetaData) = getRecords(array(
    'tableName'   => 'property',
    'perPage'     => '3',
    'orderBy'     => 'updatedDate DESC, new_price',
    'allowSearch' => '0',
  ));

//load featured record
list($featuredpropertyRecords, $featuredpropertyMetaData) = getRecords(array(
'tableName' => 'property',
'where' => 'featured = 1',
'orderBy' => 'date',
'perPage' => '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>Our Property Sales List</title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="property_sales/swpc2.css" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="property_sales/print.css" media="print" />
</head>
<body>


<!--left side content-->



    <?php include("property_sales/menu.php"); ?>
    
      <h2>LATEST PROPERTIES:</h2>
      

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->

   <?php foreach ($propertyRecords as $record): ?>
<?php if (!$record['featured']): ?>
<div align="center">
<?php foreach ($record['property_images'] as $upload): ?>    
  <img src="<?php echo $upload['urlPath'] ?>" width="140px" height="80px alt="" />   
  <?php break ?>  
<?php endforeach ?></div>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>

<h2> <?php echo $record['address'] ?><br/>
      Listed: <?php echo date("D, M jS, Y ", strtotime($record['date'])) ?><br/>
                    Read Full Details:</h2> <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>
      <hr style="color:#840000; background-color:#840000;height:1px;border:none;" />
<?php endif ?> 
    <?php endforeach ?>

    <?php if ($propertyMetaData['invalidPageNum']): ?>
      Results page '<?php echo $propertyMetaData['page']?>' not found, <a href="<?php echo $propertyMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
    <?php elseif (!$propertyRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->




<!--right side content-->


    <h2>LATEST MOVERS</h2>
    
<?php foreach ($moverspropertyRecords as $record): ?>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h4> New Price! &pound;<?php echo number_format($record['new_price']) ?></h4>
<?php endif; ?>
<?php echo $record['address'] ?>
<p>&nbsp</p>
<div align="center">
<?php foreach ($record['property_images'] as $upload): ?>    
  <img src="<?php echo $upload['urlPath'] ?>" width="140px" height="80px alt="" />   
  <?php break ?>  
<?php endforeach ?>
</div>
<h5><a href="<?php echo $record['_link'] ?>">View Details -> -></a></h5>


    <?php endforeach ?>

    



<!--main content area-->
  
<h2>FEATURED PROPERTY</h2>

<?php foreach ($featuredpropertyRecords as $record): ?>
<?php if ($record['featured']): ?>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h2> New Price!:&pound;<?php echo number_format($record['new_price']) ?></h2>
<?php endif; ?>
<h3> <?php echo $record['address'] ?></h3> (<?php echo $record['type'] ?>)<br/>
Featured: <?php echo $record['featured'] ?><br/>
Listed: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?> // Updated: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['updatedDate'])) ?><br/><br/>
<?php echo $record['teaser'] ?><br/>
Council Tax Band: <?php echo $record['council_tax_band'] ?> // Bedrooms: <?php echo $record['bedrooms'] ?> //

Read Full Details: <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>

<?php endforeach ?>

<?php if ($propertyMetaData['invalidPageNum']): ?>
Results page '<?php echo $propertyMetaData['page']?>' not found, <a href="<?php echo $propertyMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$propertyRecords): ?>
No records were found!<br/><br/>
<?php endif ?>



</body>
</html>
