diff --git a/Modules/Internal/Http/Controllers/Api/CorporateMemberController.php b/Modules/Internal/Http/Controllers/Api/CorporateMemberController.php index 5e2f3bb6..93f4e075 100755 --- a/Modules/Internal/Http/Controllers/Api/CorporateMemberController.php +++ b/Modules/Internal/Http/Controllers/Api/CorporateMemberController.php @@ -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'); + } } diff --git a/Modules/Internal/Routes/api.php b/Modules/Internal/Routes/api.php index 3c1a9447..143727c9 100755 --- a/Modules/Internal/Routes/api.php +++ b/Modules/Internal/Routes/api.php @@ -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); diff --git a/Modules/Internal/Routes/web.php b/Modules/Internal/Routes/web.php index 9a648594..7e42844d 100755 --- a/Modules/Internal/Routes/web.php +++ b/Modules/Internal/Routes/web.php @@ -11,6 +11,8 @@ | */ +use Modules\Internal\Http\Controllers\Api\CorporateMemberController; + Route::prefix('internal')->group(function() { Route::get('/', 'InternalController@index'); -}); +}); \ No newline at end of file diff --git a/composer.json b/composer.json index 7c33d5ef..cfc4fff1 100755 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 58d2c2e9..b31e8526 100755 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/config/app.php b/config/app.php index 1a018790..a5c0496d 100755 --- a/config/app.php +++ b/config/app.php @@ -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(), ]; diff --git a/config/snappy.php b/config/snappy.php new file mode 100644 index 00000000..46d12ec0 --- /dev/null +++ b/config/snappy.php @@ -0,0 +1,52 @@ + [ + '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' => [], + ], + +]; diff --git a/frontend/dashboard/src/pages/Corporates/Member/List.tsx b/frontend/dashboard/src/pages/Corporates/Member/List.tsx index b733e789..b0cad9bb 100755 --- a/frontend/dashboard/src/pages/Corporates/Member/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/Member/List.tsx @@ -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 }) { 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) => { + 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 ( *': { borderBottom: 'unset' } }}> @@ -516,6 +535,19 @@ export default function CorporatePlanList() { + + } + // sx={{ p: 1.8 }} + onClick={() => {handleDownloadLog(row)}} + loading={loadingLog} + > + Download LOG + + + {/* Sub Corporate diff --git a/public/fonts/PublicSans-Black.ttf b/public/fonts/PublicSans-Black.ttf new file mode 100644 index 00000000..8c9e8ec4 Binary files /dev/null and b/public/fonts/PublicSans-Black.ttf differ diff --git a/public/fonts/PublicSans-BlackItalic.ttf b/public/fonts/PublicSans-BlackItalic.ttf new file mode 100644 index 00000000..98cde4ba Binary files /dev/null and b/public/fonts/PublicSans-BlackItalic.ttf differ diff --git a/public/fonts/PublicSans-Bold.ttf b/public/fonts/PublicSans-Bold.ttf new file mode 100644 index 00000000..7a14109e Binary files /dev/null and b/public/fonts/PublicSans-Bold.ttf differ diff --git a/public/fonts/PublicSans-BoldItalic.ttf b/public/fonts/PublicSans-BoldItalic.ttf new file mode 100644 index 00000000..505553bf Binary files /dev/null and b/public/fonts/PublicSans-BoldItalic.ttf differ diff --git a/public/fonts/PublicSans-ExtraBold.ttf b/public/fonts/PublicSans-ExtraBold.ttf new file mode 100644 index 00000000..148fee4a Binary files /dev/null and b/public/fonts/PublicSans-ExtraBold.ttf differ diff --git a/public/fonts/PublicSans-ExtraBoldItalic.ttf b/public/fonts/PublicSans-ExtraBoldItalic.ttf new file mode 100644 index 00000000..433e2b89 Binary files /dev/null and b/public/fonts/PublicSans-ExtraBoldItalic.ttf differ diff --git a/public/fonts/PublicSans-ExtraLight.ttf b/public/fonts/PublicSans-ExtraLight.ttf new file mode 100644 index 00000000..ccad63c3 Binary files /dev/null and b/public/fonts/PublicSans-ExtraLight.ttf differ diff --git a/public/fonts/PublicSans-ExtraLightItalic.ttf b/public/fonts/PublicSans-ExtraLightItalic.ttf new file mode 100644 index 00000000..8c573f5d Binary files /dev/null and b/public/fonts/PublicSans-ExtraLightItalic.ttf differ diff --git a/public/fonts/PublicSans-Italic.ttf b/public/fonts/PublicSans-Italic.ttf new file mode 100644 index 00000000..7315d657 Binary files /dev/null and b/public/fonts/PublicSans-Italic.ttf differ diff --git a/public/fonts/PublicSans-Light.ttf b/public/fonts/PublicSans-Light.ttf new file mode 100644 index 00000000..286bb3a4 Binary files /dev/null and b/public/fonts/PublicSans-Light.ttf differ diff --git a/public/fonts/PublicSans-LightItalic.ttf b/public/fonts/PublicSans-LightItalic.ttf new file mode 100644 index 00000000..d2c621aa Binary files /dev/null and b/public/fonts/PublicSans-LightItalic.ttf differ diff --git a/public/fonts/PublicSans-Medium.ttf b/public/fonts/PublicSans-Medium.ttf new file mode 100644 index 00000000..1421f42f Binary files /dev/null and b/public/fonts/PublicSans-Medium.ttf differ diff --git a/public/fonts/PublicSans-MediumItalic.ttf b/public/fonts/PublicSans-MediumItalic.ttf new file mode 100644 index 00000000..11449236 Binary files /dev/null and b/public/fonts/PublicSans-MediumItalic.ttf differ diff --git a/public/fonts/PublicSans-Regular.ttf b/public/fonts/PublicSans-Regular.ttf new file mode 100644 index 00000000..7f55dba9 Binary files /dev/null and b/public/fonts/PublicSans-Regular.ttf differ diff --git a/public/fonts/PublicSans-SemiBold.ttf b/public/fonts/PublicSans-SemiBold.ttf new file mode 100644 index 00000000..c7a1944c Binary files /dev/null and b/public/fonts/PublicSans-SemiBold.ttf differ diff --git a/public/fonts/PublicSans-SemiBoldItalic.ttf b/public/fonts/PublicSans-SemiBoldItalic.ttf new file mode 100644 index 00000000..49780a69 Binary files /dev/null and b/public/fonts/PublicSans-SemiBoldItalic.ttf differ diff --git a/public/fonts/PublicSans-Thin.ttf b/public/fonts/PublicSans-Thin.ttf new file mode 100644 index 00000000..3d45ec84 Binary files /dev/null and b/public/fonts/PublicSans-Thin.ttf differ diff --git a/public/fonts/PublicSans-ThinItalic.ttf b/public/fonts/PublicSans-ThinItalic.ttf new file mode 100644 index 00000000..293ad1dd Binary files /dev/null and b/public/fonts/PublicSans-ThinItalic.ttf differ diff --git a/public/images/logo-linksehat-vertical-default.png b/public/images/logo-linksehat-vertical-default.png new file mode 100644 index 00000000..97f9d558 Binary files /dev/null and b/public/images/logo-linksehat-vertical-default.png differ diff --git a/resources/views/pdf/guaranted_leter.blade.php b/resources/views/pdf/guaranted_leter.blade.php new file mode 100644 index 00000000..f68f4f07 --- /dev/null +++ b/resources/views/pdf/guaranted_leter.blade.php @@ -0,0 +1,159 @@ + + + + + LOG {{ $member->full_name }} + + {{-- --}} + + + + + + + + + + + + + + + +
+ +
PT. Link Medis Sehat
Graha Cempaka Mas Blok D/20
+ Jl. Let. Jend. Suprapto, Jakarta Pusat 10640

+ Whatsapp : +62 858-9000-8500 E-mail :linksehat@linksehat.com +
+ + + + + + + + + + + + + + + + + + + + +
GUARANTEE OF PAYMENT
+
Name of patient
+
{{ $member->full_name }}
+
+
Member ID
+
{{ $member->member_id }}
+
+
DOB
+
{{ \Carbon\Carbon::parse($member->birth_date)->format('d/m/Y') }}
+
+
Policy Number
+
{{ $member->currentPolicy->code ?? '' }}
+
+
Date of Admission
+
{{ !empty($member->start) ? \Carbon\Carbon::parse($member->start)->format('d/m/Y') : $member->created_at->format('d/m/Y') }}
+
+
Plan
+
{{ $member->currentPlan->code ?? '' }}
+
+ +
+ + + + + + + + + + + + + {{-- @foreach ($member->currentPlan->corporateBenefits as $corporateBenefit) + + + + + @endforeach --}} +
Detail BenefitLimit
Medical Check UpUnlimited
{{ $corporateBenefit->corporate_benefit_code ?? '' }}IDR {{ number_format($corporateBenefit->limit_amount, 0, ',', '.') ?? '' }}
+
+ +
Generated by Primecenter Linksehat at {{ now() }}
+ + \ No newline at end of file