Example #1
0
    public static function pageHouseView(House $house)
    {
        $properties_val = $house->getPropertiesVal();
        $vals_html = Html::getViewRealty($properties_val);
        if ($house->user_id > 0) {
            $val = $house->company_name;
            if ($house->tariff_id == TARIFF_PAID) {
                $val = "<a href='http://" . $house->domain . "." . $_SERVER['HTTP_HOST'] . "' target='_blank'>{$val}</a>";
            }
            $vals_html .= '<div class="flat_view">Автор: <b>' . $val . '</b></div>';
        }
        $address = $house->city;
        if ($house->street != '') {
            $address .= ', ' . $house->street;
        }
        $photos = $house->getPhotos();
        $photo_tenement_path = $house->getPhotoWebPath();
        $photo_gallery_html = Html::getPhotosGallery($photos, $photo_tenement_path);
        //lon=47 - долгота
        //lat=56 - широта
        $map = $house->lat > 0 && $house->lon > 0 ? self::getMap($house->lon, $house->lat, 10) : '';
        $date = formatDateExact($house->created_on);
        $date_up = formatDateExact($house->updated_on);
        $counter_html = "<br><br>\n\t\t<div class='flat_view'>Обновлено: <b>{$date_up}</b></div>\n\t\t<div class='flat_view'>Размещено: <b>{$date}</b></div>\n\t\t<div class='flat_view'>Просмотров в списке: <b>{$house->quick_views}</b></div>\n\t\t<div class='flat_view'>Просмотров подробно: <b>{$house->counter_views}</b></div>\n\t\t<p><b>Пожалуйста сообщите риэлтору что Вы нашли объявление на сайте mari12.ru. Так Вы поможете развитию портала!</b></p>\n\t\t";
        $struct_html = '<table width="100%" class="content">
		<tr>
		<td style="text-align:left; vertical-align:top;" width="500px;">' . $vals_html . $counter_html . '</td>
		<td style="vertical-align:top;">' . $map . $photo_gallery_html . '
		<div id="div_history" class="base_text"></div>		
		</td>
		</tr>		
		</table>
		';
        $is_admin = 0;
        $id = intval($_REQUEST['id']);
        $url_edit = false;
        $url_apply = false;
        $url_sold = false;
        $url_delete = false;
        if (isset($_SESSION['last_house_id']) && $id == $_SESSION['last_house_id'] && !isset($_SESSION['admin']) && ($house->status == REALTY_STATUS_NEW || $flat->status == REALTY_STATUS_RENT_NEW)) {
            if ($house->status == REALTY_STATUS_NEW) {
                $status = REALTY_STATUS_APPLY;
            } else {
                $status = REALTY_STATUS_RENT_APPLY;
            }
            $url_edit = Html::getUrl('house', 'edit', $house->id);
            $url_apply = Html::getUrl('house', 'apply', $house->id, '&status=' . $status);
        }
        if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $house->user_id || isset($_SESSION['last_house_id']) && $id == $_SESSION['last_house_id']) {
            $url_edit = Html::getUrl('house', 'edit', $house->id);
        }
        if (isset($_SESSION['admin'])) {
            $is_admin = 1;
            $url_edit = Html::getUrl('house', 'edit', $house->id);
            $url_sold = Html::getUrl('house', 'sold', $house->id);
            $status = -1;
            if ($house->status == REALTY_STATUS_APPLY) {
                $status = REALTY_STATUS_SALE;
            } elseif ($house->status == REALTY_STATUS_RENT_APPLY) {
                $status = REALTY_STATUS_RENT;
            }
            if ($status > -1) {
                $url_approve = Html::getUrl('house', 'approve', $house->id, '&status=' . $status);
            }
            $url_delete = Html::getUrl('house', 'delete', $house->id);
        }
        $html_page = '';
        if ($url_edit) {
            $html_page .= '<input type="button" onclick="location=\'' . $url_edit . '\'" value="Редактировать (добавить фотографии)" class="btn btn-primary">';
        }
        if (isset($_SESSION['last_house_id']) && $id == $_SESSION['last_house_id'] && $url_apply) {
            $html_page .= '&nbsp;<input type="button" onclick="location=\'' . $url_apply . '\'" value="Отправить объявление на проверку" class="btn btn-success">';
        }
        if ($is_admin && $url_approve) {
            $html_page .= '&nbsp;<input type="button" onclick="location=\'' . $url_approve . '\'" value="Активировать объявление" class="btn btn-success">';
        }
        if ($is_admin && $url_delete) {
            $html_page .= '&nbsp;<input type="button" onclick="location=\'' . $url_delete . '\'" value="Удалить объявление" class="btn btn-danger">';
        }
        if ($is_admin && $url_sold) {
            $html_page .= '&nbsp;<input type="button" onclick="location=\'' . $url_sold . '\'" value="Продано" class="btn btn-info">';
        }
        $block_html = Html::getBlock('Продажа частного дома: ' . $address, $struct_html . $html_page);
        return $block_html;
    }