public static function pageCommercialView(Commercial $commercial, $address, $act) { $properties_val = $commercial->getPropertiesVal(); $vals_html = Html::getViewRealty($properties_val); $photos = $commercial->getPhotos(); $photo_path = $commercial->getPhotoWebPath(); $photo_gallery_html = Html::getPhotosGallery($photos, $photo_path); if ($commercial->tenement_id > 0) { $tenement = new Tenement(); $tenement->getFull($commercial->tenement_id); $photos_tenement = $tenement->getPhotos(); $photo_path_tenement = $tenement->getPhotoWebPath(); $photo_gallery_html_tenement = Html::getPhotosGallery($photos_tenement, $photo_path_tenement); $photo_gallery_html .= $photo_gallery_html_tenement; } //lon=47 - долгота //lat=56 - широта if ($commercial->lat > 0 && $commercial->lon > 0) { $map = self::getMap($commercial->lon, $commercial->lat, 16); } elseif ($commercial->tlat > 0 && $commercial->tlon > 0) { $map = self::getMap($commercial->tlon, $commercial->tlat, 16); } else { $map = ''; } $date = formatDateExact($commercial->created_on); $date_up = formatDateExact($commercial->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>{$commercial->quick_views}</b></div>\n\t\t<div class='flat_view'>Просмотров подробно: <b>{$commercial->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_commercial_id']) && $id == $_SESSION['last_commercial_id'] && !isset($_SESSION['admin']) && ($commercial->status == REALTY_STATUS_NEW || $commercial->status == REALTY_STATUS_RENT_NEW)) { if ($commercial->status == REALTY_STATUS_NEW) { $status = REALTY_STATUS_APPLY; } else { $status = REALTY_STATUS_RENT_APPLY; } $url_edit = Html::getUrl('commercial', 'edit', $commercial->id); $url_apply = Html::getUrl('commercial', 'apply', $commercial->id, '&status=' . $status); } if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $commercial->user_id || isset($_SESSION['last_commercial_id']) && $id == $_SESSION['last_commercial_id']) { $url_edit = Html::getUrl('commercial', 'edit', $commercial->id); } if (isset($_SESSION['admin'])) { $is_admin = 1; $url_edit = Html::getUrl('commercial', 'edit', $commercial->id); $url_sold = Html::getUrl('commercial', 'sold', $commercial->id); $status = -1; if ($commercial->status == REALTY_STATUS_APPLY) { $status = REALTY_STATUS_SALE; } elseif ($commercial->status == REALTY_STATUS_RENT_APPLY) { $status = REALTY_STATUS_RENT; } if ($status > -1) { $url_approve = Html::getUrl('commercial', 'approve', $commercial->id, '&status=' . $status); } $url_delete = Html::getUrl('commercial', 'delete', $commercial->id); } $html_page = ''; if ($url_edit) { $html_page .= '<input type="button" onclick="location=\'' . $url_edit . '\'" value="Редактировать (добавить фотографии)" class="btn btn-primary">'; } if (isset($_SESSION['last_commercial_id']) && $id == $_SESSION['last_commercial_id'] && $url_apply) { $html_page .= ' <input type="button" onclick="location=\'' . $url_apply . '\'" value="Отправить объявление на проверку" class="btn btn-success">'; } if ($is_admin && $url_approve) { $html_page .= ' <input type="button" onclick="location=\'' . $url_approve . '\'" value="Активировать объявление" class="btn btn-success">'; } if ($is_admin && $url_delete) { $html_page .= ' <input type="button" onclick="location=\'' . $url_delete . '\'" value="Удалить объявление" class="btn btn-danger">'; } if ($is_admin && $url_sold) { $html_page .= ' <input type="button" onclick="location=\'' . $url_sold . '\'" value="Продано" class="btn btn-info">'; } $block_html = Html::getBlock($act . ' коммерческой недвижимости: ' . $address, $struct_html . $html_page); return $block_html; }
function edit($s) { if (!isset($_SESSION['admin']) && !isset($_SESSION['user_id'])) { header("Location: /index.html"); exit(); } $id = intval($_GET['id']); $tenement = new Tenement(); $tenement->getFull($id); if ($tenement->status!=REALTY_STATUS_NEW && !isset($_SESSION['admin'])) { header("Location: /index.html"); exit(); } if (empty($_POST) && $tenement->id>0) { $block_html = Html::pageTenementEdit($tenement); $s->assign("block_html",$block_html); $s->assign("YANDEX_KEY",YANDEX_KEY); $s->assign("LAT_CENTER_REGION",LAT_CENTER_REGION); $s->assign("LON_CENTER_REGION",LON_CENTER_REGION); $s->assign("city_id",$tenement->city_id); $s->assign("city",$tenement->city); $s->assign("street_id",$tenement->street_id); $s->assign("street",$tenement->street); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->display("tenement_edit.tpl"); } //Смена адреса на существующий дом elseif (isset($_POST['id']) && $_POST['id']>0 && (isset($_SESSION['admin']) || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) { $tenement_id = intval($_POST['id']); $tenement->find($tenement_id); if (!$tenement->id) { echo "Дом не найден"; exit(); } //дом есть, переводим все кв в него, старый удаляем Flat::changeTenement($id,$tenement_id); if ($id != $tenement_id) { //Tenement::delete($id); //echo "delete $id"; } header("Location: /tenement.html?action=view&id=".$tenement_id); exit(); } elseif($id>0 && !empty($_POST) && (isset($_SESSION['admin']) || (isset($_SESSION['user_id']) && $tenement->user_id==$_SESSION['user_id']))) { if ($_REQUEST['city_id']>1) { Tenement::$_properties['street']['required']=null; Tenement::$_properties['street_id']['required']=null; Tenement::$_properties['number']['required']=null; } $errors = $tenement->checkForm($_REQUEST); if (!isset($errors['is_error']) && $tenement->id > 0) { $tenement->update($_POST); $photo_path = $tenement->getPhotoPath(); if (!is_dir($photo_path)) { mkdir($photo_path,0777); chmod($photo_path,0777); } //добавляем новые фото if (isset($_POST['photo_tenement']) && is_array($_POST['photo_tenement'])) { foreach ($_POST['photo_tenement'] as $fname) { $fname = clearTextData($fname); if ($fname!='') $tenement->addPhoto($fname,$_POST); } } //редактируем существующие фото if (isset($_POST['photo_'.TENEMENT.'_exist']) && is_array($_POST['photo_'.TENEMENT.'_exist'])) { foreach ($_POST['photo_'.TENEMENT.'_exist'] as $fname) { $fname = clearTextData($fname); if ($fname!='') $tenement->editPhoto($fname,$_POST); } } header("Location: /tenement.html?action=view&id=".$tenement->id); exit(); } else { print_r($errors); } } else { //$block_html = Html::pageTenementEdit($tenement); $s->assign("YANDEX_KEY",YANDEX_KEY); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->assign("block_html",'Дом не найден'); $s->display("tenement_edit.tpl"); } }