mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-16 11:42:06 -06:00
Updated budget view.
This commit is contained in:
parent
6058ccff0d
commit
9d5d1c0a41
@ -190,6 +190,7 @@ class BudgetController extends Controller
|
||||
$next->addDay();
|
||||
$prev = clone $start;
|
||||
$prev->subDay();
|
||||
$prev = Navigation::startOfPeriod($prev, $range);
|
||||
|
||||
|
||||
$this->repository->cleanupBudgets();
|
||||
@ -205,6 +206,32 @@ class BudgetController extends Controller
|
||||
$spent = array_sum(array_column($budgetInformation, 'spent'));
|
||||
$budgeted = array_sum(array_column($budgetInformation, 'budgeted'));
|
||||
|
||||
// select thing for last 12 periods:
|
||||
$previousLoop = [];
|
||||
$previousDate = clone $start;
|
||||
$count = 0;
|
||||
while ($count < 12) {
|
||||
$previousDate->subDay();
|
||||
$previousDate = Navigation::startOfPeriod($previousDate, $range);
|
||||
$format = $previousDate->format('Y-m-d');
|
||||
$previousLoop[$format] = Navigation::periodShow($previousDate, $range);
|
||||
$count++;
|
||||
}
|
||||
|
||||
// select thing for next 12 periods:
|
||||
$nextLoop = [];
|
||||
$nextDate = clone $end;
|
||||
$nextDate->addDay();
|
||||
$count = 0;
|
||||
|
||||
while ($count < 12) {
|
||||
$format = $nextDate->format('Y-m-d');
|
||||
$nextLoop[$format] = Navigation::periodShow($nextDate, $range);
|
||||
$nextDate = Navigation::endOfPeriod($nextDate, $range);
|
||||
$count++;
|
||||
$nextDate->addDay();
|
||||
}
|
||||
|
||||
// display info
|
||||
$currentMonth = Navigation::periodShow($start, $range);
|
||||
$nextText = Navigation::periodShow($next, $range);
|
||||
@ -214,7 +241,7 @@ class BudgetController extends Controller
|
||||
'budgets.index',
|
||||
compact(
|
||||
'available', 'currentMonth', 'next', 'nextText', 'prev', 'prevText', 'periodStart', 'periodEnd', 'budgetInformation', 'inactive', 'budgets',
|
||||
'spent', 'budgeted'
|
||||
'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/** global: spent, budgeted, available, currencySymbol */
|
||||
/** global: spent, budgeted, available, currencySymbol, budgetIndexURI */
|
||||
|
||||
function drawSpentBar() {
|
||||
"use strict";
|
||||
@ -99,6 +99,15 @@ $(function () {
|
||||
*/
|
||||
$('input[type="number"]').on('input', updateBudgetedAmounts);
|
||||
|
||||
//
|
||||
$('.selectPeriod').change(function (e) {
|
||||
var sel = $(e.target).val();
|
||||
if (sel !== "x") {
|
||||
var newURI = budgetIndexURI.replace("REPLACE", sel);
|
||||
window.location.assign(newURI);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function updateIncome() {
|
||||
|
@ -20,6 +20,7 @@ return [
|
||||
'everything' => 'Everything',
|
||||
'customRange' => 'Custom range',
|
||||
'apply' => 'Apply',
|
||||
'select_date' => 'Select date..',
|
||||
'cancel' => 'Cancel',
|
||||
'from' => 'From',
|
||||
'to' => 'To',
|
||||
@ -112,8 +113,8 @@ return [
|
||||
'budget_in_period' => 'All transactions for budget ":name" between :start and :end',
|
||||
'chart_budget_in_period' => 'Chart for all transactions for budget ":name" between :start and :end',
|
||||
'chart_account_in_period' => 'Chart for all transactions for account ":name" between :start and :end',
|
||||
'chart_category_in_period' => 'Chart for all transactions for category ":name" between :start and :end',
|
||||
'chart_category_all' => 'Chart for all transactions for category ":name"',
|
||||
'chart_category_in_period' => 'Chart for all transactions for category ":name" between :start and :end',
|
||||
'chart_category_all' => 'Chart for all transactions for category ":name"',
|
||||
'budget_in_period_breadcrumb' => 'Between :start and :end',
|
||||
'clone_withdrawal' => 'Clone this withdrawal',
|
||||
'clone_deposit' => 'Clone this deposit',
|
||||
|
@ -98,20 +98,26 @@
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-2">
|
||||
<select class="form-control">
|
||||
<option>x</option>
|
||||
<select class="form-control selectPeriod" name="previous">
|
||||
<option label="{{ 'select_date'|_ }}" value="x">{{ 'select_date'|_ }}</option>
|
||||
{% for format, previousLabel in previousLoop %}
|
||||
<option label="{{ previousLabel }}" value="{{ format }}">{{ previousLabel }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-8 text-center">
|
||||
<div class="btn btn-group btn-group-lg" style="padding-top:0;">
|
||||
<a href="{{ route('budgets.index', [prev.format('Y-m-d')]) }}" class="btn btn-default" title="{{ prevText }}">←</a>
|
||||
<a href="#" class="btn btn-default">{{ currentMonth }}</a>
|
||||
<a href="{{ route('budgets.index', [start.format('Y-m-d')]) }}" class="btn btn-default">{{ currentMonth }}</a>
|
||||
<a href="{{ route('budgets.index', [next.format('Y-m-d')]) }}" class="btn btn-default" title="{{ nextText }}">→</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 text-right">
|
||||
<select class="form-control">
|
||||
<option>x</option>
|
||||
<select class="form-control selectPeriod" name="next">
|
||||
<option label="{{ 'select_date'|_ }}" value="x">{{ 'select_date'|_ }}</option>
|
||||
{% for format, nextLabel in nextLoop %}
|
||||
<option label="{{ nextLabel }}" value="{{ format }}">{{ nextLabel }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -131,10 +137,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:10%;"> </th>
|
||||
<th>Budget</th>
|
||||
<th>{{ 'budget'|_ }}</th>
|
||||
<th style="width:25%;">{{ 'budgeted'|_ }}</th>
|
||||
<th>Spent</th>
|
||||
<th>Left</th>
|
||||
<th>{{ 'spent'|_ }}</th>
|
||||
<th>{{ 'left'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -264,6 +270,7 @@
|
||||
// budgeted data:
|
||||
var budgeted = {{ budgeted }};
|
||||
var available = {{ available }};
|
||||
var budgetIndexURI = "{{ route('budgets.index','REPLACE') }}";
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="js/ff/budgets/index.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user