Phalcon Framework 1.3.4

ErrorException: Trying to get property of non-object

/var/www/vhosts/winkworth-search/src/app/Models/Property.php (1471)
#0exceptions_error_handler(8, Trying to get property of non-object, /var/www/vhosts/winkworth-search/src/app/Models/Property.php, 1471, Array([property] => Object(WAI\Search\Models\Winkworth\Property), [text] => Tenant(s) Fees Apply, [class] => asaTerms))
<?php
 
namespace WAI\Search\Models;
 
use Phalcon\DI;
use Phalcon\Tag;
use WAI\Search\Controllers\SearchControllerBase;
use WAI\Search\Library\SphinxPropertySearch\BitConfig;
use WAI\Search\Library\SphinxPropertySearch\Search;
 
/**
 * Class Property
 * @package WAI\Search\Models
 */
class Property extends ModelBase
{
    const PRICE_ON_APPLICATION = 'Price on Application';
 
    /**
     *
     * @var integer
     */
    public $companyId;
 
    /**
     *
     * @var integer
     */
    public $officeId;
 
    /**
     *
     * @var string
     */
    public $propertyCode;
 
    /**
     *
     * @var integer
     */
    public $officeId2;
 
    /**
     *
     * @var string
     */
    public $addressToDisplay;
 
    /**
     *
     * @var string
     */
    public $addressBuilding;
 
    /**
     *
     * @var string
     */
    public $addressStreet;
 
    /**
     *
     * @var string
     */
    public $addressSubStreet;
 
    /**
     *
     * @var string
     */
    public $addressTown;
 
    /**
     *
     * @var string
     */
    public $addressSubLocality;
 
    /**
     *
     * @var string
     */
    public $addressLocality;
 
    /**
     *
     * @var string
     */
    public $addressCounty;
 
    /**
     *
     * @var string
     */
    public $addressCountry;
 
    /**
     *
     * @var string
     */
    public $addressPostcodePrefix;
 
    /**
     *
     * @var string
     */
    public $addressPostcodeFull;
 
    /**
     *
     * @var string
     */
    public $addressAlias;
 
    /**
     *
     * @var string
     */
    public $latitude;
 
    /**
     *
     * @var string
     */
    public $longitude;
 
    /**
     *
     * @var integer
     */
    public $bathrooms;
 
    /**
     *
     * @var integer
     */
    public $bedrooms;
 
    /**
     *
     * @var string
     */
    public $summary;
 
    /**
     *
     * @var string
     */
    public $fullDetails;
 
    /**
     *
     * @var string
     */
    public $webFeatures;
 
    /**
     *
     * @var integer
     */
    public $bit1;
 
    /**
     *
     * @var integer
     */
    public $bit2;
 
    /**
     *
     * @var integer
     */
    public $dateAdded;
 
    /**
     *
     * @var integer
     */
    public $dateAmended;
 
    /**
     *
     * @var integer
     */
    public $dateArchived;
 
    /**
     *
     * @var integer
     */
    public $dateAmendedEmailUpdate;
 
    /**
     *
     * @var integer
     */
    public $dateSold;
 
    /**
     *
     * @var string
     */
    public $officeIdRemote;
 
    /**
     *
     * @var integer
     */
    public $parentPropertyId;
 
    /**
     *
     * @var string
     */
    public $negotiatorId;
 
    /**
     *
     * @var integer
     */
    public $negotiatorId2;
 
    /**
     *
     * @var string
     */
    public $addressAlias3;
 
    /**
     *
     * @var string
     */
    public $addressAlias4;
 
    /**
     *
     * @var integer
     */
    public $receptions;
 
    /**
     *
     * @var integer
     */
    public $tenureDuration;
 
    /**
     *
     * @var string
     */
    public $websiteUrl;
 
    /**
     *
     * @var string
     */
    public $availableFrom;
 
    /**
     *
     * @var string
     */
    public $updatedBy;
 
    /**
     *
     * @var integer
     */
    public $bit3;
 
    /**
     *
     * @var integer
     */
    public $bit4;
 
    /**
     *
     * @var integer
     */
    public $bit5;
 
    /**
     *
     * @var integer
     */
    public $pricePerWeek;
 
    /**
     *
     * @var double
     */
    public $price_week_min;
 
    /**
     *
     * @var double
     */
    public $price_week_max;
 
    /**
     *
     * @var double
     */
    public $price_month_min;
 
    /**
     *
     * @var double
     */
    public $price_month_max;
 
    /**
     *
     * @var integer
     */
    public $price_frequency;
 
    /**
     *
     * @var double
     */
    public $size_sqm_min;
 
    /**
     *
     * @var double
     */
    public $size_sqm_max;
 
    /**
     *
     * @var double
     */
    public $size_sqft_min;
 
    /**
     *
     * @var double
     */
    public $size_sqft_max;
 
    /**
     *
     * @var string
     */
    public $orig_size_unit;
 
    /**
     *
     * @var string
     */
    public $mainImage;
 
    /**
     *
     * @var array
     */
    public $features;
 
    /**
     *
     * @var string
     */
    public $locationDescription;
 
    /**
     *
     * @var string
     */
    public $yield;
 
    /**
     *
     * @var double
     */
    public $rentalIncome;
 
    /**
     *
     * @var string
     */
    public $serviceCharge;
 
    /**
     *
     * @var string
     */
    public $availability;
 
    /**
     *
     * @var string
     */
    public $terms;
 
    /**
     *
     * @var string
     */
    public $rates;
 
    /**
     *
     * @var string
     */
    public $mainBrochure;
 
    /**
     *
     * @var string
     */
    public $addressAlias2;
 
    /**
     *
     * @var integer
     */
    public $bit6;
 
    /**
     *
     * @var integer
     */
    public $officeId3;
 
    /**
     *
     * @var string
     */
    public $addressCounty2;
 
    /**
     *
     * @var string
     */
    public $strapline;
 
    /**
     *
     * @var string
     */
    protected $fullDetailsExtra;
 
    /**
     *
     * @var string
     */
    protected $interactiveFloorplans;
 
    /**
     *
     * @var string
     */
    public $webFeatures2;
 
    /**
     *
     * @var string
     */
    public $webFeaturesCaption2;
 
    /**
     *
     * @var string
     */
    public $webFeaturesCaption;
 
    /**
     *
     * @var string
     */
    public $houseName;
 
    /**
     *
     * @var integer
     */
    public $emailUpdateReason;
 
    /**
     *
     * @var integer
     */
    public $previousBit1;
 
    /**
     *
     * @var double
     */
    public $previousPriceWeekMin;
 
    /**
     *
     * @var string
     */
    public $parentPropertyCode;
 
    /**
     *
     * @var string
     */
    public $activeRanges;
 
    /**
     * Non-DB properties
     */
 
    /**
     * @var \WAI\Search\Library\SphinxPropertySearch\BitConfig
     */
    protected $bitConfig;
 
    /**
     * @var string
     */
    protected $generatedDisplayAddress;
 
    /**
     * @var \WAI\Search\Library\Utilities\Utilities
     */
    protected $utilities;
 
    /**
     * @var string
     */
    protected $seoUrl;
 
    /**
     * @var string
     */
    protected $houseSubType;
 
    /**
     * @var string
     */
    protected $generatedDisplayAddressShortPostcode;
 
    /**
     * @var string
     */
    protected $price;
 
    protected $currencySymbol = Search::POUND;
 
    /** @var  \Phalcon\Translate\Adapter\NativeArray */
    protected $messages;
    protected $priceOnApplication;
    protected $config;
 
    /**
     * Setup relationships
     */
    public function initialize()
    {
        // link to assets
        $this->hasMany('id', 'WAI\Search\Models\Asset', 'propertyId', array('alias' => 'assets'));
 
        // link to parent / child properties
        $this->hasMany('parentPropertyId', 'WAI\Search\Models\Property', 'id', array(
            'alias' => 'parent',
            'reusable' => true
        ));
        $this->hasMany('id', 'WAI\Search\Models\Property', 'parentPropertyId', array(
            'alias' => 'children',
            'reusable' => true
        ));
 
        // link to offices
        $this->belongsTo('officeId', 'WAI\Search\Models\Office', 'id', array(
            'alias' => 'office',
            'reusable' => true
        ));
 
        // link to offices
        $this->belongsTo('officeId2', 'WAI\Search\Models\Office', 'id', array(
            'alias' => 'office2',
            'reusable' => true
        ));
    }
 
