summaryrefslogtreecommitdiff
path: root/app/Controller/CurrencyController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controller/CurrencyController.php')
-rw-r--r--app/Controller/CurrencyController.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/app/Controller/CurrencyController.php b/app/Controller/CurrencyController.php
new file mode 100644
index 00000000..5a0fac37
--- /dev/null
+++ b/app/Controller/CurrencyController.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Currency Controller
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class CurrencyController extends BaseController
+{
+ /**
+ * Display all currency rates and form
+ *
+ * @access public
+ * @param array $values
+ * @param array $errors
+ */
+ public function index(array $values = array(), array $errors = array())
+ {
+ $this->response->html($this->helper->layout->config('currency/index', array(
+ 'config_values' => array('application_currency' => $this->config->get('application_currency')),
+ 'values' => $values,
+ 'errors' => $errors,
+ 'rates' => $this->currency->getAll(),
+ 'currencies' => $this->currency->getCurrencies(),
+ 'title' => t('Settings').' &gt; '.t('Currency rates'),
+ )));
+ }
+
+ /**
+ * Validate and save a new currency rate
+ *
+ * @access public
+ */
+ public function create()
+ {
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->currencyValidator->validateCreation($values);
+
+ if ($valid) {
+ if ($this->currency->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'));
+ } else {
+ $this->flash->failure(t('Unable to add this currency rate.'));
+ }
+ }
+
+ return $this->index($values, $errors);
+ }
+
+ /**
+ * Save reference currency
+ *
+ * @access public
+ */
+ public function reference()
+ {
+ $values = $this->request->getValues();
+
+ if ($this->config->save($values)) {
+ $this->flash->success(t('Settings saved successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to save your settings.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('CurrencyController', 'index'));
+ }
+}