Example #1
0
 public static function getHouseList($where, $order, $direction, $per_page = 10, $current_page = 1, $action = 'sales', $user_id = NULL)
 {
     $start_pos = ($current_page - 1) * $per_page;
     $limit = " LIMIT {$start_pos},{$per_page}";
     $sort = $order == '' ? "f.updated_on" : $order;
     $where_param = $where . " GROUP BY f.id ORDER BY " . $sort . " " . $direction . $limit;
     $params = '';
     $price_min = 0;
     $price_max = 0;
     if (isset($_REQUEST['f_price'])) {
         $f_price = intval($_REQUEST['f_price']);
         $params .= '&f_price=' . $f_price;
         switch ($f_price) {
             case 1:
                 $price_max = 1000000;
                 break;
             case 2:
                 $price_min = 1000000;
                 $price_max = 1500000;
                 break;
             case 3:
                 $price_min = 1500000;
                 $price_max = 2000000;
                 break;
             case 4:
                 $price_min = 2000000;
                 $price_max = 3000000;
                 break;
             case 5:
                 $price_min = 3000000;
                 break;
         }
     } else {
         if (isset($_REQUEST['price_min']) && $_REQUEST['price_min'] > 0) {
             $price_min = intval($_REQUEST['price_min']);
         } else {
             $price_min = 0;
         }
         if (isset($_REQUEST['price_max']) && $_REQUEST['price_max'] > 0) {
             $price_max = intval($_REQUEST['price_max']);
         } else {
             $price_max = 0;
         }
         if ($price_min > 0) {
             $params .= '&price_min=' . $price_min;
         }
         if ($price_max > 0) {
             $params .= '&price_max=' . $price_max;
         }
     }
     if (isset($_REQUEST['f_price_sq'])) {
         $params .= '&f_price_sq=' . intval($_REQUEST['f_price_sq']);
     }
     if (isset($_REQUEST['f_radius'])) {
         $params .= '&f_radius=' . intval($_REQUEST['f_radius']);
     }
     if (isset($_REQUEST['f_house'])) {
         $params .= '&f_house=' . intval($_REQUEST['f_house']);
     }
     if (isset($_REQUEST['f_total_area'])) {
         $params .= '&f_total_area=' . intval($_REQUEST['f_total_area']);
     }
     if (isset($_REQUEST['f_city']) && isset($_REQUEST['f_city_id'])) {
         $params .= '&f_city=' . clearTextData($_REQUEST['f_city']);
         $params .= '&f_city_id=' . intval($_REQUEST['f_city_id']);
     }
     if (isset($_REQUEST['f_photo'])) {
         $params .= '&f_photo=' . intval($_REQUEST['f_photo']);
     }
     if (isset($_SESSION['direction'])) {
         $direction = $_SESSION['direction'] == 'ASC' ? 'ASC' : 'DESC';
         $arrow = $direction == 'ASC' ? '↓' : '↑';
         $direction = 'direction=' . $direction;
     } else {
         $direction = '';
         $arrow = '';
     }
     $arrow_date = '';
     $arrow_price = '';
     if ($sort == 'updated_on') {
         $arrow_date = $arrow;
     } else {
         if ($sort == 'price') {
             $arrow_price = $arrow;
         }
     }
     $amount = House::getAmountInList($where . " GROUP BY f.id");
     $paginator = self::paginator("house.html?action={$action}" . $params, $amount, $per_page, $current_page);
     $html = "\n\t\tНайдено {$amount} объявлений:\n\t\t<br>\t\t\t\t\t\t\n\t\t<table class='table table-striped table-bordered table-condensed'>\n\t\t<thead>\n\t\t <tr>\n\t\t <th>Адрес</th>\n\t\t <th><a href='/house.html?action={$action}&sort=price" . $params . "'><b>Цена(руб.)</b></a>{$arrow_price}<br>руб./м<sup>2</sup></th>\n\t\t <th>Этажей</th>\t\t \t\t \t\t \t\t \n\t\t <th>Фото</th>\t\t \t\t \n\t\t <th>Общая м<sup>2</sup></th>\n\t\t <th>Удаленность</th>\t\t \t\t \n\t\t <th>Описание</th>\n\t\t <th><a href='/house.html?action={$action}&sort=updated_on" . $params . "'><b>Дата</b></a>{$arrow_date}</th>\t\t \n\t\t <th></th>\n\t\t </tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t";
     $ids = array();
     $db_res = House::getFullListLink($where_param);
     $tenement_icons = array('derevo', 'kirpich', 'monolit', 'block');
     while ($row = $db_res->fetchRow()) {
         $ids[] = $row['id'];
         $type_name = House::$TYPE[$row['type_id']];
         $type = $tenement_icons[$row['type_id']];
         $type = "<img src='/images/icon_{$type}.png' title='{$type_name}'>";
         $price = number_format($row['price'], 0);
         $price_m = number_format($row['price_m'], 0);
         //$city = ($row['city_id']==0) ? '' : $row['city'].',';
         //$addr = "{$row['city']} {$row['street']}";
         $addr = "{$row['city']}";
         //$hr = ($desc_all!='') ? '<hr>' : '';
         //$description = $desc_all.$hr.$row['contacts'];
         $is_owner = $row['is_owner'] ? '<br><b>Собственник</b>' : '';
         $description = textReduce($row['description']) . $is_owner;
         $flat_url = "/house.html?action=view&id={$row['id']}";
         $photo_html = $row['photo'] != '' ? "<a href='{$flat_url}'><img src='/" . PHOTOS_WEBPATH . HOUSE . "/" . $row['id'] . "/" . $row['photo'] . "_prev'></a>" : 'Нет фото';
         $date = explode(' ', $row['updated_on']);
         $dates = explode('-', $date[0]);
         $date = $dates[2] . '.' . $dates[1];
         //.'.'.$dates[0]
         $url_del = !isset($_SESSION['admin']) ? '' : '<br><br><a href="javascript:delObject(' . $row['id'] . ');">Удалить</a>';
         if ($user_id) {
             $url_del .= ' <a href="javascript:update(' . $row['id'] . ');" title="Обновить дату на текущую"><img src="/images/icon_update.png" title="Обновить дату на сегодняшнюю"></a>';
             $url_del .= ' <a href="house.html?action=edit&id=' . $row['id'] . '"><img src="/images/icon_edit.png" title="Редактировать"></a>';
             $url_del .= ' <a href="javascript:remove(' . $row['id'] . ');"><img src="/images/icon_delete.png" title="Снять"></a>';
             $url_del .= ' <a href="javascript:sold(' . $row['id'] . ');"><img src="/images/icon_sold.png" title="Продано"></a>';
         }
         $dist = $row['dist'] > 0 ? $row['dist'] . ' км' : '';
         $html .= "<tr>\n\t\t\t<td><a href='{$flat_url}'>{$addr}</a></td>\t\t\t\t\t\t\n\t\t\t<td><b>{$price}</b><br><br>{$price_m}</td>\n\t\t\t<td>{$row['storeys']}<br>{$type}</td>\t\t\t\n\t\t\t<td>{$photo_html}</td>\t\t\t\n\t\t\t<td>{$row['total_area']}</td>\n\t\t\t<td>{$dist}</td>\t\t\t\t\n\t\t\t<td>{$description}</td>\n\t\t\t<td>{$date}</td>\n\t\t\t<td><a href='{$flat_url}'><img src='/images/icon_view.png' title='Смотреть'></a>{$url_del}</td>\n\t\t\t</tr>\t\t\t\n\t\t\t";
     }
     $html .= "</tbody></table>\n\t\t<div>{$paginator}</div>\t\t\n\t\t";
     return array('html' => $html, 'ids' => $ids);
 }