    /**
     * After fetching put the main image back to an array
     */
    public function afterFetch()
    {
        if(DI::getDefault()->getMessages()->_('price_on_application') === 'price_on_application') {
            $this->priceOnApplication = DI::getDefault()->getMessages()->_('price_on_application');
        } else {
            $this->priceOnApplication = self::PRICE_ON_APPLICATION;
        }
 
        $this->hydrateMainImage();
 
        // convert prices into
        $this->convertPrices($this->getCurrency());
        $pricing = $this->getDI()->getRequest()->get('pricing') ? $this->getDI()->getRequest()->get('pricing') : SearchControllerBase::DEFAULT_PRICING;
        $bitConfig = new BitConfig();
 
        if ($pricing === Search::SEARCH_PRICING_MONTHLY && !$this->isMonthly()) {
            // remove weekly add monthly
            $bit = $bitConfig->findBit(Search::SEARCH_PRICING_WEEKLY);
            if($bit !== false) {
                $this->{$bit->field} = $this->{$bit->field} ^ $bit->value;
            }
 
            $bit = $bitConfig->findBit(Search::SEARCH_PRICING_MONTHLY);
            if($bit !== false) {
                $this->{$bit->field} = $this->{$bit->field} | $bit->value;
            }
        } elseif ($pricing === Search::SEARCH_PRICING_WEEKLY && !$this->isWeekly()) {
            // remove monthly add weekly
            $bit = $bitConfig->findBit(Search::SEARCH_PRICING_MONTHLY);
            if($bit !== false) {
                $this->{$bit->field} = $this->{$bit->field} ^ $bit->value;
            }
 
            $bit = $bitConfig->findBit(Search::SEARCH_PRICING_WEEKLY);
            if($bit !== false) {
                $this->{$bit->field} = $this->{$bit->field} | $bit->value;
            }
        }
 
        $this->features = explode("\n", $this->features);
 
        if($this->getDisplayAddress() === '' || !$this->isActive()) {
            $this->isActive = false;
            $this->propertyStatus = $this->getPropertyStatus() . ' - Property no longer available';
            $this->summary = '';
            $this->fullDetails = '';
        }
 
        $this->parent = $this->getParent('bit1&1 = 1');
        $this->children = $this->getChildren('bit1&1 = 1');
    }
 
    public $active = true;
 
    /**
     * After saving put the main image back to an array
     */
    public function afterSave()
    {
        $this->hydrateMainImage();
    }
 
    /**
     * Before Property is saved serialize main image array
     */
    public function beforeSave()
    {
        if (is_array($this->mainImage)) {
            $this->mainImage = serialize($this->mainImage);
        }
    }
 
    /**
     * If main image is in serialized format then unserialize it
     */
    protected function hydrateMainImage()
    {
        $serial = DI::getDefault()->getUtilities()->unserialize($this->mainImage);
 
        if ($serial !== false) {
            $this->mainImage = $serial;
        } else {
            $this->mainImage = array($this->mainImage);
        }
    }
 
    /**
     *
     * @param string $currency
     */
    protected function convertPrices($currency = Search::POUND) {
        if ($currency === Search::POUND) {
            return;
        } elseif ($currency === Search::EURO) {
            $this->currencySymbol = Search::SYMBOL_EURO;
            $this->convertPricesToCurrency(Search::POUND, Search::EURO);
        } elseif ($currency === Search::DOLLAR) {
            $this->currencySymbol = Search::SYMBOL_DOLLAR;
            $this->convertPricesToCurrency(Search::POUND, Search::DOLLAR);
        };
    }
 
    /**
     * Convert property prices to new currency
     * @param $currencyFrom
     * @param $currencyTo
     */
    private function convertPricesToCurrency($currencyFrom, $currencyTo){
        $currencyConverter = $this->getDI()
                                  ->getCurrencyConverter();
 
        if($currencyConverter === null) {
            return;
        }
 
        $this->price_month_min = $currencyConverter->convert($this->price_month_min, $currencyFrom, $currencyTo);
        $this->price_month_max = $currencyConverter->convert($this->price_month_max, $currencyFrom, $currencyTo);
        $this->price_week_min = $currencyConverter->convert($this->price_week_min, $currencyFrom, $currencyTo);
        $this->price_week_max = $currencyConverter->convert($this->price_week_max, $currencyFrom, $currencyTo);
    }
 
    /**
     * Get the SEO URL
     * @return string
     */
    public function getSeoUrl()
    {
        if (!isset($this->seoUrl)) {
            $department = $this->getSaleType() === Search::SEARCH_TYPE_RENT ? "property-to-rent" : "property-for-sale";
 
            if (preg_match("/,/", $this->getDisplayAddress())) {
                $street = explode(",", $this->getDisplayAddress());
                $street = $street[0];
            } else {
                $street = $this->getDisplayAddress();
            }
 
            if ($this->isNewBuilt()) {
                $department = "new-homes";
            }
 
            $beds = $this->bedrooms;
            $type = $this->isHouse() ? "house" : "apartment";
 
            $this->seoUrl = "/$department/" . DI::getDefault()->getUtilities()->seoise($this->addressAlias) . "/" . DI::getDefault()->getUtilities()->seoise("$street-$beds-bed-$type") . "/" . $this->propertyCode;
        }
 
        return $this->seoUrl;
    }
 
    /**
     * Get the sale type for the property
     * @return string
     */
    public function getSaleType()
    {
        $bitConfig = new BitConfig();
        $rentBit = $bitConfig->findBit('rent');
 
        if ($rentBit !== false) {
            if (isset($this->{$rentBit->field}) && ($this->{$rentBit->field} & $rentBit->value) === $rentBit->value) {
                return Search::SEARCH_TYPE_RENT;
            } else {
                return Search::SEARCH_TYPE_BUY;
            }
        }
 
        return false;
    }
 
    /**
     * Get dis[play address with a specified number of parts
     *
     * @param int $start
     * @param int $stop
     *
     * @return string
     */
    public function getDisplayAddress($start = 0, $stop = 9)
    {
        if (!isset($this->generatedDisplayAddress)) {
            $this->generatedDisplayAddress = implode(",",
                array_slice(explode(",", $this->addressToDisplay), $start, $stop));
        }
 
        return $this->generatedDisplayAddress;
    }
 
    /**
     * @return string
     */
    public function getHouseSubType()
    {
        if (!isset($this->houseSubType)) {
            $subType = 'house';
 
            if ($this->isHouse()) {
                if ($this->isPlot() || $this->isLand()) {
                    $subType = 'development plot';
                } elseif ($this->isDetached()) {
                    $subType = 'detached house';
                } elseif ($this->isSemiDetached()) {
                    $subType = 'semi-detached house';
                } elseif ($this->isTerraced()) {
                    $subType = 'terraced house';
                } elseif ($this->isBungalow() && $this->isDetached()) {
                    $subType = 'detached bungalow';
                } elseif ($this->isBungalow() && $this->isSemiDetached()) {
                    $subType = 'semi-detached bungalow';
                } elseif ($this->isBungalow()) {
                    $subType = 'bungalow';
                } elseif ($this->isEndOfTerraced()) {
                    $subType = 'end of terrace house';
                } elseif ($this->isMews()) {
                    $subType = 'mews';
                } elseif ($this->isClusterHouse()) {
                    $subType = 'cluster house';
                } elseif ($this->isLinkDetachedHouse()) {
                    $subType = 'link detached house';
                } elseif ($this->isTownHouse()) {
                    $subType = 'town house';
                } elseif ($this->isCottage()) {
                    $subType = 'cottage';
                } elseif ($this->isChalet()) {
                    $subType = 'chalet';
                } elseif ($this->isVilla()) {
                    $subType = 'villa';
                } elseif ($this->isVillageHouse()) {
                    $subType = 'end of terraced house';
                }
            } else {
                if ($this->isPlot() || $this->isLand()) {
                    $subType = 'development plot';
                } elseif ($this->isMaisonette()) {
                    $subType = 'maisonette';
                } elseif ($this->isGroundFlat()) {
                    $subType = 'ground floor flat';
                } elseif ($this->isStudio()) {
                    $subType = 'studio';
                } elseif ($this->isPenthouse()) {
                    $subType = 'penthouse';
                } elseif ($this->isGroundMaisonette()) {
                    $subType = 'ground floor maisonette';
                } elseif ($this->isFlat()) {
                    $subType = 'flat';
                } else {
                    $subType = 'apartment';
                }
            }
 
            $this->houseSubType = $subType;
        }
 
        return $this->houseSubType;
    }
 
    /**
     * Get display address, hiding postcode suffix
     * @param int  $start
     * @param int  $stop
     * @param bool $showLondonSurrey
     *
     * @return mixed|string
     */
    public function getDisplayAddressShortPostcode($start = 1, $stop = 10, $showLondonSurrey = true)
    {
        if (!isset($this->generatedDisplayAddressShortPostcode)) {
            $address = trim($this->getDisplayAddress($start, $stop));
            $addressArray = explode(' ', $address);
 
            if ($this->containsPostcode($address)) {
                array_pop($addressArray);
            }
 
            $returnAddress = implode(" ", $addressArray);
 
            if (!$showLondonSurrey) {
                $returnAddress = str_replace(', London', ',', $returnAddress);
                $returnAddress = str_replace(', Surrey', ',', $returnAddress);
            }
 
            $this->generatedDisplayAddressShortPostcode = preg_replace('/([,]*)$/', '', $returnAddress);
        }
 
        return $this->generatedDisplayAddressShortPostcode;
    }
 
    /**
     * Checks whether or not a string contains a postcode
     * @param $string
     *
     * @return bool
     */
    public function containsPostcode($string)
    {
        $string = strtoupper(str_replace(' ', '', $string));
        return (preg_match("/[A-Z]{1,2}[0-9]{2,3}[A-Z]{2}$/", $string) ||
            preg_match("/[A-Z]{1,2}[0-9]{1}[A-Z]{1}[0-9]{1}[A-Z]{2}$/", $string) ||
            preg_match("/GIR0[A-Z]{2}/", $string));
    }
 
