Add Download LOG

This commit is contained in:
R
2023-02-01 19:15:31 +07:00
parent 8d5f4bb0bd
commit f0c787fede
28 changed files with 470 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Storage;
use Modules\Internal\Services\MemberEnrollmentService;
use PDF;
class CorporateMemberController extends Controller
{
@@ -228,4 +229,17 @@ class CorporateMemberController extends Controller
]
];
}
public function generateLog($member_id)
{
$member = Member::findOrFail($member_id)
->load(['currentPlan', 'currentPolicy', 'currentPlan.corporateBenefits', 'currentPlan.corporateBenefits.benefit']);
// dd($member->currentPlan->corporateBenefits->toArray());
// return view('pdf.guaranted_leter', compact('member'));
$pdf = PDF::loadView('pdf.guaranted_leter', compact('member'));
return $pdf->download('Guaranted Letter - '.$member->full_name.'.pdf');
}
}

View File

@@ -120,6 +120,9 @@ Route::prefix('internal')->group(function () {
Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']);
Route::resource('organizations', OrganizationController::class);
Route::resource('doctors', DoctorController::class);
Route::get('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
});
// Route::resource('organizations', OrganizationController::class);

View File

@@ -11,6 +11,8 @@
|
*/
use Modules\Internal\Http\Controllers\Api\CorporateMemberController;
Route::prefix('internal')->group(function() {
Route::get('/', 'InternalController@index');
});
});

View File

