9 changed files with 430 additions and 2 deletions
-
49app/Entities/Reports/ReportsRepository.php
-
58app/Http/Controllers/ReportsController.php
-
1app/Http/routes.php
-
11app/Http/routes/reports.php
-
2app/helpers.php
-
15resources/views/layouts/partials/sidebar.blade.php
-
80resources/views/reports/payments/daily.blade.php
-
110resources/views/reports/payments/monthly.blade.php
-
104resources/views/reports/payments/yearly.blade.php
@ -0,0 +1,49 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entities\Reports; |
||||
|
|
||||
|
use App\Entities\BaseRepository; |
||||
|
use App\Entities\Payments\Payment; |
||||
|
use DB; |
||||
|
|
||||
|
/** |
||||
|
* Reports Repository Class |
||||
|
*/ |
||||
|
class ReportsRepository extends BaseRepository |
||||
|
{ |
||||
|
protected $model; |
||||
|
|
||||
|
public function __construct(Payment $model) |
||||
|
{ |
||||
|
parent::__construct($model); |
||||
|
} |
||||
|
|
||||
|
public function getDailyReports($date, $q) |
||||
|
{ |
||||
|
return Payment::orderBy('date','desc') |
||||
|
->where('date', $date) |
||||
|
->with('customer','project') |
||||
|
->get(); |
||||
|
} |
||||
|
|
||||
|
public function getMonthlyReports($year, $month) |
||||
|
{ |
||||
|
return Payment::select(DB::raw("date, count(`id`) as count, sum(if(type = 1, amount, 0)) AS cashin, sum(if(type = 0, amount, 0)) AS cashout, type")) |
||||
|
->where(DB::raw('YEAR(date)'), $year) |
||||
|
->where(DB::raw('MONTH(date)'), $month) |
||||
|
->groupBy('date') |
||||
|
->orderBy('date','asc') |
||||
|
->get(); |
||||
|
} |
||||
|
|
||||
|
public function getYearlyReports($year) |
||||
|
{ |
||||
|
return Payment::select(DB::raw("MONTH(date) as month, count(`id`) as count, sum(if(type = 1, amount, 0)) AS cashin, sum(if(type = 0, amount, 0)) AS cashout, type")) |
||||
|
->where(DB::raw('YEAR(date)'), $year) |
||||
|
->groupBy(DB::raw('YEAR(date)')) |
||||
|
->groupBy(DB::raw('MONTH(date)')) |
||||
|
->orderBy('date','asc') |
||||
|
->get(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Controllers; |
||||
|
|
||||
|
use App\Http\Controllers\Controller; |
||||
|
use App\Entities\Reports\ReportsRepository; |
||||
|
|
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class ReportsController extends Controller { |
||||
|
|
||||
|
private $repo; |
||||
|
|
||||
|
public function __construct(ReportsRepository $repo) |
||||
|
{ |
||||
|
$this->repo = $repo; |
||||
|
} |
||||
|
|
||||
|
public function index(Request $req) |
||||
|
{ |
||||
|
$reports = $this->repo->getAll($req->get('q')); |
||||
|
return view('reports.payments.index',compact('reports')); |
||||
|
} |
||||
|
|
||||
|
public function daily(Request $req) |
||||
|
{ |
||||
|
$q = $req->get('q'); |
||||
|
$date = $req->get('date',date('Y-m-d')); |
||||
|
|
||||
|
$payments = $this->repo->getDailyReports($date, $q); |
||||
|
return view('reports.payments.daily', compact('payments','date')); |
||||
|
} |
||||
|
|
||||
|
public function monthly(Request $req) |
||||
|
{ |
||||
|
$year = date('Y'); |
||||
|
$month = date('m'); |
||||
|
if ($req->has('year') && $req->has('month')) |
||||
|
{ |
||||
|
$year = $req->get('year'); |
||||
|
$month = $req->get('month'); |
||||
|
} |
||||
|
$reports = $this->repo->getMonthlyReports($year, $month); |
||||
|
$months = \getMonths(); |
||||
|
$years = \getYears(); |
||||
|
return view('reports.payments.monthly', compact('reports','months','years','month','year')); |
||||
|
} |
||||
|
|
||||
|
public function yearly(Request $req) |
||||
|
{ |
||||
|
$year = $req->get('year',date('Y')); |
||||
|
|
||||
|
$reports = $this->repo->getYearlyReports($year); |
||||
|
$years = \getYears(); |
||||
|
return view('reports.payments.yearly', compact('reports','years','year')); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
<?php |
||||
|
|
||||
|
Route::group(['middleware' => ['web','role:admin'],'prefix' => 'reports'], function() { |
||||
|
/** |
||||
|
* Reports Routes |
||||
|
*/ |
||||
|
Route::get('payments', ['as'=>'reports.payments.index', 'uses' => 'ReportsController@monthly']); |
||||
|
Route::get('payments/daily', ['as'=>'reports.payments.daily', 'uses' => 'ReportsController@daily']); |
||||
|
Route::get('payments/monthly', ['as'=>'reports.payments.monthly', 'uses' => 'ReportsController@monthly']); |
||||
|
Route::get('payments/yearly', ['as'=>'reports.payments.yearly', 'uses' => 'ReportsController@yearly']); |
||||
|
}); |
||||
@ -0,0 +1,80 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', 'Laporan Harian : ' . dateId($date)) |
||||
|
|
||||
|
@section('content') |
||||
|
<?php $dt = Carbon::parse($date) ?>
|
||||
|
|
||||
|
<ul class="breadcrumb hidden-print"> |
||||
|
<li>{{ link_to_route('reports.payments.yearly', 'Laporan Tahun ' . $dt->year, ['year' => $dt->year]) }}</li> |
||||
|
<li>{{ link_to_route('reports.payments.monthly', getMonths()[monthNumber($dt->month)], ['year' => $dt->year,'month' => monthNumber($dt->month)]) }}</li> |
||||
|
<li class="active">{{ $dt->format('d') }}</li> |
||||
|
</ul> |
||||
|
|
||||
|
<h1 class="page-header">Laporan Harian : {{ dateId($date) }}</h1> |
||||
|
|
||||
|
{!! Form::open(['method'=>'get','class'=>'form-inline well well-sm']) !!} |
||||
|
{!! Form::text('date', $date, ['class'=>'form-control','required','id'=>'date']) !!} |
||||
|
{!! Form::submit('Lihat Laporan', ['class'=>'btn btn-primary']) !!} |
||||
|
{!! link_to_route('reports.payments.daily', 'Hari Ini', [], ['class'=>'btn btn-default']) !!} |
||||
|
{!! link_to_route('reports.payments.monthly', 'Lihat Bulanan', ['month' => monthNumber($dt->month), 'year' => $dt->year], ['class'=>'btn btn-default']) !!} |
||||
|
{!! Form::close() !!} |
||||
|
|
||||
|
<table class="table table-condensed table-hover"> |
||||
|
<thead> |
||||
|
<th>{{ trans('app.table_no') }}</th> |
||||
|
<th class="col-md-3">{{ trans('payment.project') }}</th> |
||||
|
<th class="col-md-1 text-center">{{ trans('app.date') }}</th> |
||||
|
<th class="col-md-2 text-right">{{ trans('payment.amount') }}</th> |
||||
|
<th class="col-md-2">{{ trans('payment.customer') }}</th> |
||||
|
<th class="col-md-3">{{ trans('payment.description') }}</th> |
||||
|
<th class="col-md-1">{{ trans('app.action') }}</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php $total = 0; ?>
|
||||
|
@forelse($payments as $key => $payment) |
||||
|
<tr> |
||||
|
<td>{{ 1 + $key }}</td> |
||||
|
<td>{{ $payment->project->name }}</td> |
||||
|
<td class="text-center">{{ $payment->date }}</td> |
||||
|
<td class="text-right">{{ $payment->present()->amount }}</td> |
||||
|
<td>{{ $payment->customer->name }}</td> |
||||
|
<td>{{ $payment->description }}</td> |
||||
|
<td> |
||||
|
{!! link_to_route('payments.show','Lihat',[$payment->id],['title' => 'Lihat Detail Pembayaran','target' => '_blank','class'=>'btn btn-info btn-xs']) !!} |
||||
|
</td> |
||||
|
</tr> |
||||
|
<?php $total = $payment->type == 0 ? $total - $payment->amount : $total + $payment->amount ?>
|
||||
|
@empty |
||||
|
<tr><td colspan="5">{{ trans('payment.not_found') }}</td></tr> |
||||
|
@endforelse |
||||
|
</tbody> |
||||
|
<tfoot> |
||||
|
<tr> |
||||
|
<th class="text-right" colspan="3">Jumlah</th> |
||||
|
<th class="text-right">{{ formatRp($total) }}</th> |
||||
|
<th colspan="3"></th> |
||||
|
</tr> |
||||
|
</tfoot> |
||||
|
</table> |
||||
|
@endsection |
||||
|
|
||||
|
|
||||
|
@section('ext_css') |
||||
|
{!! Html::style(url('assets/css/plugins/jquery.datetimepicker.css')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_js') |
||||
|
{!! Html::script(url('assets/js/plugins/jquery.datetimepicker.js')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('script') |
||||
|
<script> |
||||
|
(function() { |
||||
|
$('#date').datetimepicker({ |
||||
|
timepicker:false, |
||||
|
format:'Y-m-d' |
||||
|
}); |
||||
|
})(); |
||||
|
</script> |
||||
|
@endsection |
||||
@ -0,0 +1,110 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', 'Laporan Bulanan : ' . $months[$month] . ' ' . $year) |
||||
|
|
||||
|
@section('content') |
||||
|
<ul class="breadcrumb hidden-print"> |
||||
|
<li>{{ link_to_route('reports.payments.yearly', 'Laporan Tahun ' . $year, ['year' => $year]) }}</li> |
||||
|
<li class="active">{{ $months[$month] }}</li> |
||||
|
</ul> |
||||
|
|
||||
|
<h1 class="page-header"> |
||||
|
Laporan Bulanan : {{ $months[$month] }} {{ $year }} |
||||
|
</h1> |
||||
|
|
||||
|
{!! Form::open(['method'=>'get','class'=>'form-inline well well-sm']) !!} |
||||
|
{!! Form::select('month', $months, $month, ['class'=>'form-control']) !!} |
||||
|
{!! Form::select('year', $years, $year, ['class'=>'form-control']) !!} |
||||
|
{!! Form::submit('Lihat Laporan', ['class'=>'btn btn-info']) !!} |
||||
|
{!! link_to_route('reports.payments.monthly','Bulan ini',[],['class'=>'btn btn-default']) !!} |
||||
|
{!! link_to_route('reports.payments.yearly','Lihat Tahunan',['year' => $year],['class'=>'btn btn-default']) !!} |
||||
|
{!! Form::close() !!} |
||||
|
|
||||
|
<div class="panel panel-primary"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">Grafik Profit {{ $months[$month] }} {{ $year }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<strong>Rp.</strong> |
||||
|
<div id="monthly-chart" style="height: 250px;"></div> |
||||
|
<div class="text-center"><strong>Tanggal</strong></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="panel panel-success"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">Detail Laporan</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<th class="text-center">Tanggal</th> |
||||
|
<th class="text-center">Jumlah Transfer</th> |
||||
|
<th class="text-right">Uang Masuk</th> |
||||
|
<th class="text-right">Uang Keluar</th> |
||||
|
<th class="text-right">Profit</th> |
||||
|
<th class="text-center">Pilihan</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php |
||||
|
$invoicesCount = 0; |
||||
|
$sumTotal = 0; |
||||
|
$sumCapital = 0; |
||||
|
$sumProfit = 0; |
||||
|
$cartData = []; |
||||
|
?>
|
||||
|
@forelse($reports as $key => $report) |
||||
|
<tr> |
||||
|
<td class="text-center">{{ dateId($report->date) }}</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.daily','Lihat Harian',['date' => $report->date] , ['class'=>'btn btn-info btn-xs','title'=>'Lihat laporan harian ' . $report->date]) !!} |
||||
|
</td> |
||||
|
</tr> |
||||
|
<?php |
||||
|
$invoicesCount += $report->count; |
||||
|
$sumTotal += $report->cashin; |
||||
|
$sumCapital += $report->cashout; |
||||
|
$sumProfit += ($report->cashin - $report->cashout); |
||||
|
$cartData[] = ['date'=>dateId($report->date),'value'=>($report->cashin - $report->cashout)]; |
||||
|
?>
|
||||
|
@empty |
||||
|
<tr><td colspan="6">{{ trans('payment.not_found') }}</td></tr> |
||||
|
@endforelse |
||||
|
</tbody> |
||||
|
<tfoot> |
||||
|
<tr> |
||||
|
<th class="text-right">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> |
||||
|
<td></td> |
||||
|
</tr> |
||||
|
</tfoot> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_css') |
||||
|
{!! Html::style(url('assets/css/plugins/morris.css')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_js') |
||||
|
{!! Html::script(url('assets/js/plugins/morris/raphael.min.js')) !!} |
||||
|
{!! Html::script(url('assets/js/plugins/morris/morris.min.js')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('script') |
||||
|
<script> |
||||
|
(function() { |
||||
|
new Morris.Line({ |
||||
|
element: 'monthly-chart', |
||||
|
data: {!! json_encode($cartData) !!}, |
||||
|
xkey: 'date', |
||||
|
ykeys: ['value'], |
||||
|
labels: ['Profit'], |
||||
|
parseTime:false |
||||
|
}); |
||||
|
})(); |
||||
|
</script> |
||||
|
@endsection |
||||
@ -0,0 +1,104 @@ |
|||||
|
@extends('layouts.app') |
||||
|
|
||||
|
@section('title', 'Laporan Tahunan : ' . $year) |
||||
|
|
||||
|
@section('content') |
||||
|
<ul class="breadcrumb hidden-print"> |
||||
|
<li>{{ link_to_route('reports.payments.yearly', 'Laporan Tahun ' . $year, ['year' => $year]) }}</li> |
||||
|
<li class="active">Laporan Tahunan</li> |
||||
|
</ul> |
||||
|
|
||||
|
<h1 class="page-header">Laporan Tahunan : {{ $year }}</h1> |
||||
|
|
||||
|
{!! Form::open(['method'=>'get','class'=>'form-inline well well-sm']) !!} |
||||
|
{!! Form::select('year', $years, $year, ['class'=>'form-control']) !!} |
||||
|
{!! Form::submit('Lihat Laporan', ['class'=>'btn btn-info']) !!} |
||||
|
{!! link_to_route('reports.payments.yearly','Tahun ini',[],['class'=>'btn btn-default']) !!} |
||||
|
{!! Form::close() !!} |
||||
|
|
||||
|
<div class="panel panel-primary"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">Grafik Profit {{ $year }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<strong>Rp.</strong> |
||||
|
<div id="yearly-chart" style="height: 250px;"></div> |
||||
|
<div class="text-center"><strong>Bulan</strong></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="panel panel-success"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">Detail Laporan</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<thead> |
||||
|
<th class="text-center">Bulan</th> |
||||
|
<th class="text-center">Jumlah Transfer</th> |
||||
|
<th class="text-right">Uang Masuk</th> |
||||
|
<th class="text-right">Uang Keluar</th> |
||||
|
<th class="text-right">Profit</th> |
||||
|
<th class="text-center">Pilihan</th> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
<?php |
||||
|
$invoicesCount = 0; |
||||
|
$sumTotal = 0; |
||||
|
$sumCapital = 0; |
||||
|
$sumProfit = 0; |
||||
|
$cartData = []; |
||||
|
?>
|
||||
|
@forelse($reports as $key => $report) |
||||
|
<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> |
||||
|
</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)]; |
||||
|
?>
|
||||
|
@empty |
||||
|
<tr><td colspan="6">{{ trans('payment.not_found') }}</td></tr> |
||||
|
@endforelse |
||||
|
</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> |
||||
|
<td></td> |
||||
|
</tr> |
||||
|
</tfoot> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_css') |
||||
|
{!! Html::style(url('assets/css/plugins/morris.css')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('ext_js') |
||||
|
{!! Html::script(url('assets/js/plugins/morris/raphael.min.js')) !!} |
||||
|
{!! Html::script(url('assets/js/plugins/morris/morris.min.js')) !!} |
||||
|
@endsection |
||||
|
|
||||
|
@section('script') |
||||
|
<script> |
||||
|
(function() { |
||||
|
new Morris.Line({ |
||||
|
element: 'yearly-chart', |
||||
|
data: {!! json_encode($cartData) !!}, |
||||
|
xkey: 'month', |
||||
|
ykeys: ['value'], |
||||
|
labels: ['Profit'], |
||||
|
parseTime:false |
||||
|
}); |
||||
|
})(); |
||||
|
</script> |
||||
|
@endsection |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue