if (!$this->user->hasPermission('modify', 'localisation/zone')) {
$this->error['warning'] = $this->language->get('error_permission');
}
$this->load->model('setting/store');
$this->load->model('sale/customer');
$this->load->model('sale/affiliate');
$this->load->model('localisation/geo_zone');
foreach ($this->request->post['selected'] as $zone_id) {
if ($this->config->get('config_zone_id') == $zone_id) {
$this->error['warning'] = $this->language->get('error_default');
}
$store_total = $this->model_setting_store->getTotalStoresByZoneId($zone_id);
if ($store_total) {
$this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
}
$address_total = $this->model_sale_customer->getTotalAddressesByZoneId($zone_id);
if ($address_total) {
$this->error['warning'] = sprintf($this->language->get('error_address'), $address_total);
}
$affiliate_total = $this->model_sale_affiliate->getTotalAffiliatesByZoneId($zone_id);
if ($affiliate_total) {
$this->error['warning'] = sprintf($this->language->get('error_affiliate'), $affiliate_total);
}
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByZoneId($zone_id);
if ($zone_to_geo_zone_total) {
$this->error['warning'] = sprintf($this->language->get('error_zone_to_geo_zone'), $zone_to_geo_zone_total);
}
}
if (!$this->error) {
return true;
} else {
return false;
}