@@ -6,9 +6,11 @@
"license": "MIT",
"require": {
"php": "^8.0.2",
"barryvdh/laravel-snappy": "^1.0",
"box/spout": "^3.3",
"duitkupg/duitku-php": "dev-master",
"guzzlehttp/guzzle": "^7.2",
"h4cc/wkhtmltopdf-amd64": "0.12.x",
"laravel/framework": "^9.11",
"laravel/sanctum": "^2.15",
"laravel/socialite": "^5.5",

203
composer.lock generated
View File

@@ -4,8 +4,86 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "bce7c2a0879fd09f793f1bfa9aeb0a68",
"content-hash": "001e5beb4f35e725aaab5763c69eaeed",
"packages": [
{
"name": "barryvdh/laravel-snappy",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-snappy.git",
"reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-snappy/zipball/2c18a3602981bc6f25b32908cf8aaa05952ab2f7",
"reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7",
"shasum": ""
},
"require": {
"illuminate/filesystem": "^6|^7|^8|^9",
"illuminate/support": "^6|^7|^8|^9",
"knplabs/knp-snappy": "^1",
"php": ">=7.2"
},
"require-dev": {
"orchestra/testbench": "^4|^5|^6|^7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Barryvdh\\Snappy\\ServiceProvider"
],
"aliases": {
"PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf",
"SnappyImage": "Barryvdh\\Snappy\\Facades\\SnappyImage"
}
}
},
"autoload": {
"psr-4": {
"Barryvdh\\Snappy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Snappy PDF/Image for Laravel",
"keywords": [
"image",
"laravel",
"pdf",
"snappy",
"wkhtmltoimage",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/barryvdh/laravel-snappy/issues",
"source": "https://github.com/barryvdh/laravel-snappy/tree/v1.0.0"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2022-01-29T19:36:49+00:00"
},
{
"name": "box/spout",
"version": "v3.3.0",
@@ -1199,6 +1277,129 @@
],
"time": "2022-10-26T14:07:24+00:00"
},
{
"name": "h4cc/wkhtmltopdf-amd64",
"version": "0.12.4",
"source": {
"type": "git",
"url": "https://github.com/h4cc/wkhtmltopdf-amd64.git",
"reference": "4e2ab2d032a5d7fbe2a741de8b10b8989523c95b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h4cc/wkhtmltopdf-amd64/zipball/4e2ab2d032a5d7fbe2a741de8b10b8989523c95b",
"reference": "4e2ab2d032a5d7fbe2a741de8b10b8989523c95b",
"shasum": ""
},
"bin": [
"bin/wkhtmltopdf-amd64"
],
"type": "library",
"autoload": {
"psr-4": {
"h4cc\\WKHTMLToPDF\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL Version 3"
],
"authors": [
{
"name": "Julius Beckmann",
"email": "github@h4cc.de"
}
],
"description": "Convert html to pdf using webkit (qtwebkit). Static linked linux binary for amd64 systems.",
"homepage": "http://wkhtmltopdf.org/",
"keywords": [
"binary",
"convert",
"pdf",
"snapshot",
"thumbnail",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/h4cc/wkhtmltopdf-amd64/issues",
"source": "https://github.com/h4cc/wkhtmltopdf-amd64/tree/master"
},
"time": "2018-01-15T06:57:33+00:00"
},
{
"name": "knplabs/knp-snappy",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/KnpLabs/snappy.git",
"reference": "5126fb5b335ec929a226314d40cd8dad497c3d67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/KnpLabs/snappy/zipball/5126fb5b335ec929a226314d40cd8dad497c3d67",
"reference": "5126fb5b335ec929a226314d40cd8dad497c3d67",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/log": "^1.0||^2.0||^3.0",
"symfony/process": "~3.4||~4.3||~5.0||~6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16||^3.0",
"pedrotroller/php-cs-custom-fixer": "^2.19",
"phpstan/phpstan": "^0.12.7",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpunit/phpunit": "~7.4||~8.5"
},
"suggest": {
"h4cc/wkhtmltoimage-amd64": "Provides wkhtmltoimage-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltoimage-i386": "Provides wkhtmltoimage-i386 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltopdf-amd64": "Provides wkhtmltopdf-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltopdf-i386": "Provides wkhtmltopdf-i386 binary for Linux-compatible machines, use version `~0.12` as dependency",
"wemersonjanuario/wkhtmltopdf-windows": "Provides wkhtmltopdf executable for Windows, use version `~0.12` as dependency"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Knp\\Snappy\\": "src/Knp/Snappy"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KNP Labs Team",
"homepage": "http://knplabs.com"
},
{
"name": "Symfony Community",
"homepage": "http://github.com/KnpLabs/snappy/contributors"
}
],
"description": "PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.",
"homepage": "http://github.com/KnpLabs/snappy",
"keywords": [
"knp",
"knplabs",
"pdf",
"snapshot",
"thumbnail",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/KnpLabs/snappy/issues",
"source": "https://github.com/KnpLabs/snappy/tree/v1.4.1"
},
"time": "2022-01-07T13:03:38+00:00"
},
{
"name": "laravel/framework",
"version": "v9.47.0",

View File

@@ -187,6 +187,7 @@ return [
*/
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Barryvdh\Snappy\ServiceProvider::class,
/*
* Application Service Providers...
@@ -218,6 +219,8 @@ return [
'Duitku' => App\Services\Duitku::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'LmsApi' => App\Services\LmsApi::class,
'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class,
])->toArray(),
];

52
config/snappy.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Snappy PDF / Image Configuration
|--------------------------------------------------------------------------
|
| This option contains settings for PDF generation.
|
| Enabled:
|
| Whether to load PDF / Image generation.
|
| Binary:
|
| The file path of the wkhtmltopdf / wkhtmltoimage executable.
|
| Timout:
|
| The amount of time to wait (in seconds) before PDF / Image generation is stopped.
| Setting this to false disables the timeout (unlimited processing time).
|
| Options:
|
| The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
| See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
|
| Env:
|
| The environment variables to set while running the wkhtmltopdf process.
|
*/
'pdf' => [
'enabled' => true,
'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'),
'timeout' => false,
'options' => [],
'env' => [],
],
];

View File

