summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-13 16:56:51 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-13 16:56:51 -0400
commit4b6672d0b33563ab8888d592ef86616ca9238007 (patch)
tree0ba5c0b2244f08ddac55169161271ca2a25ce005 /app/Controller
parentd400f7c5be4b3f7371dce73510e5fd4a54375025 (diff)
Move budget outside of the core
The budget planning feature is now a plugin See: https://github.com/kanboard/plugin-budget
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Budget.php135
-rw-r--r--app/Controller/Hourlyrate.php89
2 files changed, 0 insertions, 224 deletions
diff --git a/app/Controller/Budget.php b/app/Controller/Budget.php
deleted file mode 100644
index a2f7e0db..00000000
--- a/app/Controller/Budget.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-namespace Controller;
-
-/**
- * Budget
- *
- * @package controller
- * @author Frederic Guillot
- */
-class Budget extends Base
-{
- /**
- * Budget index page
- *
- * @access public
- */
- public function index()
- {
- $project = $this->getProject();
-
- $this->response->html($this->projectLayout('budget/index', array(
- 'daily_budget' => $this->budget->getDailyBudgetBreakdown($project['id']),
- 'project' => $project,
- 'title' => t('Budget')
- ), 'budget/sidebar'));
- }
-
- /**
- * Cost breakdown by users/subtasks/tasks
- *
- * @access public
- */
- public function breakdown()
- {
- $project = $this->getProject();
-
- $paginator = $this->paginator
- ->setUrl('budget', 'breakdown', array('project_id' => $project['id']))
- ->setMax(30)
- ->setOrder('start')
- ->setDirection('DESC')
- ->setQuery($this->budget->getSubtaskBreakdown($project['id']))
- ->calculate();
-
- $this->response->html($this->projectLayout('budget/breakdown', array(
- 'paginator' => $paginator,
- 'project' => $project,
- 'title' => t('Budget')
- ), 'budget/sidebar'));
- }
-
- /**
- * Create budget lines
- *
- * @access public
- */
- public function create(array $values = array(), array $errors = array())
- {
- $project = $this->getProject();
-
- if (empty($values)) {
- $values['date'] = date('Y-m-d');
- }
-
- $this->response->html($this->projectLayout('budget/create', array(
- 'lines' => $this->budget->getAll($project['id']),
- 'values' => $values + array('project_id' => $project['id']),
- 'errors' => $errors,
- 'project' => $project,
- 'title' => t('Budget lines')
- ), 'budget/sidebar'));
- }
-
- /**
- * Validate and save a new budget
- *
- * @access public
- */
- public function save()
- {
- $project = $this->getProject();
-
- $values = $this->request->getValues();
- list($valid, $errors) = $this->budget->validateCreation($values);
-
- if ($valid) {
-
- if ($this->budget->create($values['project_id'], $values['amount'], $values['comment'], $values['date'])) {
- $this->session->flash(t('The budget line have been created successfully.'));
- $this->response->redirect($this->helper->url->to('budget', 'create', array('project_id' => $project['id'])));
- }
- else {
- $this->session->flashError(t('Unable to create the budget line.'));
- }
- }
-
- $this->create($values, $errors);
- }
-
- /**
- * Confirmation dialog before removing a budget
- *
- * @access public
- */
- public function confirm()
- {
- $project = $this->getProject();
-
- $this->response->html($this->projectLayout('budget/remove', array(
- 'project' => $project,
- 'budget_id' => $this->request->getIntegerParam('budget_id'),
- 'title' => t('Remove a budget line'),
- ), 'budget/sidebar'));
- }
-
- /**
- * Remove a budget
- *
- * @access public
- */
- public function remove()
- {
- $this->checkCSRFParam();
- $project = $this->getProject();
-
- if ($this->budget->remove($this->request->getIntegerParam('budget_id'))) {
- $this->session->flash(t('Budget line removed successfully.'));
- } else {
- $this->session->flashError(t('Unable to remove this budget line.'));
- }
-
- $this->response->redirect($this->helper->url->to('budget', 'create', array('project_id' => $project['id'])));
- }
-}
diff --git a/app/Controller/Hourlyrate.php b/app/Controller/Hourlyrate.php
deleted file mode 100644
index 19650ede..00000000
--- a/app/Controller/Hourlyrate.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-namespace Controller;
-
-/**
- * Hourly Rate controller
- *
- * @package controller
- * @author Frederic Guillot
- */
-class Hourlyrate extends User
-{
- /**
- * Display rate and form
- *
- * @access public
- */
- public function index(array $values = array(), array $errors = array())
- {
- $user = $this->getUser();
-
- $this->response->html($this->layout('hourlyrate/index', array(
- 'rates' => $this->hourlyRate->getAllByUser($user['id']),
- 'currencies_list' => $this->config->getCurrencies(),
- 'values' => $values + array('user_id' => $user['id']),
- 'errors' => $errors,
- 'user' => $user,
- )));
- }
-
- /**
- * Validate and save a new rate
- *
- * @access public
- */
- public function save()
- {
- $values = $this->request->getValues();
- list($valid, $errors) = $this->hourlyRate->validateCreation($values);
-
- if ($valid) {
-
- if ($this->hourlyRate->create($values['user_id'], $values['rate'], $values['currency'], $values['date_effective'])) {
- $this->session->flash(t('Hourly rate created successfully.'));
- $this->response->redirect($this->helper->url->to('hourlyrate', 'index', array('user_id' => $values['user_id'])));
- }
- else {
- $this->session->flashError(t('Unable to save the hourly rate.'));
- }
- }
-
- $this->index($values, $errors);
- }
-
- /**
- * Confirmation dialag box to remove a row
- *
- * @access public
- */
- public function confirm()
- {
- $user = $this->getUser();
-
- $this->response->html($this->layout('hourlyrate/remove', array(
- 'rate_id' => $this->request->getIntegerParam('rate_id'),
- 'user' => $user,
- )));
- }
-
- /**
- * Remove a row
- *
- * @access public
- */
- public function remove()
- {
- $this->checkCSRFParam();
- $user = $this->getUser();
-
- if ($this->hourlyRate->remove($this->request->getIntegerParam('rate_id'))) {
- $this->session->flash(t('Rate removed successfully.'));
- }
- else {
- $this->session->flash(t('Unable to remove this rate.'));
- }
-
- $this->response->redirect($this->helper->url->to('hourlyrate', 'index', array('user_id' => $user['id'])));
- }
-}