    protected $altPrice;
 
    /**
     * Get the property price
     *
     * @param bool $altPrice
     *
     * @return float|string
     */
    public function getPrice($altPrice = false) {
        if($altPrice === false) {
            if (!isset($this->price)) {
                $price = $this->price_month_min;
 
                if ($this->isWeekly() || $this->isStudentLet()) {
                    $price = $this->price_week_min;
                }
 
                $this->price = $price;
            }
 
            return $this->price;
        } else {
            if (!isset($this->altPrice)) {
                $price = $this->price_week_min;
 
                if($this->isStudentLet()) {
                    $price = round((int) $price / (int) $this->bedrooms);
                } else if ($this->isWeekly()) {
                    $price = $this->price_month_min;
                }
 
                $this->altPrice = $price;
            }
 
            return $this->altPrice;
        }
    }
 
    /**
     * Get the price to display
     *
     * @param bool $altPrice
     *
     * @return string
     */
    public function getDisplayPrice($altPrice = false) {
        return $this->getPriceWithPrefix($altPrice);
    }
 
    protected $priceWithPrefix;
    protected $altPriceWithPrefix;
 
    /**
     * Returns the price with any prefixes and suffixes
     *
     * @param bool $altPrice
     *
     * @return string
     */
    public function getPriceWithPrefix($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'WithPrefix';
 
        if(!isset($this->{$attribute})) {
            $this->{$attribute} = $this->getPricePrefix($altPrice) . " " . $this->getPriceFormattedWithSymbol($altPrice) . " " . $this->getPriceSuffix($altPrice);
 
            if ($this->getPricePrefix($altPrice) === $this->priceOnApplication ||
                ($this->getPrice($altPrice) == 0 && !preg_match("/([1-9])/", $this->getPrice($altPrice)))
            ) {
                $this->{$attribute} = $this->priceOnApplication;
            } elseif (preg_match('/(week|month|pwpp)$/', $this->getPriceSuffix($altPrice))) {
                $this->{$attribute} = $this->getCurrencyFormatted($altPrice) . number_format($this->getPrice($altPrice)) . " " . $this->getPriceSuffix($altPrice);
            } else {
                $this->{$attribute} = $this->getPricePrefix($altPrice) . " " . $this->getCurrencyFormatted($altPrice) . number_format($this->getPrice($altPrice));
            }
        }
 
        return $this->{$attribute};
    }
 
    protected $priceFormattedWithSymbol;
    protected $altPriceFormattedWithSymbol;
 
    /**
     * Returns the price with a currency symbol
     *
     * @param bool $altPrice
     *
     * @return string
     */
    public function getPriceFormattedWithSymbol($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'FormattedWithSymbol';
 
        if(!isset($this->{$attribute})) {
            $price = $this->getPrice($altPrice);
            $priceMax = $this->getPriceMax();
            $places = 0;
 
            if ($this->isPerSqm() || $this->isPerSqft()) {
                $places = 2;
            }
 
            if ($this->isPriceOnApplication()) {
                $this->{$attribute} = '';
            } elseif ($priceMax > $price) {
                if ($this->isCommercialPricingPer()) {
                    $this->{$attribute} = $this->currencySymbol . number_format($price, $places) . " to " . $this->currencySymbol . number_format($priceMax, $places);
                } elseif (DI::getDefault()->getMessages()->_('range_label') !== 'range_label') {
                    $this->{$attribute} = $this->currencySymbol . number_format($price, $places) . " " . DI::getDefault()->getMessages()->_('range_label') . " " . $this->currencySymbol . number_format($priceMax, $places);
                }
            } else {
                $this->{$attribute} = $this->currencySymbol . number_format($price, $places);
            }
        }
 
        return $this->{$attribute};
    }
 
    protected $priceMax;
 
    /**
     * Gets the max price for a property
     */
    public function getPriceMax() {
        if(!isset($this->priceMax)) {
            $price = $this->price_week_max;
            if (!$price) {
                $price = $this->price_week_min;
            }
 
            $this->priceMax = $price;
        }
 
        return $this->priceMax;
    }
 
    protected $priceSuffix;
    protected $altPriceSuffix;
 
    /**
     * Get the suffix for the price
     *
     * @param bool $altPrice
     *
     * @return string
     */
    public function getPriceSuffix($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'Suffix';
 
        if(!isset($this->{$attribute})) {
            $suffix = '';
 
            if ($this->isRent()) {
                if($altPrice === false) {
                    if ($this->isWeekly() || $this->isStudentLet()) {
                        $suffix = 'per week';
                    } elseif ($this->isMonthly()) {
                        $suffix = 'per month';
                    } elseif ($this->isAnnually()) {
                        $suffix = 'per annum';
                    }
                } else {
                    if($this->isStudentLet()) {
                        $suffix = "pwpp";
                    } else {
                        if ($this->isMonthly()) {
                            $suffix = "per week";
                        } elseif ($this->isWeekly()) {
                            $suffix = "per month";
                        } elseif ($this->isAnnually()) {
                            $suffix = "per annum";
                        }
                    }
                }
            } else {
                if ($this->isPerSqm()) {
                    $suffix = 'per sqm';
                } elseif ($this->isPerSqft()) {
                    $suffix = 'per sqft';
                } elseif ($this->isPax()) {
                    $suffix = 'per person';
 
                    if (DI::getDefault()->getMessages()->_('pax') !== 'pax') {
                        $suffix = DI::getDefault()->getMessages()->_('pax');
                    }
                } elseif ($this->isAnnually()) {
                    $suffix = 'per annum';
                } elseif ($this->isMonthly() && $this->isCommercial()) {
                    $suffix = 'per month';
                } elseif ($this->isSubjectToSection5()) {
                    $suffix = 'subject to section 5 notices';
                } elseif ($this->isSubjectToPlanning()) {
                    $suffix = 'subject to planning';
                } elseif ($this->isPerAnnumExclusive()) {
                    $suffix = 'per annum (exclusive)';
                } elseif ($this->isPerMonthExclusive()) {
                    $suffix = 'per month (exclusive)';
                } elseif ($this->isSubjectToContract()) {
                    $suffix = 'subject to contract';
                }
            }
 
            $this->{$attribute} = $suffix !== '' ? " $suffix" : $suffix;
        }
 
        return $this->{$attribute};
    }
 
    protected $priceMinEuro;
    protected $priceMinDollar;
    protected $altPriceMinEuro;
    protected $altPriceMinDollar;
 
    /**
     * Set prices in converted currencies
     *
     * @param string $currency
     * @param bool   $altPrice
     */
    protected function setPriceOtherCurrencies($currency = Search::POUND, $altPrice = false) {
        if ($this->getDI()->getCurrencyConverter() === null || $currency !== Search::POUND) {
            return;
        }
 
        $attribute = $altPrice === false ? 'price' : 'altPrice';
 
        $currencyConverter = $this->getDI()
                                  ->getCurrencyConverter();
 
        $prefix = $this->getPricePrefix($altPrice);
        if ($prefix) {
            $prefix = "$prefix ";
        }
 
        $suffix = $this->getPriceSuffix($altPrice);
        if ($suffix) {
            $suffix = " $suffix";
        }
 
        if ($this->getPricePrefix($altPrice) === $this->priceOnApplication || $this->getPrice($altPrice) === '0') {
            $this->{$attribute . 'MinEuro'} = $this->priceOnApplication;
            $this->{$attribute . 'MinDollar'} = $this->priceOnApplication;
            return;
        }
 
        $price = $this->price_week_min;
 
        if ($this->isMonthly() && !$this->isStudentLet()) {
            $price = $this->price_month_min;
        }
 
        $this->{$attribute . 'MinEuro'} = $prefix . Search::SYMBOL_EURO . number_format($currencyConverter->convert($price, Search::POUND, Search::EURO)) . $suffix;
        $this->{$attribute . 'MinDollar'} = $prefix . Search::SYMBOL_DOLLAR . number_format($currencyConverter->convert($price, Search::POUND, Search::DOLLAR)) . $suffix;
    }
 
    /**
     * Get the formatted price in Euros
     *
     * @param bool $altPrice
     *
     * @return mixed
     */
    public function getDisplayPriceEuros($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'MinEuro';
 
        if(!isset($this->{$attribute})) {
            $this->setPriceOtherCurrencies($this->getCurrency(), $altPrice);
        }
 
        return $this->{$attribute};
    }
 
 
    /**
     * Get the formatted price in US Dollars
     *
     * @param bool $altPrice
     *
     * @return mixed
     */
    public function getDisplayPriceDollars($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'MinDollar';
 
        if(!isset($this->{$attribute})) {
            $this->setPriceOtherCurrencies($this->getCurrency(), $altPrice);
        }
 
        return $this->{$attribute};
    }
 
    protected $pricePrefix;
    protected $altPricePrefix;
 