@@ -33,6 +33,7 @@ import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
// hooks
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../../hooks/useSettings';
@@ -327,6 +328,7 @@ export default function CorporatePlanList() {
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
const [loadingLog, setLoadingLog] = React.useState(false);
const handleActivate = (model: any, status: string) => {
axios
.put(`/members/${row.id}/activation`, {
@@ -353,6 +355,23 @@ export default function CorporatePlanList() {
);
});
};
const handleDownloadLog = (row: ReturnType<typeof createData>) => {
setLoadingLog(true);
axios.get(`generate-log/${row.id}`)
.then((response) => {
const link = document.createElement('a');
link.href = response.data.data.file_url;
link.setAttribute('download', response.data.data.file_name);
document.body.appendChild(link);
link.click();
setLoadingLog(false);
})
.catch((response) => {
enqueueSnackbar(response.message, {variant: 'error'})
setLoadingLog(false);
})
}
return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
@@ -516,6 +535,19 @@ export default function CorporatePlanList() {
</Grid>
</Grid>
<Grid>
<LoadingButton
id="upload-button"
variant="outlined"
startIcon={<InsertDriveFileIcon />}
// sx={{ p: 1.8 }}
onClick={() => {handleDownloadLog(row)}}
loading={loadingLog}
>
Download LOG
</LoadingButton>
</Grid>
{/* <Typography sx={{ fontWeight: '600', mb: 1, mt: 2 }}>Sub Corporate</Typography>
<Grid container>
<Grid item xs={12}>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -0,0 +1,159 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>LOG {{ $member->full_name }}</title>
{{-- <link rel="stylesheet" href="{{ asset('css/app.css') }}"> --}}
<style>
/* @font-face {
font-family: Public Sans;
src: url('{{asset('fonts/PublicSans-Medium.ttf')}}');
src: url('{{asset('fonts/PublicSans-Medium.ttf')}}') format('truetype');
} */
body {
font-family: 'Public Sans';
color: #404040;
}
.text-sm {
font-size: 12px;
}
.text-md {
font-size: 14px;
}
.text-lg {
font-size: 16px;
}
.text-gray {
color: #919EAB;
}
#member-detail{
}
#member-detail td {
width: 50%;
padding: 10px 0px;
}
#member-detail td>div{
margin-bottom: 5px;
}
.benefit-table-wrapper {
border: 1px solid #E0E0E0;
border-radius: 5px;
overflow: hidden;
}
#benefit-table {
width: 100%;
border-collapse: collapse;
}
#benefit-table th, #benefit-table th {
width: 50%;
}
#benefit-table th{
font-size: 14px;
font-weight: 400;
padding: 15px;
text-align: left;
}
#benefit-table tr:first-child {
background: #F5F5F5;
border-bottom: 1px solid #E0E0E0;
}
#benefit-table td {
padding: 15px;
font-size: 12px;
}
</style>
</head>
<body>
<table style="width: 100%;">
<tr>
<td rowspan="4" style="width: 100px;">
<img src="{{ public_path('images/logo-linksehat-vertical-default.png') }}" width="80px">
</td>
</tr>
<tr>
<td class="text-lg">PT. Link Medis Sehat</td>
</tr>
<tr>
<td class="text-sm"><span style="margin-bottom: 5px;">Graha Cempaka Mas Blok D/20<br >
Jl. Let. Jend. Suprapto, Jakarta Pusat 10640</span><br/>
<span>Whatsapp : +62 858-9000-8500</span> <span>E-mail :linksehat@linksehat.com</span>
</td>
</tr>
</table>
<table id="member-detail" style="margin-top: 20px; width: 100%;">
<tr>
<td><span style="color: #1890FF">GUARANTEE OF PAYMENT</span></td>
</tr>
<tr>
<td>
<div class="text-sm text-gray">Name of patient</div>
<div class="text-md">{{ $member->full_name }}</div>
</td>
<td>
<div class="text-sm text-gray">Member ID</div>
<div class="text-md">{{ $member->member_id }}</div>
</td>
</tr>
<tr>
<td>
<div class="text-sm text-gray">DOB</div>
<div class="text-md">{{ \Carbon\Carbon::parse($member->birth_date)->format('d/m/Y') }}</div>
</td>
<td>
<div class="text-sm text-gray">Policy Number</div>
<div class="text-md">{{ $member->currentPolicy->code ?? '' }}</div>
</td>
</tr>
<tr>
<td>
<div class="text-sm text-gray">Date of Admission</div>
<div class="text-md">{{ !empty($member->start) ? \Carbon\Carbon::parse($member->start)->format('d/m/Y') : $member->created_at->format('d/m/Y') }}</div>
</td>
<td>
<div class="text-sm text-gray">Plan</div>
<div class="text-md">{{ $member->currentPlan->code ?? '' }}</div>
</td>
</tr>
</table>
<div class="benefit-table-wrapper">
<table id="benefit-table">
<tr>
<th>Detail Benefit</th>
<th>Limit</th>
</tr>
<tr>
<td>Medical Check Up</td>
<td style="align-right">Unlimited</td>
</tr>
{{-- @foreach ($member->currentPlan->corporateBenefits as $corporateBenefit)
<tr>
<td>{{ $corporateBenefit->corporate_benefit_code ?? '' }}</td>
<td style="align-right">IDR {{ number_format($corporateBenefit->limit_amount, 0, ',', '.') ?? '' }}</td>
</tr>
@endforeach --}}
</table>
</div>
<div style="width: 100%; text-align: right; font-size: 10px; color: #777; margin-top: 20px;"><span style="padding: 15px;">Generated by Primecenter Linksehat at {{ now() }}</span></div>
</body>
</html>