[-] BO : #PSCFI-4484 - Add historisation of the order status

This commit is contained in:
mDeflotte
2012-01-03 16:06:18 +00:00
parent 06d9e22156
commit c53e1fcfec
5 changed files with 53 additions and 44 deletions
+4
View File
@@ -58,6 +58,9 @@ class OrderStateCore extends ObjectModel
/** @var boolean Paid */ /** @var boolean Paid */
public $paid; public $paid;
/** @var boolean True if carrier has been deleted (staying in database as deleted) */
public $deleted = 0;
/** /**
* @see ObjectModel::$definition * @see ObjectModel::$definition
@@ -76,6 +79,7 @@ class OrderStateCore extends ObjectModel
'delivery' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'delivery' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'hidden' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'hidden' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'paid' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'paid' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'deleted' => array('type' => self::TYPE_BOOL, 'validade' => 'isBool'),
// Lang fields // Lang fields
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 64),
+45 -44
View File
@@ -29,10 +29,10 @@ class AdminStatusesControllerCore extends AdminController
{ {
public function __construct() public function __construct()
{ {
$this->table = 'order_state'; $this->table = 'order_state';
$this->className = 'OrderState'; $this->className = 'OrderState';
$this->lang = true; $this->lang = true;
$this->deleted = false; $this->deleted = true;
$this->colorOnBackground = false; $this->colorOnBackground = false;
$this->context = Context::getContext(); $this->context = Context::getContext();
$this->imageType = 'gif'; $this->imageType = 'gif';
@@ -96,7 +96,7 @@ class AdminStatusesControllerCore extends AdminController
) )
); );
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
parent::__construct(); parent::__construct();
} }
@@ -106,23 +106,23 @@ class AdminStatusesControllerCore extends AdminController
$this->addRowAction('edit'); $this->addRowAction('edit');
$this->addRowAction('delete'); $this->addRowAction('delete');
$list_orders_status = parent::renderList(); $list_orders_status = parent::renderList();
// Added new list // Added new list
// reset actions and query vars // reset actions and query vars
$this->actions = array(); $this->actions = array();
unset($this->fieldsDisplay, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter, $this->identifier); unset($this->fieldsDisplay, $this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter, $this->identifier);
$this->table = 'order_return_state'; $this->table = 'order_return_state';
$this->_defaultOrderBy = $this->identifier = 'id_order_return_state'; $this->_defaultOrderBy = $this->identifier = 'id_order_return_state';
$this->deleted = false; $this->deleted = false;
$this->toolbar_btn = array(); $this->toolbar_btn = array();
$this->bulk_actions = array(); $this->bulk_actions = array();
$this->addRowAction('editstatus'); $this->addRowAction('editstatus');
// test if a filter is applied for this list // test if a filter is applied for this list
if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false) if (Tools::isSubmit('submitFilter'.$this->table) || $this->context->cookie->{'submitFilter'.$this->table} !== false)
$this->filter = true; $this->filter = true;
@@ -155,7 +155,7 @@ class AdminStatusesControllerCore extends AdminController
return $list_orders_status.$list_orders_returns_status; return $list_orders_status.$list_orders_returns_status;
} }
/** /**
* Display editaddresses action link * Display editaddresses action link
* @param string $token the token to add to the link * @param string $token the token to add to the link
* @param int $id the identifier to add to the link * @param int $id the identifier to add to the link
@@ -163,17 +163,17 @@ class AdminStatusesControllerCore extends AdminController
*/ */
public function displayEditaddressesLink($token = null, $id) public function displayEditaddressesLink($token = null, $id)
{ {
if (!array_key_exists('editaddresses', self::$cache_lang)) if (!array_key_exists('editaddresses', self::$cache_lang))
self::$cache_lang['editaddresses'] = $this->l('Edit Adresses'); self::$cache_lang['editaddresses'] = $this->l('Edit Adresses');
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'href' => self::$currentIndex. 'href' => self::$currentIndex.
'&'.$this->identifier.'='.$id. '&'.$this->identifier.'='.$id.
'&editaddresses&token='.($token != null ? $token : $this->token), '&editaddresses&token='.($token != null ? $token : $this->token),
'action' => self::$cache_lang['editaddresses'], 'action' => self::$cache_lang['editaddresses'],
)); ));
return $this->context->smarty->fetch('manufacturers/list_action_edit_adresses.tpl'); return $this->context->smarty->fetch('manufacturers/list_action_edit_adresses.tpl');
} }
public function renderForm() public function renderForm()
@@ -337,7 +337,7 @@ class AdminStatusesControllerCore extends AdminController
{ {
$id_order_return_state = Tools::getValue('id_order_return_state'); $id_order_return_state = Tools::getValue('id_order_return_state');
// Create Object OrderReturnState // Create Object OrderReturnState
$order_return_state = new OrderReturnState($id_order_return_state); $order_return_state = new OrderReturnState($id_order_return_state);
$this->fields_form[0]['form'] = array( $this->fields_form[0]['form'] = array(
@@ -458,7 +458,7 @@ class AdminStatusesControllerCore extends AdminController
return parent::initContent(); return parent::initContent();
} }
/** /**
* Display editaddresses action link * Display editaddresses action link
* @param string $token the token to add to the link * @param string $token the token to add to the link
* @param int $id the identifier to add to the link * @param int $id the identifier to add to the link
@@ -466,17 +466,17 @@ class AdminStatusesControllerCore extends AdminController
*/ */
public function displayEditstatusLink($token = null, $id) public function displayEditstatusLink($token = null, $id)
{ {
if (!array_key_exists('editstatus', self::$cache_lang)) if (!array_key_exists('editstatus', self::$cache_lang))
self::$cache_lang['editstatus'] = $this->l('Edit Status'); self::$cache_lang['editstatus'] = $this->l('Edit Status');
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'href' => self::$currentIndex. 'href' => self::$currentIndex.
'&'.$this->identifier.'='.$id. '&'.$this->identifier.'='.$id.
'&editstatus&token='.($token != null ? $token : $this->token), '&editstatus&token='.($token != null ? $token : $this->token),
'action' => self::$cache_lang['editstatus'], 'action' => self::$cache_lang['editstatus'],
)); ));
return $this->context->smarty->fetch('helper/list/list_action_edit.tpl'); return $this->context->smarty->fetch('helper/list/list_action_edit.tpl');
} }
public function postProcess() public function postProcess()
@@ -485,7 +485,7 @@ class AdminStatusesControllerCore extends AdminController
{ {
$id_order_return_state = (int)Tools::getValue('id_order_return_state'); $id_order_return_state = (int)Tools::getValue('id_order_return_state');
// Create Object OrderReturnState // Create Object OrderReturnState
$order_return_state = new OrderReturnState($id_order_return_state); $order_return_state = new OrderReturnState($id_order_return_state);
$order_return_state->name = array(); $order_return_state->name = array();
@@ -502,6 +502,7 @@ class AdminStatusesControllerCore extends AdminController
if (Tools::isSubmit('submitAdd'.$this->table)) if (Tools::isSubmit('submitAdd'.$this->table))
{ {
$this->deleted = false; // Disabling saving historisation
$_POST['invoice'] = (int)Tools::getValue('invoice_on'); $_POST['invoice'] = (int)Tools::getValue('invoice_on');
$_POST['logable'] = (int)Tools::getValue('logable_on'); $_POST['logable'] = (int)Tools::getValue('logable_on');
$_POST['send_email'] = (int)Tools::getValue('send_email_on'); $_POST['send_email'] = (int)Tools::getValue('send_email_on');
@@ -519,23 +520,23 @@ class AdminStatusesControllerCore extends AdminController
} }
else if (isset($_GET['delete'.$this->table])) else if (isset($_GET['delete'.$this->table]))
{ {
$order_state = new OrderState($_GET['id_order_state'], $this->context->language->id); $order_state = new OrderState($_GET['id_order_state'], $this->context->language->id);
if (!$order_state->isRemovable()) if (!$order_state->isRemovable())
$this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.'); $this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.');
else else
return parent::postProcess(); return parent::postProcess();
} }
else if (isset($_POST['submitDelorder_state'])) else if (isset($_POST['submitDelorder_state']))
{ {
foreach ($_POST[$this->table.'Box'] as $selection) foreach ($_POST[$this->table.'Box'] as $selection)
{ {
$order_state = new OrderState($selection, $this->context->language->id); $order_state = new OrderState($selection, $this->context->language->id);
if (!$order_state->isRemovable()) if (!$order_state->isRemovable())
{ {
$this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.'); $this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.');
break; break;
} }
} }
if (empty($this->_errors)) if (empty($this->_errors))
return parent::postProcess(); return parent::postProcess();
} }
+1
View File
@@ -1252,6 +1252,7 @@ CREATE TABLE `PREFIX_order_state` (
`delivery` tinyint(1) UNSIGNED NOT NULL default '0', `delivery` tinyint(1) UNSIGNED NOT NULL default '0',
`shipped` tinyint(1) UNSIGNED NOT NULL default '0', `shipped` tinyint(1) UNSIGNED NOT NULL default '0',
`paid` tinyint(1) UNSIGNED NOT NULL default '0', `paid` tinyint(1) UNSIGNED NOT NULL default '0',
`deleted` tinyint(1) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`id_order_state`) PRIMARY KEY (`id_order_state`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+2
View File
@@ -1,2 +1,4 @@
SET NAMES 'utf8'; SET NAMES 'utf8';
ALTER TABLE `PREFIX_order_state` ADD COLUMN `deleted` tinyint(1) UNSIGNED NOT NULL default '0' AFTER `paid`;
+1
View File
@@ -1252,6 +1252,7 @@ CREATE TABLE `PREFIX_order_state` (
`delivery` tinyint(1) UNSIGNED NOT NULL default '0', `delivery` tinyint(1) UNSIGNED NOT NULL default '0',
`shipped` tinyint(1) UNSIGNED NOT NULL default '0', `shipped` tinyint(1) UNSIGNED NOT NULL default '0',
`paid` tinyint(1) UNSIGNED NOT NULL default '0', `paid` tinyint(1) UNSIGNED NOT NULL default '0',
`deleted` tinyint(1) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`id_order_state`) PRIMARY KEY (`id_order_state`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;