diff --git a/app/Http/Controllers/BayaranController.php b/app/Http/Controllers/BayaranController.php index 4e39014..3874901 100644 --- a/app/Http/Controllers/BayaranController.php +++ b/app/Http/Controllers/BayaranController.php @@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Log; use Money\Money; use App\Services\OnlineTransactionLoggerService; use Illuminate\Support\Facades\Session; +use PDF; class BayaranController extends Controller { @@ -215,7 +216,49 @@ class BayaranController extends Controller ->json(); $gadai = $gadai_details[0][0]; - return view('pembayaran.resit.resitportal', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai')); + $company = Session::get('company'); + + return view('pembayaran.resit.resitportal', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai','company')); + } + + public function generateResit(Request $request) + { + $this->serviceCallHttp($request->company); + + $kpbaru = Auth::User()->icno; + + $customer = $this->CallableHttp + ->get('/api/customers/' . $kpbaru) + ->json(); + $customer_details = $customer; + + $current = Carbon::now(); + $current = new Carbon(); + $date = $current->toDateTimeString(); + + $payment_details = $this->CallableHttp + ->get('/api/transaction/online/express', ['billplz_id' => $request->billplzid]) + ->json(); + + $cawangan_info = $this->CallableHttp + ->get('/api/cawangan/' . $payment_details['kodcaw']) + ->json(); + $cawangan = $this->CallableHttp + ->get('/api/cawangan/detail/' . $payment_details['kodcaw']) + ->json(); + $cawangan_detail = $cawangan[0]; + $nama_cawangan = $cawangan_info['details_caw']; + + $gadai_details = $this->CallableHttp + ->get('/api/gadai/norujukan/' . $payment_details['norujukan']) + ->json(); + $gadai = $gadai_details[0][0]; + + // Load a view and pass data to it + $pdf = PDF::loadView('pembayaran.resit.resitpdf', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai')); + + // Return the generated PDF (inline display in browser) + return $pdf->stream('resit_pembayaran.pdf'); } public function callback(Request $request) diff --git a/composer.json b/composer.json index 531e898..6c677f0 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^7.3|^8.0", + "barryvdh/laravel-dompdf": "^2.2", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", diff --git a/resources/views/pembayaran/resit/resitpdf.blade.php b/resources/views/pembayaran/resit/resitpdf.blade.php new file mode 100644 index 0000000..c8482cd --- /dev/null +++ b/resources/views/pembayaran/resit/resitpdf.blade.php @@ -0,0 +1,93 @@ + + +
+ + +
+
+