    /**
     * Gets the price prefix string
     *
     * @param bool $altPrice
     *
     * @return string
     */
    public function getPricePrefix($altPrice = false) {
        $attribute = ($altPrice === false ? 'price' : 'altPrice') . 'Prefix';
 
        if(!isset($this->{$attribute})) {
            $prefix = '';
            $commercialPer = $this->isCommercialPricingPer();
 
            if ($this->isRent() || $commercialPer) {
                if ($commercialPer && ($this->price_week_max === $this->price_week_min || $this->price_week_max === 0)) {
                    $this->{$attribute} = DI::getDefault()->getMessages()->_('from');
                } else {
                    $this->{$attribute} = '';
                }
            } else {
                if ($this->isPriceReduced()) {
                    $prefix = DI::getDefault()->getMessages()->_('price_reduced');
                } elseif ($this->isFixedPrice()) {
                    $prefix = DI::getDefault()->getMessages()->_('fixed_price');
                } elseif ($this->isOffersInvited()) {
                    $prefix = DI::getDefault()->getMessages()->_('offers_invited');
                } elseif ($this->isPriceOnApplication()) {
                    $prefix = $this->priceOnApplication;
                } elseif ($this->isRegionOf()) {
                    $prefix = DI::getDefault()->getMessages()->_('region_of');
                } elseif ($this->isExcessOf()) {
                    $prefix = DI::getDefault()->getMessages()->_('excess_of');
                } elseif ($this->isOffersOver()) {
                    $prefix = DI::getDefault()->getMessages()->_('offers_over');
                } elseif ($this->isGuidePrice()) {
                    $prefix = DI::getDefault()->getMessages()->_('guide_price');
                } elseif ($this->isPriceFrom()) {
                    $prefix = DI::getDefault()->getMessages()->_('price_from');
                } elseif ($this->isAskingPrice()) {
                    $prefix = DI::getDefault()->getMessages()->_('asking_price');
                } elseif ($this->isSubjectToContract()) {
                    $prefix = DI::getDefault()->getMessages()->_('subject_to_contract');
                } elseif ($this->isMonthly() && $this->isCommercial()) {
                    $prefix = '';
                } elseif ($this->isQuotingRent()) {
                    $prefix = DI::getDefault()->getMessages()->_('quoting_rent');
                }
            }
 
            $this->{$attribute} = !empty($prefix) ? $prefix : '';
        }
 
        return $this->{$attribute};
    }
 
    protected $tenure;
 
    /**
     * Get the tenure label of a property
     * @return string
     */
    public function getTenure() {
        if(!isset($this->tenure)) {
            $label = '';
 
            if ($this->isNewLease()) {
                $label = 'New Lease';
            } elseif ($this->isFreehold()) {
                $label = 'Freehold';
            } else {
                if ($this->isShareOfFreehold()) {
                    $label = 'Share of Freehold';
                } else {
                    if ($this->isLeasehold()) {
                        if ((trim($this->tenureDuration) === '') || ((int)$this->tenureDuration === 0)) {
                            $label = 'Leasehold';
                        } else {
                            $label = 'Leasehold circa ' . $this->tenureDuration . ' years';
                        }
                    }
                }
            }
 
            $this->tenure = $label;
        }
 
        return $this->tenure;
    }
 
    protected $currency;
 
    /**
     * Gets the currency from the request
     * @return mixed
     */
    public function getCurrency() {
        if(!isset($this->currency)) {
            $this->currency = $this->getDI()->getRequest()->get('currency');
 
            if($this->currency === null) {
                $this->currency = Search::POUND;
            }
        }
 
        return $this->currency;
    }
 
    /**
     * Returns the HTML entity for the current currency
     * @return string
     */
    public function getCurrencyFormatted() {
        if ($this->getCurrency() === Search::POUND || $this->getCurrency() === '') {
            return Search::SYMBOL_POUND;
        } elseif ($this->getCurrency() === Search::DOLLAR) {
            return Search::SYMBOL_DOLLAR;
        } elseif ($this->getCurrency() === Search::EURO) {
            return Search::SYMBOL_EURO;
        } else {
            return '';
        }
    }
 
//    /**
//     * Returns the ASCII character for the current currency
//     * @return string
//     */
//    public function getCurrencyAsciiSymbol() {
//        if ($this->getCurrency() === self::POUND || $this->getCurrency() === '') {
//            return chr(163);
//        } elseif ($this->getCurrency() === self::DOLLAR) {
//            return chr(36);
//        } elseif ($this->getCurrency() === self::EURO) {
//            return chr(8364);
//        }
//
//        return '';
//    }
 
    /**
     * @return bool
     */
    public function isCommercialPricingPer() {
        return $this->isAnnually() || $this->isPerSqm() || $this->isPerSqft();
    }
 
    /**
     * @return string
     */
    public function getMainImage() {
        if(is_array($this->mainImage)) {
            $str = $this->mainImage[0];
        } else {
            $str = $this->mainImage;
        }
 
        if($str === null) {
            $str = '';
        }
 
        return $str;
    }
 
    /**
     * @return string
     */
    public function getMainImageUrl() {
        return rtrim(DI::getDefault()->getConfig()->client->assets->imagesUrl, '/') . '/' . $this->getMainImage();
    }
 
    /**
     * Get a URL for the resized version of an image
     * @param $width
     * @param $height
     *
     * @return string
     */
    public function getMainImageUrlResized($width, $height) {
        $image = $this->getMainImage();
        $path = '/search/resize-image';
 
        if($image !== '') {
            $parts = explode('.', $image);
 
            $parts[count($parts) - 2] = "{$parts[count($parts) - 2]}-{$width}x{$height}";
 
            return $path . rtrim(DI::getDefault()->getConfig()->client->assets->imagesUrl, '/') . '/' . implode('.', $parts);
        } else {
 
            return $path . "/assets/missing/residential-{$width}x{$height}.jpg";
        }
    }
 
    /**
     * @return string
     */
    public function getMainBrochureUrl() {
        return rtrim(DI::getDefault()->getConfig()->client->assets->brochuresUrl, '/') . '/' . $this->mainBrochure;
    }
 
    protected $propertyStatus;
 
    /**
     * Get the property status as text
     * @return string
     */
    public function getPropertyStatus() {
        if(!isset($this->propertyStatus)) {
            $status = '';
 
            if ($this->isUnderOffer()) {
                $status = DI::getDefault()->getMessages()->_('under_offer');
            } elseif ($this->isLetAgreed()) {
                $status = DI::getDefault()->getMessages()->_('let_agreed');
            } elseif ($this->isLeasehold() && $this->tenureDuration <= 25 && $this->tenureDuration > 0) {
                $status = DI::getDefault()->getMessages()->_('short_lease');
            } elseif ($this->isSoldStc()) {
                $status = DI::getDefault()->getMessages()->_('sold_stc');
                } elseif ($this->isLet()) {
                $status = DI::getDefault()->getMessages()->_('let');
            } elseif ($this->isSold()) {
                $status = DI::getDefault()->getMessages()->_('sold');
            } elseif ($this->isShortLet()) {
                $status = DI::getDefault()->getMessages()->_('short_let');
            }
 
            $this->propertyStatus = $status;
        }
 
        return $this->propertyStatus;
    }
 
    protected $area;
 
    /**
     * Get the name of the area that the property is in
     * @return \Phalcon\Mvc\Model\Resultset|string
     */
    public function getArea() {
        if(!isset($this->area)) {
            if (isset($this->addressAlias2) && $this->addressAlias2 !== '') {
                $this->area =  $this->addressAlias2;
            } elseif(isset($this->addressLocality) && $this->addressLocality !== '') {
                $this->area = $this->addressLocality;
            } else {
                $this->area = $this->addressTown;
            }
        }
 
        return $this->area;
    }
 
    protected $isActive;
 
    /**
     * Checks if the property is active.
     * Used a lot so added as a method rather than using _call
     * @return bool
     */
    public function isActive() {
        return ($this->bit1 & 1) === 1;
    }
 
    /**
     * Checks if the property is weekly priced.
     * Used a lot so added as a method rather than using _call
     * @return bool
     */
    public function isWeekly() {
        return ($this->bit1 & 2048) === 2048;
    }
 
    /**
     * Checks if the property is monthly priced.
     * Used a lot so added as a method rather than using _call
     * @return bool
     */
    public function isMonthly() {
        return ($this->bit1 & 4096) === 4096;
    }
 
    /**
     * Get the ASA terms URL
     * @param $property
     * @param $text
     * @param $class
     *
     * @return string
     */
    public function getAsaLettingsFeesUrl($property, $text, $class) {
        return Tag::linkTo(array(
            DI::getDefault()->getConfig()->client->forms->asaTermsUrl . '?id=' . $property->id . '&propertyCode=' . $property->propertyCode . '&officeName=' . urlencode($property->office->name),
            $text,
            'class' => $class
        ));
    }
 
    /**
     * Magic method to support bit checks. Works for methods such as isHouse()
     *
     * @param string     $name
     * @param array|null $arguments
     *
     * @return mixed|void
     */
    public function __call($name, $arguments = null)
    {
        if (strpos($name, 'is') === 0) {
            if(isset($this->{$name})) {
                return $this->{$name};
            } else {
                $bitConfig = new BitConfig();
                $bitName = substr($name, 2);
                $bitName = strtolower(DI::getDefault()->getUtilities()->camelSeparate($bitName, '_'));
                $bit = $bitConfig->findBit($bitName);
 
                if ($bit !== false) {
                    if(isset($this->{$bit->field})) {
                        $value = ($this->{$bit->field}&$bit->value) === $bit->value;
                        $this->{$name} = $value;
                        return $value;
                    }
 
                    return false;
                }
            }
        }
 
        return parent::__call($name, $arguments);
    }
 
