Some visual updates to repeated expenses.

This commit is contained in:
James Cole 2014-11-24 23:02:08 +01:00
parent fd6e7fc1ab
commit e9b7e82aea
4 changed files with 37 additions and 53 deletions

View File

@ -39,7 +39,6 @@ class RepeatedExpenseController extends BaseController
$expenses->each(
function (Piggybank $piggyBank) use ($repository) {
$piggyBank->currentRelevantRep();
$piggyBank->currentRep = $repository->calculateParts($piggyBank->currentRep);
}
);

View File

@ -1,6 +1,7 @@
<?php
namespace FireflyIII\Shared\Toolkit;
use Carbon\Carbon;
/**
@ -31,4 +32,20 @@ class Steam
);
}
/**
* @param \Piggybank $piggyBank
* @param \PiggybankRepetition $repetition
*
* @return int
*/
public function percentage(\Piggybank $piggyBank, \PiggybankRepetition $repetition)
{
$pct = $repetition->currentamount / $piggyBank->targetamount * 100;
if ($pct > 100) {
return 100;
} else {
return floor($pct);
}
}
}

View File

@ -13,68 +13,34 @@
</div>
</div>
@foreach($expenses as $entry)
<?php
$barSize = floor(12 / $entry->currentRep->bars->count()) == 0 ? 1 : floor(12 / $entry->currentRep->bars->count());
?>
<div class="row">
<div class="col-lg-12 col-sm-12 col-md-12">
@foreach($expenses as $entry)
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">
<a href="{{route('repeated.show',$entry->id)}}" title="{{{$entry->name}}}">{{{$entry->name}}}</a>
({{mf($entry->targetamount)}})
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-12 col-sm-12 col-md-12">
<p>
Target amount: {{mf($entry->targetamount)}}. Currently saved: {{mf($entry->currentRep->currentamount)}}. Left to save: {{mf($entry->targetamount-$entry->currentRep->currentamount)}}<br />
Runs from {{$entry->currentRep->startdate->format('j F Y')}} to {{$entry->currentRep->targetdate->format('j F Y')}}
</p>
</div>
</div>
<div class="row">
@foreach($entry->currentRep->bars as $bar)
<div class="col-lg-{{$barSize}} col-md-{{$barSize}} col-sm-{{$barSize}}">
<div class="progress">
<!-- currentAmount:{{$bar->getCurrentAmount()}} getAmount:{{$bar->getCumulativeAmount()}} -->
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="{{$bar->percentage()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$bar->percentage()}}%;"></div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{100-$bar->percentage()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{100-$bar->percentage()}}%;"></div>
</div>
</div>
@endforeach
{{--
@for($i=0;$i<$entry->parts;$i++)
<!-- {{$entry->currentRep->currentamount}} < {{$entry->bars[$i]['amount']}} -->
<div class="col-lg-{{$entry->barCount}} col-md-{{$entry->barCount}} col-sm-{{$entry->barCount}}">
<div class="progress">
@if($entry->currentRep->currentamount < $entry->bars[$i]['amount'])
<!-- TRUE (smaller) -->
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">{{mf($entry->bars[$i]['amount'],false)}}</div>
@else
<!-- FALSE (larger) -->
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">{{mf($entry->bars[$i]['amount'],false)}}</div>
<div class="progress progress-striped">
<div class="progress-bar" role="progressbar" aria-valuenow="{{Steam::percentage($entry,$entry->currentRep)}}" aria-valuemin="0" aria-valuemax="100" style="width: {{Steam::percentage($entry,$entry->currentRep)}}%; min-width:15px;">
@if(Steam::percentage($entry,$entry->currentRep) > 30)
{{mf($entry->currentRep->currentamount,false)}}
@endif
</div>
@if(Steam::percentage($entry,$entry->currentRep) <= 30)
&nbsp;<small>{{mf($entry->currentRep->currentamount,false)}}</small>
@endif
</div>
@endfor
--}}
</div>
<div class="row">
{{--
@for($i=0;$i<$entry->parts;$i++)
<div class="col-lg-{{$entry->barCount}} col-md-{{$entry->barCount}} col-sm-{{$entry->barCount}}">
<small>{{DateKit::periodShow($entry->bars[$i]['date'],$entry->reminder)}}</small>
</div>
@endfor
--}}
</div>
<div class="panel-footer">
<small>{{$entry->currentRep->startdate->format('j F Y')}} to {{$entry->currentRep->targetdate->format('j F Y')}}</small>
</div>
</div>
</div>
@endforeach
</div>
@endforeach

View File

@ -43,9 +43,11 @@
{{mf($rep->currentamount,false)}}
@endif
</div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{100-$bar->percentage()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{100-$bar->percentage()}}%;">
</div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{100-$bar->percentage()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{100-$bar->percentage()}}%;"></div>
</div>
<p class="small">
{{$bar->getStartDate()->format('j F Y')}} &mdash; {{$bar->getTargetDate()->format('j F Y')}}
</p>
</div>
@endforeach