Browse Source

Update yearly report page

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
7e7298d087
  1. 16
      app/Entities/Reports/ReportsRepository.php
  2. 1
      app/helpers.php
  3. 132
      composer.lock
  4. 53
      resources/views/reports/payments/yearly.blade.php

16
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()

1
app/helpers.php

@ -110,7 +110,6 @@ function monthId($monthNumber)
function getMonths()
{
return [
'' => 'Pilih Bulan',
'01' => 'Januari',
'02' => 'Pebruari',
'03' => 'Maret',

132
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",

53
resources/views/reports/payments/yearly.blade.php

@ -38,39 +38,46 @@
</thead>
<tbody>
<?php
$invoicesCount = 0;
$sumTotal = 0;
$sumCapital = 0;
$sumProfit = 0;
$cartData = [];
?>
@forelse($reports as $key => $report)
@foreach(getMonths() as $monthNumber => $monthName)
<?php
$any = isset($reports[$monthNumber]);
$count = $any ? $reports[$monthNumber]->count : 0;
$cashin = $any ? $reports[$monthNumber]->cashin : 0;
$cashout = $any ? $reports[$monthNumber]->cashout : 0;
$profit = $any ? $reports[$monthNumber]->profit : 0;
?>
<tr>
<td class="text-center">{{ monthId($report->month) }}</td>
<td class="text-center">{{ $report->count }}</td>
<td class="text-right">{{ formatRp($report->cashin) }}</td>
<td class="text-right">{{ formatRp($report->cashout) }}</td>
<td class="text-right">{{ formatRp(($report->cashin - $report->cashout)) }}</td>
<td class="text-center">{!! 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)]) !!}</td>
<td class="text-center">{{ monthId($monthNumber) }}</td>
<td class="text-center">{{ $count }}</td>
<td class="text-right">{{ formatRp($cashin) }}</td>
<td class="text-right">{{ formatRp($cashout) }}</td>
<td class="text-right">{{ formatRp($profit) }}</td>
<td class="text-center">
{!! link_to_route(
'reports.payments.monthly',
'Lihat Bulanan',
['month' => $monthNumber, 'year' => $year],
[
'class'=>'btn btn-info btn-xs',
'title'=>'Lihat laporan bulanan ' . monthId($monthNumber)
]
) !!}
</td>
</tr>
<?php
$invoicesCount += $report->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
<tr><td colspan="6">{{ trans('payment.not_found') }}</td></tr>
@endforelse
@endforeach
</tbody>
<tfoot>
<tr>
<th class="text-center">Jumlah</th>
<th class="text-center">{{ $invoicesCount }}</th>
<th class="text-right">{{ formatRp($sumTotal) }}</th>
<th class="text-right">{{ formatRp($sumCapital) }}</th>
<th class="text-right">{{ formatRp($sumProfit) }}</th>
<th class="text-center">{{ $reports->sum('count') }}</th>
<th class="text-right">{{ formatRp($reports->sum('cashin')) }}</th>
<th class="text-right">{{ formatRp($reports->sum('cashout')) }}</th>
<th class="text-right">{{ formatRp($reports->sum('profit')) }}</th>
<td></td>
</tr>
</tfoot>

Loading…
Cancel
Save