    /**
     * overridden version of toArray that only gives essential details
     *
     * @param null $columns
     *
     * @return array
     */
    public function toArray($columns = null) {
        if(isset($columns) && is_array($columns)) {
            $arr = array();
 
            foreach($columns as $col) {
                if(isset($this->{$col})) {
                    $arr[$col] = $this->{$col};
                }
            }
 
            return $arr;
        }
 
        return parent::toArray($columns);
    }
 
    protected $photos;
 
    /**
     * Get related picture assets
     * @return mixed
     */
    public function getPhotos() {
        if(!isset($this->photos)) {
            $this->photos = $this->getAssets(array(
                'conditions' => "type = 'Picture' AND archived = 0",
                'order' => 'position'
            ));
        }
 
        return $this->photos;
    }
 
    /**
     * Get photo at index
     *
     * @param int $index
     *
     * @return \WAI\Search\Models\Asset
     */
    public function getPhoto($index) {
        $photos = $this->getPhotos();
 
        if($index > count($photos) - 1) {
            $photo = false;
        } else {
            $photo = $photos[$index];
        }
 
        return $photo;
    }
 
    protected $brochures;
 
    /**
     * Get related brochure assets
     * @return mixed
     */
    public function getBrochures() {
        if(!isset($this->brochures)) {
            $this->brochures = $this->getAssets(array(
                'conditions' => "type = 'Brochure' AND archived = 0",
                'order' => 'position'
            ));
        }
 
        return $this->brochures;
    }
 
    /**
     * Get brochure at index
     *
     * @param int $index
     *
     * @return \WAI\Search\Models\Asset
     */
    public function getBrochure($index) {
        $brochures = $this->getBrochures();
 
        if($index > count($brochures) - 1) {
            $brochure = false;
        } else {
            $brochure = $brochures[$index];
        }
 
        return $brochure;
    }
 
    protected $epcs;
 
    /**
     * Get related EPC assets
     * @return mixed
     */
    public function getEpcs() {
        if(!isset($this->epcs)) {
            $this->epcs = $this->getAssets(array(
                'conditions' => "type = 'EPC' AND archived = 0",
                'order' => 'position'
            ));
        }
 
        return $this->epcs;
    }
 
    /**
     * Get EPC at index
     *
     * @param int $index
     *
     * @return \WAI\Search\Models\Asset
     */
    public function getEpc($index) {
        $epcs = $this->getEpcs();
 
        if($index > count($epcs) - 1) {
            $epc = false;
        } else {
            $epc = $epcs[$index];
        }
 
        return $epc;
    }
 
    /**
     * Get related Floorplan assets
     * @return mixed
     */
    public function getFloorplans() {
        if(!isset($this->floorplans)) {
            $this->floorplans = $this->getAssets(array(
                'conditions' => "type = 'Floorplan' AND archived = 0",
                'order' => 'position'
            ));
        }
 
        return $this->floorplans;
    }
 
    /**
     * Get Floorplan at index
     *
     * @param int $index
     *
     * @return \WAI\Search\Models\Asset
     */
    public function getFloorplan($index) {
        $floorplans = $this->getFloorplans();
 
        if($index > count($floorplans) - 1) {
            $floorplan = false;
        } else {
            $floorplan = $floorplans[$index];
        }
 
        return $floorplan;
    }
 
    /**
     * Get character limited summary
     * @param int $length
     *
     * @return mixed
     */
    public function getSummary ($length = 1000) {
        return DI::getDefault()->getUtilities()->excerptText($this->summary, $length);
    }
 
    /**
     * Returns a HTML formatted version of the description
     * @return string
     */
    public function getDescriptionFormatted() {
        $desc = "<p>{$this->fullDetails}</p>";
        $desc = str_replace("\n\n", '</p><p>', $desc);
        $desc = nl2br($desc);
 
        return $desc;
    }
 
    /**
     * Winkworth Specific Version
     * May be needed in future
     * @return bool|string
     */
    public function getFloorplanPdfUrl() {
        return false;
    }
}
#1WAI\Search\Models\Property->getAsaLettingsFeesUrl(Object(WAI\Search\Models\Winkworth\Property: 111), Tenant(s) Fees Apply, asaTerms)
<?php
/**
 * @var \WAI\Search\Models\Winkworth\Property $property
 * @var string $cssClass
 * @var bool $isRent
 * @var \Phalcon\Mvc\Model\Resultset $photos
 * @var \Phalcon\Mvc\Model\Resultset $brochures
 * @var \Phalcon\Mvc\Model\Resultset $epcs
 * @var \Phalcon\Mvc\Model\Resultset $floorplans
 * @var \SimpleXMLElement $soldPropertyInfo
 * @var array $averagePrices
 * @var array $averageListingPrice
 * @var array $landRegistrySalesForMonth
 */
use \Phalcon\Tag;
 
if(!isset($canSeeMarketTrends)) {
    $canSeeMarketTrends = false;
}
 
