export pdf list

pull/1/head
Aji Kamaludin 3 years ago
parent 9328d5c10d
commit c9e21b29aa
No known key found for this signature in database
GPG Key ID: 670E1F26AD5A8099

@ -0,0 +1,33 @@
<?php
namespace App\Exports;
use App\Models\Payroll;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\Exportable;
class PayrollExportFromView implements FromView
{
use Exportable;
private $startDate;
private $endDate;
public function __construct($startDate, $endDate)
{
$this->startDate = $startDate;
$this->endDate = $endDate;
}
public function view(): View
{
$items = Payroll::with('employee')->whereBetween('date', [$this->startDate, $this->endDate])->get();
return view('report', [
'data' => $items,
'startDate' => $this->startDate,
'endDate' => $this->endDate
]);
}
}

@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Exports\PayrollExport; use App\Exports\PayrollExport;
use App\Exports\PayrollExportFromView;
use App\Models\Payroll; use App\Models\Payroll;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -34,4 +35,9 @@ class ReportController extends Controller
{ {
return (new PayrollExport($request->startDate, $request->endDate))->download('reports.xlsx', \Maatwebsite\Excel\Excel::XLSX); return (new PayrollExport($request->startDate, $request->endDate))->download('reports.xlsx', \Maatwebsite\Excel\Excel::XLSX);
} }
public function exportPdf(Request $request)
{
return (new PayrollExportFromView($request->startDate, $request->endDate))->download('reports.pdf', \Maatwebsite\Excel\Excel::DOMPDF);
}
} }

@ -6,6 +6,7 @@
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^7.3|^8.0", "php": "^7.3|^8.0",
"dompdf/dompdf": "^1.1",
"fruitcake/laravel-cors": "^2.0", "fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.0.1",
"inertiajs/inertia-laravel": "^0.3.5", "inertiajs/inertia-laravel": "^0.3.5",

211
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c5410ec6a8eaf9a5cb55eb33ce135948", "content-hash": "0922ffcc8eeffdaa23c9299eafaf4746",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
@ -368,6 +368,73 @@
], ],
"time": "2020-05-25T17:44:05+00:00" "time": "2020-05-25T17:44:05+00:00"
}, },
{
"name": "dompdf/dompdf",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/dompdf/dompdf.git",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/de4aad040737a89fae2129cdeb0f79c45513128d",
"reference": "de4aad040737a89fae2129cdeb0f79c45513128d",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-mbstring": "*",
"phenx/php-font-lib": "^0.5.2",
"phenx/php-svg-lib": "^0.3.3",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^7.5 || ^8 || ^9",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"ext-gd": "Needed to process images",
"ext-gmagick": "Improves image processing performance",
"ext-imagick": "Improves image processing performance",
"ext-zlib": "Needed for pdf stream compression"
},
"type": "library",
"autoload": {
"psr-4": {
"Dompdf\\": "src/"
},
"classmap": [
"lib/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
},
{
"name": "Brian Sweeney",
"email": "eclecticgeek@gmail.com"
},
{
"name": "Gabriel Bull",
"email": "me@gabrielbull.com"
}
],
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
"homepage": "https://github.com/dompdf/dompdf",
"support": {
"issues": "https://github.com/dompdf/dompdf/issues",
"source": "https://github.com/dompdf/dompdf/tree/v1.1.1"
},
"time": "2021-11-24T00:45:04+00:00"
},
{ {
"name": "dragonmantank/cron-expression", "name": "dragonmantank/cron-expression",
"version": "v3.1.0", "version": "v3.1.0",
@ -2551,6 +2618,95 @@
}, },
"time": "2021-04-09T13:42:10+00:00" "time": "2021-04-09T13:42:10+00:00"
}, },
{
"name": "phenx/php-font-lib",
"version": "0.5.4",
"source": {
"type": "git",
"url": "https://github.com/dompdf/php-font-lib.git",
"reference": "dd448ad1ce34c63d09baccd05415e361300c35b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/dd448ad1ce34c63d09baccd05415e361300c35b4",
"reference": "dd448ad1ce34c63d09baccd05415e361300c35b4",
"shasum": ""
},
"require": {
"ext-mbstring": "*"
},
"require-dev": {
"symfony/phpunit-bridge": "^3 || ^4 || ^5"
},
"type": "library",
"autoload": {
"psr-4": {
"FontLib\\": "src/FontLib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
}
],
"description": "A library to read, parse, export and make subsets of different types of font files.",
"homepage": "https://github.com/PhenX/php-font-lib",
"support": {
"issues": "https://github.com/dompdf/php-font-lib/issues",
"source": "https://github.com/dompdf/php-font-lib/tree/0.5.4"
},
"time": "2021-12-17T19:44:54+00:00"
},
{
"name": "phenx/php-svg-lib",
"version": "0.3.4",
"source": {
"type": "git",
"url": "https://github.com/PhenX/php-svg-lib.git",
"reference": "f627771eb854aa7f45f80add0f23c6c4d67ea0f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/f627771eb854aa7f45f80add0f23c6c4d67ea0f2",
"reference": "f627771eb854aa7f45f80add0f23c6c4d67ea0f2",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"sabberworm/php-css-parser": "^8.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Svg\\": "src/Svg"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
}
],
"description": "A library to read, parse and export to PDF SVG files.",
"homepage": "https://github.com/PhenX/php-svg-lib",
"support": {
"issues": "https://github.com/PhenX/php-svg-lib/issues",
"source": "https://github.com/PhenX/php-svg-lib/tree/0.3.4"
},
"time": "2021-10-18T02:13:32+00:00"
},
{ {
"name": "phpoffice/phpspreadsheet", "name": "phpoffice/phpspreadsheet",
"version": "1.20.0", "version": "1.20.0",
@ -3381,6 +3537,59 @@
], ],
"time": "2021-09-25T23:10:38+00:00" "time": "2021-09-25T23:10:38+00:00"
}, },
{
"name": "sabberworm/php-css-parser",
"version": "8.4.0",
"source": {
"type": "git",
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
"reference": "e41d2140031d533348b2192a83f02d8dd8a71d30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sabberworm/PHP-CSS-Parser/zipball/e41d2140031d533348b2192a83f02d8dd8a71d30",
"reference": "e41d2140031d533348b2192a83f02d8dd8a71d30",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": ">=5.6.20"
},
"require-dev": {
"codacy/coverage": "^1.4",
"phpunit/phpunit": "^4.8.36"
},
"suggest": {
"ext-mbstring": "for parsing UTF-8 CSS"
},
"type": "library",
"autoload": {
"psr-4": {
"Sabberworm\\CSS\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Raphael Schweikert"
}
],
"description": "Parser for CSS Files written in PHP",
"homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
"keywords": [
"css",
"parser",
"stylesheet"
],
"support": {
"issues": "https://github.com/sabberworm/PHP-CSS-Parser/issues",
"source": "https://github.com/sabberworm/PHP-CSS-Parser/tree/8.4.0"
},
"time": "2021-12-11T13:40:54+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.3.0", "version": "v6.3.0",

10
public/js/app.js vendored

@ -10391,13 +10391,17 @@ function Reports(props) {
className: "card-body", className: "card-body",
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", {
className: "flex flex-col md:flex-row space-y-2 md:space-y-0 items-start md:items-stretch w-full mb-4 justify-between", className: "flex flex-col md:flex-row space-y-2 md:space-y-0 items-start md:items-stretch w-full mb-4 justify-between",
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", {
className: "btn-group my-auto", className: "btn-group my-auto",
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", {
className: "btn btn-info btn-outline", className: "btn btn-info btn-outline",
href: "".concat(route('report.export'), "?").concat(qs__WEBPACK_IMPORTED_MODULE_2___default().stringify(params)), href: "".concat(route('report.export'), "?").concat(qs__WEBPACK_IMPORTED_MODULE_2___default().stringify(params)),
children: "Download Excel" children: "Download Excel"
}) }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("a", {
className: "btn btn-info btn-outline",
href: "".concat(route('report.export-pdf'), "?").concat(qs__WEBPACK_IMPORTED_MODULE_2___default().stringify(params)),
children: "Download PDF"
})]
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", {
className: "flex flex-row md:space-x-4", className: "flex flex-row md:space-x-4",
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", {

