mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-11 16:05:50 -06:00
Some changes in views to make it all look better.
This commit is contained in:
parent
9ecc8ab547
commit
ac2fbc4105
@ -114,6 +114,12 @@ class BudgetController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function show(Budget $budget)
|
public function show(Budget $budget)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Use the
|
||||||
|
*/
|
||||||
|
$useSessionDates = Input::get('useSession') == 'true' ? true : false;
|
||||||
|
|
||||||
|
|
||||||
$filters = [];
|
$filters = [];
|
||||||
|
|
||||||
if (!is_null(Input::get('rep'))) {
|
if (!is_null(Input::get('rep'))) {
|
||||||
@ -127,13 +133,13 @@ class BudgetController extends BaseController
|
|||||||
$filters[] = 'no_envelope';
|
$filters[] = 'no_envelope';
|
||||||
} else {
|
} else {
|
||||||
// grab all limit repetitions, order them, show them:
|
// 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(
|
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
|
||||||
'filters', $filters
|
'filters', $filters
|
||||||
)->with('highlight', Input::get('highlight'));
|
)->with('highlight', Input::get('highlight'))->with('useSessionDates',$useSessionDates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +29,8 @@ class Budget implements BudgetInterface
|
|||||||
$period = $rep->periodShow();
|
$period = $rep->periodShow();
|
||||||
$return[$periodOrder] = isset($return[$periodOrder])
|
$return[$periodOrder] = isset($return[$periodOrder])
|
||||||
? $return[$periodOrder]
|
? $return[$periodOrder]
|
||||||
: ['date' => $period,
|
: ['date' => $period,
|
||||||
'budget_id' => $limit->budget_id];
|
'budget_id' => $limit->budget_id];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,27 +62,27 @@ class Budget implements BudgetInterface
|
|||||||
$repetition = \LimitRepetition::with('limit', 'limit.budget')->leftJoin(
|
$repetition = \LimitRepetition::with('limit', 'limit.budget')->leftJoin(
|
||||||
'limits', 'limit_repetitions.limit_id', '=', 'limits.id'
|
'limits', 'limit_repetitions.limit_id', '=', 'limits.id'
|
||||||
)->leftJoin('components', 'limits.component_id', '=', 'components.id')->where(
|
)->leftJoin('components', 'limits.component_id', '=', 'components.id')->where(
|
||||||
'components.user_id', \Auth::user()->id
|
'components.user_id', \Auth::user()->id
|
||||||
)
|
)
|
||||||
->where('limit_repetitions.id', $repetitionId)->first(['limit_repetitions.*']);
|
->where('limit_repetitions.id', $repetitionId)->first(['limit_repetitions.*']);
|
||||||
|
|
||||||
// get transactions:
|
// get transactions:
|
||||||
$set = $repetition->limit->budget->transactionjournals()->with(
|
$set = $repetition->limit->budget->transactionjournals()->with(
|
||||||
'transactions', 'transactions.account', 'components', 'transactiontype'
|
'transactions', 'transactions.account', 'components', 'transactiontype'
|
||||||
)->leftJoin(
|
)->leftJoin(
|
||||||
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
)->where('transaction_types.type', 'Withdrawal')->where(
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
'date', '>=', $repetition->startdate->format('Y-m-d')
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
||||||
'id', 'DESC'
|
'id', 'DESC'
|
||||||
)->get(['transaction_journals.*']);
|
)->get(['transaction_journals.*']);
|
||||||
|
|
||||||
$result[0] = [
|
$result[0] = [
|
||||||
'date' => $repetition->periodShow(),
|
'date' => $repetition->periodShow(),
|
||||||
'limit' => $repetition->limit,
|
'limit' => $repetition->limit,
|
||||||
'limitrepetition' => $repetition,
|
'limitrepetition' => $repetition,
|
||||||
'journals' => $set,
|
'journals' => $set,
|
||||||
'paginated' => false
|
'paginated' => false
|
||||||
];
|
];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -90,33 +90,47 @@ class Budget implements BudgetInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
*
|
* @param bool $useSessionDates
|
||||||
* @return mixed|void
|
* @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 = [];
|
$result = [];
|
||||||
$inRepetition = [];
|
$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) {
|
foreach ($limit->limitrepetitions as $repetition) {
|
||||||
$order = $repetition->periodOrder();
|
$order = $repetition->periodOrder();
|
||||||
$result[$order] = [
|
$result[$order] = [
|
||||||
'date' => $repetition->periodShow(),
|
'date' => $repetition->periodShow(),
|
||||||
'limitrepetition' => $repetition,
|
'limitrepetition' => $repetition,
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'journals' => [],
|
'journals' => [],
|
||||||
'paginated' => false
|
'paginated' => false
|
||||||
];
|
];
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
$set = $budget->transactionjournals()->with(
|
$set = $budget->transactionjournals()->with(
|
||||||
'transactions', 'transactions.account', 'components', 'transactiontype'
|
'transactions', 'transactions.account', 'components', 'transactiontype'
|
||||||
)->leftJoin(
|
)->leftJoin(
|
||||||
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
)->where('transaction_types.type', 'Withdrawal')->where(
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
'date', '>=', $repetition->startdate->format('Y-m-d')
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
||||||
'id', 'DESC'
|
'id', 'DESC'
|
||||||
)->get(['transaction_journals.*']);
|
)->get(['transaction_journals.*']);
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$transactions[] = $entry;
|
$transactions[] = $entry;
|
||||||
$inRepetition[] = $entry->id;
|
$inRepetition[] = $entry->id;
|
||||||
@ -125,42 +139,42 @@ class Budget implements BudgetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if ($useSessionDates === false) {
|
||||||
if (count($inRepetition) > 0) {
|
if (count($inRepetition) > 0) {
|
||||||
$query = $budget->transactionjournals()->with(
|
$query = $budget->transactionjournals()->with(
|
||||||
'transactions', 'transactions.account', 'components', 'transactiontype',
|
'transactions', 'transactions.account', 'components', 'transactiontype',
|
||||||
'transactions.account.accounttype'
|
'transactions.account.accounttype'
|
||||||
)->whereNotIn(
|
)->whereNotIn(
|
||||||
'transaction_journals.id', $inRepetition
|
'transaction_journals.id', $inRepetition
|
||||||
)->orderBy('date', 'DESC')->orderBy(
|
)->orderBy('date', 'DESC')->orderBy(
|
||||||
'transaction_journals.id', 'DESC'
|
'transaction_journals.id', 'DESC'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$query = $budget->transactionjournals()->with(
|
$query = $budget->transactionjournals()->with(
|
||||||
'transactions', 'transactions.account', 'components', 'transactiontype',
|
'transactions', 'transactions.account', 'components', 'transactiontype',
|
||||||
'transactions.account.accounttype'
|
'transactions.account.accounttype'
|
||||||
)->orderBy('date', 'DESC')->orderBy(
|
)->orderBy('date', 'DESC')->orderBy(
|
||||||
'transaction_journals.id', 'DESC'
|
'transaction_journals.id', 'DESC'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// build paginator:
|
||||||
|
$perPage = 25;
|
||||||
|
$totalItems = $query->count();
|
||||||
|
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
|
||||||
|
$skip = ($page - 1) * $perPage;
|
||||||
|
$set = $query->skip($skip)->take($perPage)->get();
|
||||||
|
|
||||||
|
// stupid paginator!
|
||||||
|
$items = [];
|
||||||
|
/** @var $item \TransactionJournal */
|
||||||
|
foreach ($set as $item) {
|
||||||
|
$items[] = $item;
|
||||||
|
}
|
||||||
|
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
||||||
|
$result['0000'] = ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
||||||
|
'journals' => $paginator];
|
||||||
}
|
}
|
||||||
|
|
||||||
// build paginator:
|
|
||||||
$perPage = 25;
|
|
||||||
$totalItems = $query->count();
|
|
||||||
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
|
|
||||||
$skip = ($page - 1) * $perPage;
|
|
||||||
$set = $query->skip($skip)->take($perPage)->get();
|
|
||||||
|
|
||||||
// stupid paginator!
|
|
||||||
$items = [];
|
|
||||||
/** @var $item \TransactionJournal */
|
|
||||||
foreach ($set as $item) {
|
|
||||||
$items[] = $item;
|
|
||||||
}
|
|
||||||
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
|
||||||
$result['0000'] = ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
|
||||||
'journals' => $paginator];
|
|
||||||
|
|
||||||
krsort($result);
|
krsort($result);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -179,10 +193,10 @@ class Budget implements BudgetInterface
|
|||||||
$set = $budget->transactionjournals()->leftJoin(
|
$set = $budget->transactionjournals()->leftJoin(
|
||||||
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
)->where('transaction_types.type', 'Withdrawal')->where(
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
'date', '>=', $repetition->startdate->format('Y-m-d')
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->get(
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->get(
|
||||||
['transaction_journals.id']
|
['transaction_journals.id']
|
||||||
);
|
);
|
||||||
foreach ($set as $item) {
|
foreach ($set as $item) {
|
||||||
$inRepetitions[] = $item->id;
|
$inRepetitions[] = $item->id;
|
||||||
}
|
}
|
||||||
@ -194,10 +208,10 @@ class Budget implements BudgetInterface
|
|||||||
'transactions', 'transactions.account', 'components', 'transactiontype',
|
'transactions', 'transactions.account', 'components', 'transactiontype',
|
||||||
'transactions.account.accounttype'
|
'transactions.account.accounttype'
|
||||||
)->whereNotIn(
|
)->whereNotIn(
|
||||||
'transaction_journals.id', $inRepetitions
|
'transaction_journals.id', $inRepetitions
|
||||||
)->orderBy('date', 'DESC')->orderBy(
|
)->orderBy('date', 'DESC')->orderBy(
|
||||||
'transaction_journals.id', 'DESC'
|
'transaction_journals.id', 'DESC'
|
||||||
);
|
);
|
||||||
|
|
||||||
// build paginator:
|
// build paginator:
|
||||||
$perPage = 25;
|
$perPage = 25;
|
||||||
@ -213,8 +227,8 @@ class Budget implements BudgetInterface
|
|||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
}
|
}
|
||||||
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
||||||
$result = [0 => ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
$result = [0 => ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
||||||
'journals' => $paginator]];
|
'journals' => $paginator]];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,13 @@ interface BudgetInterface
|
|||||||
*/
|
*/
|
||||||
public function organizeRepetition($repetitionId);
|
public function organizeRepetition($repetitionId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
*
|
* @param bool $useSessionDates
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function organizeRepetitions(\Budget $budget);
|
public function organizeRepetitions(\Budget $budget, $useSessionDates = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<td>Related budgets</td>
|
<td>Related budgets</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach($show['statistics']['budgets'] as $bud)
|
@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
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -5,20 +5,39 @@
|
|||||||
<h1>Firefly
|
<h1>Firefly
|
||||||
<small>Overview for budget "{{{$budget->name}}}"</small>
|
<small>Overview for budget "{{{$budget->name}}}"</small>
|
||||||
</h1>
|
</h1>
|
||||||
@if(count($filters) == 0)
|
|
||||||
<p class="lead">Budgets can help you cut back on spending.</p>
|
<p class="lead">Budgets can help you cut back on spending.</p>
|
||||||
@else
|
<!-- warning for selected limit -->
|
||||||
<p class="lead">
|
|
||||||
@if(isset($filters[0]) && is_object($filters[0]) && get_class($filters[0]) == 'Limit')
|
@if(isset($filters[0]) && is_object($filters[0]) && get_class($filters[0]) == 'Limit')
|
||||||
{{{$repetitions[0]['limitrepetition']->periodShow()}}}, {{mf($repetitions[0]['limit']->amount,false)}}
|
<p class="bg-primary" style="padding:15px;">
|
||||||
@elseif(isset($filters[0]) && $filters[0] == 'no_envelope')
|
This view is filtered to show only the envelope from {{{$repetitions[0]['limitrepetition']->periodShow()}}}
|
||||||
These transactions are not caught in an envelope.
|
with a total amount of {{mf($repetitions[0]['limit']->amount,false)}}.
|
||||||
|
</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 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
|
@endif
|
||||||
</p>
|
|
||||||
<p class="text-info">
|
|
||||||
<a href="{{route('budgets.show',$budget->id)}}">See the whole picture</a>
|
|
||||||
</p>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user