Example #2
0
function getLandListByCity($param)
{
    global $config;
    $id = intval($param['id']);
    if (isset($_SESSION['user_id']) && in_array($_SESSION['user_id'], $config['user_workers'])) {
        $is_editor = true;
        $h = '<th></th>';
    } else {
        $is_editor = false;
        $h = '';
    }
    if (!$is_editor) {
        $limit = 3;
    } else {
        $limit = 30;
    }
    $html = '
	История продаж в этом населенном пункте:<br><br>
	<table class="table table-striped table-bordered table-condensed"><thead>
	<tr>
	<th>Дата</th><th>Цена (руб.)</th></th><th>Площадь (соток)</th><th>Описание</th>' . $h . '
	</tr></thead>';
    $db_res = Land::getFullListLink("f.city_id={$id} AND f.status=" . REALTY_STATUS_SALE . " GROUP BY f.id ORDER BY updated_on DESC LIMIT {$limit}");
    while ($row = $db_res->fetchRow()) {
        $html .= '<tr>';
        $date = formatDate($row['updated_on']);
        $t = $is_editor ? '<td><a href="/land.html?action=updateDate&id=' . $row['id'] . '" title="Обновить дату"><img src="/images/icon_update.png"></a></td>' : '';
        $price = number_format($row['price'], 0);
        $description = textReduce($row['description']);
        $html .= "<td><a href='/land.html?action=view&id={$row['id']}' title='смотреть'>{$date}</a></td><td>{$price}</td><td>{$row['area']}</td><td>{$description}</td>{$t}";
        $html .= '</tr>';
    }
    $html .= '</table>';
    if (isset($date)) {
        echo $html;
    } else {
        echo '';
    }
}