public function view() { if (empty($this->id)) { \Layout::add('<h1>Sorry</h1><p>This property is not in our system. Please return to the <a href="./">property listing page</a> to try again.</p>'); return; } $tpl = $this->getBaseTpl(); $refund = '<span style="font-size : 90%">(Refundable)</span>'; \PHPWS_Core::initModClass('properties', 'Contact.php'); $max_width = PANEL_WIDTH; $max_height = PANEL_HEIGHT; \Layout::addStyle('properties', 'view.css'); $tpl['NAME'] = $this->viewLink($this->name); $photos = $this->getPhotos(); if ($photos) { javascriptMod('properties', 'galleryview', array('panel_width' => $max_width, 'panel_height' => $max_height)); foreach ($photos as $p) { if (is_file($p['path'])) { $dim = getimagesize($p['path']); $width =& $dim[0]; $height =& $dim[1]; $diff = \PHPWS_File::getDiff($width, $max_width, $height, $max_height); $new_width = round($width * $diff); $new_height = round($height * $diff); if ($new_width > $max_width || $new_height > $max_height) { $diff = \PHPWS_File::getDiff($new_width, $max_width, $new_height, $max_height); $new_width = round($width * $diff); $new_height = round($height * $diff); } } else { $p['path'] = PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif'; $p['title'] = 'Photo not found'; $new_width = '150px'; $new_height = '113px'; } $all[] = sprintf('<li><img src="%s" title="%s" /> <div class="panel-content lightbox"> <a class="lightbox" href="%s"><img src="%s" width="%s" height="%s" /></a> </div></li>', Photo::thumbnailPath($p['path']), $p['title'], $p['path'], $p['path'], $new_width, $new_height); } $tpl['PHOTOS'] = implode("\n", $all); } else { $tpl['NO_PHOTO'] = '<img src="' . PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif" alt="No photo" title="No photos available" />'; } $contact = new Contact($this->contact_id); if (!empty($contact->company_address)) { $tpl['COMPANY_ADDRESS'] = $contact->getCompanyAddress(); $tpl['GOOGLE_COMPANY'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s"> <img class="google-map" src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($contact->company_address), PHPWS_SOURCE_HTTP); } $tpl['COMPANY_NAME'] = $contact->getCompanyUrl(); $tpl['EMAIL'] = $contact->getEmailAddress(true); $tpl['PHONE'] = $contact->getPhone(); $tpl['TIMES_AVAILABLE'] = $contact->getTimesAvailable(); $tpl['ADDRESS'] = $this->getAddress(); $tpl['GOOGLE_MAP'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s"> <img src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($this->address), PHPWS_SOURCE_HTTP); $tpl['LEASE_TYPE'] = $this->getLeaseType(); if ($this->efficiency) { $tpl['BEDROOMS'] = 'One room efficiency'; } else { $tpl['BEDROOMS'] = $this->bedroom_no; } $tpl['BATHROOMS'] = $this->getBathroomNo(); if ($this->window_number) { $tpl['WINDOWS'] = 'Yes'; } else { $tpl['WINDOWS'] = 'No'; } if (!empty($this->admin_fee_amt)) { $tpl['ADMIN_FEE'] = '$' . $this->getAdminFeeAmt(); $tpl['ADMIN_FEE_REFUND'] = $this->admin_fee_refund ? $refund : null; } if (!empty($this->parking_fee)) { $tpl['PARKING_FEE'] = '$' . $this->getParkingFee(); } if (!empty($this->security_amt)) { $tpl['SECURITY_AMT'] = '$' . $this->getSecurityAmt(); $tpl['SECURITY_REFUND'] = $this->security_refund ? $refund : null; } if (!empty($this->other_fees)) { $tpl['OTHER_FEES'] = $this->getOtherFees(); } if (!empty($this->clean_fee_amt)) { $tpl['CLEAN_FEE_AMT'] = '$' . $this->getCleanFeeAmt(); $tpl['CLEAN_FEE_REFUND'] = $this->clean_fee_refund ? $refund : null; } $tpl['PARKING_PER_UNIT'] = $this->getParkingPerUnit(); if ($this->pets_allowed) { $tpl['PETS_ALLOWED'] = 'Yes'; $tpl['PET_TYPES'] = $this->getPetType(); if ($this->pet_deposit) { $tpl['PET_DEPOSIT'] = '$' . $this->getPetDeposit() . ' <span style="font-size : 90%">(refundable)</span>'; } else { $tpl['PET_DEPOSIT'] = 'None'; } if ($this->pet_fee) { $tpl['PET_FEE'] = '$' . $this->getPetFee() . ' <span style="font-size : 90%">(nonrefundable)</span>'; } else { $tpl['PET_FEE'] = 'None'; } } else { $tpl['PETS_ALLOWED'] = 'No'; } $utility_allowance = false; $tpl['STUDENT_TYPE'] = $this->getStudentType(); if ($this->util_water) { $utility_allowance = true; $tpl['UTIL_WATER'] = $this->getUtilWater(); } if ($this->util_trash) { $utility_allowance = true; $tpl['UTIL_TRASH'] = $this->getUtilTrash(); } if ($this->util_power) { $utility_allowance = true; $tpl['UTIL_POWER'] = $this->getUtilPower(); } if ($this->util_fuel) { $utility_allowance = true; $tpl['UTIL_FUEL'] = $this->getUtilFuel(); } if ($this->util_cable) { $utility_allowance = true; $tpl['UTIL_CABLE'] = $this->getUtilCable(); } if ($this->util_internet) { $utility_allowance = true; $tpl['UTIL_INTERNET'] = $this->getUtilInternet(); } if ($this->util_phone) { $utility_allowance = true; $tpl['UTIL_PHONE'] = $this->getUtilPhone(); } $photo = new Photo(); $photo->setPropertyId($this->id); if (isset($_GET['photo'])) { $data['pid'] = $this->id; } $data['view'] = 1; if (\Current_User::allow('properties')) { javascriptMod('properties', 'photo_upload', $data); $tpl['ADD_PHOTO'] = $photo->uploadNew(false); $tpl['EDIT'] = \PHPWS_Text::secureLink('<i class="fa fa-edit"></i> Edit', 'properties', array('aop' => 'edit_property', 'pid' => $this->id), null, null, 'btn btn-default'); if (!$this->active) { $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>'; } } elseif (isset($_SESSION['Contact_User']->id) && $_SESSION['Contact_User']->id == $this->contact_id) { if (!$this->active) { $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>'; } $data['is_contact'] = 1; javascriptMod('properties', 'photo_upload', $data); $tpl['ADD_PHOTO'] = $photo->uploadNew(false); $tpl['EDIT'] = \PHPWS_Text::moduleLink('Edit property', 'properties', array('cop' => 'edit_property', 'pid' => $this->id, 'k' => $_SESSION['Contact_User']->getKey())); } elseif (!$this->active) { \Layout::add('This property is currently not available'); return; } $heat_type = $this->getHeatType(); if ($heat_type) { $tpl['HEAT_TYPE'] = implode(', ', $this->getHeatType()); } $content = \PHPWS_Template::process($tpl, 'properties', 'view.tpl'); \Layout::add($content); }