public function execute() { $id = waRequest::post('id', null, waRequest::TYPE_STRING_TRIM); if (!$id) { $this->errors[] = _w("Unknown state"); return; } $before_id = waRequest::post('before_id', null, waRequest::TYPE_STRING_TRIM); $config = shopWorkflow::getConfig(); $item = $config['states'][$id]; if (!isset($config['states'][$id])) { $this->errors[] = _w("Unknown state"); return; } unset($config['states'][$id]); if (!$before_id) { $config['states'][$id] = $item; } else { if (!isset($config['states'][$before_id])) { $this->errors[] = _w("Unknown state"); return; } $states = array(); foreach ($config['states'] as $state_id => $state) { if ($state_id == $before_id) { $states[$id] = $item; } $states[$state_id] = $state; } $config['states'] = $states; } if (!shopWorkflow::setConfig($config)) { $this->errors[] = _w("Error when save config"); } }
public function save($data) { $id = $data['state']['id']; unset($data['state']['id']); $this->config['states'] = !empty($this->config['states']) ? $this->config['states'] : array(); $this->config['states'][$id] = $data['state']; $this->config['actions'] = !empty($this->config['actions']) ? $this->config['actions'] + $data['actions'] : $data['actions']; if (!shopWorkflow::setConfig($this->config)) { throw new waException(_w("Error when save config")); } }
public function execute() { $id = waRequest::post('id'); if (!$id) { $this->errors = _w("Unknown state"); return; } $order_model = new shopOrderModel(); if ($order_model->countByField('state_id', $id)) { $this->errors = _w("Cannot delete order status while there are active orders in this status"); return; } $config = shopWorkflow::getConfig(); if (isset($config['states'][$id])) { unset($config['states'][$id]); } shopWorkflow::setConfig($config); }