Some changes in views to make it all look better.

This commit is contained in:
James Cole 2014-08-22 10:16:52 +02:00
parent 9ecc8ab547
commit ac2fbc4105
5 changed files with 123 additions and 83 deletions

View File

@ -114,6 +114,12 @@ class BudgetController extends BaseController
*/
public function show(Budget $budget)
{
/**
* Use the
*/
$useSessionDates = Input::get('useSession') == 'true' ? true : false;
$filters = [];
if (!is_null(Input::get('rep'))) {
@ -127,13 +133,13 @@ class BudgetController extends BaseController
$filters[] = 'no_envelope';
} else {
// grab all limit repetitions, order them, show them:
$repetitions = $this->_budgets->organizeRepetitions($budget);
$repetitions = $this->_budgets->organizeRepetitions($budget,$useSessionDates);
}
}
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
'filters', $filters
)->with('highlight', Input::get('highlight'));
)->with('highlight', Input::get('highlight'))->with('useSessionDates',$useSessionDates);
}
/**

View File

@ -90,14 +90,28 @@ class Budget implements BudgetInterface
/**
* @param \Budget $budget
*
* @return mixed|void
* @param bool $useSessionDates
* @return array|mixed
* @throws \Firefly\Exception\FireflyException
*/
public function organizeRepetitions(\Budget $budget)
public function organizeRepetitions(\Budget $budget, $useSessionDates = false)
{
$sessionStart = \Session::get('start');
$sessionEnd = \Session::get('end');
$result = [];
$inRepetition = [];
foreach ($budget->limits as $limit) {
// get the limits:
if ($useSessionDates) {
$limits = $budget->limits()->where('startdate', '>=', $sessionStart->format('Y-m-d'))->
where('startdate', '<=', $sessionEnd->format('Y-m-d'))->get();
} else {
$limits = $budget->limits;
}
/** @var \Limit $limit */
foreach ($limits as $limit) {
foreach ($limit->limitrepetitions as $repetition) {
$order = $repetition->periodOrder();
$result[$order] = [
@ -125,7 +139,7 @@ class Budget implements BudgetInterface
}
}
if ($useSessionDates === false) {
if (count($inRepetition) > 0) {
$query = $budget->transactionjournals()->with(
'transactions', 'transactions.account', 'components', 'transactiontype',
@ -160,7 +174,7 @@ class Budget implements BudgetInterface
$paginator = \Paginator::make($items, $totalItems, $perPage);
$result['0000'] = ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
'journals' => $paginator];
}
krsort($result);
return $result;

View File

@ -25,12 +25,13 @@ interface BudgetInterface
*/
public function organizeRepetition($repetitionId);
/**
* @param \Budget $budget
*
* @param bool $useSessionDates
* @return mixed
*/
public function organizeRepetitions(\Budget $budget);
public function organizeRepetitions(\Budget $budget, $useSessionDates = false);
/**
* @param \Budget $budget

View File

@ -87,7 +87,7 @@
<td>Related budgets</td>
<td>
@foreach($show['statistics']['budgets'] as $bud)
<a href="{{route('budgets.show',$bud->id)}}" class="btn btn-default btn-xs">{{{$bud->name}}}</a>
<a href="{{route('budgets.show',$bud->id)}}?useSession=true" class="btn btn-default btn-xs">{{{$bud->name}}}</a>
@endforeach
</td>
</tr>

View File

@ -5,18 +5,37 @@
<h1>Firefly
<small>Overview for budget "{{{$budget->name}}}"</small>
</h1>
@if(count($filters) == 0)
<p class="lead">Budgets can help you cut back on spending.</p>
@else
<p class="lead">
<!-- warning for selected limit -->
@if(isset($filters[0]) && is_object($filters[0]) && get_class($filters[0]) == 'Limit')
{{{$repetitions[0]['limitrepetition']->periodShow()}}}, {{mf($repetitions[0]['limit']->amount,false)}}
@elseif(isset($filters[0]) && $filters[0] == 'no_envelope')
These transactions are not caught in an envelope.
@endif
<p class="bg-primary" style="padding:15px;">
This view is filtered to show only the envelope from {{{$repetitions[0]['limitrepetition']->periodShow()}}}
with a total amount of {{mf($repetitions[0]['limit']->amount,false)}}.
</p>
<p class="text-info">
<a href="{{route('budgets.show',$budget->id)}}">See the whole picture</a>
<p class="bg-info" style="padding:15px;">
<a href="{{route('budgets.show',$budget->id)}}" class="text-info">Reset the filters.</a>
</p>
@endif
<!-- warning for non-caught only -->
@if(isset($filters[0]) && $filters[0] == 'no_envelope')
<p class="bg-primary" style="padding:15px;">
This view is filtered to show transactions not in an envelope only.
</p>
<p class="bg-info" style="padding:15px;">
<a href="{{route('budgets.show',$budget->id)}}" class="text-info">Reset the filters.</a>
</p>
@endif
<!-- warning for session date -->
@if($useSessionDates == true)
<p class="bg-primary" style="padding:15px;">
This view is filtered to only show transactions between {{Session::get('start')->format('d M Y')}}
and {{Session::get('end')->format('d M Y')}}.
</p>
<p class="bg-info" style="padding:15px;">
<a href="{{route('budgets.show',$budget->id)}}" class="text-info">Reset the filters.</a>
</p>
@endif