summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-01-08 21:08:33 -0500
committerFrederic Guillot <fred@kanboard.net>2017-01-08 21:08:33 -0500
commit47f4bceb1aea51bda9211a16d635b7a0f9664976 (patch)
tree3203b087f33498b91da6d89338772798263c16d7 /app/Controller
parent1078cac70d079ee0917b1a540a9f0633661ec303 (diff)
Improve currencies pages navigation
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/CurrencyController.php55
1 files changed, 44 insertions, 11 deletions
diff --git a/app/Controller/CurrencyController.php b/app/Controller/CurrencyController.php
index ad590035..2b2275ac 100644
--- a/app/Controller/CurrencyController.php
+++ b/app/Controller/CurrencyController.php
@@ -11,21 +11,33 @@ namespace Kanboard\Controller;
class CurrencyController extends BaseController
{
/**
- * Display all currency rates and form
+ * Display all currency rates
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $this->response->html($this->helper->layout->config('currency/show', array(
+ 'application_currency' => $this->configModel->get('application_currency'),
+ 'rates' => $this->currencyModel->getAll(),
+ 'currencies' => $this->currencyModel->getCurrencies(),
+ 'title' => t('Settings').' &gt; '.t('Currency rates'),
+ )));
+ }
+
+ /**
+ * Add or change currency rate
*
* @access public
* @param array $values
* @param array $errors
*/
- public function index(array $values = array(), array $errors = array())
+ public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->helper->layout->config('currency/index', array(
- 'config_values' => array('application_currency' => $this->configModel->get('application_currency')),
+ $this->response->html($this->helper->layout->config('currency/create', array(
'values' => $values,
'errors' => $errors,
- 'rates' => $this->currencyModel->getAll(),
'currencies' => $this->currencyModel->getCurrencies(),
- 'title' => t('Settings').' &gt; '.t('Currency rates'),
)));
}
@@ -34,7 +46,7 @@ class CurrencyController extends BaseController
*
* @access public
*/
- public function create()
+ public function save()
{
$values = $this->request->getValues();
list($valid, $errors) = $this->currencyValidator->validateCreation($values);
@@ -42,13 +54,34 @@ class CurrencyController extends BaseController
if ($valid) {
if ($this->currencyModel->create($values['currency'], $values['rate'])) {
$this->flash->success(t('The currency rate have been added successfully.'));
- return $this->response->redirect($this->helper->url->to('CurrencyController', 'index'));
+ $this->response->redirect($this->helper->url->to('CurrencyController', 'show'), true);
+ return;
} else {
$this->flash->failure(t('Unable to add this currency rate.'));
}
}
- return $this->index($values, $errors);
+ $this->create($values, $errors);
+ }
+
+ /**
+ * Change reference currency
+ *
+ * @access public
+ * @param array $values
+ * @param array $errors
+ */
+ public function change(array $values = array(), array $errors = array())
+ {
+ if (empty($values)) {
+ $values['application_currency'] = $this->configModel->get('application_currency');
+ }
+
+ $this->response->html($this->helper->layout->config('currency/change', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'currencies' => $this->currencyModel->getCurrencies(),
+ )));
}
/**
@@ -56,7 +89,7 @@ class CurrencyController extends BaseController
*
* @access public
*/
- public function reference()
+ public function update()
{
$values = $this->request->getValues();
@@ -66,6 +99,6 @@ class CurrencyController extends BaseController
$this->flash->failure(t('Unable to save your settings.'));
}
- $this->response->redirect($this->helper->url->to('CurrencyController', 'index'));
+ $this->response->redirect($this->helper->url->to('CurrencyController', 'show'), true);
}
}