@ -62,10 +62,20 @@ export default function Reports(props) {
<div className="btn-group my-auto"> <div className="btn-group my-auto">
<a <a
className="btn btn-info btn-outline" className="btn btn-info btn-outline"
href={`${route('report.export')}?${qs.stringify(params)}`} href={`${route(
'report.export'
)}?${qs.stringify(params)}`}
> >
Download Excel Download Excel
</a> </a>
<a
className="btn btn-info btn-outline"
href={`${route(
'report.export-pdf'
)}?${qs.stringify(params)}`}
>
Download PDF
</a>
</div> </div>
<div className="flex flex-row md:space-x-4"> <div className="flex flex-row md:space-x-4">
<div> <div>
@ -158,19 +168,23 @@ export default function Reports(props) {
{formatDate(payroll.date)} {formatDate(payroll.date)}
</th> </th>
<td>{payroll.employee.name}</td> <td>{payroll.employee.name}</td>
<td>{payroll.employee.whatsapp}</td> <td>
{payroll.employee.whatsapp}
</td>
<td> <td>
{formatIDR(payroll.recived)} {formatIDR(payroll.recived)}
</td> </td>
<td> <td>
{formatIDR(payroll.item_count)} {formatIDR(
payroll.item_count
)}
</td> </td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</div> </div>
<Pagination links={links} params={params}/> <Pagination links={links} params={params} />
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>
<table style="text-align: center;">
<thead>
<tr>
<th>
Laporan
</th>
<th>
{{$startDate}}
</th>
<th>
{{$endDate}}
</th>
</tr>
</thead>
<thead>
<tr>
<th colSpan="5" style="padding: 3em;"></th>
</tr>
<tr style="font-weight: bold;">
<th>
Nama karyawan
</th>
<th>
Kontak
</th>
<th>
Jumlah Item
</th>
<th>
Total Gajian
</th>
<th>
Tanggal
</th>
</tr>
</thead>
<tbody>
@foreach($data as $item)
<tr>
<td style="width: 200px">{{$item->employee->name}}</td>
<td style="width: 100px">{{$item->employee->whatsapp}}</td>
<td style="width: 100px">{{$item->item_count}}</td>
<td style="width: 100px">{{$item->recived}}</td>
<td style="width: 100px">{{$item->date}}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

@ -59,6 +59,7 @@ Route::middleware(['auth'])->group(function () {
Route::get('/report', [ReportController::class, 'index'])->name('report'); Route::get('/report', [ReportController::class, 'index'])->name('report');
Route::get('/report/export', [ReportController::class, 'export'])->name('report.export'); Route::get('/report/export', [ReportController::class, 'export'])->name('report.export');
Route::get('/report/export-pdf', [ReportController::class, 'exportPdf'])->name('report.export-pdf');
}); });
require __DIR__.'/auth.php'; require __DIR__.'/auth.php';

Loading…
Cancel
Save