function sales($s,$user_id=NULL,$status=REALTY_STATUS_SALE) { $s->assign("top_img_num",1); $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $res = _filter($status); $tenement_status = ($status!=REALTY_STATUS_IMPORT_SALE && $status!=REALTY_STATUS_IMPORT_RENT) ? "t.status='".REALTY_STATUS_ACTIVE."' AND " : ''; $add_sql = $tenement_status.$res['sql']; $filter = $res['filter']; if (isset($_GET['sort'])) { $sort_by = clearTextData($_GET['sort']); } elseif (isset($_SESSION['sort_by'])) { $sort_by = $_SESSION['sort_by']; } else { $sort_by = 'updated_on'; } if (isset($_GET['sort']) && isset($_SESSION['sort_by']) && $_GET['sort']==$_SESSION['sort_by']) { if (isset($_SESSION['direction']) && $_SESSION['direction']=='ASC') $direction = 'DESC'; else if (isset($_SESSION['direction']) && $_SESSION['direction']=='DESC') $direction = 'ASC'; } else { $direction = (isset($_SESSION['direction'])) ? $_SESSION['direction'] : 'DESC'; } if ($user_id) { $add_sql .= " AND f.user_id=".$_SESSION['user_id']; } $_SESSION['direction'] = $direction; $_SESSION['sort_by'] = $sort_by; $filter_html = Html::getFlatFilter($filter,$user_id,$status); if (in_array($status,array(REALTY_STATUS_SALE,REALTY_STATUS_NEW,REALTY_STATUS_SOLD,REALTY_STATUS_IMPORT_SALE,REALTY_STATUS_IMPORT_RENT))) { $action = 'sales'; if ($user_id && $status!=REALTY_STATUS_IMPORT_SALE) $action = 'userSales'; elseif ($status==REALTY_STATUS_IMPORT_SALE) $action = 'userImportSales'; } else { $action = 'rent'; if ($user_id && $status!=REALTY_STATUS_IMPORT_RENT) $action = 'userRent'; elseif ($status==REALTY_STATUS_IMPORT_RENT) $action = 'userImportRent'; } //Объявления не старше месяца $add_sql .= " AND f.updated_on>'".getNextDate(date('Y-m-d'),-61)."'"; $content = Html::getFlatList("$add_sql",$sort_by,$direction,PER_PAGE,$page,$action,$user_id); if ($status == REALTY_STATUS_SALE || $status == REALTY_STATUS_IMPORT_SALE) { $act = 'Продажа'; } else if ($status == REALTY_STATUS_RENT || $status == REALTY_STATUS_IMPORT_RENT) { $act = 'Аренда'; } if ($status == REALTY_STATUS_IMPORT_SALE || $status == REALTY_STATUS_IMPORT_RENT) { $add = ' (импортированные)'; } else { $add = ''; } if (!$user_id) { $block_name = $act.' квартир в Йошкар-Оле - последние объявления'; } else { $block_name = $act.' квартир - мои объявления'.$add; } $s->assign("block_name",$block_name); $s->assign("block_html",$filter_html.$content['html']); if ((!isset($_SESSION['admin']) || !isset($user_id)) && count($content['ids'])>0) { Flat::incQuickMassVisitorCount($content['ids']); } $s->display("flat_sales.tpl"); }