if(isset($property)) : ?>
    <?php
    /** @var \WAI\Search\Models\Winkworth\Office $office */
    $office = $property->office;
    ?>
 
    <div id="fullDetailsWrapper" class="clearfix searchtype<?= isset($cssClass) ? $cssClass : ''; ?>">
        <div id="fd-nav-wrapper">
            <ul id="fdNav">
                <li>
                     <?php if(isset($backToSearchUrl)) : ?>
                        <a href="<?= $backToSearchUrl; ?>" class="backSearch" title="Back to search results">Back to search results</a>
                        &nbsp;&nbsp;|&nbsp;&nbsp;
                    <?php endif; ?>
                </li>
                <li class="new-search">
                    <a href="/" title="New Search">New search</a>
                </li>
 
                <li class="currency">
                    <a class="selected currencyselect" id="currencypound" title="Switch price to Pounds">&pound;</a> |
                    <a class="currencyselect" id="currencydollar" title="Switch price to Dollars">&#36;</a> |
                    <a class="currencyselect" id="currencyeuro" title="Switch price to Euro's">&euro;</a>
                </li>
 
                <?php if(isset($nextPropertyUrl)) : ?>
                    <li class="nextProperty">
                        <a href="<?= $nextPropertyUrl; ?>" class="site-icons-next-property" title="Next property">Next</a>
                    </li>
                <?php endif; ?>
                <?php if(isset($previousPropertyUrl)) : ?>
                    <li class="prevProperty">
                        <a href="<?= $previousPropertyUrl; ?>" class="site-icons-prev-property" title="Previous property">Previous</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    </li>
                <?php endif; ?>
            </ul>
        </div>
 
 
        <div id="fdPropertyHeader" class="clearfix">
            <div class="priceBlock">
                <h3>
                    <span id="pricepound" class="prices"><?= $property->getDisplayPrice(); ?></span>
                    <span id="pricedollar" class="prices" style="display:none"><?= $property->getDisplayPriceDollars(); ?></span>
                    <span id="priceeuro" class="prices" style="display:none"><?= $property->getDisplayPriceEuros(); ?></span>
                    <?= $property->getTenure(); ?>
                </h3>
                <?php if($isRent) : ?>
                    <h2 class="altPrice">
                        <span id="altpricepound" class="prices"><?= $property->getDisplayPrice(true); ?></span>
                        <span id="altpricedollar" class="prices" style="display:none"><?= $property->getDisplayPriceDollars(true); ?></span>
                        <span id="altpriceeuro" class="prices" style="display:none"><?= $property->getDisplayPriceEuros(true); ?></span>
                    </h2>
                    <div class="clearfix">
                        <p>
                            <?= $property->getAsaLettingsFeesUrl($property, 'Tenant(s) Fees Apply', 'asaTerms'); ?>
                        </p>
                    </div>
                <?php endif; ?>
 
                <p>Ref No: <?= $property->propertyCode; ?></p>
            </div>
 
            <h1><?= $property->getDisplayAddressShortPostcode(); ?></h1>
            <?php
            $bedroomText = $property->bedrooms > 0 ? $property->bedrooms . ' bedroom' : "Studio";
            if($property->getHouseSubType() === 'development plot') : ?>
                <h2 class="property-subtitle"><?= ucfirst($property->getHouseSubType()); ?> in <?= $property->getArea(); ?></h2>
            <?php else : ?>
                <h2 class="property-subtitle"><?= $bedroomText; ?> <?= $property->getHouseSubType(); ?> in <?= $property->getArea(); ?></h2>
            <?php endif; ?>
        </div>
 
 
        <div id="image-office-area">
            <?php if ($property->getPropertyStatus() !== '') : ?>
                <div class="propertyStatus"><?= $property->getPropertyStatus(); ?></div>
            <?endif;?>
 
            <div id="mainImage">
                <?php
                $count = 0;
                /** @var \WAI\Search\Models\Asset $photo */
                foreach ($photos as $photo) :
                    echo Tag::image(array($photo->getResizedUrl(615, 410), 'width' => 615, 'height' => 410));
 
                    $count++;
                    if ($count == 5) {
                        break;
                    }
                endforeach; ?>
            </div>
 
            <div id="thumbanil-panel" class="clearfix">
                <ul id="thumbNav" class="clearfix">
                    <?php
                    $count = 0;
                    /** @var \WAI\Search\Models\Asset $photo */
                    foreach ($photos as $photo):?>
                        <li>
                            <a href="#">
                                <?= Tag::image(array($photo->getResizedUrl(102, 60), 'width' => 102, 'height' => 60)); ?>
                            </a>
                        </li>
                        <?php
                        $count++;
                        if ($count == 5) {
                            break;
                        }
                    endforeach; ?>
                </ul>
                <ul id="lightbox-thumbs" class="clearfix">
                    <?php if($property->isActive() === true) : ?>
                        <?php foreach ($photos as $photo):?>
                            <li>
                                <a href="/<?= $photo->getResizedUrl(800, 533); ?>" rel="main-images">
                                    <?= Tag::image(array($photo->getResizedUrl(102, 60), 'width' => 102, 'height' => 60)); ?>
                                </a>
                            </li>
                        <?php endforeach;?>
                    <?php endif; ?>
                    <li class="full-width">
                        <p>Click on a thumbnail to see an enlarged view</p>
                    </li>
                </ul>
 
                <a href="#" class="text-link show-link" title="See Gallery">See more images</a>
                <a href="#" class="text-link hidden-link" title="Hide Gallery">Back</a>
            </div>
 
            <div id="office">
                <h4>
                    <a href="<?= $office->url; ?>">Winkworth <?= $office->name; ?></a>
                </h4>
                <div class="office-negotiator clearfix">
                    <p class="officeAddress">
                        <?php foreach ($office->getAddressAsArray() as $address) : ?>
                            <?= $address; ?>
                            <br />
                        <?php endforeach;?>
                    </p>
                    <ul class="officeContact">
                        <li id="phone-fax">
                            T: <?= $office->telephone; ?>
                            <?php if (isset($office->fax) && $office->fax !== ''):?>
                                | F: <?= $office->fax; ?>
                            <?php endif;?>
                        </li>
                        <li id="email">
                            E: <?= $this->utilities->emailContactFormLink($office->email); ?>
                        </li>
                    </ul>
                </div>
                <div class="form-buttons">
                  <?= Tag::linkTo(array(
                    $this->pssForms->getContactAgentFormUrl($property),
                    "<span>Arrange a viewing</span>",
                    'class' => 'arrange-a-viewing lightboxContactAgent button enquire',
                    'title' => 'Arrange a Viewing',
                    'onclick' => "_gaq.push(['_trackEvent', 'Property Enquiry', 'Arrange a Viewing', '{$property->getSeoUrl()}']);"
                  )); ?>
                  <?= Tag::linkTo(array(
                    $this->pssForms->getRequestValuationFormUrl($office),
                    '<span class="request">Request a valuation</span>',
                    'class' => 'button',
                    'title' => 'Request Valuation',
                    'onclick' => "_gaq.push(['_trackEvent', 'Office Enquiry', 'Request Valuation', '{$office->url}']);"
                  )); ?>
                </div>
                <p>
                  <?= Tag::linkTo(array(
                    $office->getSearchUrl($property),
                    'View more properties from this office',
                    'class' => 'office-buttons',
                    'title' => 'View more properties from this office',
                    'onclick' => "_gaq.push(['_trackEvent', 'Office Enquiry', 'More Properties', '{$office->url}']);"
                  )); ?>
                </p>
                <p>
                  <?= Tag::linkTo(array(
                    ltrim($office->url, '/'),
                    "{$office->name} office microsite",
                    'class' => 'office-buttons',
                    'title' => "{$office->name} office microsite",
                    'onclick' => "_gaq.push(['_trackEvent', 'Office Enquiry', 'More Properties', '{$office->url}']);"
                  )); ?>
                </p>
            </div>
        </div>
        <div id="propFDLeft">
 
            <div class="inner-left">
                <?php if($property->isActive() === true) : ?>
                    <?php $formattedDescription = $property->getDescriptionFormatted(); ?>
                    <?php if(strip_tags($formattedDescription) !== '') : ?>
                        <h4>Description</h4>
                        <?= $formattedDescription; ?>
                    <?php else : ?>
                        <h4>Summary</h4>
                        <p><?= $property->getSummary(); ?></p>
                    <?php endif; ?>
                <?php else : ?>
                    <h4>Property no longer available</h4>
                <?php endif; ?>
                <p>
                    <a href="<?= $office->areaGuideUrl; ?>" title="Local Guide" class="reverse arrow-link">
                        <strong>Your local guide: <?= $office->name; ?></strong>
                    </a>
                </p>
            </div>
            <?php
            $total = $property->receptions + $property->bedrooms + $property->bathrooms + count($property->features);
 
            if($total > 0) : ?>
                <div class="inner-right">
                    <h4>At a glance</h4>
                    <ul>
                        <?php if($property->bedrooms > 0) : ?>
                            <li class="site-icons-bedrooms"><?= $property->bedrooms; ?> Bedrooms</li>
                        <?php endif; ?>
                        <?php if($property->receptions > 0) : ?>
                            <li class="site-icons-reception-rooms"><?= $property->receptions; ?> Reception rooms</li>
                        <?php endif; ?>
                        <?php if($property->bathrooms > 0) : ?>
                            <li class="site-icons-bathrooms"><?= $property->bathrooms; ?> Bathrooms</li>
                        <?php endif; ?>
                        <?php foreach ($property->features as $feature):?>
                            <li class="feature"><?= $feature; ?></li>
                        <?php endforeach;?>
                    </ul>
                </div>
            <?php endif; ?>
            <?php if(count($property->children) > 0 || $property->parent !== false) : ?>
                <div class="related-properties">
                    <table>
                        <thead>
                            <tr>
                                <th>Unit</th>
                                <th>Beds</th>
                                <th>Ref</th>
                                <th>Price</th>
                                <th width="140"></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                        if(count($property->children) > 0) { // is parent
                            $parentProperty = $property;
                            $relatedProperties = $property->children;
                        } elseif($property->parent !== false) {
                            $parentProperty = $property->parent;
                            $relatedProperties = $property->parent->children;
                        } else {
                            $parentProperty = array();
                            $relatedProperties = array();
                        }
 
                        if(!empty($parentProperty)) :
                        ?>
                            <tr class="master-record">
                                <td><?= isset($parentProperty->houseName) ? $parentProperty->houseName : ''; ?></td>
                                <td><?= $parentProperty->bedrooms; ?></td>
                                <td class="ref"><?= $parentProperty->propertyCode; ?></td>
                                <td>
                                    <span class="pricepound prices"><?= $parentProperty->getPriceWithPrefix(); ?></span>
                                    <span class="pricedollar prices" style="display:none"><?= $parentProperty->getDisplayPriceDollars(); ?></span>
                                    <span class="priceeuro prices" style="display:none"><?= $parentProperty->getDisplayPriceEuros(); ?></span>
                                </td>
                                <td>
                                    <a href="<?= $parentProperty->getSeoUrl(); ?>" class="button">
                                        <span>More details</span>
                                    </a>
                                </td>
                            </tr>
                        <?php
                        endif;
                        /** @var \WAI\Search\Models\Property $relatedProperty */
                        foreach($relatedProperties as $relatedProperty) : ?>
                            <tr>
                                <td><?= $relatedProperty->houseName; ?></td>
                                <td><?= $relatedProperty->bedrooms; ?></td>
                                <td class="ref"><?= $relatedProperty->propertyCode; ?></td>
                                <td>
                                    <span class="pricepound prices"><?= $relatedProperty->getPriceWithPrefix(); ?></span>
                                    <span class="pricedollar prices" style="display:none"><?= $relatedProperty->getDisplayPriceDollars(); ?></span>
                                    <span class="priceeuro prices" style="display:none"><?= $relatedProperty->getDisplayPriceEuros(); ?></span>
                                </td>
                                <td>
                                    <a href="<?= $relatedProperty->getSeoUrl(); ?>" class="button">
                                        <span>More details</span>
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            <?php endif; ?>
        </div>
        <div id="propFDRight">
            <ul id="buttons" class="clearfix">
                <?php if($property->isActive() === true) : ?>
                    <li>
                        <?= $this->pssMySite->getSavePropertyLink($property, 'button'); ?>
                    </li>
                <?php endif; ?>
                <?php if ($canSeeMarketTrends !== false): ?>
                    <li>
                        <?= Tag::linkTo(array(
                            '#',
                            '<span>View market trends</span>',
                            'class' => 'button market-trends',
                            'id' => 'market-trends',
                            'title' => 'Market trends',
                            'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'View market trends', '{$property->getSeoUrl()}']);"
                        )); ?>
                    </li>
                <?php endif; ?>
            </ul>
 
            <div class="property-social-media">
                <!-- AddThis Button BEGIN -->
                <div class="addthis_toolbox addthis_default_style ">
                    <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
                    <a class="addthis_button_tweet" tw:count="none" tw:via="<?= $office->getTwitterUsername(); ?>"></a>
                    <a class="addthis_button_google_plusone" g:plusone:size="medium" g:plusone:count="false"></a>
                    <a class="addthis_button_pinterest_pinit" count-layout="none"></a>
                </div>
                <!-- AddThis Button END -->
                <a href="#" title="Follow Us" class="follow-us-trigger">
                    <span>Follow us</span>
                </a>
 
                <ul class="follow-us">
                    <li class="close">
                        <a href="#" title="Close">X</a>
                    </li>
                    <li class="googleplus">
                        <a href="https://plus.google.com/<?= $office->getGoogleplusUsername(); ?>" title="Google +" target="_blank">Google +</a>
                    </li>
                    <li class="facebook">
                        <a href="https://www.facebook.com/<?= $office->getFacebookUsername(); ?>" title="Facebook" target="_blank">Facebook</a>
                    </li>
                    <li class="twitter">
                        <a href="https://twitter.com/<?= $office->getTwitterUsername(); ?>" title="Twitter" target="_blank">Twitter</a>
                    </li>
                    <li class="pintrest">
                        <a href="http://www.pinterest.com/<?= $office->getPinterestUsername(); ?>" title="Pinterest" target="_blank">Pinterest</a>
                    </li>
                </ul>
            </div>
 
            <ul id="property-quick-links" class="clearfix">
                <?php if (isset($brochures) && count($brochures) > 0) : ?>
                    <?php
                    $brochure = $property->getBrochure(0);
 
                    if($brochure !== false) : ?>
                        <li>
                          <?= Tag::linkTo(array(
                            $brochure->getUrl(),
                            "Print brochure",
                            'class' => 'site-icons-print',
                            'title' => "Print brochure for {$property->getDisplayAddress(1, 1)}, {$property->getDisplayAddressShortPostcode(2, 10, false)}",
                            'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'Print brochure', '{$property->getSeoUrl()}']);",
                            'target' => '_blank'
                          )); ?>
                        </li>
                    <?php endif;?>
                <?php endif;?>
 
                <?php if($office->id != 181) : ?>
                    <li>
                      <?= Tag::linkTo(array(
                        '#',
                        "Journey heatmap",
                        'class' => 'site-icons-journey-heatmap',
                        'id' => 'heatmap',
                        'title' => 'See the journey heatmap',
                        'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'Journey heatmap', '{$property->getSeoUrl()}']);",
                        'target' => '_blank'
                      )); ?>
                    </li>
                <?php endif; ?>
 
                <?php if (isset($epcs) && count($epcs) > 0) :
                    $epc = $property->getEpc(0);
                    $epc2 = $property->getEpc(1);
                    $isEpcPdf = false;
 
                    if ($epc2 !== false && !preg_match("/.pdf$/i", $epc->getUrl())) {
                        if (preg_match ("/.pdf$/i", $epc2->getUrl())) {
                            $epc = $epc2;
                            $isEpcPdf = true;
                        }
                    }
                    ?>
                    <li>
                        <?= Tag::linkTo(array(
                          $epc->getUrl(),
                          "EPC",
                          'class' => $isEpcPdf === true ? 'site-icons-epc' : 'site-icons-epc epc-lightbox',
                          'title' => 'View property EPC',
                          'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'EPC', '{$property->getSeoUrl()}']);",
                          'target' => '_blank'
                        )); ?>
                    </li>
                <?php endif;?>
 
                <?php if (!$isRent) : ?>
                    <li>
                      <?= Tag::linkTo(array(
                        $this->pssForms->getMortgageCalculatorUrl($property),
                        "Mortgage calculator",
                        'class' => 'site-icons-mortgage-calculator',
                        'title' => 'Mortgage Calculator',
                        'onclick' => "_gaq.push(['_trackEvent', 'Property Enquiry', 'Mortgage calculator', '{$property->getSeoUrl()}']);"
                      )); ?>
                    </li>
                <?php endif;?>
 
                <?php
                $floorplanUrl = $property->getFloorplanPDFUrl();
                $class = 'site-icons-floorplans';
                if($floorplanUrl === false && isset($floorplans) && count($floorplans) > 0) {
                  $fp = $property->getFloorplan(0);
                  if($fp !== false) {
                    $floorplanUrl = $fp->getUrl();
                    $class .= ' floorplan-lightbox';
                  }
                }
 
                if ($floorplanUrl !== false) : ?>
                    <li>
                      <?= Tag::linkTo(array(
                        $floorplanUrl,
                        "Floorplans",
                        'class' => $class,
                        'title' => 'View property floorplans',
                        'target' => '_blank',
                        'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'Floorplans', '{$property->getSeoUrl()}']);"
                      )); ?>
                    </li>
                <?php endif;?>
 
                <li>
                  <?= Tag::linkTo(array(
                    $this->pssForms->getEmailFriendFormUrl($property),
                    "Share with a friend",
                    'class' => 'site-icons-share-friend',
                    'title' => 'Share with friend',
                    'onclick' => "_gaq.push(['_trackEvent', 'Share with friend', 'Open form', '{$property->getSeoUrl()}']);"
                  )); ?>
                </li>
                <?php
                // try and get the panoramic imaging virtual tour link
                $vtLink = $property->getVirtualTourVideoLinks();
                // if we have a valid panoramic imaging virtual tour link
                if($vtLink) :
                    echo $vtLink;
                endif;
 
                if ($property->getVirtualTourLink(1) !== false) : ?>
                    <li>
                      <?= Tag::linkTo(array(
                        "property-virtual-tour?property={$property->propertyCode}",
                        "Virtual tour",
                        'class' => 'site-icons-virtual-tour',
                        'title' => 'See the property Virtual Tour',
                        'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'Virtual tours', '{$property->getSeoUrl()}']);"
                      )); ?>
                    </li>
                <?php endif;?>
 
                <?php if (isset($property->micrositeLink)) : ?>
                    <li class="full-width">
                        <?= Tag::linkTo(array(
                            $property->micrositeLink,
                            isset($property->micrositeLabel) ? $property->micrositeLabel : "Property website",
                            'class' => 'site-icons-property-website',
                            'title' => "See the property website",
                            'target' => '_blank'
                        )); ?>
                    </li>
                <?php endif;?>
 
                <?php if ($property->getInteractiveFloorplans() !== false) : ?>
                    <li class="full-width">
                        <?= Tag::linkTo(array(
                            "search/interactive-floorplan?property={$property->propertyCode}",
                            'View interactive floorplan',
                            'class' => 'site-icons-interactive-presentation',
                            'title' => "Interactive Floorplans",
                            'target' => '_blank',
                            'id' => 'interactive-floorplans',
                        'onclick' => "_gaq.push(['_trackEvent', 'Property Details', 'Interactive floorplan', '{$property->getSeoUrl()}']);"
                        )); ?>
                    </li>
                <?php elseif (isset($property->floorplanLink)): ?>
                    <li class="full-width">
                        <?= Tag::linkTo(array(
                            $property->floorplanLink,
                            isset($property->floorplanLabel) ? $property->floorplanLabel : "Interactive property presentation",
                            'class' => 'site-icons-interactive-presentation',
                            'title' => "See an interactive presentation",
                            'target' => '_blank'
                        )); ?>
                    </li>
                <?php endif;?>
 
                <?php
                if(!isset($brochure)) {
                    $brochure = $property->getBrochure(0);
                }
                if($brochure !== false) {
                    $brochure = $brochure->getFullUrl();
                    $local = false;
                } else {
                    $brochure = 'pdf/view?property=' . $property->propertyCode;
                    $local = true;
                }
                ?>
                <li class="full-width">
                    <?= Tag::linkTo(array(
                        $brochure,
                        "View brochure",
                        'class' => 'site-icons-interactive-presentation',
                        'title' => "View brochure",
                        'target' => '_blank',
                        'id' => 'brochure-link',
                        'local' => $local
                    )); ?>
                </li>
            </ul>
            <div class="gmap_enlarge_icon">
                <div id="gmap_enlarge">
                    <?= Tag::linkTo(array(
                        $this->pssForms->getMapFormUrl($property),
                        "",
                        'class' => 'enlarge_map'
                    )); ?>
                </div>
                <div id="gmap">
                    <img src="http://maps.google.com/maps/api/staticmap?zoom=15&size=296x198&maptype=roadmap&markers=icon:http://<?= $_SERVER['HTTP_HOST'] .'/search/map-icon/'.($property->isHouse() ? "house" : "flat").'/25/'.($property->isHouse() ? "H" : "F"); ?>|<?=$property->latitude?>,<?=$property->longitude?>&sensor=false" width="296" height="198" />
                </div>
            </div>
        </div>
 
        <?= $this->view->partial('partials/recent-modules'); ?>
    </div>
 
    <div class="popup-wrapper">
        <div id="heatmap-popup" class="panel">
            <h3>Journey heatmap</h3>
            <div class="loadingBlock">
                <p>Your heatmap is loading. Please be patient.</p>
            </div>
        </div>
    </div>
 
    <?php if($canSeeMarketTrends !== false) : ?>
        <div class="popup-wrapper">
            <div id="market-trends-popup" >
                <h3>Market trends</h3>
                <div id="market-trends-holder">
                    <div class="panel">
                        <h4>Average prices in this area</h4>
                        <?php if (!empty($averagePrices)): ?>
                            <table border="0" cellpadding="0" cellspacing="0" width="210">
                                <tr valign="top">
                                    <th class="column-1">Nearby streets</th>
                                    <th class="column-2">Average price</th>
                                </tr>
 
                                <?php foreach ($averagePrices as $street => $averagePrice): ?>
                                    <tr valign="top">
                                        <td class="column-1"><?= ucwords($street); ?></td>
                                        <td class="column-2"><?= $averagePrice; ?></td>
                                    </tr>
                                <?php endforeach; ?>
                            </table>
                        <?php else: ?>
                            <p>No information available</p>
                        <?php endif; ?>
                    </div>
 
                    <div id="market-activity" class="panel">
                        <h4>Market activity in <?= $property->addressPostcodePrefix; ?></h4>
                        <p>
                            <span>Average Listing Price</span><br />
                            <?= isset($averageListingPrice['thisQuarterPrice']) ? $averageListingPrice['thisQuarterPrice'] : ''; ?>
                            <?= isset($averageListingPrice['lastQuarterDiff']) ? $averageListingPrice['lastQuarterDiff'] : ''; ?>
                            (<?= isset($averageListingPrice['lastQuarterDiffPercent']) ? $averageListingPrice['lastQuarterDiffPercent'] : ''; ?>%)
                            <?= isset($averageListingPrice['startDate']) ? $averageListingPrice['startDate'] : ''; ?> - <?= isset($averageListingPrice['endDate']) ? $averageListingPrice['endDate'] : ''; ?>
                        </p>
                        <p>
                            <span>Land Registry Sales for <?= isset($landRegistrySalesForMonth['compareDate']) ? $landRegistrySalesForMonth['compareDate'] : ''; ?></span><br />
                            <?= isset($landRegistrySalesForMonth['lastMonthCount']) ? $landRegistrySalesForMonth['lastMonthCount'] : ''; ?>,
                            <?= isset($landRegistrySalesForMonth['lastMonthDiff']) ? $landRegistrySalesForMonth['lastMonthDiff'] : ''; ?>
                            (<?= isset($landRegistrySalesForMonth['lastMonthDiffPercent']) ? $landRegistrySalesForMonth['lastMonthDiffPercent'] : ''; ?>%) month-on-month
                        </p>
                        <p>
                            <span>Properties for Sale</span><br/>
                            <?php if($soldPropertyInfo !== false) : ?>
                                <?= (string) $soldPropertyInfo->forsaleText; ?>
                            <?php endif; ?>
                        </p>
 
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>
<?php endif;
#2Phalcon\Mvc\View\Engine\Php->render(/var/www/vhosts/winkworth-search/src/app/Views/winkworth/property/view.phtml, Array(18), true)
#3Phalcon\Mvc\View->_engineRender(Array([.volt] => Object(Phalcon\Mvc\View\Engine\Volt), [.phtml] => Object(Phalcon\Mvc\View\Engine\Php)), property/view, true, true, null)
#4Phalcon\Mvc\View->render(property, view, Array([type] => rent, [code] => WNKSLE000583))
#5Phalcon\Mvc\Application->handle()
<?php
 
