Система регионов
This commit is contained in:
@@ -177,6 +177,7 @@ class ControllerLocalisationZone extends Controller {
|
||||
'country' => $result['country'],
|
||||
'name' => $result['name'] . (($result['zone_id'] == $this->config->get('config_zone_id')) ? $this->language->get('text_default') : null),
|
||||
'code' => $result['code'],
|
||||
'slug' => $result['slug'],
|
||||
'edit' => $this->url->link('localisation/zone/edit', 'user_token=' . $this->session->data['user_token'] . '&zone_id=' . $result['zone_id'] . $url, true)
|
||||
);
|
||||
}
|
||||
@@ -216,6 +217,7 @@ class ControllerLocalisationZone extends Controller {
|
||||
$data['sort_country'] = $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . '&sort=c.name' . $url, true);
|
||||
$data['sort_name'] = $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . '&sort=z.name' . $url, true);
|
||||
$data['sort_code'] = $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . '&sort=z.code' . $url, true);
|
||||
$data['sort_slug'] = $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . '&sort=z.slug' . $url, true);
|
||||
|
||||
$url = '';
|
||||
|
||||
@@ -262,6 +264,12 @@ class ControllerLocalisationZone extends Controller {
|
||||
$data['error_name'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->error['slug'])) {
|
||||
$data['error_slug'] = $this->error['slug'];
|
||||
} else {
|
||||
$data['error_slug'] = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
@@ -324,6 +332,14 @@ class ControllerLocalisationZone extends Controller {
|
||||
$data['code'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['slug'])) {
|
||||
$data['slug'] = $this->request->post['slug'];
|
||||
} elseif (!empty($zone_info)) {
|
||||
$data['slug'] = $zone_info['slug'];
|
||||
} else {
|
||||
$data['slug'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['country_id'])) {
|
||||
$data['country_id'] = $this->request->post['country_id'];
|
||||
} elseif (!empty($zone_info)) {
|
||||
@@ -352,6 +368,16 @@ class ControllerLocalisationZone extends Controller {
|
||||
$this->error['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
$this->request->post['slug'] = strtolower(trim((string)$this->request->post['slug']));
|
||||
|
||||
$is_default = isset($this->request->get['zone_id']) && ((int)$this->request->get['zone_id'] == (int)$this->config->get('config_zone_id'));
|
||||
|
||||
if ((!$is_default && $this->request->post['slug'] === '') || ($this->request->post['slug'] !== '' && !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $this->request->post['slug']))) {
|
||||
$this->error['slug'] = $this->language->get('error_slug');
|
||||
} elseif ($this->request->post['slug'] !== '' && $this->model_localisation_zone->getTotalZonesBySlug($this->request->post['slug'], isset($this->request->get['zone_id']) ? $this->request->get['zone_id'] : 0)) {
|
||||
$this->error['slug'] = $this->language->get('error_slug_exists');
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
@@ -390,4 +416,4 @@ class ControllerLocalisationZone extends Controller {
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,6 +608,14 @@ class ControllerSettingStore extends Controller {
|
||||
$data['config_logo'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['config_logo_text'])) {
|
||||
$data['config_logo_text'] = $this->request->post['config_logo_text'];
|
||||
} elseif (isset($store_info['config_logo_text'])) {
|
||||
$data['config_logo_text'] = $store_info['config_logo_text'];
|
||||
} else {
|
||||
$data['config_logo_text'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->post['config_logo']) && is_file(DIR_IMAGE . $this->request->post['config_logo'])) {
|
||||
$data['logo'] = $this->model_tool_image->resize($this->request->post['config_logo'], 100, 100);
|
||||
} elseif (isset($store_info['config_logo']) && is_file(DIR_IMAGE . $store_info['config_logo'])) {
|
||||
|
||||
@@ -14,20 +14,24 @@ $_['text_edit'] = 'Редактирование';
|
||||
// Column
|
||||
$_['column_name'] = 'Название региона';
|
||||
$_['column_code'] = 'Код региона';
|
||||
$_['column_slug'] = 'Slug';
|
||||
$_['column_country'] = 'Страна';
|
||||
$_['column_action'] = 'Действие';
|
||||
|
||||
// Entry
|
||||
$_['entry_name'] = 'Название региона';
|
||||
$_['entry_code'] = 'Код региона';
|
||||
$_['entry_slug'] = 'Slug для URL';
|
||||
$_['entry_country'] = 'Страна';
|
||||
$_['entry_status'] = 'Статус';
|
||||
|
||||
// Error
|
||||
$_['error_permission'] = 'У вас недостаточно прав для внесения изменений!';
|
||||
$_['error_name'] = 'Название должно содержать от 3 до 128 символов!';
|
||||
$_['error_slug'] = 'Slug обязателен для всех регионов, кроме региона по умолчанию, и может содержать только строчные латинские буквы, цифры и дефисы!';
|
||||
$_['error_slug_exists'] = 'Такой slug уже используется другим регионом!';
|
||||
$_['error_default'] = 'Этот Регион нельзя удалить, поскольку он используется по умолчанию!';
|
||||
$_['error_store'] = 'Этот Регион нельзя удалить, поскольку он используется в %s магазинах!';
|
||||
$_['error_address'] = 'Этот Регион нельзя удалить, поскольку он используется в %s адресах!';
|
||||
$_['error_affiliate'] = 'Этот Регион нельзя удалить, поскольку он используется в %s партнёрах!';
|
||||
$_['error_zone_to_geo_zone'] = 'Этот Регион нельзя удалить, поскольку он используется в %s географических зонах!';
|
||||
$_['error_zone_to_geo_zone'] = 'Этот Регион нельзя удалить, поскольку он используется в %s географических зонах!';
|
||||
|
||||
@@ -63,6 +63,7 @@ $_['entry_order_status'] = 'Статус заказа';
|
||||
$_['entry_stock_display'] = 'Показывать остаток на складе';
|
||||
$_['entry_stock_checkout'] = 'Заказ при нехватке на складе';
|
||||
$_['entry_logo'] = 'Логотип';
|
||||
$_['entry_logo_text'] = 'Текстовый логотип';
|
||||
$_['entry_icon'] = 'Иконка';
|
||||
$_['entry_image_category'] = 'Размер изображений категории';
|
||||
$_['entry_image_thumb'] = 'Размер большого изображения товара';
|
||||
@@ -125,4 +126,4 @@ $_['error_image_wishlist'] = 'Необходимо установи
|
||||
$_['error_image_cart'] = 'Необходимо установить размер изображений товаров в корзине!';
|
||||
$_['error_image_location'] = 'Необходимо установить размер изображения магазина!';
|
||||
$_['error_default'] = 'Нельзя удалить основной магазин!';
|
||||
$_['error_store'] = 'Этот магазин нельзя удалить, поскольку он назначен к %s заказам!';
|
||||
$_['error_store'] = 'Этот магазин нельзя удалить, поскольку он назначен к %s заказам!';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
class ModelLocalisationZone extends Model {
|
||||
public function addZone($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
|
||||
@@ -9,7 +9,7 @@ class ModelLocalisationZone extends Model {
|
||||
}
|
||||
|
||||
public function editZone($zone_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
}
|
||||
@@ -32,7 +32,8 @@ class ModelLocalisationZone extends Model {
|
||||
$sort_data = array(
|
||||
'c.name',
|
||||
'z.name',
|
||||
'z.code'
|
||||
'z.code',
|
||||
'z.slug'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
@@ -89,4 +90,10 @@ class ModelLocalisationZone extends Model {
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalZonesBySlug($slug, $zone_id = 0) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone WHERE slug = '" . $this->db->escape($slug) . "' AND zone_id != '" . (int)$zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,15 @@
|
||||
<input type="text" name="code" value="{{ code }}" placeholder="{{ entry_code }}" id="input-code" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group required">
|
||||
<label class="col-sm-2 control-label" for="input-slug">{{ entry_slug }}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="slug" value="{{ slug }}" placeholder="{{ entry_slug }}" id="input-slug" class="form-control" />
|
||||
{% if error_slug %}
|
||||
<div class="text-danger">{{ error_slug }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="input-country">{{ entry_country }}</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -73,4 +82,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ footer }}
|
||||
{{ footer }}
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
{% else %}
|
||||
<a href="{{ sort_code }}">{{ column_code }}</a>
|
||||
{% endif %}</td>
|
||||
<td class="text-left">{% if sort == 'z.slug' %}
|
||||
<a href="{{ sort_slug }}" class="{{ order|lower }}">{{ column_slug }}</a>
|
||||
{% else %}
|
||||
<a href="{{ sort_slug }}">{{ column_slug }}</a>
|
||||
{% endif %}</td>
|
||||
<td class="text-right">{{ column_action }}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -65,12 +70,13 @@
|
||||
<td class="text-left">{{ zone.country }}</td>
|
||||
<td class="text-left">{{ zone.name }}</td>
|
||||
<td class="text-left">{{ zone.code }}</td>
|
||||
<td class="text-left">{{ zone.slug }}</td>
|
||||
<td class="text-right"><a href="{{ zone.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td class="text-center" colspan="5">{{ text_no_results }}</td>
|
||||
<td class="text-center" colspan="6">{{ text_no_results }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
@@ -85,4 +91,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ footer }}
|
||||
{{ footer }}
|
||||
|
||||
Reference in New Issue
Block a user