Skip to content

Commit

Permalink
feat: Add prev and next month buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
nafiesl committed Aug 11, 2023
1 parent 903b0cf commit 9e27543
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
5 changes: 4 additions & 1 deletion app/Http/Controllers/TransactionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Requests\Transactions\CreateRequest;
use App\Http\Requests\Transactions\UpdateRequest;
use App\Transaction;
use Carbon\Carbon;

class TransactionsController extends Controller
{
Expand Down Expand Up @@ -34,12 +35,14 @@ public function index()

$incomeTotal = $this->getIncomeTotal($transactions);
$spendingTotal = $this->getSpendingTotal($transactions);
$prevMonthDate = Carbon::parse($yearMonth.'-10')->subMonth();
$nextMonthDate = Carbon::parse($yearMonth.'-10')->addMonth();

return view('transactions.index', compact(
'transactions', 'editableTransaction',
'yearMonth', 'month', 'year', 'categories',
'incomeTotal', 'spendingTotal', 'partners',
'startDate', 'date'
'startDate', 'date', 'prevMonthDate', 'nextMonthDate'
));
}

Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
'detail' => 'Report Detail',
'view_monthly' => 'View Monthly',
'monthly' => 'Report Month :year_month',
'prev_month' => 'Prev Month',
'next_month' => 'Next Month',
'view_weekly' => 'View Weekly',
'weekly' => 'Report Week :year_week',
];
2 changes: 2 additions & 0 deletions resources/lang/id/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
'detail' => 'Detail Laporan',
'view_monthly' => 'Lihat Bulanan',
'monthly' => 'Laporan Bulan :year_month',
'prev_month' => 'Bulan Sblm',
'next_month' => 'Bulan Brkt',
'view_weekly' => 'Lihat Mingguan',
'weekly' => 'Laporan Minggu :year_week',
];
2 changes: 1 addition & 1 deletion resources/views/transactions/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-md-12">
@include('transactions.partials.stats')
<div class="card table-responsive">
<div class="card-header">
<div class="card-header px-4">
@include('transactions.partials.index_filters')
</div>
@desktop
Expand Down
22 changes: 13 additions & 9 deletions resources/views/transactions/partials/index_filters.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{{ Form::open(['method' => 'get', 'class' => 'form-inline']) }}
{!! Form::text('query', request('query'), ['class' => 'form-control form-control-sm mr-2', 'placeholder' => __('transaction.search_text')]) !!}
{{ Form::select('date', get_dates(), $date, ['class' => 'form-control form-control-sm mr-2', 'placeholder' => '--']) }}
{{ Form::select('month', get_months(), $month, ['class' => 'form-control form-control-sm mr-2']) }}
{{ Form::select('year', get_years(), $year, ['class' => 'form-control form-control-sm mr-2']) }}
{{ Form::select('category_id', $categories, request('category_id'), ['placeholder' => __('category.all'), 'class' => 'form-control form-control-sm mr-2']) }}
{{ Form::select('partner_id', $partners, request('partner_id'), ['placeholder' => __('partner.all'), 'class' => 'form-control form-control-sm mr-2']) }}
{!! Form::text('query', request('query'), ['class' => 'form-control form-control-sm mr-1', 'placeholder' => __('transaction.search_text')]) !!}
{{ Form::select('date', get_dates(), $date, ['class' => 'form-control form-control-sm mr-1', 'placeholder' => '--']) }}
{{ Form::select('month', get_months(), $month, ['class' => 'form-control form-control-sm mr-1']) }}
{{ Form::select('year', get_years(), $year, ['class' => 'form-control form-control-sm mr-1']) }}
{{ Form::select('category_id', $categories, request('category_id'), ['placeholder' => __('category.all'), 'class' => 'form-control form-control-sm mr-1']) }}
{{ Form::select('partner_id', $partners, request('partner_id'), ['placeholder' => __('partner.all'), 'class' => 'form-control form-control-sm mr-1']) }}
<div class="form-group mt-4 mt-sm-0">
{{ Form::submit(__('app.submit'), ['class' => 'btn btn-primary btn-sm mr-2']) }}
{{ link_to_route('transactions.index', __('app.reset'), [], ['class' => 'btn btn-secondary btn-sm mr-2']) }}
{{ link_to_route('transactions.exports.csv', __('transaction.download'), request()->all(), ['class' => 'btn btn-info btn-sm']) }}
{{ Form::submit(__('app.submit'), ['class' => 'btn btn-primary btn-sm mr-1']) }}
{{ link_to_route('transactions.index', __('app.reset'), [], ['class' => 'btn btn-secondary btn-sm mr-1']) }}
{{ link_to_route('transactions.exports.csv', __('transaction.download'), request()->all(), ['class' => 'btn btn-info btn-sm mr-1']) }}
</div>
<div class="form-group">
{{ link_to_route('transactions.index', __('report.prev_month'), ['month' => $prevMonthDate->format('m'), 'year' => $prevMonthDate->format('Y')], ['class' => 'btn btn-sm btn-secondary mr-1']) }}
{{ link_to_route('transactions.index', __('report.next_month'), ['month' => $nextMonthDate->format('m'), 'year' => $nextMonthDate->format('Y')], ['class' => 'btn btn-sm btn-secondary']) }}
</div>
{{ Form::close() }}

0 comments on commit 9e27543

Please sign in to comment.