firefly-iii/resources/twig/budgets/show.twig
2015-10-03 22:32:36 +02:00

127 lines
6.2 KiB
Twig

{% extends "./layout/default.twig" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, budget, repetition) }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-9 col-md-9 col-sm-7">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'overview'|_ }}</h3>
<!-- ACTIONS MENU -->
<div class="pull-right">
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
{{ 'actions'|_ }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="{{ route('budgets.edit',budget.id) }}"><i class="fa fa-pencil fa-fw"></i> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('budgets.delete',budget.id) }}"><i class="fa fa-trash fa-fw"></i> {{ 'delete'|_ }}</a></li>
</ul>
</div>
</div>
</div>
<div class="box-body">
{% if Config.get('firefly.chart') == 'google' %}
<div id="budgetOverview"></div>
{% endif %}
{% if Config.get('firefly.chart') == 'chartjs' %}
<canvas id="budgetOverview" style="width:100%;height:400px;"></canvas>
{% endif %}
</div>
</div>
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transactions'|_ }}</h3>
</div>
{% include 'list/journals.twig' %}
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-5">
{% if limits|length == 1 %}
<p class="small text-center"><a href="{{ route('budgets.show',budget.id) }}">{{ 'showEverything'|_ }}</a></p>
{% endif %}
{% for limit in limits %}
{% for rep in limit.limitRepetitions %}
{% set spentInRep = (spentInRepetitionCorrected(rep)*-1) %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('budgets.show',[budget.id,rep.id]) }}">{{ rep.startdate.formatLocalized(monthFormat) }}</a>
</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
{{ 'amount'|_ }}: {{ rep.amount|formatAmount }}
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
{{ 'spent'|_ }}: <span class="text-danger">{{ spentInRep|formatAmountPlain }}</span>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
{% set overspent = spentInRep > rep.amount %}
{% if overspent %}
{% set pct = (spentInRep != 0 ? (rep.amount / spentInRep)*100 : 0) %}
<div class="progress progress-striped">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0"
aria-valuemax="100" style="width: {{ pct|round }}%;"></div>
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{ (100-pct)|round }}"
aria-valuemin="0" aria-valuemax="100" style="width: {{ (100-pct)|round }}%;"></div>
</div>
{% else %}
{% set amount = rep.amount %}
{% set pct = (amount != 0 ? ((spentInRep / amount)*100) : 0) %}
<div class="progress progress-striped">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{ pct|round }}" aria-valuemin="0"
aria-valuemax="100" style="width: {{ pct|round }}%;"></div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% if limits|length == 1 %}
<p class="small text-center"><a href="{{ route('budgets.show',budget.id) }}">{{ 'showEverything'|_ }}</a></p>
{% endif %}
</div>
</div>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
var budgetID = {{budget.id}};
{% if repetition.id %}
var repetitionID = {{repetition.id}};
var year = {{repetition.startdate.format('Y')}};
{% else %}
var year = {{Session.get('start').format('Y')}};
{% endif %}
</script>
<!-- load the libraries and scripts necessary for Google Charts: -->
{% if Config.get('firefly.chart') == 'google' %}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="js/gcharts.js"></script>
{% endif %}
{% if Config.get('firefly.chart') == 'chartjs' %}
<script type="text/javascript" src="js/Chart.min.js"></script>
<script type="text/javascript" src="js/charts.js"></script>
{% endif %}
<script type="text/javascript" src="js/budgets.js"></script>
{% endblock %}