//try {
    /** Define the environment */
    require_once __DIR__ . "/../app/config/environment.php";
 
    $debug = new \Phalcon\Debug();
    $debug->listen();
 
    /**
     * Read the configuration
     */
    $config = include APP_DIR . "/config/config.php";
 
    /**
     * Read auto-loader
     */
    include APP_DIR . "/config/loader.php";
 
    /**
     * Read services
     */
    include APP_DIR . "/config/services.php";
 
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);
 
 
    echo $application->handle()
                     ->getContent();
 
//} catch (\Exception $e) {
   // echo $e->getMessage();
//}
#6require_once(/var/www/vhosts/winkworth-search/src/public/index.php)
<?php
if(preg_match('/(staging)/', $_SERVER['HTTP_HOST'])) {
    $folder = '/../../winkworth-search';
    $file = 'src/app/config/clients/config.winkworth.staging.php';
} elseif(preg_match('/(dev)/', $_SERVER['HTTP_HOST'])) {
    $folder = '/../../search';
    $file = 'src/app/config/clients/config.winkworth.dev.php';
} else {
    $folder = '/../../winkworth-search';
    $file = 'src/app/config/clients/config.winkworth.php';
}
 
if(file_exists(__DIR__ . "{$folder}/{$file}")) {
    $clientConfig = require_once(__DIR__ . "{$folder}/{$file}");
}
 
