rekod gadai tebus hari sama
This commit is contained in:
@@ -10,6 +10,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\LaporanKeseluruhan\GadaiTebusAllExportExcel;
|
||||
|
||||
class GadaianController extends Controller
|
||||
{
|
||||
@@ -66,4 +67,36 @@ class GadaianController extends Controller
|
||||
$file_title = sprintf("LaporanGadaian %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new GadaianExport($data), $file_title);
|
||||
}
|
||||
|
||||
public function gadaitebus(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
$action = $request->input('action', 'search');
|
||||
$kod_cawangan = $request->kod_cawangan;
|
||||
|
||||
$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/gadaitebus', [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
if ($action === 'excel') {
|
||||
$file_title = sprintf("LaporanGadaiTebus %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new GadaiTebusAllExportExcel($gadaian), $file_title);
|
||||
}
|
||||
|
||||
return view('reports.gadaitebus.index', compact('gadaian', 'startDate', 'endDate'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user