public static function getAdminCommercialList($action, $per_page = 10, $current_page = 1) { if ($action == 'newSales') { $where = "f.status='" . REALTY_STATUS_APPLY . "'"; } else { if ($action == 'newRent') { $where = "f.status='" . REALTY_STATUS_RENT_APPLY . "'"; } } $start_pos = ($current_page - 1) * $per_page; $limit = " LIMIT {$start_pos},{$per_page}"; $amount = Commercial::getAmountInList($where); $order = " ORDER BY id DESC"; $db_res = Commercial::getFullListLink($where . ' GROUP BY f.id ' . $order . $limit); $paginator = self::paginator("commercial.php?action={$action}", $amount, $per_page, $current_page); $html = "\n\t\t<div>{$paginator}</div>\n\t\t<div><a href='commercial.html?action=activateAll'>Активировать все</a></div>\t\n\t\t<table class='base_text'>\n\t\t<thead>\n\t\t<tr>\n\t\t <th>Адрес</th>\n\t\t <th>Цена</th>\t\t \n\t\t <th>Тип</th>\n\t\t <th>Карта</th>\n\t\t <th>Юзер</th>\t\t \n\t\t <th></th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t"; $status = $action == 'newSales' ? REALTY_STATUS_SALE : REALTY_STATUS_RENT; while ($row = $db_res->fetchRow()) { $type = Commercial::$TYPE[$row['type_id']]; $city = $row['city_id'] == 0 ? '' : $row['city'] . ','; $addr = $city; $price = number_format($row['price'], 0); $map = $row['lat'] && $row['lon'] ? 'Да' : '<b>Нет</b>'; $user = ''; if ($row['user_name'] != '') { $user = $row['user_name']; } if ($row['company_name'] != '') { $user .= ' - ' . $row['company_name']; } $html .= "<tr>\n\t\t\t<td>{$addr}</td>\n\t\t\t<td>{$price}</td>\n\t\t\t<td>{$type}</td>\t\t\t\n\t\t\t<td>{$map}</td>\n\t\t\t<td>{$user}</td>\n\t\t\t<td><a href='/commercial.html?action=edit&id={$row['id']}' target='_blank'>Редактировать</a></td>\t\t\t\n\t\t\t<td><a href='/commercial.html?action=view&id={$row['id']}' target='_blank'>Смотреть</a></td>\n\t\t\t<td><a href='javascript:delObject({$row['id']})'>Удалить</a></td>\n\t\t\t<td><a href='/commercial.html?action=approve&id={$row['id']}&status={$status}' target='_blank'>Активировать</a></td>\n\t\t\t</tr>"; } $html .= "</tbody></table>\n\t\t<script>\t\t\n\t\t\tdelObject = function(id) {\n\t\t\tif (confirm('Вы уверены удалить этот объект?')) {\n\t\t\t\tlocation.href = '/commercial.html?action=delete&id='+id;\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\t\t\t\t\n\t\t</script>"; return $html; }