mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some new stuff for budget management. [skip ci]
This commit is contained in:
parent
36901359d0
commit
a40b281ea3
39
app/config/firefly.php
Normal file
39
app/config/firefly.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'index_periods' => '1D', '1W', '1M', '3M', '6M', 'custom',
|
||||||
|
'budget_periods' => 'daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly',
|
||||||
|
'periods_to_text' => [
|
||||||
|
'weekly' => 'A week',
|
||||||
|
'monthly' => 'A month',
|
||||||
|
'quarterly' => 'A quarter',
|
||||||
|
'half-year' => 'Six months',
|
||||||
|
'yearly' => 'A year',
|
||||||
|
],
|
||||||
|
'range_to_text' => [
|
||||||
|
'1D' => 'day',
|
||||||
|
'1W' => 'week',
|
||||||
|
'1M' => 'month',
|
||||||
|
'3M' => 'three months',
|
||||||
|
'6M' => 'half year',
|
||||||
|
'custom' => '(custom)'
|
||||||
|
],
|
||||||
|
'range_to_repeat_freq' => [
|
||||||
|
'1D' => 'weekly',
|
||||||
|
'1W' => 'weekly',
|
||||||
|
'1M' => 'monthly',
|
||||||
|
'3M' => 'quarterly',
|
||||||
|
'6M' => 'half-year',
|
||||||
|
'custom' => 'monthly'
|
||||||
|
],
|
||||||
|
|
||||||
|
'date_formats_by_period' => [
|
||||||
|
'monthly' => [
|
||||||
|
'group_date' => 'Y-m',
|
||||||
|
'display_date' => 'F Y'
|
||||||
|
],
|
||||||
|
'weekly' => [
|
||||||
|
'group_date' => 'Y-W',
|
||||||
|
'display_date' => '\W\e\e\k W, Y'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
@ -13,24 +13,22 @@ class BudgetController extends BaseController
|
|||||||
View::share('menu', 'budgets');
|
View::share('menu', 'budgets');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($group = null)
|
public function indexByDate()
|
||||||
{
|
{
|
||||||
|
|
||||||
$opts = ['date', 'budget'];
|
|
||||||
$group = in_array($group, $opts) ? $group : 'date';
|
|
||||||
|
|
||||||
switch ($group) {
|
|
||||||
case 'date':
|
|
||||||
// get a list of dates by getting all repetitions:
|
// get a list of dates by getting all repetitions:
|
||||||
$budgets = $this->_budgets->get();
|
$budgets = $this->_budgets->get();
|
||||||
$reps = [];
|
$reps = [];
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
foreach ($limit->limitrepetitions as $rep) {
|
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
|
||||||
|
if(is_null($dateFormats)) {
|
||||||
|
die('No date formats for ' . $limit->repeat_freq);
|
||||||
|
}
|
||||||
|
|
||||||
$monthOrder = $rep->startdate->format('Y-m');
|
foreach ($limit->limitrepetitions as $rep) {
|
||||||
$month = $rep->startdate->format('F Y');
|
$periodOrder = $rep->startdate->format($dateFormats['group_date']);
|
||||||
$reps[$monthOrder] = isset($reps[$monthOrder]) ? $reps[$monthOrder] : ['date' => $month];
|
$period = $rep->startdate->format($dateFormats['display_date']);
|
||||||
|
$reps[$periodOrder] = isset($reps[$periodOrder]) ? $reps[$periodOrder] : ['date' => $period];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,42 +36,34 @@ class BudgetController extends BaseController
|
|||||||
// put all the budgets under their respective date:
|
// put all the budgets under their respective date:
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
|
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
|
||||||
|
if(is_null($dateFormats)) {
|
||||||
|
die('No date formats for ' . $limit->repeat_freq);
|
||||||
|
}
|
||||||
foreach ($limit->limitrepetitions as $rep) {
|
foreach ($limit->limitrepetitions as $rep) {
|
||||||
$month = $rep->startdate->format('Y-m');
|
|
||||||
|
$month = $rep->startdate->format($dateFormats['group_date']);
|
||||||
$reps[$month]['limitrepetitions'][] = $rep;
|
$reps[$month]['limitrepetitions'][] = $rep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
krsort($reps);
|
krsort($reps);
|
||||||
|
|
||||||
return View::make('budgets.index')->with('group', $group)->with('reps', $reps);
|
return View::make('budgets.indexByDate')->with('reps', $reps);
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'budget':
|
|
||||||
$budgets = $this->_budgets->get();
|
|
||||||
$today = new \Carbon\Carbon;
|
|
||||||
return View::make('budgets.index')->with('budgets', $budgets)->with('today', $today)->with(
|
|
||||||
'group', $group
|
|
||||||
);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function indexByBudget()
|
||||||
|
{
|
||||||
|
$budgets = $this->_budgets->get();
|
||||||
|
$today = new \Carbon\Carbon;
|
||||||
|
return View::make('budgets.indexByBudget')->with('budgets', $budgets)->with('today', $today);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
$periods = \Config::get('firefly.periods_to_text');
|
||||||
$periods = [
|
|
||||||
'weekly' => 'A week',
|
|
||||||
'monthly' => 'A month',
|
|
||||||
'quarterly' => 'A quarter',
|
|
||||||
'half-year' => 'Six months',
|
|
||||||
'yearly' => 'A year',
|
|
||||||
];
|
|
||||||
|
|
||||||
return View::make('budgets.create')->with('periods', $periods);
|
return View::make('budgets.create')->with('periods', $periods);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +82,15 @@ class BudgetController extends BaseController
|
|||||||
return Redirect::route('budgets.index');
|
return Redirect::route('budgets.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO actual view, actual content.
|
||||||
|
* @param $budgetId
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function show($budgetId)
|
public function show($budgetId)
|
||||||
{
|
{
|
||||||
|
/** @var \Budget $budget */
|
||||||
$budget = $this->_budgets->find($budgetId);
|
$budget = $this->_budgets->find($budgetId);
|
||||||
|
|
||||||
$list = $budget->transactionjournals()->get();
|
$list = $budget->transactionjournals()->get();
|
||||||
@ -102,7 +99,6 @@ class BudgetController extends BaseController
|
|||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
$month = $entry->date->format('F Y');
|
$month = $entry->date->format('F Y');
|
||||||
$return[$month] = isset($return[$month]) ? $return[$month] : [];
|
$return[$month] = isset($return[$month]) ? $return[$month] : [];
|
||||||
|
|
||||||
$return[$month][] = $entry;
|
$return[$month][] = $entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,7 @@ class ChartController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function homeAccount($accountId = null)
|
public function homeAccount($accountId = null)
|
||||||
{
|
{
|
||||||
list($start, $end) = $this->_tk->getDateRange();
|
list($start, $end) = $this->_tk->getDateRangeDates();
|
||||||
\Log::debug('Start is (cannot clone?): ' . $start);
|
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
$return = [];
|
$return = [];
|
||||||
$account = null;
|
$account = null;
|
||||||
@ -75,10 +74,7 @@ class ChartController extends BaseController
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return[0] = ['name' => $account->name, 'id' => $account->id, 'data' => []];
|
$return[0] = ['name' => $account->name, 'id' => $account->id, 'data' => []];
|
||||||
\Log::debug('Start is: '.$start);
|
|
||||||
\Log::debug('End is: '.$end);
|
|
||||||
while ($current <= $end) {
|
while ($current <= $end) {
|
||||||
\Log::debug('Current: ' . $current.' is smaller or equal to ' . $end);
|
|
||||||
if ($current > $today) {
|
if ($current > $today) {
|
||||||
$return[0]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)];
|
$return[0]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)];
|
||||||
} else {
|
} else {
|
||||||
@ -88,21 +84,6 @@ class ChartController extends BaseController
|
|||||||
$current->addDay();
|
$current->addDay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // add an error bar as experiment:
|
|
||||||
// foreach($return as $index => $serie) {
|
|
||||||
// $err = [
|
|
||||||
// 'type' => 'errorbar',
|
|
||||||
// 'name' => $serie['name'].' pred',
|
|
||||||
// 'linkedTo' => $serie['id'],
|
|
||||||
// 'data' => []
|
|
||||||
// ];
|
|
||||||
// foreach($serie['data'] as $entry) {
|
|
||||||
// $err['data'][] = [$entry[0],10,300];
|
|
||||||
// }
|
|
||||||
// $return[] = $err;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
return Response::json($return);
|
return Response::json($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +121,7 @@ class ChartController extends BaseController
|
|||||||
|
|
||||||
public function homeCategories()
|
public function homeCategories()
|
||||||
{
|
{
|
||||||
list($start, $end) =$this->_tk->getDateRange();
|
list($start, $end) =$this->_tk->getDateRangeDates();
|
||||||
$account = null;
|
$account = null;
|
||||||
$result = [];
|
$result = [];
|
||||||
// grab all transaction journals in this period:
|
// grab all transaction journals in this period:
|
||||||
|
@ -40,7 +40,7 @@ class HomeController extends BaseController
|
|||||||
{
|
{
|
||||||
// count, maybe we need some introducing text to show:
|
// count, maybe we need some introducing text to show:
|
||||||
$count = $this->_accounts->count();
|
$count = $this->_accounts->count();
|
||||||
list($start, $end) = $this->_tk->getDateRange();
|
list($start, $end) = $this->_tk->getDateRangeDates();
|
||||||
|
|
||||||
|
|
||||||
// get the preference for the home accounts to show:
|
// get the preference for the home accounts to show:
|
||||||
@ -53,12 +53,14 @@ class HomeController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
// get the budgets for this period:
|
// get the budgets for this period:
|
||||||
$dates = $this->_tk->getDateRange();
|
$budgets = $this->_budgets->getWithRepetitionsInPeriod($start, \Session::get('range'));
|
||||||
$budgets = $this->_budgets->getWithRepetitionsInPeriod($dates[0], \Session::get('range'));
|
|
||||||
|
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$transactions[] = [$this->_journal->getByAccountInDateRange($account, 15, $start, $end), $account];
|
$set = $this->_journal->getByAccountInDateRange($account, 15, $start, $end);
|
||||||
|
if (count($set) > 0) {
|
||||||
|
$transactions[] = [$set, $account];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($transactions) % 2 == 0) {
|
if (count($transactions) % 2 == 0) {
|
||||||
@ -73,4 +75,10 @@ class HomeController extends BaseController
|
|||||||
'budgets', $budgets
|
'budgets', $budgets
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
Cache::flush();
|
||||||
|
return Redirect::route('index');
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,20 +19,16 @@ class LimitController extends BaseController
|
|||||||
|
|
||||||
public function create($budgetId = null)
|
public function create($budgetId = null)
|
||||||
{
|
{
|
||||||
$periods = [
|
$periods = \Config::get('firefly.periods_to_text');
|
||||||
'weekly' => 'A week',
|
$prefilled = [
|
||||||
'monthly' => 'A month',
|
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
|
||||||
'quarterly' => 'A quarter',
|
'repeat_freq' => Input::get('repeat_freq') ? : 'monthly'
|
||||||
'half-year' => 'Six months',
|
|
||||||
'yearly' => 'A year',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$budget = $this->_budgets->find($budgetId);
|
|
||||||
$budget_id = is_null($budget) ? null : $budget->id;
|
|
||||||
$budgets = $this->_budgets->getAsSelectList();
|
$budgets = $this->_budgets->getAsSelectList();
|
||||||
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budget_id)->with(
|
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budgetId)->with(
|
||||||
'periods', $periods
|
'periods', $periods
|
||||||
);
|
)->with('prefilled', $prefilled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($limitId = null)
|
public function edit($limitId = null)
|
||||||
@ -50,8 +46,9 @@ class LimitController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
return View::make('limits.edit')->with('limit', $limit)->with('budgets', $budgets)->
|
return View::make('limits.edit')->with('limit', $limit)->with('budgets', $budgets)->with(
|
||||||
with('periods',$periods);
|
'periods', $periods
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
App::before(
|
App::before(
|
||||||
function ($request) {
|
function ($request) {
|
||||||
|
Event::fire('app.before');
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
$toolkit->getDateRange();
|
return $toolkit->getDateRange();
|
||||||
}
|
}
|
||||||
Event::fire('app.before');
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -37,9 +37,23 @@ class Toolkit implements ToolkitInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// switch $range, update range or something:
|
// switch $range, update range or something:
|
||||||
|
$start = \Session::has('start') ? \Session::get('start') : new \Carbon\Carbon();
|
||||||
|
$end = \Session::has('end') ? \Session::get('end') : new \Carbon\Carbon();
|
||||||
$today = new \Carbon\Carbon;
|
$today = new \Carbon\Carbon;
|
||||||
$start = clone $today;
|
\Log::debug('Start: ' . $start.' ('.\Session::has('start').')');
|
||||||
$end = clone $today;
|
\Log::debug('End: ' . $end);
|
||||||
|
|
||||||
|
// see if we have to do a prev / next thing:
|
||||||
|
$doPrev = false;
|
||||||
|
$doNext = false;
|
||||||
|
if (\Input::get('action') == 'prev') {
|
||||||
|
$doPrev = true;
|
||||||
|
}
|
||||||
|
if (\Input::get('action') == 'next') {
|
||||||
|
$doNext = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ($range) {
|
switch ($range) {
|
||||||
case 'custom':
|
case 'custom':
|
||||||
// when range is custom AND input, we ignore $today
|
// when range is custom AND input, we ignore $today
|
||||||
@ -53,39 +67,94 @@ class Toolkit implements ToolkitInterface
|
|||||||
break;
|
break;
|
||||||
case '1D':
|
case '1D':
|
||||||
$start->startOfDay();
|
$start->startOfDay();
|
||||||
|
$end = clone $start;
|
||||||
$end->endOfDay();
|
$end->endOfDay();
|
||||||
|
if ($doNext) {
|
||||||
|
$start->addDay();
|
||||||
|
$end->addDay();
|
||||||
|
}
|
||||||
|
if ($doPrev) {
|
||||||
|
$start->subDay();
|
||||||
|
$end->subDay();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '1W':
|
case '1W':
|
||||||
$start->startOfWeek();
|
$start->startOfWeek();
|
||||||
|
$end = clone $start;
|
||||||
$end->endOfWeek();
|
$end->endOfWeek();
|
||||||
|
if ($doNext) {
|
||||||
|
$start->addWeek();
|
||||||
|
$end->addWeek();
|
||||||
|
}
|
||||||
|
if ($doPrev) {
|
||||||
|
$start->subWeek();
|
||||||
|
$end->subWeek();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '1M':
|
case '1M':
|
||||||
$start->startOfMonth();
|
$start->startOfMonth();
|
||||||
|
$end = clone $start;
|
||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
if ($doNext) {
|
||||||
|
$start->addMonth();
|
||||||
|
$end->addMonth();
|
||||||
|
}
|
||||||
|
if ($doPrev) {
|
||||||
|
$start->subMonth();
|
||||||
|
\Log::debug('1M prev. Before: ' . $end);
|
||||||
|
$end->startOfMonth()->subMonth()->endOfMonth();
|
||||||
|
\Log::debug('1M prev. After: ' . $end);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '3M':
|
case '3M':
|
||||||
$start->firstOfQuarter();
|
$start->firstOfQuarter();
|
||||||
|
$end = clone $start;
|
||||||
$end->lastOfQuarter();
|
$end->lastOfQuarter();
|
||||||
|
if ($doNext) {
|
||||||
|
$start->addMonths(3)->firstOfQuarter();
|
||||||
|
$end->addMonths(6)->lastOfQuarter();
|
||||||
|
}
|
||||||
|
if ($doPrev) {
|
||||||
|
$start->subMonths(3)->firstOfQuarter();
|
||||||
|
$end->subMonths(3)->lastOfQuarter();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '6M':
|
case '6M':
|
||||||
if (intval($today->format('m')) >= 7) {
|
if (intval($today->format('m')) >= 7) {
|
||||||
$start->startOfYear()->addMonths(6);
|
$start->startOfYear()->addMonths(6);
|
||||||
|
$end = clone $start;
|
||||||
$end->endOfYear();
|
$end->endOfYear();
|
||||||
} else {
|
} else {
|
||||||
$start->startOfYear();
|
$start->startOfYear();
|
||||||
|
$end = clone $start;
|
||||||
$end->startOfYear()->addMonths(6);
|
$end->startOfYear()->addMonths(6);
|
||||||
}
|
}
|
||||||
|
if ($doNext) {
|
||||||
|
$start->addMonths(6);
|
||||||
|
$end->addMonths(6);
|
||||||
|
}
|
||||||
|
if ($doPrev) {
|
||||||
|
$start->subMonths(6);
|
||||||
|
$end->subMonths(6);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// save in session:
|
// save in session:
|
||||||
\Session::put('start', $start);
|
\Session::put('start', $start);
|
||||||
\Session::put('end', $end);
|
\Session::put('end', $end);
|
||||||
\Session::put('range', $range);
|
\Session::put('range', $range);
|
||||||
|
if ($doPrev || $doNext) {
|
||||||
|
return \Redirect::route('index');
|
||||||
|
|
||||||
// and return:
|
}
|
||||||
return [$start, $end];
|
return;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDateRangeDates()
|
||||||
|
{
|
||||||
|
return [\Session::get('start'), \Session::get('end')];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -7,4 +7,6 @@ interface ToolkitInterface
|
|||||||
{
|
{
|
||||||
public function getDateRange();
|
public function getDateRange();
|
||||||
|
|
||||||
|
public function getDateRangeDates();
|
||||||
|
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
|||||||
|
|
||||||
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
|
/** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */
|
||||||
$toolkit = \App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
$toolkit = \App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
$dates = $toolkit->getDateRange();
|
$dates = $toolkit->getDateRangeDates();
|
||||||
$start = $dates[0];
|
$start = $dates[0];
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
|
|
||||||
// home controller
|
// home controller
|
||||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||||
|
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
|
||||||
|
|
||||||
// chart controller
|
// chart controller
|
||||||
Route::get('/chart/home/account/{account?}', ['uses' => 'ChartController@homeAccount', 'as' => 'chart.home']);
|
Route::get('/chart/home/account/{account?}', ['uses' => 'ChartController@homeAccount', 'as' => 'chart.home']);
|
||||||
@ -28,7 +29,8 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
|
|
||||||
// budget controller:
|
// budget controller:
|
||||||
Route::get('/budget/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
Route::get('/budget/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
||||||
Route::get('/budgets/{group?}',['uses' => 'BudgetController@index','as' => 'budgets.index']);
|
Route::get('/budgets',['uses' => 'BudgetController@indexByDate','as' => 'budgets.index']);
|
||||||
|
Route::get('/budgets/budget',['uses' => 'BudgetController@indexByBudget','as' => 'budgets.index.budget']);
|
||||||
Route::get('/budget/show/{id}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
Route::get('/budget/show/{id}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
||||||
|
|
||||||
// limit controller:
|
// limit controller:
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h1>Firefly
|
||||||
|
<small>Budgets and limits</small>
|
||||||
|
</h1>
|
||||||
|
<p class="text-info">
|
||||||
|
These are your budgets and if set, their "limits". Firefly uses an "<a
|
||||||
|
href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope system</a>" for your
|
||||||
|
budgets,
|
||||||
|
which means that for each period of time (for example a month) a virtual "envelope" can be created
|
||||||
|
containing a certain amount of money. Money spent within a budget is removed from the envelope.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a class="btn btn-default" href ="{{route('budgets.index')}}"><span class="glyphicon glyphicon-th"></span> Group by date</a>
|
||||||
|
<a class="btn btn-default" href ="{{route('budgets.limits.create')}}"><span class="glyphicon glyphicon-plus-sign"></span> Create a limit</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
@ -82,3 +102,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@stop
|
@ -1,3 +1,24 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h1>Firefly
|
||||||
|
<small>Budgets and limits</small>
|
||||||
|
</h1>
|
||||||
|
<p class="text-info">
|
||||||
|
These are your budgets and if set, their "limits". Firefly uses an "<a
|
||||||
|
href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope system</a>" for your
|
||||||
|
budgets,
|
||||||
|
which means that for each period of time (for example a month) a virtual "envelope" can be created
|
||||||
|
containing a certain amount of money. Money spent within a budget is removed from the envelope.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a class="btn btn-default" href ="{{route('budgets.index.budget')}}"><span class="glyphicon glyphicon-indent-left"></span> Group by budget</a>
|
||||||
|
<a class="btn btn-default" href ="{{route('budgets.limits.create')}}"><span class="glyphicon glyphicon-plus-sign"></span> Create a limit</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@foreach($reps as $date => $data)
|
@foreach($reps as $date => $data)
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
@ -47,3 +68,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@stop
|
@ -1,47 +1,6 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
@include('partials.date_nav')
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
|
||||||
<h1>Firefly
|
|
||||||
@if($count > 0)
|
|
||||||
<small>What's playing?</small>
|
|
||||||
@endif
|
|
||||||
</h1>
|
|
||||||
@if($count > 0)
|
|
||||||
<form role="form" class="form-horizontal">
|
|
||||||
<div class="input-group">
|
|
||||||
|
|
||||||
<?php $r = Session::get('range', '1M'); ?>
|
|
||||||
<span class="input-group-btn input-group-btn">
|
|
||||||
<button name="range" value="1D" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
|
|
||||||
type="submit">1D
|
|
||||||
</button>
|
|
||||||
<button name="range" value="1W" class="btn btn-default @if($r=='1W') btn-info @endif btn-sm"
|
|
||||||
type="submit">1W
|
|
||||||
</button>
|
|
||||||
<button name="range" value="1M" class="btn btn-default @if($r=='1M') btn-info @endif btn-sm"
|
|
||||||
type="submit">1M
|
|
||||||
</button>
|
|
||||||
<button name="range" value="3M" class="btn btn-default @if($r=='3M') btn-info @endif btn-sm"
|
|
||||||
type="submit">3M
|
|
||||||
</button>
|
|
||||||
<button name="range" value="6M" class="btn btn-default @if($r=='6M') btn-info @endif btn-sm"
|
|
||||||
type="submit">6M
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
<input value="{{Session::get('start')->format('Y-m-d')}}" name="start" type="date"
|
|
||||||
style="width:15%;border-right:0;" class="form-control input-sm">
|
|
||||||
<input value="{{Session::get('end')->format('Y-m-d')}}" name="end" type="date"
|
|
||||||
style="width:15%;border-right:0;" class="form-control input-sm">
|
|
||||||
<button class="btn btn-default btn-sm @if($r=='custom') btn-info @endif" type="submit" name="range"
|
|
||||||
value="custom">Custom
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@if($count == 0)
|
@if($count == 0)
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
@ -101,7 +60,8 @@
|
|||||||
<h5><a href="{{route('budgets.show',$budget->id)}}">{{{$budget->name}}}</a></h5>
|
<h5><a href="{{route('budgets.show',$budget->id)}}">{{{$budget->name}}}</a></h5>
|
||||||
@if($budget->count == 0)
|
@if($budget->count == 0)
|
||||||
<p>
|
<p>
|
||||||
<small><em>No budget set for this period.</em></small>
|
<a href="{{route('budgets.limits.create',[$budget->id])}}?startdate={{\Session::get('start')->format('Y-m-d')}}&repeat_freq={{\Config::get('firefly.range_to_repeat_freq.' . \Session::get('range'))}}" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-envelope"></span> Add a new envelope</a>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
@else
|
@else
|
||||||
@foreach($budget->limits as $limit)
|
@foreach($budget->limits as $limit)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<h1>Firefly
|
<h1>Firefly
|
||||||
<small>Set a limit to a budget</small>
|
<small>Create an envelope for a budget</small>
|
||||||
</h1>
|
</h1>
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
|
Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
|
||||||
@ -41,7 +41,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-3 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input type="date" name="startdate" value="{{Input::old('startdate') ?: date('Y-m-d')}}"
|
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $prefilled['startdate']}}"
|
||||||
class="form-control"/>
|
class="form-control"/>
|
||||||
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
||||||
here will correct itself to the nearest [period] you select below.</span>
|
here will correct itself to the nearest [period] you select below.</span>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<label for="period" class="col-sm-3 control-label">Spending period</label>
|
<label for="period" class="col-sm-3 control-label">Spending period</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
{{Form::select('period',$periods,Input::old('period') ?: 'monthly',['class' => 'form-control'])}}
|
{{Form::select('period',$periods,Input::old('period') ?: $prefilled['repeat_freq'],['class' => 'form-control'])}}
|
||||||
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
61
app/views/partials/date_nav.blade.php
Normal file
61
app/views/partials/date_nav.blade.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h1>Firefly
|
||||||
|
@if($count > 0)
|
||||||
|
<small>What's playing?</small>
|
||||||
|
@endif
|
||||||
|
</h1>
|
||||||
|
@if($count > 0)
|
||||||
|
<form role="form" method="GET">
|
||||||
|
<?php $r = Session::get('range', '1M'); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<button name="action" value="prev" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
|
||||||
|
type="submit">« Previous {{Config::get('firefly.range_to_text.'.$r)}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<button name="range" value="1D" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
|
||||||
|
type="submit">1D
|
||||||
|
</button>
|
||||||
|
<button name="range" value="1W" class="btn btn-default @if($r=='1W') btn-info @endif btn-sm"
|
||||||
|
type="submit">1W
|
||||||
|
</button>
|
||||||
|
<button name="range" value="1M" class="btn btn-default @if($r=='1M') btn-info @endif btn-sm"
|
||||||
|
type="submit">1M
|
||||||
|
</button>
|
||||||
|
<button name="range" value="3M" class="btn btn-default @if($r=='3M') btn-info @endif btn-sm"
|
||||||
|
type="submit">3M
|
||||||
|
</button>
|
||||||
|
<button name="range" value="6M" class="btn btn-default @if($r=='6M') btn-info @endif btn-sm"
|
||||||
|
type="submit">6M
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<input value="{{Session::get('start')->format('Y-m-d')}}" name="start" type="date"
|
||||||
|
class="form-control input-sm">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<input value="{{Session::get('end')->format('Y-m-d')}}" name="end" type="date"
|
||||||
|
class="form-control input-sm">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-1">
|
||||||
|
<button class="btn btn-default btn-sm @if($r=='custom') btn-info @endif" type="submit" name="range"
|
||||||
|
value="custom">Custom
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2" style="text-align:right;">
|
||||||
|
<button name="action" value="next" class="btn btn-default @if($r=='1D') btn-info @endif btn-sm"
|
||||||
|
type="submit">» Next {{Config::get('firefly.range_to_text.'.$r)}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
1
dev
Normal file
1
dev
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href="http://localhost/projects/firefly-iii/public">home</a>
|
1
dev.1
Normal file
1
dev.1
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a href="http://localhost/projects/firefly-iii/public">home</a>
|
@ -2,7 +2,7 @@
|
|||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
bootstrap="bootstrap/autoload.php"
|
bootstrap="bootstrap/autoload.php"
|
||||||
colors="true"
|
colors="false"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
var accountChart;
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user