Gadaian overall reports
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Reports;
|
||||
|
||||
use App\Exports\Ansuran\AnsuranExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class AnsuranController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$data = Http::get($request->hostname . '/api/reports/ansuran', [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$summary_ansuran_by_cawangan = $data['summary_ansuran_by_cawangan'];
|
||||
$summary_ansuran = $data['summary_ansuran'];
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
return view('reports.ansuran.index', compact('summary_ansuran_by_cawangan', 'summary_ansuran', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function downloadAnsuranCawanganExcel(Request $request)
|
||||
{
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
$kod_cawangan = $request->kod_cawangan;
|
||||
|
||||
$data = Http::get($request->hostname . '/api/reports/ansuran/' . $kod_cawangan, [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$file_title = sprintf("LaporanAnsuran %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new AnsuranExport($data), $file_title);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Reports;
|
||||
|
||||
use App\Exports\GadaianExport;
|
||||
use App\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class GadaianController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$gadaian = Http::get($request->hostname . '/api/reports/gadaian', [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
return view('reports.gadaian.index', compact('gadaian', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function downloadGadaianCawanganExcel(Request $request)
|
||||
{
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
$kod_cawangan = $request->kod_cawangan;
|
||||
|
||||
$data = Http::get($request->hostname . '/api/reports/gadaian/' . $kod_cawangan, [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
|
||||
$file_title = sprintf("LaporanGadaian %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new GadaianExport($data), $file_title);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Reports;
|
||||
|
||||
use App\Exports\Penebusan\PenebusanExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class PenebusanController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$penebusan = Http::get($request->hostname . '/api/reports/penebusan', [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
return view('reports.penebusan.index', compact('penebusan', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function downloadPenebusanCawanganExcel(Request $request)
|
||||
{
|
||||
$api_url = $request->hostname;
|
||||
$auth_user = Auth::user();
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$tarikh_cetak = $current->toDateString();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
if ($date_string == null) {
|
||||
return $current->toDateString();
|
||||
}
|
||||
|
||||
return $date_string;
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
$kod_cawangan = $request->kod_cawangan;
|
||||
|
||||
$data = Http::get($request->hostname . '/api/reports/penebusan/' . $kod_cawangan, [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$file_title = sprintf("LaporanPenebusan %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new PenebusanExport($data), $file_title);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user