mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Take page size into account. [skip ci]
This commit is contained in:
parent
2bb883219c
commit
ef48a79d0c
@ -174,7 +174,10 @@ class BillController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(BillRepositoryInterface $repository, Bill $bill)
|
public function show(BillRepositoryInterface $repository, Bill $bill)
|
||||||
{
|
{
|
||||||
$journals = $repository->getJournals($bill);
|
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||||
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
|
$journals = $repository->getJournals($bill, $page, $pageSize);
|
||||||
|
$journals->setPath('/bills/show/' . $bill->id);
|
||||||
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
|
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
|
||||||
$hideBill = true;
|
$hideBill = true;
|
||||||
$subTitle = e($bill->name);
|
$subTitle = e($bill->name);
|
||||||
|
@ -13,6 +13,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
->get(
|
->get(
|
||||||
[
|
[
|
||||||
'bills.*',
|
'bills.*',
|
||||||
DB::raw('((`bills`.`amount_min` + `bills`.`amount_max`) / 2) as `expectedAmount`'),
|
DB::raw('((`bills`.`amount_min` + `bills`.`amount_max`) / 2) as `expectedAmount`'),
|
||||||
]
|
]
|
||||||
)->sortBy('name');
|
)->sortBy('name');
|
||||||
|
|
||||||
@ -304,18 +305,24 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @param int $page
|
||||||
|
* @param int $pageSize
|
||||||
|
*
|
||||||
|
* @return LengthAwarePaginator|Collection
|
||||||
*/
|
*/
|
||||||
public function getJournals(Bill $bill): Collection
|
public function getJournals(Bill $bill, int $page, int $pageSize = 50): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$set = $bill->transactionjournals()
|
$offset = ($page - 1) * $pageSize;
|
||||||
->expanded()
|
$query = $bill->transactionjournals()
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
->expanded()
|
||||||
->orderBy('transaction_journals.order', 'ASC')
|
->orderBy('transaction_journals.date', 'DESC')
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
->orderBy('transaction_journals.order', 'ASC')
|
||||||
->get(TransactionJournal::QUERYFIELDS);
|
->orderBy('transaction_journals.id', 'DESC');
|
||||||
|
$count = $query->count();
|
||||||
|
$set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::QUERYFIELDS);
|
||||||
|
$paginator = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
||||||
|
|
||||||
return $set;
|
return $paginator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ namespace FireflyIII\Repositories\Bill;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,9 +98,12 @@ interface BillRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @param int $page
|
||||||
|
* @param int $pageSize
|
||||||
|
*
|
||||||
|
* @return LengthAwarePaginator
|
||||||
*/
|
*/
|
||||||
public function getJournals(Bill $bill): Collection;
|
public function getJournals(Bill $bill, int $page, int $pageSize = 50): LengthAwarePaginator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all journals that were recorded on this bill between these dates.
|
* Get all journals that were recorded on this bill between these dates.
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
<div class="col-lg-12 col-sm-12 col-md-12">
|
<div class="col-lg-12 col-sm-12 col-md-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ 'connected_journals' }}</h3>
|
<h3 class="box-title">{{ 'connected_journals'|_ }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body table-responsive no-padding">
|
<div class="box-body table-responsive no-padding">
|
||||||
{% include 'list/journals' %}
|
{% include 'list/journals' %}
|
||||||
|
Loading…
Reference in New Issue
Block a user