Skip to content
This repository has been archived by the owner on May 20, 2018. It is now read-only.

Commit

Permalink
Import from Kanboard core
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Sep 13, 2015
0 parents commit a694a09
Show file tree
Hide file tree
Showing 41 changed files with 1,687 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Asset/Javascript/BudgetChart.js
@@ -0,0 +1,54 @@
jQuery(document).ready(function() {
if (document.getElementById("budget-chart")) {
var categories = [];
var metrics = $("#chart").data("metrics");
var labels = $("#chart").data("labels");
var inputFormat = d3.time.format("%Y-%m-%d");
var outputFormat = d3.time.format($("#chart").data("date-format"));

var columns = [
[labels["in"]],
[labels["left"]],
[labels["out"]]
];

var colors = {};
colors[labels["in"]] = '#5858FA';
colors[labels["left"]] = '#04B404';
colors[labels["out"]] = '#DF3A01';

for (var i = 0; i < metrics.length; i++) {
categories.push(outputFormat(inputFormat.parse(metrics[i]["date"])));
columns[0].push(metrics[i]["in"]);
columns[1].push(metrics[i]["left"]);
columns[2].push(metrics[i]["out"]);
}

c3.generate({
data: {
columns: columns,
colors: colors,
type : 'bar'
},
bar: {
width: {
ratio: 0.25
}
},
grid: {
x: {
show: true
},
y: {
show: true
}
},
axis: {
x: {
type: 'category',
categories: categories
}
}
});
}
});
137 changes: 137 additions & 0 deletions Controller/Budget.php
@@ -0,0 +1,137 @@
<?php

namespace Plugin\Budget\Controller;

use Controller\Base;

/**
* 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:budget/index', array(
'daily_budget' => $this->budget->getDailyBudgetBreakdown($project['id']),
'project' => $project,
'title' => t('Budget')
), '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:budget/breakdown', array(
'paginator' => $paginator,
'project' => $project,
'title' => t('Budget')
), '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: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: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('plugin' => 'budget', '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:budget/remove', array(
'project' => $project,
'budget_id' => $this->request->getIntegerParam('budget_id'),
'title' => t('Remove a budget line'),
), 'budget: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('plugin' => 'budget', 'project_id' => $project['id'])));
}
}
91 changes: 91 additions & 0 deletions Controller/Hourlyrate.php
@@ -0,0 +1,91 @@
<?php

namespace Plugin\Budget\Controller;

use Controller\User;

/**
* 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('budget: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('plugin' => 'budget', '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('budget: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('plugin' => 'budget', 'user_id' => $user['id'])));
}
}
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014-2015 Frédéric Guillot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
33 changes: 33 additions & 0 deletions Locale/cs_CZ/translations.php
@@ -0,0 +1,33 @@
<?php

return array(
'Remove hourly rate' => 'Stundensatz entfernen',
'Do you really want to remove this hourly rate?' => 'Opravdu chcete odstranit tuto hodinovou sazbu?',
'Hourly rate' => 'Hodinová sazba',
'Effective date' => 'Datum účinnosti',
'Add new rate' => 'Přidat novou hodinovou sazbu',
'Rate removed successfully.' => 'Sazba byla úspěšně odstraněna',
'Unable to remove this rate.' => 'Sazbu nelze odstranit.',
'Unable to save the hourly rate.' => 'Hodinovou sazbu nelze uložit',
'Hourly rate created successfully.' => 'Hodinová sazba byla úspěšně vytvořena.',
'Amount' => 'Částka',
'Budget' => 'Rozpočet',
'Budget line' => 'Položka rozpočtu',
'Budget line removed successfully.' => 'Položka rozpočtu byla odstraněna',
'Budget lines' => 'Položky rozpočtu',
'Cost' => 'Cena',
'Cost breakdown' => 'Rozpis nákladů',
'Do you really want to remove this budget line?' => 'Opravdu chcete odstranit tuto rozpočtovou řádku?',
'Expenses' => 'Náklady',
'New budget line' => 'Nová položka rozpočtu',
'Remove a budget line' => 'Budgetlinie entfernen',
'Remove budget line' => 'Budgetlinie entfernen',
'The budget line have been created successfully.' => 'Položka rozpočtu byla úspěšně vytvořena.',
'Unable to create the budget line.' => 'Nelze vytvořit rozpočtovou řádku.',
'Unable to remove this budget line.' => 'Nelze vyjmout rozpočtovou řádku.',
'Remaining' => 'Zbývající',
'Currency rates are used to calculate project budget.' => 'Měnové sazby se používají k výpočtu rozpočtu projektu.',
'Burndown chart for "%s"' => 'Burndown-Chart für "%s"',
'Budget overview' => 'Budget Übersicht',
'Type' => 'Typ',
);
33 changes: 33 additions & 0 deletions Locale/da_DK/translations.php
@@ -0,0 +1,33 @@
<?php

return array(
// 'Remove hourly rate' => '',
// 'Do you really want to remove this hourly rate?' => '',
// 'Hourly rate' => '',
// 'Effective date' => '',
// 'Add new rate' => '',
// 'Rate removed successfully.' => '',
// 'Unable to remove this rate.' => '',
// 'Unable to save the hourly rate.' => '',
// 'Hourly rate created successfully.' => '',
// 'Amount' => '',
// 'Budget' => '',
// 'Budget line' => '',
// 'Budget line removed successfully.' => '',
// 'Budget lines' => '',
// 'Cost' => '',
// 'Cost breakdown' => '',
// 'Do you really want to remove this budget line?' => '',
// 'Expenses' => '',
// 'New budget line' => '',
// 'Remove a budget line' => '',
// 'Remove budget line' => '',
// 'The budget line have been created successfully.' => '',
// 'Unable to create the budget line.' => '',
// 'Unable to remove this budget line.' => '',
// 'Remaining' => '',
// 'Currency rates are used to calculate project budget.' => '',
// 'Burndown chart for "%s"' => '',
// 'Budget overview' => '',
// 'Type' => '',
);

0 comments on commit a694a09

Please sign in to comment.