mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Sortable accounts.
This commit is contained in:
parent
505aee22bb
commit
651a4fd3cc
@ -7,7 +7,6 @@ use FireflyIII\Http\Requests;
|
|||||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
use Input;
|
use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
use Session;
|
||||||
@ -123,18 +122,14 @@ class AccountController extends Controller
|
|||||||
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
||||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||||
$types = Config::get('firefly.accountTypesByIdentifier.' . $what);
|
$types = Config::get('firefly.accountTypesByIdentifier.' . $what);
|
||||||
$size = 50;
|
$accounts = $repository->getAccounts($types);
|
||||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
|
||||||
$set = $repository->getAccounts($types, $page);
|
|
||||||
$total = $repository->countAccounts($types);
|
|
||||||
|
|
||||||
// last activity:
|
// last activity:
|
||||||
/**
|
/**
|
||||||
* HERE WE ARE
|
* HERE WE ARE
|
||||||
*/
|
*/
|
||||||
$start = clone Session::get('start', Carbon::now()->startOfMonth());
|
$start = clone Session::get('start', Carbon::now()->startOfMonth());
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
$set->each(
|
$accounts->each(
|
||||||
function (Account $account) use ($start, $repository) {
|
function (Account $account) use ($start, $repository) {
|
||||||
$account->lastActivityDate = $repository->getLastActivity($account);
|
$account->lastActivityDate = $repository->getLastActivity($account);
|
||||||
$account->startBalance = Steam::balance($account, $start);
|
$account->startBalance = Steam::balance($account, $start);
|
||||||
@ -142,10 +137,6 @@ class AccountController extends Controller
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$accounts = new LengthAwarePaginator($set, $total, $size, $page);
|
|
||||||
$accounts->setPath(route('accounts.index', $what));
|
|
||||||
|
|
||||||
|
|
||||||
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class BillController extends Controller
|
|||||||
$expense = null;
|
$expense = null;
|
||||||
|
|
||||||
// get users expense accounts:
|
// get users expense accounts:
|
||||||
$accounts = $repository->getAccounts(Config::get('firefly.accountTypesByIdentifier.expense'), -1);
|
$accounts = $repository->getAccounts(Config::get('firefly.accountTypesByIdentifier.expense'));
|
||||||
|
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$match = strtolower($match);
|
$match = strtolower($match);
|
||||||
|
@ -53,26 +53,16 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
* @param int $page
|
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getAccounts(array $types, $page)
|
public function getAccounts(array $types)
|
||||||
{
|
{
|
||||||
$query = Auth::user()->accounts()->with(
|
$result = Auth::user()->accounts()->with(
|
||||||
['accountmeta' => function (HasMany $query) {
|
['accountmeta' => function (HasMany $query) {
|
||||||
$query->where('name', 'accountRole');
|
$query->where('name', 'accountRole');
|
||||||
}]
|
}]
|
||||||
)->accountTypeIn($types)->orderBy('accounts.name', 'ASC');
|
)->accountTypeIn($types)->orderBy('accounts.name', 'ASC')->get(['accounts.*'])->sortBy('name');
|
||||||
|
|
||||||
if ($page == -1) {
|
|
||||||
$result = $query->get(['accounts.*']);
|
|
||||||
} else {
|
|
||||||
$size = 50;
|
|
||||||
$offset = ($page - 1) * $size;
|
|
||||||
|
|
||||||
$result = $query->take($size)->offset($offset)->get(['accounts.*']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,10 @@ interface AccountRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
* @param int $page
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAccounts(array $types, $page);
|
public function getAccounts(array $types);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
@ -22,13 +22,16 @@
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
@include('list.accounts')
|
||||||
@include('list.accounts')
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
|
@section('styles')
|
||||||
|
<link rel="stylesheet" href="css/bootstrap-sortable.css" type="text/css" media="all" />
|
||||||
|
@stop
|
||||||
|
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var what = '{{{$what}}}';
|
var what = '{{{$what}}}';
|
||||||
@ -39,5 +42,6 @@
|
|||||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||||
<script type="text/javascript" src="js/gcharts.options.js"></script>
|
<script type="text/javascript" src="js/gcharts.options.js"></script>
|
||||||
<script type="text/javascript" src="js/gcharts.js"></script>
|
<script type="text/javascript" src="js/gcharts.js"></script>
|
||||||
|
<script type="text/javascript" src="js/bootstrap-sortable.js"></script>
|
||||||
<script type="text/javascript" src="js/accounts.js"></script>
|
<script type="text/javascript" src="js/accounts.js"></script>
|
||||||
@stop
|
@stop
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
@if(is_object($accounts) && method_exists($accounts, 'render'))
|
<table class="table table-striped table-bordered sortable">
|
||||||
{!! $accounts->render() !!}
|
<thead>
|
||||||
@endif
|
|
||||||
<table class="table table-striped table-bordered">
|
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th data-defaultsort="disabled"> </th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
@if(isset($what) && $what == 'asset')
|
@if(isset($what) && $what == 'asset')
|
||||||
<th>Role</th>
|
<th>Role</th>
|
||||||
@endif
|
@endif
|
||||||
<th>Current balance</th>
|
<th>Current balance</th>
|
||||||
<th>Active</th>
|
<th>Active</th>
|
||||||
<th>Last activity</th>
|
<th data-dateformat="DD-MMM-YYYY">Last activity</th>
|
||||||
<th>Balance difference between {{Session::get('start')->format('jS F Y')}} and {{Session::get('end')->format('jS F Y')}}</th>
|
<th>Balance difference between {{Session::get('start')->format('jS F Y')}} and {{Session::get('end')->format('jS F Y')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
@foreach($accounts as $account)
|
@foreach($accounts as $account)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -31,29 +31,30 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
@endif
|
@endif
|
||||||
<td>{!! Amount::format(Steam::balance($account)) !!}</td>
|
<?php $balance = Steam::balance($account);?>
|
||||||
<td>
|
<td data-value="{{$balance}}">{!! Amount::format($balance) !!}</td>
|
||||||
|
<td data-value="{{intval($account->active)}}">
|
||||||
@if($account->active)
|
@if($account->active)
|
||||||
<i class="fa fa-fw fa-check"></i>
|
<i class="fa fa-fw fa-check"></i>
|
||||||
@else
|
@else
|
||||||
<i class="fa fa-fw fa-ban"></i>
|
<i class="fa fa-fw fa-ban"></i>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
@if($account->lastActivityDate)
|
@if($account->lastActivityDate)
|
||||||
{{{$account->lastActivityDate->format('j F Y')}}}
|
<td data-value="{{$account->lastActivityDate->format('d-m-Y')}}">
|
||||||
|
{{{$account->lastActivityDate->format('j F Y')}}}
|
||||||
|
</td>
|
||||||
@else
|
@else
|
||||||
<em>Never</em>
|
<td data-value="00-00-0000">
|
||||||
|
<em>Never</em>
|
||||||
|
</td>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
<td data-value="{{$account->endBalance - $account->startBalance}}">
|
||||||
<td>
|
|
||||||
{!! Amount::format($account->endBalance - $account->startBalance) !!}
|
{!! Amount::format($account->endBalance - $account->startBalance) !!}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</tbody>
|
||||||
@if(is_object($accounts) && method_exists($accounts, 'render'))
|
</table>
|
||||||
{!! $accounts->render() !!}
|
|
||||||
@endif
|
|
Loading…
Reference in New Issue
Block a user