require_once(__DIR__ . "{$folder}/src/public/index.php");
KeyValue
_url/rent/property/WNKSLE000583
KeyValue
REDIRECT_STATUS200
HTTP_HOSTwww.winkworth.co.uk
HTTP_ACCEPT_ENCODINGx-gzip, gzip, deflate
HTTP_USER_AGENTCCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_ACCEPT_LANGUAGEen-us,en-gb,en;q=0.7,*;q=0.3
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
PATH/sbin:/usr/sbin:/bin:/usr/bin
SERVER_SIGNATURE
SERVER_SOFTWAREApache
SERVER_NAMEwww.winkworth.co.uk
SERVER_ADDR172.24.32.114
SERVER_PORT80
REMOTE_ADDR174.129.93.155
DOCUMENT_ROOT/var/www/vhosts/site.winkworth.supadu.com/httpdocs
SERVER_ADMINjamie.hannaford@wai.co.uk
SCRIPT_FILENAME/var/www/vhosts/site.winkworth.supadu.com/httpdocs/phalcon.php
REMOTE_PORT40705
REDIRECT_QUERY_STRING_url=/rent/property/WNKSLE000583
REDIRECT_URL/rent/property/WNKSLE000583
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.0
REQUEST_METHODGET
QUERY_STRING_url=/rent/property/WNKSLE000583
REQUEST_URI/rent/property/WNKSLE000583
SCRIPT_NAME/phalcon.php
PHP_SELF/phalcon.php
REQUEST_TIME_FLOAT1422436271.269
REQUEST_TIME1422436271
#Path
0/var/www/vhosts/site.winkworth.supadu.com/httpdocs/phalcon.php
1/var/www/vhosts/winkworth-search/src/app/config/clients/config.winkworth.php
2/var/www/vhosts/winkworth-search/src/public/index.php
3/var/www/vhosts/winkworth-search/src/app/config/environment.php
4/var/www/vhosts/winkworth-search/src/app/config/config.php
5/var/www/vhosts/winkworth-search/src/app/config/loader.php
6/var/www/vhosts/winkworth-search/src/vendor/autoload.php
7/var/www/vhosts/winkworth-search/src/vendor/composer/autoload_real.php
8/var/www/vhosts/winkworth-search/src/vendor/composer/ClassLoader.php
9/var/www/vhosts/winkworth-search/src/vendor/composer/autoload_namespaces.php
10/var/www/vhosts/winkworth-search/src/vendor/composer/autoload_psr4.php
11/var/www/vhosts/winkworth-search/src/vendor/composer/autoload_classmap.php
12/var/www/vhosts/winkworth-search/src/app/config/services.php
13/var/www/vhosts/winkworth-search/src/app/config/routes.php
14/var/www/vhosts/winkworth-search/src/app/Router/Router.php
15/var/www/vhosts/winkworth-search/src/app/Router/Routes/Winkworth/Routes.php
16/var/www/vhosts/winkworth-search/src/app/Router/Routes/Routes.php
17/var/www/vhosts/winkworth-search/src/app/Controllers/Winkworth/SearchController.php
18/var/www/vhosts/winkworth-search/src/app/Controllers/SearchControllerBase.php
19/var/www/vhosts/winkworth-search/src/app/Controllers/ControllerBase.php
20/var/www/vhosts/winkworth-search/src/app/Controllers/Winkworth/PropertyController.php
21/var/www/vhosts/winkworth-search/src/app/Controllers/PropertyControllerBase.php
22/var/www/vhosts/winkworth-search/src/app/Plugins/MobileRedirect.php
23/var/www/vhosts/winkworth-search/src/app/Plugins/NotFound.php
24/var/www/vhosts/winkworth-search/src/app/Models/Winkworth/Property.php
25/var/www/vhosts/winkworth-search/src/app/Models/Property.php
26/var/www/vhosts/winkworth-search/src/app/Models/ModelBase.php
27/var/www/vhosts/winkworth-search/src/app/Library/SphinxPropertySearch/Search.php
28/var/www/vhosts/winkworth-search/src/app/Library/Utilities/Utilities.php
29/var/www/vhosts/winkworth-search/src/app/Library/SphinxPropertySearch/BitConfig.php
30/var/www/vhosts/winkworth-search/src/app/Library/SphinxPropertySearch/Bit.php
31/var/www/vhosts/winkworth-search/src/app/Models/Winkworth/Asset.php
32/var/www/vhosts/winkworth-search/src/app/Models/Asset.php
33/var/www/vhosts/winkworth-search/src/app/Views/winkworth/property/view.phtml
34/var/www/vhosts/winkworth-search/src/app/Models/Winkworth/Office.php
35/var/www/vhosts/winkworth-search/src/app/Models/Office.php
36/var/www/vhosts/winkworth-search/src/app/Library/Currency/Converter.php
Memory
Usage3670016