test update2
This commit is contained in:
@@ -10,6 +10,8 @@ use Illuminate\Support\Facades\DB;
|
|||||||
use Modules\Internal\Http\Controllers\Api\RequestLogController as primeCenterRequestLog;
|
use Modules\Internal\Http\Controllers\Api\RequestLogController as primeCenterRequestLog;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
|
use Dompdf\Dompdf;
|
||||||
|
use Dompdf\Options;
|
||||||
|
|
||||||
class RequestLogController extends Controller
|
class RequestLogController extends Controller
|
||||||
{
|
{
|
||||||
@@ -281,4 +283,27 @@ class RequestLogController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downlodLog($request_log_id)
|
||||||
|
{
|
||||||
|
$data = ['key' => $request_log_id];
|
||||||
|
$pdf = new Dompdf();
|
||||||
|
|
||||||
|
$options = new Options();
|
||||||
|
$options->set('isHtml5ParserEnabled', true);
|
||||||
|
$options->set('isPhpEnabled', true);
|
||||||
|
$pdf->setOptions($options);
|
||||||
|
|
||||||
|
$html = view('pdf.view', $data);
|
||||||
|
$pdf->loadHtml($html);
|
||||||
|
|
||||||
|
$pdf->render();
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'inline; filename="file.pdf"',
|
||||||
|
];
|
||||||
|
|
||||||
|
return response($pdf->output(), 200, $headers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ Route::prefix('v1')->group(function() {
|
|||||||
Route::get('get-request-log', 'getRequestLog');
|
Route::get('get-request-log', 'getRequestLog');
|
||||||
Route::get('get-final-log', 'getFinalLog');
|
Route::get('get-final-log', 'getFinalLog');
|
||||||
Route::post('request-final-log', 'requestFinalLog');
|
Route::post('request-final-log', 'requestFinalLog');
|
||||||
|
Route::get('download-log/{request_log_id}', 'downlodLog');
|
||||||
});
|
});
|
||||||
//Notification
|
//Notification
|
||||||
Route::controller(NotificationController::class)->group(function() {
|
Route::controller(NotificationController::class)->group(function() {
|
||||||
|
|||||||
@@ -51,23 +51,16 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) {
|
|||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
// Download LOG
|
// Download LOG
|
||||||
async function handleDownloadLog(claimRequest:any) {
|
async function handleDownloadLog(request_log_id:any) {
|
||||||
return axios
|
return axios
|
||||||
.get(`claim-requests/${claimRequest}/log`, {
|
.get(`download-log/${request_log_id}`, {
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
window.open(URL.createObjectURL(response.data));
|
window.open(URL.createObjectURL(response.data), '_blank');
|
||||||
// setLoadingLog(false);
|
|
||||||
})
|
})
|
||||||
// .then((blobFile) => {
|
|
||||||
// new File([blobFile], 'asdads.pdf', { type: blobFile.type })
|
|
||||||
// setLoadingLog(false);
|
|
||||||
// })
|
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
console.log(response);
|
|
||||||
enqueueSnackbar(response.message, { variant: 'error' });
|
enqueueSnackbar(response.message, { variant: 'error' });
|
||||||
// setLoadingLog(false);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +351,7 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) {
|
|||||||
View
|
View
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/* {obj.status === 'approved' ? ( */}
|
{/* {obj.status === 'approved' ? ( */}
|
||||||
<MenuItem onClick={() => handleDownloadLog(38)}>
|
<MenuItem onClick={() => handleDownloadLog(obj.id)}>
|
||||||
<Iconify icon="eva:download-fill" />
|
<Iconify icon="eva:download-fill" />
|
||||||
Download LOG
|
Download LOG
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
37
resources/views/pdf/view.blade.php
Normal file
37
resources/views/pdf/view.blade.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!-- your/view.blade.php -->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Ivan Julian</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, p {
|
||||||
|
/* Gaya teks Anda */
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
opacity: 0.3; /* Sesuaikan dengan tingkat kecerahan yang diinginkan */
|
||||||
|
z-index: -1; /* Letakkan gambar di belakang konten lain */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Sisipkan gambar sebagai elemen img -->
|
||||||
|
<img src="{{public_path('images/logo-linksehat-vertical-default.png')}}" width="100px">
|
||||||
|
|
||||||
|
<!-- Konten HTML -->
|
||||||
|
<h1>Hello, {{ $key }}</h1>
|
||||||
|
<p>This is a simple example for generating PDF in Laravel using Dompdf.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user