From 7e7298d087b5a2c5101c3bc02cb7fec4d9bcc3f6 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 12 Nov 2017 15:54:05 +0800 Subject: [PATCH] Update yearly report page --- app/Entities/Reports/ReportsRepository.php | 16 ++- app/helpers.php | 1 - composer.lock | 132 +++++++++++----------- resources/views/reports/payments/yearly.blade.php | 55 +++++---- 4 files changed, 112 insertions(+), 92 deletions(-) diff --git a/app/Entities/Reports/ReportsRepository.php b/app/Entities/Reports/ReportsRepository.php index 93dbb9c..e07d769 100755 --- a/app/Entities/Reports/ReportsRepository.php +++ b/app/Entities/Reports/ReportsRepository.php @@ -41,12 +41,26 @@ class ReportsRepository extends BaseRepository public function getYearlyReports($year) { - return Payment::select(DB::raw("MONTH(date) as month, count(`id`) as count, sum(if(in_out = 1, amount, 0)) AS cashin, sum(if(in_out = 0, amount, 0)) AS cashout, in_out")) + $rawQuery = "MONTH(date) as month"; + $rawQuery .= ", count(`id`) as count"; + $rawQuery .= ", sum(if(in_out = 1, amount, 0)) AS cashin"; + $rawQuery .= ", sum(if(in_out = 0, amount, 0)) AS cashout"; + + $reportsData = DB::table('payments')->select(DB::raw($rawQuery)) ->where(DB::raw('YEAR(date)'), $year) ->groupBy(DB::raw('YEAR(date)')) ->groupBy(DB::raw('MONTH(date)')) ->orderBy('date', 'asc') ->get(); + + $reports = []; + foreach ($reportsData as $report) { + $key = str_pad($report->month, 2, '0', STR_PAD_LEFT); + $reports[$key] = $report; + $reports[$key]->profit = $report->cashin - $report->cashout; + } + + return collect($reports); } public function getCurrentCredits() diff --git a/app/helpers.php b/app/helpers.php index b27a1f7..113569d 100755 --- a/app/helpers.php +++ b/app/helpers.php @@ -110,7 +110,6 @@ function monthId($monthNumber) function getMonths() { return [ - '' => 'Pilih Bulan', '01' => 'Januari', '02' => 'Pebruari', '03' => 'Maret', diff --git a/composer.lock b/composer.lock index ea55fac..879c670 100644 --- a/composer.lock +++ b/composer.lock @@ -1096,16 +1096,16 @@ }, { "name": "luthfi/formfield", - "version": "0.2.1", + "version": "0.2.2", "source": { "type": "git", "url": "https://github.com/nafiesl/FormField.git", - "reference": "26a491ef89f187024d26913872c66b42a310b9b0" + "reference": "185bf67c52f4aca8227add187c72b84b945ab72f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nafiesl/FormField/zipball/26a491ef89f187024d26913872c66b42a310b9b0", - "reference": "26a491ef89f187024d26913872c66b42a310b9b0", + "url": "https://api.github.com/repos/nafiesl/FormField/zipball/185bf67c52f4aca8227add187c72b84b945ab72f", + "reference": "185bf67c52f4aca8227add187c72b84b945ab72f", "shasum": "" }, "require": { @@ -1144,7 +1144,7 @@ } ], "description": "Laravel Form Field the extension of Laravelcollective Form for Laravel 5.3, 5.4 and 5.5 with Twitter Bootstrap 3", - "time": "2017-10-09T01:45:40+00:00" + "time": "2017-11-10T06:49:59+00:00" }, { "name": "maatwebsite/excel", @@ -2053,16 +2053,16 @@ }, { "name": "symfony/console", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c" + "reference": "fd684d68f83568d8293564b4971928a2c4bdfc5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/116bc56e45a8e5572e51eb43ab58c769a352366c", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c", + "url": "https://api.github.com/repos/symfony/console/zipball/fd684d68f83568d8293564b4971928a2c4bdfc5c", + "reference": "fd684d68f83568d8293564b4971928a2c4bdfc5c", "shasum": "" }, "require": { @@ -2117,20 +2117,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-07T14:16:22+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "07447650225ca9223bd5c97180fe7c8267f7d332" + "reference": "66e6e046032ebdf1f562c26928549f613d428bd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/07447650225ca9223bd5c97180fe7c8267f7d332", - "reference": "07447650225ca9223bd5c97180fe7c8267f7d332", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/66e6e046032ebdf1f562c26928549f613d428bd1", + "reference": "66e6e046032ebdf1f562c26928549f613d428bd1", "shasum": "" }, "require": { @@ -2170,20 +2170,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-05T15:47:03+00:00" }, { "name": "symfony/debug", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd" + "reference": "74557880e2846b5c84029faa96b834da37e29810" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", + "url": "https://api.github.com/repos/symfony/debug/zipball/74557880e2846b5c84029faa96b834da37e29810", + "reference": "74557880e2846b5c84029faa96b834da37e29810", "shasum": "" }, "require": { @@ -2226,20 +2226,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-10T16:38:39+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423" + "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d7ba037e4b8221956ab1e221c73c9e27e05dd423", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/271d8c27c3ec5ecee6e2ac06016232e249d638d9", + "reference": "271d8c27c3ec5ecee6e2ac06016232e249d638d9", "shasum": "" }, "require": { @@ -2289,20 +2289,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-05T15:47:03+00:00" }, { "name": "symfony/finder", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "773e19a491d97926f236942484cb541560ce862d" + "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/773e19a491d97926f236942484cb541560ce862d", - "reference": "773e19a491d97926f236942484cb541560ce862d", + "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880", + "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880", "shasum": "" }, "require": { @@ -2338,20 +2338,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-05T15:47:03+00:00" }, { "name": "symfony/http-foundation", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "22cf9c2b1d9f67cc8e75ae7f4eaa60e4c1eff1f8" + "reference": "873ccdf8c1cae20da0184862820c434e20fdc8ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/22cf9c2b1d9f67cc8e75ae7f4eaa60e4c1eff1f8", - "reference": "22cf9c2b1d9f67cc8e75ae7f4eaa60e4c1eff1f8", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/873ccdf8c1cae20da0184862820c434e20fdc8ce", + "reference": "873ccdf8c1cae20da0184862820c434e20fdc8ce", "shasum": "" }, "require": { @@ -2391,20 +2391,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2017-10-05T23:10:23+00:00" + "time": "2017-11-05T19:07:00+00:00" }, { "name": "symfony/http-kernel", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "654f047a78756964bf91b619554f956517394018" + "reference": "f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/654f047a78756964bf91b619554f956517394018", - "reference": "654f047a78756964bf91b619554f956517394018", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0", + "reference": "f38c96b8d88a37b4f6bc8ae46a48b018d4894dd0", "shasum": "" }, "require": { @@ -2412,7 +2412,7 @@ "psr/log": "~1.0", "symfony/debug": "~2.8|~3.0", "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/http-foundation": "~3.3" + "symfony/http-foundation": "^3.3.11" }, "conflict": { "symfony/config": "<2.8", @@ -2477,7 +2477,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2017-10-05T23:40:19+00:00" + "time": "2017-11-10T20:08:13+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2648,16 +2648,16 @@ }, { "name": "symfony/process", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "fdf89e57a723a29baf536e288d6e232c059697b1" + "reference": "e14bb64d7559e6923fb13ee3b3d8fa763a2c0930" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/fdf89e57a723a29baf536e288d6e232c059697b1", - "reference": "fdf89e57a723a29baf536e288d6e232c059697b1", + "url": "https://api.github.com/repos/symfony/process/zipball/e14bb64d7559e6923fb13ee3b3d8fa763a2c0930", + "reference": "e14bb64d7559e6923fb13ee3b3d8fa763a2c0930", "shasum": "" }, "require": { @@ -2693,20 +2693,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-05T15:47:03+00:00" }, { "name": "symfony/routing", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "2e26fa63da029dab49bf9377b3b4f60a8fecb009" + "reference": "cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/2e26fa63da029dab49bf9377b3b4f60a8fecb009", - "reference": "2e26fa63da029dab49bf9377b3b4f60a8fecb009", + "url": "https://api.github.com/repos/symfony/routing/zipball/cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95", + "reference": "cf7fa1dfcfee2c96969bfa1c0341e5627ecb1e95", "shasum": "" }, "require": { @@ -2771,20 +2771,20 @@ "uri", "url" ], - "time": "2017-10-02T07:25:00+00:00" + "time": "2017-11-07T14:16:22+00:00" }, { "name": "symfony/translation", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "409bf229cd552bf7e3faa8ab7e3980b07672073f" + "reference": "373e553477e55cd08f8b86b74db766c75b987fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/409bf229cd552bf7e3faa8ab7e3980b07672073f", - "reference": "409bf229cd552bf7e3faa8ab7e3980b07672073f", + "url": "https://api.github.com/repos/symfony/translation/zipball/373e553477e55cd08f8b86b74db766c75b987fdb", + "reference": "373e553477e55cd08f8b86b74db766c75b987fdb", "shasum": "" }, "require": { @@ -2836,20 +2836,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-07T14:12:55+00:00" }, { "name": "symfony/var-dumper", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "03e3693a36701f1c581dd24a6d6eea2eba2113f6" + "reference": "805de6bd6869073e60610df1b14ab7d969c61b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/03e3693a36701f1c581dd24a6d6eea2eba2113f6", - "reference": "03e3693a36701f1c581dd24a6d6eea2eba2113f6", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/805de6bd6869073e60610df1b14ab7d969c61b01", + "reference": "805de6bd6869073e60610df1b14ab7d969c61b01", "shasum": "" }, "require": { @@ -2904,7 +2904,7 @@ "debug", "dump" ], - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-07T14:16:22+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -4784,16 +4784,16 @@ }, { "name": "symfony/dom-crawler", - "version": "v3.3.10", + "version": "v3.3.11", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "40dafd42d5dad7fe5ad4e958413d92a207522ac1" + "reference": "cebe3c068867956e012d9135282ba6a05d8a259e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/40dafd42d5dad7fe5ad4e958413d92a207522ac1", - "reference": "40dafd42d5dad7fe5ad4e958413d92a207522ac1", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/cebe3c068867956e012d9135282ba6a05d8a259e", + "reference": "cebe3c068867956e012d9135282ba6a05d8a259e", "shasum": "" }, "require": { @@ -4836,7 +4836,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2017-11-05T15:47:03+00:00" }, { "name": "theseer/tokenizer", diff --git a/resources/views/reports/payments/yearly.blade.php b/resources/views/reports/payments/yearly.blade.php index be9a61c..2531b63 100755 --- a/resources/views/reports/payments/yearly.blade.php +++ b/resources/views/reports/payments/yearly.blade.php @@ -38,39 +38,46 @@ + @foreach(getMonths() as $monthNumber => $monthName) + count : 0; + $cashin = $any ? $reports[$monthNumber]->cashin : 0; + $cashout = $any ? $reports[$monthNumber]->cashout : 0; + $profit = $any ? $reports[$monthNumber]->profit : 0; ?> - @forelse($reports as $key => $report) - {{ monthId($report->month) }} - {{ $report->count }} - {{ formatRp($report->cashin) }} - {{ formatRp($report->cashout) }} - {{ formatRp(($report->cashin - $report->cashout)) }} - {!! link_to_route('reports.payments.monthly','Lihat Bulanan', ['month' => monthNumber($report->month), 'year' => $year], ['class'=>'btn btn-info btn-xs','title'=>'Lihat laporan bulanan ' . monthId($report->month)]) !!} + {{ monthId($monthNumber) }} + {{ $count }} + {{ formatRp($cashin) }} + {{ formatRp($cashout) }} + {{ formatRp($profit) }} + + {!! link_to_route( + 'reports.payments.monthly', + 'Lihat Bulanan', + ['month' => $monthNumber, 'year' => $year], + [ + 'class'=>'btn btn-info btn-xs', + 'title'=>'Lihat laporan bulanan ' . monthId($monthNumber) + ] + ) !!} + count; - $sumTotal += $report->cashin; - $sumCapital += $report->cashout; - $sumProfit += ($report->cashin - $report->cashout); - $cartData[] = ['month'=>monthId($report->month),'value'=>($report->cashin - $report->cashout)]; + $cartData[] = ['month' => monthId($monthNumber), 'value' => $profit]; ?> - @empty - {{ trans('payment.not_found') }} - @endforelse + @endforeach Jumlah - {{ $invoicesCount }} - {{ formatRp($sumTotal) }} - {{ formatRp($sumCapital) }} - {{ formatRp($sumProfit) }} + {{ $reports->sum('count') }} + {{ formatRp($reports->sum('cashin')) }} + {{ formatRp($reports->sum('cashout')) }} + {{ formatRp($reports->sum('profit')) }}