[*] BO : you can now affect a zone to multiple countries and to multiple states

This commit is contained in:
vChabot
2011-12-02 15:41:05 +00:00
parent 1e1eec8f8d
commit 375ca90e6e
10 changed files with 303 additions and 9 deletions
+25
View File
@@ -263,6 +263,7 @@ class AdminControllerCore extends Controller
25 => $this->l('Images successfully moved'),
26 => $this->l('Cover selection saved'),
27 => $this->l('Image shop association modified'),
28 => $this->l('Zone affected to the selection successfully'),
);
if (!$this->identifier) $this->identifier = 'id_'.$this->table;
if (!$this->_defaultOrderBy) $this->_defaultOrderBy = $this->identifier;
@@ -324,6 +325,7 @@ class AdminControllerCore extends Controller
/**
* Check rights to view the current tab
*
* @param bool $disable
* @return boolean
*/
public function viewAccess($disable = false)
@@ -1808,6 +1810,12 @@ class AdminControllerCore extends Controller
$this->boxes = Tools::getValue($this->table.'Box');
break;
}
else if(Tools::isSubmit('submitBulk'))
{
$this->action = 'bulk'.Tools::getValue('select_submitBulk');
$this->boxes = Tools::getValue($this->table.'Box');
break;
}
}
else if (!empty($this->options) && empty($this->fieldsDisplay))
$this->display = 'options';
@@ -2524,6 +2532,23 @@ EOF;
return $result;
}
protected function processBulkaffectzone($token)
{
if (is_array($this->boxes) && !empty($this->boxes))
{
$object = new $this->className();
$result = $object->affectZoneToSelection(Tools::getValue($this->table.'Box'), Tools::getValue('zone_to_affect'));
if ($result)
$this->redirect_after = self::$currentIndex.'&conf=28&token='.$token;
$this->_errors[] = Tools::displayError('An error occurred while affecting a zone to the selection.');
}
else
$this->_errors[] = Tools::displayError('You must select at least one element to affect a new zone.');
return $result;
}
/**
* @TODO delete method after AdminProducts cleanup
* Display flags in forms for translations
+14
View File
@@ -336,4 +336,18 @@ class CountryCore extends ObjectModel
FROM `'._DB_PREFIX_.'country`
WHERE `id_country` = '.(int)$id_country);
}
/**
* @param $ids_countries
* @param $id_zone
* @return bool
*/
public function affectZoneToSelection($ids_countries, $id_zone)
{
// cast every array values to int (security)
$ids_countries = array_map('intval', $ids_countries);
return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'country` SET `id_zone` = '.(int)$id_zone.' WHERE `id_country` IN ('.implode(',', $ids_countries).')
');
}
}
+1
View File
@@ -591,6 +591,7 @@ class HelperListCore extends Helper
'shop_link_type' => $this->shopLinkType,
'has_actions' => !empty($this->actions),
'has_bulk_actions' => !empty($this->bulk_actions),
'bulk_actions' => $this->bulk_actions,
'table_id' => isset($table_id) ? $table_id : null,
'table_dnd' => isset($table_dnd) ? $table_dnd : null,
'name' => isset($name) ? $name : null,
+14
View File
@@ -200,5 +200,19 @@ class StateCore extends ObjectModel
FROM `'._DB_PREFIX_.'state`
WHERE `id_state` = '.(int)($id_state));
}
/**
* @param $ids_states
* @param $id_zone
* @return bool
*/
public function affectZoneToSelection($ids_states, $id_zone)
{
// cast every array values to int (security)
$ids_states = array_map('intval', $ids_states);
return Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'state` SET `id_zone` = '.(int)$id_zone.' WHERE `id_state` IN ('.implode(',', $ids_states).')
');
}
}