Example #1
0
 public static function getAdminFlatList($where, $per_page = 10, $current_page = 1, $action)
 {
     $start_pos = ($current_page - 1) * $per_page;
     $limit = " LIMIT {$start_pos},{$per_page}";
     $amount = Flat::getAmountInList($where);
     $order = " ORDER BY id DESC";
     $db_res = Flat::getAdminListLink($where . $order . $limit);
     //$flat->getFullBy($where.$order.$limit);
     $paginator = self::paginator("flat.php?action={$action}", $amount, $per_page, $current_page);
     $html = "\n\t\t<div><a href='flat.html?action=activateAll'>Активировать все</a></div>\n\t\t<div>{$paginator}</div>\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>\n\t\t <th>Тип дома</th>\n\t\t <th>Адрес</th>\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 = Tenement::$TYPE[$row['ttype']];
         $price = number_format($row['price'], 0);
         $city = $row['city_id'] == 0 ? '' : $row['city'] . ',';
         $addr = $row['tenement_status'] == REALTY_STATUS_NEW ? "(NEW!) {$city} {$row['street']}, {$row['tnum']}" : "{$city} {$row['street']}, {$row['tnum']}";
         $user = '';
         if ($row['user_name'] != '') {
             $user = $row['user_name'];
         }
         if ($row['company_name'] != '') {
             $user .= ' - ' . $row['company_name'];
         }
         $html .= "<tr>\n\t\t\t<td>{$row['rooms']}</td>\n\t\t\t<td>{$price}</td>\n\t\t\t<td>{$type}</td>\t\t\t\n\t\t\t<td><a href='/tenement.html?action=edit&id={$row['tenement_id']}' target='_blank'>{$addr}</a></td>\n\t\t\t<td>{$user}</td>\n\t\t\t<td><a href='/flat.html?action=edit&id={$row['id']}' target='_blank'>Редактировать</a></td>\n\t\t\t<td><a href='/flat.html?action=view&id={$row['id']}' target='_blank'>Смотреть</a></td>\n\t\t\t<td><a href='javascript:delFlat({$row['id']});'>Удалить</a></td>\n\t\t\t<td><a href='/flat.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\tdelFlat = function(id) {\n\t\t\tif (confirm('Вы уверены удалить эту квартиру?')) {\n\t\t\t\tlocation.href = '/flat.html?action=delete&id='+id;\n\t\t\t}\n\t\t\treturn 0;\t\t\t\n\t\t}\t\t\t\t\n\t\t</script>";
     return $html;
 }