File: /home/api/public_html/nashville/get-price-reductions.php
<?php
//ini_set( "display_errors", true );
//ini_set( "display_startup_errors", true );
require( "php/config.php" );
$iLimit = false;
$iStartDate = false;
$iEndDate = false;
foreach ( $_GET as $k => $v )
{
switch( strtolower( $k ) )
{
case "startdate":
if ( is_numeric( $v ) )
$iStartDate = $v;
break;
case "enddate":
if ( is_numeric( $v ) )
$iEndDate = $v;
break;
case "limit":
if ( is_numeric( $v ) )
$iLimit = $v;
}
}
$oRes = new Result( "PriceReductions" );
if ( ! $iStartDate )
$oRes->FatalError( "Start Date is not valid" );
if ( $iLimit )
{
$oMLS->setLimit( $iLimit );
$oRes->setLimit( $iLimit );
}
$tmp = $oMLS->getPriceReductions( $iStartDate, $iEndDate );
if ( $tmp )
{
$oRes->addData( $tmp['TotalRecords'], "TotalRecords" );
$oRes->addData( $tmp['Data'], "Data" );
}
else $oRes->addError( "AgentID '" . $sAgentID . "' is not valid." );
$oMLS->finish( "nashville", "price-reductions", json_encode( $_GET ) );
print $oRes->getJSON();