ADD платные точки - добавление, другой цвет, определение платности точки

This commit is contained in:
Krivchikov Dmitry 2016-01-07 01:21:33 +03:00
parent fd6733e43d
commit 2607750376
10 changed files with 28 additions and 18 deletions

View File

@ -43,6 +43,7 @@ class IndexController extends Controller
self::addScript('//ulogin.ru/js/ulogin.js'); self::addScript('//ulogin.ru/js/ulogin.js');
$category = Category::model()->getAll(array('order' => 'ord ASC')); $category = Category::model()->getAll(array('order' => 'ord ASC'));
$categoryArray = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
$routes = array(); $routes = array();
$favorites = array(); $favorites = array();
@ -60,11 +61,6 @@ class IndexController extends Controller
self::addVar('pointLat', (isset($_GET['lat'])?floatval($_GET['lat']):0)); self::addVar('pointLat', (isset($_GET['lat'])?floatval($_GET['lat']):0));
self::addVar('pointLng', (isset($_GET['lng'])?floatval($_GET['lng']):0)); self::addVar('pointLng', (isset($_GET['lng'])?floatval($_GET['lng']):0));
$categoryArray = array();
foreach ($category as $cat) {
$categoryArray[] = $cat->getValues();
}
$og = array(); $og = array();
if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point'])) { if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point'])) {
$id = (int) $_GET['point']; $id = (int) $_GET['point'];
@ -98,14 +94,6 @@ class IndexController extends Controller
)); ));
} }
static function actionUser()
{
App::error404();
$routes = Route::model()->getByAuthor(App::$user->id);
var_dump($routes);
}
static function actionLogout() static function actionLogout()
{ {
App::userLogout(); App::userLogout();

View File

@ -225,7 +225,7 @@ class JsonController extends Controller
$_POST['description'] = strip_tags($_POST['description']); $_POST['description'] = strip_tags($_POST['description']);
} }
if (!( isset($_POST['name']) && $_POST['name'] && strlen($_POST['name']) > 5 )) { if (!( isset($_POST['name']) && $_POST['name'] && strlen($_POST['name']) >= 5 )) {
$errors[1] = 'Неверное название точки'; $errors[1] = 'Неверное название точки';
} }

View File

@ -3,6 +3,7 @@
class Category extends Model class Category extends Model
{ {
private static $categories = NULL; private static $categories = NULL;
private static $paidIds = array(24,25);
function __construct($fromArray = array()) function __construct($fromArray = array())
{ {
@ -25,4 +26,18 @@ class Category extends Model
return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL; return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL;
} }
public function getCategoriesForChoise()
{
if (App::$user && App::$user->isAdmin == 1) {
return $this->getAll(array('order' => 'ord ASC', 'asArray' => true));
} else {
return $this->getAll(array('where' => '`id` NOT IN ('. implode(',', $this->paidIds).')', 'order' => 'ord ASC', 'asArray' => true));
}
}
public static function isPaidCategory($id)
{
return array_search($id, self::$paidIds) !== FALSE;
}
} }

View File

@ -146,4 +146,9 @@ class Point extends Model
return self::statusModeration; return self::statusModeration;
} }
} }
public function isPaid()
{
return Category::isPaidCategory($this->categoryId);
}
} }

1
public/ico/color Normal file
View File

@ -0,0 +1 @@
ff7112

BIN
public/ico/hotel_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

BIN
public/ico/restaurant_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -173,10 +173,11 @@ function showRandomPoint()
runner = 0; runner = 0;
for (var key in points) for (var key in points)
{ {
if (runner++ >= roundIndex) if (runner++ >= roundIndex) {
return showInfo(key); return showInfo(key);
} }
} }
}
/** /**
* Загружает с сервера список категорий точек. * Загружает с сервера список категорий точек.

View File

@ -136,7 +136,7 @@ if (App::$user) {
<?php endif; ?> <?php endif; ?>
</div> </div>
<?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?> <?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?>
<?= $user ? self::renderPartial('modals/addPoint.php', array('categories' => $categories), true) : '' ?> <?= $user ? self::renderPartial('modals/addPoint.php', array('categories' => Category::model()->getCategoriesForChoise()), true) : '' ?>
<?= self::renderPartial('modals/categories.php', array('categories' => $categories), true) ?> <?= self::renderPartial('modals/categories.php', array('categories' => $categories), true) ?>
<?= self::renderPartial('modals/image.php', array(), true) ?> <?= self::renderPartial('modals/image.php', array(), true) ?>
<map name="vkbutton"> <map name="vkbutton">

View File

@ -42,7 +42,7 @@
<label class="control-label" for="categoryId">Тип</label> <label class="control-label" for="categoryId">Тип</label>
<select id="addPointCategoryId" name="categoryId" class="form-control"> <select id="addPointCategoryId" name="categoryId" class="form-control">
<?php foreach ($categories as $category): ?> <?php foreach ($categories as $category): ?>
<option value="<?= $category->id ?>"><?= $category->name ?></option> <option value="<?= $category['id'] ?>"><?= $category['name'] ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>