added jurnal report
This commit is contained in:
@@ -166,18 +166,17 @@ class FormHelper
|
|||||||
$userIds = $users->pluck('user_id')->toArray();
|
$userIds = $users->pluck('user_id')->toArray();
|
||||||
|
|
||||||
if($type == 'Up Country') {
|
if($type == 'Up Country') {
|
||||||
$form = FormUpCountry::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
|
$form = FormUpCountry::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('status', ['Approved', 'Closed'])->get();
|
||||||
} else if($type == 'Vehicle Running Cost') {
|
} else if($type == 'Vehicle Running Cost') {
|
||||||
$form = FormVehicleRunningCost::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
|
$form = FormVehicleRunningCost::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('status', ['Approved', 'Closed'])->get();
|
||||||
} else if($type == 'Entertainment') {
|
} else if($type == 'Entertainment') {
|
||||||
$form = FormEntertaimentPresentation::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year);
|
$form = FormEntertaimentPresentation::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('status', ['Approved', 'Closed'])->get();
|
||||||
} else if($type == 'Meeting / Seminar') {
|
} else if($type == 'Meeting / Seminar') {
|
||||||
$form = FormMeetingSeminar::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('created_at', '=', date('m', strtotime($month)))->whereYear('created_at', '=', $year);
|
$form = FormMeetingSeminar::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('created_at', '=', date('m', strtotime($month)))->whereYear('created_at', '=', $year)->where('status', ['Approved', 'Closed'])->get();
|
||||||
} else {
|
} else {
|
||||||
$form = FormOthers::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('kategori_id', $type_id);
|
$form = FormOthers::select('approved_total')->whereIn('user_id', $userIds)->whereMonth('tanggal', '=', date('m', strtotime($month)))->whereYear('tanggal', '=', $year)->where('kategori_id', $type_id)->where('status', ['Approved', 'Closed'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$nominal = $form->sum('approved_total');
|
$nominal = $form->sum('approved_total');
|
||||||
return $nominal;
|
return $nominal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,32 +24,32 @@ class DashboardController extends Controller
|
|||||||
$forms = [
|
$forms = [
|
||||||
'vehicle' => FormVehicleRunningCost::whereMonth('tanggal', date('m'))
|
'vehicle' => FormVehicleRunningCost::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get(),
|
->get(),
|
||||||
'upcountry' => FormUpCountry::whereMonth('tanggal', date('m'))
|
'upcountry' => FormUpCountry::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get(),
|
->get(),
|
||||||
'entertainment' => FormEntertaimentPresentation::whereMonth('tanggal', date('m'))
|
'entertainment' => FormEntertaimentPresentation::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get(),
|
->get(),
|
||||||
'meeting' => FormMeetingSeminar::whereMonth('created_at', date('m'))
|
'meeting' => FormMeetingSeminar::whereMonth('created_at', date('m'))
|
||||||
->whereYear('created_at', date('Y'))
|
->whereYear('created_at', date('Y'))
|
||||||
->where('created_at', '<=', date('Y-m-10'))
|
->where('created_at', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->get(),
|
->get(),
|
||||||
'others' => FormOthers::whereMonth('tanggal', date('m'))
|
'others' => FormOthers::whereMonth('tanggal', date('m'))
|
||||||
->whereYear('tanggal', date('Y'))
|
->whereYear('tanggal', date('Y'))
|
||||||
->where('tanggal', '<=', date('Y-m-10'))
|
->where('tanggal', '<=', date('Y-m-20'))
|
||||||
->whereRaw('DAY(CURDATE()) <= 10')
|
->whereRaw('DAY(CURDATE()) <= 20')
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->get(),
|
->get(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ use App\Helpers\FormHelper;
|
|||||||
use App\Helpers\BudgetHelper;
|
use App\Helpers\BudgetHelper;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use App\Models\Kategori;
|
||||||
|
use App\Models\BudgetControlLog;
|
||||||
|
|
||||||
class ReportController extends Controller
|
class ReportController extends Controller
|
||||||
{
|
{
|
||||||
@@ -631,4 +633,60 @@ class ReportController extends Controller
|
|||||||
'availableBudget' => $availableBudget
|
'availableBudget' => $availableBudget
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jurnal()
|
||||||
|
{
|
||||||
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
|
$cabangs = [];
|
||||||
|
|
||||||
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|
||||||
|
if ($region_id) {
|
||||||
|
$cabangs = Cabang::where('region_id', $region_id)->get();
|
||||||
|
}
|
||||||
|
} else if ($role == 'Area Manager Cabang') {
|
||||||
|
$cabang_id = auth()->user()->getMyCabangAndRegionId()['cabang'];
|
||||||
|
|
||||||
|
if ($cabang_id) {
|
||||||
|
$cabangs = Cabang::where('id', $cabang_id)->get();
|
||||||
|
}
|
||||||
|
} else if ($role == 'Medical Representatif') {
|
||||||
|
$cabangs = null;
|
||||||
|
} else {
|
||||||
|
$cabangs = Cabang::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('backend.pages.report.jurnal', [
|
||||||
|
'pageInfo' => [
|
||||||
|
'title' => 'Generate Reports For Jurnal',
|
||||||
|
],
|
||||||
|
'cabang' => $cabangs,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateJurnal() {
|
||||||
|
$params = request()->all();
|
||||||
|
|
||||||
|
$kategoris = Kategori::all();
|
||||||
|
$kategori_bca = Kategori::where('name', 'Cash in Bank BCA')->first();
|
||||||
|
$cabang = Cabang::with('cost')->where('code', $params['cabang'])->first();
|
||||||
|
|
||||||
|
$year = $params['year'];
|
||||||
|
$month = $params['month'];
|
||||||
|
|
||||||
|
$budget = BudgetControlLog::where('cabang_id', $cabang->id)->where('periode_year', $year)->where('periode_month', $month)->orderBy('created_at', 'desc')->first();
|
||||||
|
|
||||||
|
return view('backend.pages.report.generate_jurnal', [
|
||||||
|
'pageInfo' => [
|
||||||
|
'title' => 'Generate Reports For Jurnal',
|
||||||
|
],
|
||||||
|
'kategori' => $kategoris,
|
||||||
|
'cabang' => $cabang,
|
||||||
|
'year' => $year,
|
||||||
|
'month' => $month,
|
||||||
|
'budget' => $budget,
|
||||||
|
'kategori_bca' => $kategori_bca
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
{{ $pageInfo['title'] }}
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('admin-content')
|
||||||
|
<section class="content-header">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<h1>{{ $pageInfo['title'] }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<ol class="breadcrumb float-sm-right">
|
||||||
|
<li class="breadcrumb-form"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a> / </li>
|
||||||
|
<li class="breadcrumb-form active"> {{ $pageInfo['title'] }}</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<ul>
|
||||||
|
<li><b>Cabang:</b> {{ $cabang->name }}</li>
|
||||||
|
<li><b>Periode:</b> {{ ucfirst($month) }} {{ $year }}</li>
|
||||||
|
<li><b>Cost Centre</b> {{ $cabang->cost->code }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
@php
|
||||||
|
use App\Helpers\FormHelper;
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<section class="content">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<!-- All Forms Table -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="data-tables">
|
||||||
|
@include('backend.layouts.partials.messages')
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="dataTable-table">
|
||||||
|
<thead class="bg-light text-capitalize">
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Account Number</th>
|
||||||
|
<th>Dr</th>
|
||||||
|
<th>Cr</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- Dynamic Rows -->
|
||||||
|
@php
|
||||||
|
$totalDr = 0;
|
||||||
|
$totalCr = 0;
|
||||||
|
@endphp
|
||||||
|
@foreach ($kategori as $item)
|
||||||
|
@php
|
||||||
|
$drValue = FormHelper::getNominalByFormType($cabang->id, $item->name, $item->id, $month, $year);
|
||||||
|
$drFormatted = $drValue == 0 ? '' : number_format($drValue, 0, ',', '.');
|
||||||
|
$totalDr += $drValue;
|
||||||
|
@endphp
|
||||||
|
<tr>
|
||||||
|
<td>{{ $loop->iteration }}</td>
|
||||||
|
<td>{{ $item->name }}</td>
|
||||||
|
<td>{{ $item->account_number }}</td>
|
||||||
|
<td>{{ $drFormatted }}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{ $kategori->count() + 1 }}</td>
|
||||||
|
<td>Petty Cash</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
@php
|
||||||
|
$crValue = $budget && $budget->amount != 0 ? $budget->amount : 0;
|
||||||
|
$totalCr += $crValue;
|
||||||
|
echo $crValue == 0 ? '' : number_format($crValue, 0, ',', '.');
|
||||||
|
@endphp
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{{-- Static Rows --}}
|
||||||
|
<tr>
|
||||||
|
<td>{{ $kategori->count() + 2 }}</td>
|
||||||
|
<td>Cash Advance (Opening Balance)</td>
|
||||||
|
<td>{{ $kategori_bca->account_number }}</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
@php
|
||||||
|
$totalCr += 500000;
|
||||||
|
@endphp
|
||||||
|
{{ number_format(500000, 0, ',', '.') }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{ $kategori->count() + 3 }}</td>
|
||||||
|
<td>Cash Advance (Ending Balance)</td>
|
||||||
|
<td>{{ $kategori_bca->account_number }}</td>
|
||||||
|
<td>
|
||||||
|
@php
|
||||||
|
$totalDr += 500000;
|
||||||
|
@endphp
|
||||||
|
{{ number_format(500000, 0, ',', '.') }}
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3" class="text-right"><strong>Total</strong></td>
|
||||||
|
<td>{{ number_format($totalDr, 0, ',', '.') }}</td>
|
||||||
|
<td>{{ number_format($totalCr, 0, ',', '.') }}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
if ($('#dataTable-table').length) {
|
||||||
|
$('#dataTable-table').DataTable({
|
||||||
|
responsive: false,
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: ['excel', 'csv', 'pdf', 'print', 'colvis'],
|
||||||
|
paging: false,
|
||||||
|
info: false,
|
||||||
|
pageLength: -1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
{{ $pageInfo['title'] }}
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('admin-content')
|
||||||
|
<section class="content-header">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row mt-1">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="{{ route('reports.jurnal.generate') }}" method="GET">
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="cabang">Pilih Cabang</label>
|
||||||
|
<select name="cabang" id="cabang" class="form-control" required>
|
||||||
|
<option value="">Semua Cabang</option>
|
||||||
|
@foreach ($cabang as $cabang)
|
||||||
|
<option value="{{ $cabang->code }}" {{ request()->cabang == $cabang->code ? 'selected' : '' }}>
|
||||||
|
{{ $cabang->name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="month">Pilih Periode Bulan</label>
|
||||||
|
<select name="month" id="month" class="form-control" required>
|
||||||
|
<option value="">Pilih Bulan</option>
|
||||||
|
<option value="january" {{ request()->month == 'january' ? 'selected' : '' }}>Januari</option>
|
||||||
|
<option value="february" {{ request()->month == 'february' ? 'selected' : '' }}>Februari</option>
|
||||||
|
<option value="march" {{ request()->month == 'march' ? 'selected' : '' }}>Maret</option>
|
||||||
|
<option value="april" {{ request()->month == 'april' ? 'selected' : '' }}>April</option>
|
||||||
|
<option value="may" {{ request()->month == 'may' ? 'selected' : '' }}>Mei</option>
|
||||||
|
<option value="june" {{ request()->month == 'june' ? 'selected' : '' }}>Juni</option>
|
||||||
|
<option value="july" {{ request()->month == 'july' ? 'selected' : '' }}>Juli</option>
|
||||||
|
<option value="august" {{ request()->month == 'august' ? 'selected' : '' }}>Agustus</option>
|
||||||
|
<option value="september" {{ request()->month == 'september' ? 'selected' : '' }}>September</option>
|
||||||
|
<option value="october" {{ request()->month == 'october' ? 'selected' : '' }}>Oktober</option>
|
||||||
|
<option value="november" {{ request()->month == 'november' ? 'selected' : '' }}>November</option>
|
||||||
|
<option value="december" {{ request()->month == 'december' ? 'selected' : '' }}>Desember</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label for="year">Pilih Periode Tahun</label>
|
||||||
|
<select name="year" id="year" class="form-control" required>
|
||||||
|
<option value="">Pilih Tahun</option>
|
||||||
|
@for ($i = 2024; $i <= date('Y'); $i++)
|
||||||
|
<option value="{{ $i }}" {{ request()->year == $i ? 'selected' : '' }}>{{ $i }}</option>
|
||||||
|
@endfor
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit" class="btn btn-primary">Filter</button>
|
||||||
|
<a href="{{ route('reports.jurnal') }}" class="btn btn-secondary">Reset</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
if ($('#dataTable-table').length) {
|
||||||
|
$('#dataTable-table').DataTable({
|
||||||
|
responsive: false,
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: ['excel', 'pdf', 'print', 'colvis'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -109,6 +109,9 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::get('/meeting', [ReportController::class, 'meeting'])->name('reports.meeting');
|
Route::get('/meeting', [ReportController::class, 'meeting'])->name('reports.meeting');
|
||||||
Route::get('/others', [ReportController::class, 'others'])->name('reports.others');
|
Route::get('/others', [ReportController::class, 'others'])->name('reports.others');
|
||||||
Route::get('/all', [ReportController::class, 'all'])->name('reports.all');
|
Route::get('/all', [ReportController::class, 'all'])->name('reports.all');
|
||||||
|
|
||||||
|
Route::get('/jurnal', [ReportController::class, 'jurnal'])->name('reports.jurnal');
|
||||||
|
Route::get('/generateJurnal', [ReportController::class, 'generateJurnal'])->name('reports.jurnal.generate');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Forms
|
// Forms
|
||||||
|
|||||||
Reference in New Issue
Block a user